5 sample application, Sample application, Section 5 – Maxim Integrated 73M1866B/73M1966B FXOAPI User Manual
Page 62

73M1866B/73M1966B FXOAPI User Guide
UG_1x66B_046
62
Rev. 2.1
5 Sample Application
This section illustrates how an FXO application can be implemented using the FXOAPIs. The sample
program is a typical telephony application that automatically answers the call when a ring burst is
detected. This is accomplished by simply going off-hook.
Note: this sample program will definitely not compile and is not a complete application. It is intended only
for demonstration purpose to show the capability and to illustrate the interaction between the application
program and the FXOAPI.
/****************************************************************
**
** FXO sample application
**
** Perform the following:
** - Initialize the API subsystem – M1x66_ApiInit()
** - Open the FXO device - M1x66_OpenDevice()
** - Open each channel - M1x66_OpenChannel()
** - Config PCM interface - M1x66_PcmIfConfig()
** - Initialize channel - M1x66_InitChannel()
**
*****************************************************************/
int main (int argc, char **argv)
{
M1x66_PCM_IF_CFG pcmIfConfig;
M1x66_CHAN_INIT
chanInit;
M1x66_HANDLE
pFxoDev;
/* Initialize the API subsystem */
if (M1x66_FxoApiInit() != M1x66_SUCCESS)
return (-1);
/* Open device descriptor with event callback function */
pFxoDev = M1x66_OpenDevice(“/dev/ter”, &fxoEventCallback);
if (pFxoDev == NULL)
return (-1);
/* For each channel descriptor */
for (i=0; i
/* Open the channel descriptor */
channles[i].pHandle = M1x66_OpenChannel(“/dev/ter”, pFxoDev, i);
if (channels[i].pHandle == NULL)
return (-1);
/* configure PCM interface */
pcmIfConfig.pcmOperMode = 0;
pcmIfConfig.pcmFrequency = M1x66_2048KHZ;
pcmIfConfig.pcmRxEdgePolarity = 0;
pcmIfConfig.pcmTxEdgePolarity = 1;
pcmIfConfig.pcmRxClockSlot = 0;
pcmIfConfig.pcmTxClockSlot = 0;
/* Now configure the PCM interface */
ret = M1x66_PcmIfConfig (channels[i].pHandle, &pcmIfConfig);
if (ret != M1x66_SUCCESS)
return (-1);