Callbacks

There are two circumstances in which the FDMA driver calls a callback function. The first is when the transfer is completed (either at the end of single node or the end of the final node in a linked list) and the second is when the FDMA driver detects an error in the transfer. The API provides two functions to enable the callback mechanism for these two scenarios: dma_parms_comp_cb() for the "end of transfer" callback and dma_parms_err_cb() for the error detected callback.

void dma_parms_comp_cb(struct stm_dma_params *p,
                       void (*fn)(void* param),
                       void* param,
                       int isr_context);
 
void dma_parms_err_cb(struct stm_dma_params *p,
                      void (*fn)(void* param),
                      void* param,
                      int isr_context);

Both functions accept the following set of parameters:

Parameters Description
p This is a pointer to the stm_dma_params structure for the transfer.
fn A pointer to a callback function, which must be declared with the type void fn(void*). If this parameter is NULL then the callback is disabled.
param The void * parameter to pass to the above callback function.
isr_context The context in which the callback should be executed (either STM_DMA_CB_CONTEXT_ISR to call directly from the interrupt handler or STM_DMA_CB_CONTEXT_TASKLET to call from a tasklet).