1.2.5.3 1.9.4.3 DMA_ChannelTransfer Function
C
bool DMA_ChannelTransfer( DMA_CHANNEL channel, const void *srcAddr, const void *destAddr, size_t blockSize )
Summary
Schedules a DMA transfer on the specified DMA channel.
Description
This function schedules a DMA transfer on the specified DMA channel and starts the transfer when the configured trigger is received. The transfer is processed based on the channel configuration performed in the DMA manager. The channel parameter specifies the channel to be used for the transfer.
The srcAddr parameter specifies the source address from where data will be transferred.
The destAddr parameter specifies the address location where the data will be stored.
If the channel is configured for software trigger, calling the channel transfer function will set the source and destination address and will also start the transfer. If the channel was configured for a peripheral trigger, the channel transfer function will set the source and destination address and will transfer data when a trigger has occurred.
If the requesting client registered an event callback function before calling the channel transfer function, this function will be called when the transfer completes. The callback function will be called with a DMA_TRANSFER EVENT_BLOCK_TRANSFER_COMPLETE event if the transfer was processed successfully and a DMA_TRANSFER_EVENT_ERROR event if the transfer was not processed successfully.
When already a transfer is in progress, this API will return false indicating that transfer request is not accepted.
Precondition
DMA should have been initialized by calling the DMA_Initialize. The required channel transfer parameters such as beat size, source and destination address increment should have been configured in MHC.
Parameters
Param | Description |
---|---|
channel | The DMA channel that should be used for the transfer. |
srcAddr | Source address of the DMA transfer |
destAddr | Destination address of the DMA transfer |
blockSize | Size of the transfer block in bytes. |
Returns
True - If transfer request is accepted.
False - If previous transfer is in progress and the request is rejected.
Example
// Transfer 10 bytes of data to UART TX using DMA channel 1 MY_APP_OBJ myAppObj; uint8_t buf[10] = {0,1,2,3,4,5,6,7,8,9}; void *srcAddr = (uint8_t *) buf; void *destAddr = (uin8_t*) &SERCOM1_REGS->USART_INT.SERCOM_DATA; size_t size = 10; // User registers an event handler with PLIB. This is done once. DMA_ChannelCallbackRegister(DMA_CHANNEL_1, APP_DMATransferEventHandler, (uintptr_t)&myAppObj); if(DMA_ChannelTransfer(DMA_CHANNEL_1, srcAddr, destAddr, size) == true) { // do something else } else { // try again? }
Remarks
None.