5 sample application, Sample application, Section 5 – Maxim Integrated 73M1822/73M1922 Modem API User Manual

Page 33

Advertising
background image

UG_1x22_055

73M1822/73M1922 Modem API User Guide

Rev. 1.0

33

5 Sample Application

This section illustrates how an application can be implemented using the Modem APIs. 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 Modem API.


/****************************************************************
**
** sample application
**
** Perform the following:
** - Initialize the API subsystem – M1X22_ApiInit()
** - Open the device

- M1X22_OpenDevice()

** - Open each channel - M1X22_OpenChannel()
** - Initialize channel - M1X22_InitChannel()
**
*****************************************************************/
int main (int argc, char **argv)
{

M1X22_CHAN_INIT

chanInit;

M1X22_HANDLE

pFxoDev;


/* Initialize the API subsystem */
if (M1X22_MdmApiInit() != M1X22_SUCCESS)

return (-1);


/* Open device descriptor with event callback function */
pFxoDev = M1X22_OpenDevice(“/dev/ter”, &fxoEventCallback);
if (pFxoDev == NULL)

return (-1);


/* For each channel descriptor */
for (i=0; i<MAX_DAA_INSTALLED; i++)
{

/* Open the channel descriptor */
channles[i].pHandle = M1X22_OpenChannel(“/dev/ter”, pFxoDev, i);
if (channels[i].pHandle == NULL)

return (-1);


/* Initialize the channel for operation in US */
if (M1X22_InitChannel (channels[i].pHandle, M1X22_CNTRY_CODE_US)
!= M1X22_SUCCESS)

return (-1);

}


/* program main loop */


While (1)

{

/* this is the main program loop…

/* . . . */

}


/* Release the API subsystem before exiting */

Advertising