Configure DMA CTRLA:desc.ul_source_addr = (uint32_t) g_dma_buf[0];
desc.ul_destination_addr = (uint32_t) g_dma_buf[1];
Set the buffer transfer size to DMA_BUF_SIZE
Set the source transfer width to 32-bit
Configure DMA CTRLB:desc.ul_ctrlA = DMAC_CTRLA_BTSIZE(DMA_BUF_SIZE) |
DMAC_CTRLA_SRC_WIDTH_WORD |
DMAC_CTRLA_DST_WIDTH_WORD;
Disable source buffer descriptor fetch
Disable destination buffer descriptor Fetch
Enable memory-to-memory transfer
Increment the source address
Initialize the DMA transfer:desc.ul_ctrlB = DMAC_CTRLB_SRC_DSCR_FETCH_DISABLE |
DMAC_CTRLB_DST_DSCR_FETCH_DISABLE |
DMAC_CTRLB_FC_MEM2MEM_DMA_FC |
DMAC_CTRLB_SRC_INCR_INCREMENTING |
DMAC_CTRLB_DST_INCR_INCREMENTING;
Start the DMA transfer:desc.ul_descriptor_addr = 0;
dmac_channel_single_buf_transfer_init(DMAC, DMA_CH, &desc);
dmac_channel_enable(DMAC, DMA_CH);
Finally, poll for the DMA transfer to complete: while
(!dmac_channel_is_transfer_done(DMAC, DMA_CH)) {
}