1.3.8.3 1.4.6.3 1.5.7.3 1.6.6.3 1.7.7.3 1.10.7.3 1.11.8.3 1.12.7.3 1.13.7.3 1.15.8.3 1.16.6.3 1.17.6.3 1.18.7.3 1.19.6.3 1.20.6.3 1.21.7.3 1.22.9.3 1.23.8.3 1.24.7.3 1.29.8.3 1.30.5.3 1.31.5.3 1.32.8.3 1.33.5.3 1.37.5.3 1.38.6.3 1.39.5.3 1.40.6.3 DMAC_ChannelTransfer Function
C
The prototype of this function varies based on device family. Refer to the generated header file for the actual prototype to be used.
bool DMAC_ChannelTransfer( DMAC_CHANNEL channel, const void *srcAddr,
size_t srcSize, const void *destAddr, size_t destSize, size_t cellSize)
bool DMAC_ChannelTransfer(DMAC_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. This address will override the source address which was specified at the time of configuring the channel in DMA Manager. When a trigger is received, the module will transfer beat size of data from the source address. In such a case, the source address is typically a result register of the peripheral generating the trigger. For a memory to memory transfer, the srcAddress parameter points to the source address location in RAM.
The destAddr parameter specifies the address location where the data will be stored. This parameter will override the setting in MHC. If the destination address is a peripheral register, the channel trigger may be an interrupt generated by the peripheral. In case of a memory to memory transfer, this is the address where the data will be stored. If the CRC engine is enabled and configured in Memory mode then Store the seed to be used by CRC engine in the destination address.
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 DMAC_TRANSFER_COMPLETE event if the transfer was processed successfully and a DMAC_TRANSFER_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
DMAC should have been initialized by calling the DMAC_Initialize. Based on device family, the required channel transfer parameters such as beat size, source and destination address increment should have been configured in MHC
Parameters
Parameters of this function varies based on device family. Refer to the one which is applicable for the device being used.
Param | Description |
---|---|
DMAC_CHANNEL channel | DMA channel to use for this transfer |
srcAddr | pointer to source data |
srcSize | Size of the source |
destAddr | pointer to where data is to be moved to |
destSize | Size of the destination |
cellSize | Size of the cell |
Param | Description |
---|---|
channel | The DMAC channel that should be used for the transfer. |
srcAddr | Source address of the DMAC transfer |
destAddr | Destination address of the DMAC transfer. If the CRC engine is enabled and configured in Memory mode then Store the seed to be used by CRC engine in the destination address. |
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
Example of this function varies based on device family. Refer to the one which is applicable for the device being used.
// Transfer 10 bytes of data to UART TX using DMAC 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*) &U1TXREG; size_t size = 10; // User registers an event handler with PLIB. This is done once. DMAC_ChannelCallbackRegister(DMAC_CHANNEL_1, APP_DMACTransferEventHandler, (uintptr_t)&myAppObj); if(DMAC_ChannelTransfer(DMAC_CHANNEL_1, srcAddr, size, destAddr, 1, 1) == true) { // do something else } else { // try again? }
// Transfer 10 bytes of data to UART TX using DMAC 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. DMAC_ChannelCallbackRegister(DMAC_CHANNEL_1, APP_DMACTransferEventHandler, (uintptr_t)&myAppObj); if(DMAC_ChannelTransfer(DMAC_CHANNEL_1, srcAddr, destAddr, size) == true) { // do something else } else { // try again? }
Remarks
None.