/** * \brief Start DMAC Multiple Buffer Transfer. */ static uint8_t _start_dma_transfer(void) { uint32_t i; /* Prepare source data to be transfered. */ for (i = 0 ; i < BUFFER_LEN ; i++) { src_buf[i] = i; dest_buf[i] = 0xFF; } printf("-I- The Source Buffer content before transfer\n\r"); _dump_buffer(src_buf); /* Start transfer */ transfer_complete = false; cache_clean_region(src_buf, BUFFER_LEN); cache_clean_region(dest_buf, BUFFER_LEN); xdmad_start_transfer(xdmad_channel); /* Wait for completion */ while (!transfer_complete) { /* always call xdmad_poll, it will do nothing if polling mode * is disabled */ xdmad_poll(); } printf("-I- The Destination Buffer content after transfer\n\r"); cache_invalidate_region(dest_buf, BUFFER_LEN); _dump_buffer(dest_buf); return 0; }
/** * \brief Play demonstration audio music with DMA. */ static void _playback_with_dma(uint8_t attn) { uint32_t* audio = (uint32_t*)(music_data + sizeof(struct _wav_header)); uint32_t audio_length = ((struct _wav_header*)music_data)->subchunk2_size; volatile bool done = false; _playback_start(); _setup_dma_transfer(audio, audio_length); xdmad_set_callback(dma_channel, _dma_callback, (void *)&done); xdmad_start_transfer(dma_channel); while (!done); _playback_stop(); }