structdma_resource_config config;
dma_get_config_defaults(&config);
dma_allocate(resource, &config);
structdma_descriptor_config descriptor_config;
dma_descriptor_get_config_defaults(&descriptor_config);
Set the specific parameters for a DMA transfer with transfer size, source address, and destination address. In this example, we have enabled the source and destination address increment. The source and destination addresses to be stored into descriptor_config must correspond to the end of the transfer.
descriptor_config.block_transfer_count =sizeof(source_memory);descriptor_config.source_address = (uint32_t)source_memory +sizeof(source_memory);descriptor_config.destination_address = (uint32_t)destination_memory +sizeof(source_memory);
dma_descriptor_create(descriptor, &descriptor_config);
dma_add_descriptor(&example_resource, &example_descriptor);
dma_register_callback(&example_resource, transfer_done,DMA_CALLBACK_TRANSFER_DONE);
staticvoidtransfer_done(structdma_resource*constresource ){transfer_is_done =true;}
dma_enable_callback(&example_resource, DMA_CALLBACK_TRANSFER_DONE);