37#ifdef LIBOPENCM3_DMA_H
39#ifndef LIBOPENCM3_DMA_COMMON_F13_H
40#define LIBOPENCM3_DMA_COMMON_F13_H
51#define DMA_ISR(dma_base) MMIO32((dma_base) + 0x00)
52#define DMA1_ISR DMA_ISR(DMA1)
53#define DMA2_ISR DMA_ISR(DMA2)
56#define DMA_IFCR(dma_base) MMIO32((dma_base) + 0x04)
57#define DMA1_IFCR DMA_IFCR(DMA1)
58#define DMA2_IFCR DMA_IFCR(DMA2)
61#define DMA_CCR(dma_base, channel) MMIO32((dma_base) + 0x08 + \
62 (0x14 * ((channel) - 1)))
64#define DMA1_CCR(channel) DMA_CCR(DMA1, channel)
65#define DMA1_CCR1 DMA1_CCR(DMA_CHANNEL1)
66#define DMA1_CCR2 DMA1_CCR(DMA_CHANNEL2)
67#define DMA1_CCR3 DMA1_CCR(DMA_CHANNEL3)
68#define DMA1_CCR4 DMA1_CCR(DMA_CHANNEL4)
69#define DMA1_CCR5 DMA1_CCR(DMA_CHANNEL5)
70#define DMA1_CCR6 DMA1_CCR(DMA_CHANNEL6)
71#define DMA1_CCR7 DMA1_CCR(DMA_CHANNEL7)
73#define DMA2_CCR(channel) DMA_CCR(DMA2, channel)
74#define DMA2_CCR1 DMA2_CCR(DMA_CHANNEL1)
75#define DMA2_CCR2 DMA2_CCR(DMA_CHANNEL2)
76#define DMA2_CCR3 DMA2_CCR(DMA_CHANNEL3)
77#define DMA2_CCR4 DMA2_CCR(DMA_CHANNEL4)
78#define DMA2_CCR5 DMA2_CCR(DMA_CHANNEL5)
81#define DMA_CNDTR(dma_base, channel) MMIO32((dma_base) + 0x0C + \
82 (0x14 * ((channel) - 1)))
84#define DMA1_CNDTR(channel) DMA_CNDTR(DMA1, channel)
85#define DMA1_CNDTR1 DMA1_CNDTR(DMA_CHANNEL1)
86#define DMA1_CNDTR2 DMA1_CNDTR(DMA_CHANNEL2)
87#define DMA1_CNDTR3 DMA1_CNDTR(DMA_CHANNEL3)
88#define DMA1_CNDTR4 DMA1_CNDTR(DMA_CHANNEL4)
89#define DMA1_CNDTR5 DMA1_CNDTR(DMA_CHANNEL5)
90#define DMA1_CNDTR6 DMA1_CNDTR(DMA_CHANNEL6)
91#define DMA1_CNDTR7 DMA1_CNDTR(DMA_CHANNEL7)
93#define DMA2_CNDTR(channel) DMA_CNDTR(DMA2, channel)
94#define DMA2_CNDTR1 DMA2_CNDTR(DMA_CHANNEL1)
95#define DMA2_CNDTR2 DMA2_CNDTR(DMA_CHANNEL2)
96#define DMA2_CNDTR3 DMA2_CNDTR(DMA_CHANNEL3)
97#define DMA2_CNDTR4 DMA2_CNDTR(DMA_CHANNEL4)
98#define DMA2_CNDTR5 DMA2_CNDTR(DMA_CHANNEL5)
101#define DMA_CPAR(dma_base, channel) MMIO32((dma_base) + 0x10 + \
102 (0x14 * ((channel) - 1)))
104#define DMA1_CPAR(channel) DMA_CPAR(DMA1, channel)
105#define DMA1_CPAR1 DMA1_CPAR(DMA_CHANNEL1)
106#define DMA1_CPAR2 DMA1_CPAR(DMA_CHANNEL2)
107#define DMA1_CPAR3 DMA1_CPAR(DMA_CHANNEL3)
108#define DMA1_CPAR4 DMA1_CPAR(DMA_CHANNEL4)
109#define DMA1_CPAR5 DMA1_CPAR(DMA_CHANNEL5)
110#define DMA1_CPAR6 DMA1_CPAR(DMA_CHANNEL6)
111#define DMA1_CPAR7 DMA1_CPAR(DMA_CHANNEL7)
113#define DMA2_CPAR(channel) DMA_CPAR(DMA2, channel)
114#define DMA2_CPAR1 DMA2_CPAR(DMA_CHANNEL1)
115#define DMA2_CPAR2 DMA2_CPAR(DMA_CHANNEL2)
116#define DMA2_CPAR3 DMA2_CPAR(DMA_CHANNEL3)
117#define DMA2_CPAR4 DMA2_CPAR(DMA_CHANNEL4)
118#define DMA2_CPAR5 DMA2_CPAR(DMA_CHANNEL5)
122#define DMA_CMAR(dma_base, channel) MMIO32((dma_base) + 0x14 + \
123 (0x14 * ((channel) - 1)))
125#define DMA1_CMAR(channel) DMA_CMAR(DMA1, channel)
126#define DMA1_CMAR1 DMA1_CMAR(DMA_CHANNEL1)
127#define DMA1_CMAR2 DMA1_CMAR(DMA_CHANNEL2)
128#define DMA1_CMAR3 DMA1_CMAR(DMA_CHANNEL3)
129#define DMA1_CMAR4 DMA1_CMAR(DMA_CHANNEL4)
130#define DMA1_CMAR5 DMA1_CMAR(DMA_CHANNEL5)
131#define DMA1_CMAR6 DMA1_CMAR(DMA_CHANNEL6)
132#define DMA1_CMAR7 DMA1_CMAR(DMA_CHANNEL7)
134#define DMA2_CMAR(channel) DMA_CMAR(DMA2, channel)
135#define DMA2_CMAR1 DMA2_CMAR(DMA_CHANNEL1)
136#define DMA2_CMAR2 DMA2_CMAR(DMA_CHANNEL2)
137#define DMA2_CMAR3 DMA2_CMAR(DMA_CHANNEL3)
138#define DMA2_CMAR4 DMA2_CMAR(DMA_CHANNEL4)
139#define DMA2_CMAR5 DMA2_CMAR(DMA_CHANNEL5)
153#define DMA_TEIF (1 << 3)
155#define DMA_HTIF (1 << 2)
157#define DMA_TCIF (1 << 1)
159#define DMA_GIF (1 << 0)
165#define DMA_FLAG_OFFSET(channel) (4*((channel) - 1))
166#define DMA_FLAGS (DMA_TEIF | DMA_TCIF | DMA_HTIF | \
168#define DMA_ISR_MASK(channel) (DMA_FLAGS << DMA_FLAG_OFFSET(channel))
171#define DMA_ISR_TEIF_BIT DMA_TEIF
172#define DMA_ISR_TEIF(channel) (DMA_ISR_TEIF_BIT << \
173 (DMA_FLAG_OFFSET(channel)))
175#define DMA_ISR_TEIF1 DMA_ISR_TEIF(DMA_CHANNEL1)
176#define DMA_ISR_TEIF2 DMA_ISR_TEIF(DMA_CHANNEL2)
177#define DMA_ISR_TEIF3 DMA_ISR_TEIF(DMA_CHANNEL3)
178#define DMA_ISR_TEIF4 DMA_ISR_TEIF(DMA_CHANNEL4)
179#define DMA_ISR_TEIF5 DMA_ISR_TEIF(DMA_CHANNEL5)
180#define DMA_ISR_TEIF6 DMA_ISR_TEIF(DMA_CHANNEL6)
181#define DMA_ISR_TEIF7 DMA_ISR_TEIF(DMA_CHANNEL7)
184#define DMA_ISR_HTIF_BIT DMA_HTIF
185#define DMA_ISR_HTIF(channel) (DMA_ISR_HTIF_BIT << \
186 (DMA_FLAG_OFFSET(channel)))
188#define DMA_ISR_HTIF1 DMA_ISR_HTIF(DMA_CHANNEL1)
189#define DMA_ISR_HTIF2 DMA_ISR_HTIF(DMA_CHANNEL2)
190#define DMA_ISR_HTIF3 DMA_ISR_HTIF(DMA_CHANNEL3)
191#define DMA_ISR_HTIF4 DMA_ISR_HTIF(DMA_CHANNEL4)
192#define DMA_ISR_HTIF5 DMA_ISR_HTIF(DMA_CHANNEL5)
193#define DMA_ISR_HTIF6 DMA_ISR_HTIF(DMA_CHANNEL6)
194#define DMA_ISR_HTIF7 DMA_ISR_HTIF(DMA_CHANNEL7)
197#define DMA_ISR_TCIF_BIT DMA_TCIF
198#define DMA_ISR_TCIF(channel) (DMA_ISR_TCIF_BIT << \
199 (DMA_FLAG_OFFSET(channel)))
201#define DMA_ISR_TCIF1 DMA_ISR_TCIF(DMA_CHANNEL1)
202#define DMA_ISR_TCIF2 DMA_ISR_TCIF(DMA_CHANNEL2)
203#define DMA_ISR_TCIF3 DMA_ISR_TCIF(DMA_CHANNEL3)
204#define DMA_ISR_TCIF4 DMA_ISR_TCIF(DMA_CHANNEL4)
205#define DMA_ISR_TCIF5 DMA_ISR_TCIF(DMA_CHANNEL5)
206#define DMA_ISR_TCIF6 DMA_ISR_TCIF(DMA_CHANNEL6)
207#define DMA_ISR_TCIF7 DMA_ISR_TCIF(DMA_CHANNEL7)
210#define DMA_ISR_GIF_BIT DMA_GIF
211#define DMA_ISR_GIF(channel) (DMA_ISR_GIF_BIT << \
212 (DMA_FLAG_OFFSET(channel)))
214#define DMA_ISR_GIF1 DMA_ISR_GIF(DMA_CHANNEL1)
215#define DMA_ISR_GIF2 DMA_ISR_GIF(DMA_CHANNEL2)
216#define DMA_ISR_GIF3 DMA_ISR_GIF(DMA_CHANNEL3)
217#define DMA_ISR_GIF4 DMA_ISR_GIF(DMA_CHANNEL4)
218#define DMA_ISR_GIF5 DMA_ISR_GIF(DMA_CHANNEL5)
219#define DMA_ISR_GIF6 DMA_ISR_GIF(DMA_CHANNEL6)
220#define DMA_ISR_GIF7 DMA_ISR_GIF(DMA_CHANNEL7)
225#define DMA_IFCR_CTEIF_BIT DMA_TEIF
226#define DMA_IFCR_CTEIF(channel) (DMA_IFCR_CTEIF_BIT << \
227 (DMA_FLAG_OFFSET(channel)))
229#define DMA_IFCR_CTEIF1 DMA_IFCR_CTEIF(DMA_CHANNEL1)
230#define DMA_IFCR_CTEIF2 DMA_IFCR_CTEIF(DMA_CHANNEL2)
231#define DMA_IFCR_CTEIF3 DMA_IFCR_CTEIF(DMA_CHANNEL3)
232#define DMA_IFCR_CTEIF4 DMA_IFCR_CTEIF(DMA_CHANNEL4)
233#define DMA_IFCR_CTEIF5 DMA_IFCR_CTEIF(DMA_CHANNEL5)
234#define DMA_IFCR_CTEIF6 DMA_IFCR_CTEIF(DMA_CHANNEL6)
235#define DMA_IFCR_CTEIF7 DMA_IFCR_CTEIF(DMA_CHANNEL7)
238#define DMA_IFCR_CHTIF_BIT DMA_HTIF
239#define DMA_IFCR_CHTIF(channel) (DMA_IFCR_CHTIF_BIT << \
240 (DMA_FLAG_OFFSET(channel)))
242#define DMA_IFCR_CHTIF1 DMA_IFCR_CHTIF(DMA_CHANNEL1)
243#define DMA_IFCR_CHTIF2 DMA_IFCR_CHTIF(DMA_CHANNEL2)
244#define DMA_IFCR_CHTIF3 DMA_IFCR_CHTIF(DMA_CHANNEL3)
245#define DMA_IFCR_CHTIF4 DMA_IFCR_CHTIF(DMA_CHANNEL4)
246#define DMA_IFCR_CHTIF5 DMA_IFCR_CHTIF(DMA_CHANNEL5)
247#define DMA_IFCR_CHTIF6 DMA_IFCR_CHTIF(DMA_CHANNEL6)
248#define DMA_IFCR_CHTIF7 DMA_IFCR_CHTIF(DMA_CHANNEL7)
251#define DMA_IFCR_CTCIF_BIT DMA_TCIF
252#define DMA_IFCR_CTCIF(channel) (DMA_IFCR_CTCIF_BIT << \
253 (DMA_FLAG_OFFSET(channel)))
255#define DMA_IFCR_CTCIF1 DMA_IFCR_CTCIF(DMA_CHANNEL1)
256#define DMA_IFCR_CTCIF2 DMA_IFCR_CTCIF(DMA_CHANNEL2)
257#define DMA_IFCR_CTCIF3 DMA_IFCR_CTCIF(DMA_CHANNEL3)
258#define DMA_IFCR_CTCIF4 DMA_IFCR_CTCIF(DMA_CHANNEL4)
259#define DMA_IFCR_CTCIF5 DMA_IFCR_CTCIF(DMA_CHANNEL5)
260#define DMA_IFCR_CTCIF6 DMA_IFCR_CTCIF(DMA_CHANNEL6)
261#define DMA_IFCR_CTCIF7 DMA_IFCR_CTCIF(DMA_CHANNEL7)
264#define DMA_IFCR_CGIF_BIT DMA_GIF
265#define DMA_IFCR_CGIF(channel) (DMA_IFCR_CGIF_BIT << \
266 (DMA_FLAG_OFFSET(channel)))
268#define DMA_IFCR_CGIF1 DMA_IFCR_CGIF(DMA_CHANNEL1)
269#define DMA_IFCR_CGIF2 DMA_IFCR_CGIF(DMA_CHANNEL2)
270#define DMA_IFCR_CGIF3 DMA_IFCR_CGIF(DMA_CHANNEL3)
271#define DMA_IFCR_CGIF4 DMA_IFCR_CGIF(DMA_CHANNEL4)
272#define DMA_IFCR_CGIF5 DMA_IFCR_CGIF(DMA_CHANNEL5)
273#define DMA_IFCR_CGIF6 DMA_IFCR_CGIF(DMA_CHANNEL6)
274#define DMA_IFCR_CGIF7 DMA_IFCR_CGIF(DMA_CHANNEL7)
277#define DMA_IFCR_CIF_BIT 0xF
278#define DMA_IFCR_CIF(channel) (DMA_IFCR_CIF_BIT << \
279 (DMA_FLAG_OFFSET(channel)))
281#define DMA_IFCR_CIF1 DMA_IFCR_CIF(DMA_CHANNEL1)
282#define DMA_IFCR_CIF2 DMA_IFCR_CIF(DMA_CHANNEL2)
283#define DMA_IFCR_CIF3 DMA_IFCR_CIF(DMA_CHANNEL3)
284#define DMA_IFCR_CIF4 DMA_IFCR_CIF(DMA_CHANNEL4)
285#define DMA_IFCR_CIF5 DMA_IFCR_CIF(DMA_CHANNEL5)
286#define DMA_IFCR_CIF6 DMA_IFCR_CIF(DMA_CHANNEL6)
287#define DMA_IFCR_CIF7 DMA_IFCR_CIF(DMA_CHANNEL7)
292#define DMA_CCR_MEM2MEM (1 << 14)
299#define DMA_CCR_PL_LOW (0x0 << 12)
300#define DMA_CCR_PL_MEDIUM (0x1 << 12)
301#define DMA_CCR_PL_HIGH (0x2 << 12)
302#define DMA_CCR_PL_VERY_HIGH (0x3 << 12)
304#define DMA_CCR_PL_MASK (0x3 << 12)
305#define DMA_CCR_PL_SHIFT 12
312#define DMA_CCR_MSIZE_8BIT (0x0 << 10)
313#define DMA_CCR_MSIZE_16BIT (0x1 << 10)
314#define DMA_CCR_MSIZE_32BIT (0x2 << 10)
316#define DMA_CCR_MSIZE_MASK (0x3 << 10)
317#define DMA_CCR_MSIZE_SHIFT 10
324#define DMA_CCR_PSIZE_8BIT (0x0 << 8)
325#define DMA_CCR_PSIZE_16BIT (0x1 << 8)
326#define DMA_CCR_PSIZE_32BIT (0x2 << 8)
328#define DMA_CCR_PSIZE_MASK (0x3 << 8)
329#define DMA_CCR_PSIZE_SHIFT 8
332#define DMA_CCR_MINC (1 << 7)
335#define DMA_CCR_PINC (1 << 6)
338#define DMA_CCR_CIRC (1 << 5)
341#define DMA_CCR_DIR (1 << 4)
344#define DMA_CCR_TEIE (1 << 3)
347#define DMA_CCR_HTIE (1 << 2)
350#define DMA_CCR_TCIE (1 << 1)
353#define DMA_CCR_EN (1 << 0)
373#define DMA_CHANNEL1 1
374#define DMA_CHANNEL2 2
375#define DMA_CHANNEL3 3
376#define DMA_CHANNEL4 4
377#define DMA_CHANNEL5 5
378#define DMA_CHANNEL6 6
379#define DMA_CHANNEL7 7
388 uint32_t interrupts);
394 uint32_t peripheral_size);
421#warning "dma_common_f13.h should not be included explicitly, only via dma.h"
void dma_set_read_from_memory(uint32_t dma, uint8_t channel)
DMA Channel Enable Transfers from Memory.
void dma_disable_transfer_complete_interrupt(uint32_t dma, uint8_t channel)
DMA Channel Disable Interrupt on Transfer Complete.
void dma_set_priority(uint32_t dma, uint8_t channel, uint32_t prio)
DMA Channel Set Priority.
void dma_enable_transfer_complete_interrupt(uint32_t dma, uint8_t channel)
DMA Channel Enable Interrupt on Transfer Complete.
void dma_set_memory_address(uint32_t dma, uint8_t channel, uint32_t address)
DMA Channel Set the Base Memory Address.
void dma_disable_memory_increment_mode(uint32_t dma, uint8_t channel)
DMA Channel Disable Memory Increment after Transfer.
void dma_set_number_of_data(uint32_t dma, uint8_t channel, uint16_t number)
DMA Channel Set the Transfer Block Size.
uint16_t dma_get_number_of_data(uint32_t dma, uint8_t channel)
DMA Channel Get the Transfer Block Size.
void dma_enable_memory_increment_mode(uint32_t dma, uint8_t channel)
DMA Channel Enable Memory Increment after Transfer.
void dma_disable_transfer_error_interrupt(uint32_t dma, uint8_t channel)
DMA Channel Disable Interrupt on Transfer Error.
void dma_set_read_from_peripheral(uint32_t dma, uint8_t channel)
DMA Channel Enable Transfers from a Peripheral.
void dma_disable_channel(uint32_t dma, uint8_t channel)
DMA Channel Disable.
void dma_disable_half_transfer_interrupt(uint32_t dma, uint8_t channel)
DMA Channel Disable Interrupt on Transfer Half Complete.
void dma_enable_peripheral_increment_mode(uint32_t dma, uint8_t channel)
DMA Channel Enable Peripheral Increment after Transfer.
void dma_enable_channel(uint32_t dma, uint8_t channel)
DMA Channel Enable.
void dma_enable_circular_mode(uint32_t dma, uint8_t channel)
DMA Channel Enable Memory Circular Mode.
void dma_enable_transfer_error_interrupt(uint32_t dma, uint8_t channel)
DMA Channel Enable Interrupt on Transfer Error.
void dma_channel_reset(uint32_t dma, uint8_t channel)
DMA Channel Reset.
void dma_disable_peripheral_increment_mode(uint32_t dma, uint8_t channel)
DMA Channel Disable Peripheral Increment after Transfer.
bool dma_get_interrupt_flag(uint32_t dma, uint8_t channel, uint32_t interrupts)
DMA Channel Read Interrupt Flag.
void dma_clear_interrupt_flags(uint32_t dma, uint8_t channel, uint32_t interrupts)
DMA Channel Clear Interrupt Flag.
void dma_enable_mem2mem_mode(uint32_t dma, uint8_t channel)
DMA Channel Enable Memory to Memory Transfers.
void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t channel)
DMA Channel Enable Interrupt on Transfer Half Complete.
void dma_set_peripheral_size(uint32_t dma, uint8_t channel, uint32_t peripheral_size)
DMA Channel Set Peripheral Word Width.
void dma_set_peripheral_address(uint32_t dma, uint8_t channel, uint32_t address)
DMA Channel Set the Peripheral Address.
void dma_set_memory_size(uint32_t dma, uint8_t channel, uint32_t mem_size)
DMA Channel Set Memory Word Width.