DRV_SST26_EventHandlerSet Function
C
void DRV_SST26_EventHandlerSet(
const DRV_HANDLE handle,
const DRV_SST26_EVENT_HANDLER eventHandler,
const uintptr_t context
)
Summary
Allows a client to identify a transfer event handling function for the driver to call back when the requested transfer has finished.
Description
This function allows a client to register a transfer event handling function with the driver to call back when the requested transfer has finished.
The event handler should be set before the client submits any transfer requests 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).
This function is only supported when sst26 driver is using
QSPI PLIB in SPI mode
SPI PLIB
Precondition
DRV_SST26_Open 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 routine. |
eventHandler | Pointer to the event handler function. |
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
#define BUFFER_SIZE 256 #define MEM_ADDRESS 0x00 // myAppObj is an application specific state data object. MY_APP_OBJ myAppObj; uint8_t CACHE_ALIGN myBuffer[BUFFER_SIZE]; // The registered event handler is called when the request is complete. void APP_SST26TransferEventHandler(DRV_SST26_TRANSFER_STATUS event, uintptr_t context) { // The context handle was set to an application specific // object. It is now retrievable easily in the event handler. MY_APP_OBJ* pMyAppObj = (MY_APP_OBJ *) context; switch(event) { case DRV_SST26_TRANSFER_COMPLETED: { // This means the data was transferred. break; } case DRV_SST26_TRANSFER_ERROR: { // Error handling here. break; } default: { break; } } } // myHandle is the handle returned from DRV_SST26_Open API. // Client registers an event handler with driver. This is done once DRV_SST26_EventHandlerSet( myHandle, APP_SST26TransferEventHandler, (uintptr_t)&myAppObj ); if (DRV_SST26_Read(myHandle, myBuffer, BUFFER_SIZE, MEM_ADDRESS) == false) { // Error handling here }
Remarks
If the client does not want to be notified when the queued buffer transfer has completed, it does not need to register a callback.