1.9.18.17 SDMMCx_CallbackRegister Function
C
/* x = SDMMC instance number */
void SDMMCx_CallbackRegister(SDMMC_CALLBACK callback, uintptr_t contextHandle)
Summary
This function allows a SDMMC PLIB application to set an event handler.
Description
This function allows a application to set an event handler. The application may want to receive transfer related events in cases when it submits a SDMMC PLIB transfer request. The event handler should be set before the application intends to perform operations that could generate events.
This function accepts a contextHandle parameter. This parameter could be set by the application to contain (or point to) any application specific data object that should be associated with this SDMMC PLIB. The contextHandle parameter is not modified by the PLIB and is passed as is in the application event handler.
Precondition
SDMMCx_Initialize() must have been called first for the associated instance.
Parameters
Param | Description |
---|---|
callback | Pointer to the event handler function |
contextHandle | The value of parameter will be passed back to the application unchanged, when the callback function is called. It can be used to identify any application specific data object that identifies the instance of the module (for example, it may be a pointer to the modules state structure) |
Returns
None.
Example
MY_APP_OBJ myAppObj;
static void SDMMC_TransferEventHandler(
SDMMC_XFER_STATUS xferStatus,
uintptr_t contextHandle
)
{
MY_APP_OBJ* myAppObj = (MY_APP_OBJ*)contextHandle;
if (xferStatus & SDMMC_XFER_STATUS_CMD_COMPLETED)
{
// Command transfer complete, read the command error status.
cmd_error = SDMMC1_CommandErrorGet();
}
if (xferStatus & SDMMC_XFER_STATUS_DATA_COMPLETED)
{
// Data transfer complete, read the data error status.
data_error = SDMMC1_DataErrorGet();
}
}
// User registers an event handler with the SDMMC PLIB. This is usually done once.
SDMMC1_CallbackRegister(SDMMC_TransferEventHandler, (uintptr_t)&myAppObj);
Remarks
None.