Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Impedance_Fast_Circuitry by
Diff: dma.cpp
- Revision:
- 40:bd6d8c35e822
- Parent:
- 39:82dc3daecf32
- Child:
- 41:3e0623d81b9a
--- a/dma.cpp Thu Jan 29 16:18:54 2015 +0000 +++ b/dma.cpp Fri Jan 30 06:16:39 2015 +0000 @@ -16,8 +16,9 @@ * @len = the length of array1 and array2, and the number of reads the DMA completes * */ -void dma_init(uint16_t* array0, uint16_t* array1, uint16_t* array2, int len, Serial &pc) +void dma_init(int len) { + // select round-robin arbitration priority DMA_CR |= DMA_CR_ERCA_MASK; @@ -36,11 +37,11 @@ // Set memory address for source and destination for DMA0, DMA1, and DMA2 DMA_TCD0_SADDR = (uint32_t)&ADC0_RA; - DMA_TCD0_DADDR = (uint32_t) array0; + DMA_TCD0_DADDR = (uint32_t) sample_array1; DMA_TCD1_SADDR = (uint32_t)&ADC1_RA; - DMA_TCD1_DADDR = (uint32_t) array1; + DMA_TCD1_DADDR = (uint32_t) sample_array2; DMA_TCD2_SADDR = (uint32_t)&rotary_count; - DMA_TCD2_DADDR = (uint32_t) array2; + DMA_TCD2_DADDR = (uint32_t) angle_array; // Set an offset for source and destination address DMA_TCD0_SOFF = 0x00; // Source address offset of 2 bits per transaction @@ -82,7 +83,7 @@ DMA_TCD1_CSR = 0; DMA_TCD2_CSR = 1; - pc.printf("DMA_CR: %08x\r\n", DMA_CR); + /*pc.printf("DMA_CR: %08x\r\n", DMA_CR); pc.printf("DMA_ES: %08x\r\n", DMA_ES); pc.printf("DMA_ERQ: %08x\r\n", DMA_ERQ); pc.printf("DMA_EEI: %08x\r\n", DMA_EEI); @@ -96,5 +97,12 @@ pc.printf("DMA_CINT: %02x\r\n", DMA_CINT); pc.printf("DMA_INT: %08x\r\n", DMA_INT); pc.printf("DMA_ERR: %08x\r\n", DMA_ERR); - pc.printf("DMA_HRS: %08x\r\n", DMA_HRS); + pc.printf("DMA_HRS: %08x\r\n", DMA_HRS);*/ } + +void reset_dma() { + // Set memory address for destinations back to the beginning + DMA_TCD0_DADDR = (uint32_t) sample_array1; + DMA_TCD1_DADDR = (uint32_t) sample_array2; + DMA_TCD2_DADDR = (uint32_t) angle_array; +}