1.2.6.1 SYS_DMA_ChannelCallbackRegister Function
C
void SYS_DMA_ChannelCallbackRegister ( SYS_DMA_CHANNEL channel, const SYS_DMA_CHANNEL_CALLBACK eventHandler, const uintptr_t contextHandle )
Summary
This function allows a DMA client to set an event handler.
Description
This function allows a client to set an event handler. The client may want to receive transfer related events in cases when it submits a DMA transfer request. The event handler should be set before the client intends to perform operations that could generate events.
This function accepts a contextHandle parameter. This parameter could be set by the client to contain (or point to) any client specific data object that should be associated with this DMA channel.
Precondition
DMA Controller should have been initialized.
Parameters
Param | Description |
---|---|
channel | A specific DMA channel from which the events are expected. |
eventHandler | Pointer to the event handler function. |
contextHandle | Value identifying the context of the application/driver/middleware that registered the event handling function. |
Returns
None.
Example
MY_APP_OBJ myAppObj;
void APP_DMA_TransferEventHandler(SYS_DMA_TRANSFER_EVENT event, uintptr_t contextHandle)
{
switch(event)
{
case SYS_DMA_TRANSFER_COMPLETE:
// This means the data was transferred.
break;
case SYS_DMA_TRANSFER_ERROR:
// Error handling here.
break;
default:
break;
}
}
// User registers an event handler with DMA channel. This is done once.
SYS_DMA_ChannelCallbackRegister(channel, APP_DMA_TransferEventHandler,(uintptr_t)&myAppObj);
Remarks
None.