1.1.7.4.13 DRV_SDSPI_EventHandlerSet Function
C
void DRV_SDSPI_EventHandlerSet ( const DRV_HANDLE handle, const void * eventHandler, const uintptr_t context )
Summary
Allows a client to identify an event handling function for the driver to call back when queued operation has completed. For the synchronous SDSPI driver, the event handler is only used by the file system.
Description
This function allows a client to identify an event handling function for the driver to call back when queued operation has completed. When a client queues a request for a read or a write operation, it is provided with a handle identifying the buffer that was added to the driver's buffer queue. The driver will pass this handle back to the client by calling "eventHandler" function when the queued operation has completed.
The event handler should be set before the client performs any read or write operations that could generate events. The event handler once set, persists until the client closes the driver or sets another event handler (which could be a "NULL" pointer to indicate no callback).
Precondition
The DRV_SDSPI_Initialize routine must have been called for the specified SDSPI driver instance.
The DRV_SDSPI_Open routine must have been called to obtain a valid opened device handle.
Parameters
Param | Description |
---|---|
handle | A valid open-instance handle, returned from the driver's open function |
eventHandler | Pointer to the event handler function implemented by the user |
context | The value of parameter will be passed back to the client unchanged, when the eventHandler function is called. It can be used to identify any client specific data object that identifies the instance of the client module (for example, it may be a pointer to the client module's state structure). |
Returns
None.
Example
// Event is received when // the buffer is processed.
void APP_SDSPIEventHandler( DRV_SDSPI_EVENT event, DRV_SDSPI_COMMAND_HANDLE commandHandle, uintptr_t contextHandle ) { // contextHandle points to myAppObj.
switch(event)
{
case DRV_SDSPI_EVENT_COMMAND_COMPLETE:
{
// This means the data was transferred successfully
break;
}
case DRV_SDSPI_EVENT_COMMAND_ERROR:
{
// Error handling here
break;
}
default:
{
break;
}
}
}
// mySDSPIHandle is the handle returned // by the DRV_SDSPI_Open function.
// Client registers an event handler with driver DRV_SDSPI_EventHandlerSet(mySDSPIHandle, APP_SDSPIEventHandler, (uintptr_t)&myAppObj);
Remarks
If the client does not want to be notified when the queued operation has completed, it does not need to register a callback. This API may not be used in applications using the SDSPI Driver in synchronous mode.