3.3. LEPI Initialization

In order for the LEPI to dispatch event data and DMA error conditions to a user, the LEPI needs a mechanism for notifying the user. The LEPI will utilize user supplied call-back functions for error handling and event processing.

3.3.1. Error Handler

Every result has the potential for DMA errors, which is determined by inspecting the result descriptor. During initialization the user provides an error handling call-back function. If an error is detected the LEPI calls the user supplied error handler, passing the error code as an argument to the handler.

The typedef for an error handling call-back function appears below:


typedef int (*LEPI_ERROR_HANDLER_FUNC)( unsigned int errCode);
        

The function prototype of the error handling call-back appears below:

intlepi_SetErrorHandler(LEPI_ERROR_HANDLER_FUNCerrHandler);

An example of registering an error handling call-back function is shown below:


/* declare call-back routine */
int myErrorHandler( unsigned int errCode);

/* register call-back */
lepi_SetErrorHandler( myErrorHandler);
        

3.3.2. Event Handler

During initialization of the LEPI the user will provide an event processing call-back function. This function will be called by the LEPI when it determines that event data is ready for processing. The LEPI will pass a pointer to the event data into the call-back function as an argument.

The typedef for an event processing call-back function appears below:


typedef int (*LEPI_EVENT_PROC_FUNC)( unsigned int *pEvent);
        

The return code from the event processing call-back is used as the "length" to free within the circular buffer. The value of 0 means "do not free anything". See Section 3.4.2 for more about freeing memory from the circular buffer.

The function prototype of the event call-back appears below:

intlepi_SetEventProc(LEPI_EVENT_PROC_FUNCprocFunc);

An example of registering an event processing call-back function is shown below:


/* declare call-back routine */
int myEventProc( unsigned int *pEvent);

/* register call-back */
lepi_SetEventProc( myEventProc);