libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
dma_common_f24.h
Go to the documentation of this file.
1/** @addtogroup dma_defines
2
3@author @htmlonly © @endhtmlonly 2011
4Fergus Noble <fergusnoble@gmail.com>
5@author @htmlonly &copy; @endhtmlonly 2012
6Ken Sarkies <ksarkies@internode.on.net>
7
8*/
9/*
10 * This file is part of the libopencm3 project.
11 *
12 * Copyright (C) 2011 Fergus Noble <fergusnoble@gmail.com>
13 * Copyright (C) 2012 Ken Sarkies <ksarkies@internode.on.net>
14 *
15 * This library is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public License
26 * along with this library. If not, see <http://www.gnu.org/licenses/>.
27 */
28
29/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA DMA.H
30The order of header inclusion is important. dma.h includes the device
31specific memorymap.h header before including this header file.*/
32
33/** @cond */
34#ifdef LIBOPENCM3_DMA_H
35/** @endcond */
36#ifndef LIBOPENCM3_DMA_COMMON_F24_H
37#define LIBOPENCM3_DMA_COMMON_F24_H
38
39/**@{*/
40
41/* --- Convenience macros -------------------------------------------------- */
42
43/* DMA controller base addresses (for convenience) */
44#define DMA1 DMA1_BASE
45#define DMA2 DMA2_BASE
46
47/* DMA stream base addresses (for API parameters) */
48/** @defgroup dma_st_number DMA Stream Number
49@ingroup STM32F4xx_dma_defines
50
51@{*/
52#define DMA_STREAM0 0
53#define DMA_STREAM1 1
54#define DMA_STREAM2 2
55#define DMA_STREAM3 3
56#define DMA_STREAM4 4
57#define DMA_STREAM5 5
58#define DMA_STREAM6 6
59#define DMA_STREAM7 7
60/**@}*/
61
62#define DMA_STREAM(port, n) ((port) + 0x10 + (24 * (n)))
63#define DMA1_STREAM(n) DMA_STREAM(DMA1, (n))
64#define DMA2_STREAM(n) DMA_STREAM(DMA2, (n))
65
66#define DMA1_STREAM0 DMA1_STREAM(0)
67#define DMA1_STREAM1 DMA1_STREAM(1)
68#define DMA1_STREAM2 DMA1_STREAM(2)
69#define DMA1_STREAM3 DMA1_STREAM(3)
70#define DMA1_STREAM4 DMA1_STREAM(4)
71#define DMA1_STREAM5 DMA1_STREAM(5)
72#define DMA1_STREAM6 DMA1_STREAM(6)
73#define DMA1_STREAM7 DMA1_STREAM(7)
74
75#define DMA2_STREAM0 DMA2_STREAM(0)
76#define DMA2_STREAM1 DMA2_STREAM(1)
77#define DMA2_STREAM2 DMA2_STREAM(2)
78#define DMA2_STREAM3 DMA2_STREAM(3)
79#define DMA2_STREAM4 DMA2_STREAM(4)
80#define DMA2_STREAM5 DMA2_STREAM(5)
81#define DMA2_STREAM6 DMA2_STREAM(6)
82#define DMA2_STREAM7 DMA2_STREAM(7)
83
84/* --- DMA controller registers -------------------------------------------- */
85
86/* DMA low interrupt status register (DMAx_LISR) */
87#define DMA_LISR(port) MMIO32((port) + 0x00)
88#define DMA1_LISR DMA_LISR(DMA1)
89#define DMA2_LISR DMA_LISR(DMA2)
90
91/* DMA high interrupt status register (DMAx_HISR) */
92#define DMA_HISR(port) MMIO32((port) + 0x04)
93#define DMA1_HISR DMA_HISR(DMA1)
94#define DMA2_HISR DMA_HISR(DMA2)
95
96/* DMA low interrupt flag clear register (DMAx_LIFCR) */
97#define DMA_LIFCR(port) MMIO32((port) + 0x08)
98#define DMA1_LIFCR DMA_LIFCR(DMA1)
99#define DMA2_LIFCR DMA_LIFCR(DMA2)
100
101/* DMA high interrupt flag clear register (DMAx_HIFCR) */
102#define DMA_HIFCR(port) MMIO32((port) + 0x0C)
103#define DMA1_HIFCR DMA_HIFCR(DMA1)
104#define DMA2_HIFCR DMA_HIFCR(DMA2)
105
106/* --- DMA stream registers ------------------------------------------------ */
107
108/* DMA Stream x configuration register (DMA_SxCR) */
109#define DMA_SCR(port, n) MMIO32(DMA_STREAM((port), (n)) + 0x00)
110#define DMA1_SCR(n) DMA_SCR(DMA1, (n))
111#define DMA2_SCR(n) DMA_SCR(DMA2, (n))
112
113#define DMA1_S0CR DMA1_SCR(0)
114#define DMA1_S1CR DMA1_SCR(1)
115#define DMA1_S2CR DMA1_SCR(2)
116#define DMA1_S3CR DMA1_SCR(3)
117#define DMA1_S4CR DMA1_SCR(4)
118#define DMA1_S5CR DMA1_SCR(5)
119#define DMA1_S6CR DMA1_SCR(6)
120#define DMA1_S7CR DMA1_SCR(7)
121
122#define DMA2_S0CR DMA2_SCR(0)
123#define DMA2_S1CR DMA2_SCR(1)
124#define DMA2_S2CR DMA2_SCR(2)
125#define DMA2_S3CR DMA2_SCR(3)
126#define DMA2_S4CR DMA2_SCR(4)
127#define DMA2_S5CR DMA2_SCR(5)
128#define DMA2_S6CR DMA2_SCR(6)
129#define DMA2_S7CR DMA2_SCR(7)
130
131/* DMA Stream x number of data register (DMA_SxNDTR) */
132#define DMA_SNDTR(port, n) MMIO32(DMA_STREAM((port), (n)) + 0x04)
133#define DMA1_SNDTR(n) DMA_SNDTR(DMA1, (n))
134#define DMA2_SNDTR(n) DMA_SNDTR(DMA2, (n))
135
136#define DMA1_S0NDTR DMA1_SNDTR(0)
137#define DMA1_S1NDTR DMA1_SNDTR(1)
138#define DMA1_S2NDTR DMA1_SNDTR(2)
139#define DMA1_S3NDTR DMA1_SNDTR(3)
140#define DMA1_S4NDTR DMA1_SNDTR(4)
141#define DMA1_S5NDTR DMA1_SNDTR(5)
142#define DMA1_S6NDTR DMA1_SNDTR(6)
143#define DMA1_S7NDTR DMA1_SNDTR(7)
144
145#define DMA2_S0NDTR DMA2_SNDTR(0)
146#define DMA2_S1NDTR DMA2_SNDTR(1)
147#define DMA2_S2NDTR DMA2_SNDTR(2)
148#define DMA2_S3NDTR DMA2_SNDTR(3)
149#define DMA2_S4NDTR DMA2_SNDTR(4)
150#define DMA2_S5NDTR DMA2_SNDTR(5)
151#define DMA2_S6NDTR DMA2_SNDTR(6)
152#define DMA2_S7NDTR DMA2_SNDTR(7)
153
154/* DMA Stream x peripheral address register (DMA_SxPAR) */
155#define DMA_SPAR(port, n) (*(volatile void **)\
156 (DMA_STREAM((port), (n)) + 0x08))
157#define DMA1_SPAR(n) DMA_SPAR(DMA1, (n))
158#define DMA2_SPAR(n) DMA_SPAR(DMA2, (n))
159
160#define DMA1_S0PAR DMA1_SPAR(0)
161#define DMA1_S1PAR DMA1_SPAR(1)
162#define DMA1_S2PAR DMA1_SPAR(2)
163#define DMA1_S3PAR DMA1_SPAR(3)
164#define DMA1_S4PAR DMA1_SPAR(4)
165#define DMA1_S5PAR DMA1_SPAR(5)
166#define DMA1_S6PAR DMA1_SPAR(6)
167#define DMA1_S7PAR DMA1_SPAR(7)
168
169#define DMA2_S0PAR DMA2_SPAR(0)
170#define DMA2_S1PAR DMA2_SPAR(1)
171#define DMA2_S2PAR DMA2_SPAR(2)
172#define DMA2_S3PAR DMA2_SPAR(3)
173#define DMA2_S4PAR DMA2_SPAR(4)
174#define DMA2_S5PAR DMA2_SPAR(5)
175#define DMA2_S6PAR DMA2_SPAR(6)
176#define DMA2_S7PAR DMA2_SPAR(7)
177
178/* DMA Stream x memory address 0 register (DMA_SxM0AR) */
179#define DMA_SM0AR(port, n) (*(volatile void **) \
180 (DMA_STREAM((port), (n)) + 0x0c))
181#define DMA1_SM0AR(n) DMA_SM0AR(DMA1, (n))
182#define DMA2_SM0AR(n) DMA_SM0AR(DMA2, (n))
183
184#define DMA1_S0M0AR DMA1_SM0AR(0)
185#define DMA1_S1M0AR DMA1_SM0AR(1)
186#define DMA1_S2M0AR DMA1_SM0AR(2)
187#define DMA1_S3M0AR DMA1_SM0AR(3)
188#define DMA1_S4M0AR DMA1_SM0AR(4)
189#define DMA1_S5M0AR DMA1_SM0AR(5)
190#define DMA1_S6M0AR DMA1_SM0AR(6)
191#define DMA1_S7M0AR DMA1_SM0AR(7)
192
193#define DMA2_S0M0AR DMA2_SM0AR(0)
194#define DMA2_S1M0AR DMA2_SM0AR(1)
195#define DMA2_S2M0AR DMA2_SM0AR(2)
196#define DMA2_S3M0AR DMA2_SM0AR(3)
197#define DMA2_S4M0AR DMA2_SM0AR(4)
198#define DMA2_S5M0AR DMA2_SM0AR(5)
199#define DMA2_S6M0AR DMA2_SM0AR(6)
200#define DMA2_S7M0AR DMA2_SM0AR(7)
201
202/* DMA Stream x memory address 1 register (DMA_SxM1AR) */
203#define DMA_SM1AR(port, n) (*(volatile void **)\
204 (DMA_STREAM((port), (n)) + 0x10))
205#define DMA1_SM1AR(n) DMA_SM1AR(DMA1, (n))
206#define DMA2_SM1AR(n) DMA_SM1AR(DMA2, (n))
207
208#define DMA1_S0M1AR DMA1_SM1AR(0)
209#define DMA1_S1M1AR DMA1_SM1AR(1)
210#define DMA1_S2M1AR DMA1_SM1AR(2)
211#define DMA1_S3M1AR DMA1_SM1AR(3)
212#define DMA1_S4M1AR DMA1_SM1AR(4)
213#define DMA1_S5M1AR DMA1_SM1AR(5)
214#define DMA1_S6M1AR DMA1_SM1AR(6)
215#define DMA1_S7M1AR DMA1_SM1AR(7)
216
217#define DMA2_S0M1AR DMA2_SM1AR(0)
218#define DMA2_S1M1AR DMA2_SM1AR(1)
219#define DMA2_S2M1AR DMA2_SM1AR(2)
220#define DMA2_S3M1AR DMA2_SM1AR(3)
221#define DMA2_S4M1AR DMA2_SM1AR(4)
222#define DMA2_S5M1AR DMA2_SM1AR(5)
223#define DMA2_S6M1AR DMA2_SM1AR(6)
224#define DMA2_S7M1AR DMA2_SM1AR(7)
225
226/* DMA Stream x FIFO control register (DMA_SxFCR) */
227#define DMA_SFCR(port, n) MMIO32(DMA_STREAM((port), (n)) + 0x14)
228#define DMA1_SFCR(n) DMA_SFCR(DMA1, (n))
229#define DMA2_SFCR(n) DMA_SFCR(DMA2, (n))
230
231#define DMA1_S0FCR DMA1_SFCR(0)
232#define DMA1_S1FCR DMA1_SFCR(1)
233#define DMA1_S2FCR DMA1_SFCR(2)
234#define DMA1_S3FCR DMA1_SFCR(3)
235#define DMA1_S4FCR DMA1_SFCR(4)
236#define DMA1_S5FCR DMA1_SFCR(5)
237#define DMA1_S6FCR DMA1_SFCR(6)
238#define DMA1_S7FCR DMA1_SFCR(7)
239
240#define DMA2_S0FCR DMA2_SFCR(0)
241#define DMA2_S1FCR DMA2_SFCR(1)
242#define DMA2_S2FCR DMA2_SFCR(2)
243#define DMA2_S3FCR DMA2_SFCR(3)
244#define DMA2_S4FCR DMA2_SFCR(4)
245#define DMA2_S5FCR DMA2_SFCR(5)
246#define DMA2_S6FCR DMA2_SFCR(6)
247#define DMA2_S7FCR DMA2_SFCR(7)
248
249/* --- DMA Interrupt Flag offset values ------------------------------------- */
250
251/* For API parameters. These are based on every interrupt flag and flag clear
252being at the same relative location */
253/** @defgroup dma_if_offset DMA Interrupt Flag Offsets within stream flag group.
254@ingroup dma_defines
255
256@{*/
257/** Transfer Complete Interrupt Flag */
258#define DMA_TCIF (1 << 5)
259/** Half Transfer Interrupt Flag */
260#define DMA_HTIF (1 << 4)
261/** Transfer Error Interrupt Flag */
262#define DMA_TEIF (1 << 3)
263/** Direct Mode Error Interrupt Flag */
264#define DMA_DMEIF (1 << 2)
265/** FIFO Error Interrupt Flag */
266#define DMA_FEIF (1 << 0)
267/**@}*/
268
269/* Offset within interrupt status register to start of stream interrupt flag
270 * field
271 */
272#define DMA_ISR_OFFSET(stream) (6*((stream) & 0x01)+16*(((stream) & 0x02) >> 1))
273#define DMA_ISR_FLAGS (DMA_TCIF | DMA_HTIF | DMA_TEIF | DMA_DMEIF | \
274 DMA_FEIF)
275#define DMA_ISR_MASK(stream) (DMA_ISR_FLAGS << DMA_ISR_OFFSET(stream))
276
277/* --- DMA_LISR values ----------------------------------------------------- */
278
279#define DMA_LISR_FEIF0 (1 << 0)
280#define DMA_LISR_DMEIF0 (1 << 2)
281#define DMA_LISR_TEIF0 (1 << 3)
282#define DMA_LISR_HTIF0 (1 << 4)
283#define DMA_LISR_TCIF0 (1 << 5)
284
285#define DMA_LISR_FEIF1 (1 << 6)
286#define DMA_LISR_DMEIF1 (1 << 8)
287#define DMA_LISR_TEIF1 (1 << 9)
288#define DMA_LISR_HTIF1 (1 << 10)
289#define DMA_LISR_TCIF1 (1 << 11)
290
291#define DMA_LISR_FEIF2 (1 << 16)
292#define DMA_LISR_DMEIF2 (1 << 18)
293#define DMA_LISR_TEIF2 (1 << 19)
294#define DMA_LISR_HTIF2 (1 << 20)
295#define DMA_LISR_TCIF2 (1 << 21)
296
297#define DMA_LISR_FEIF3 (1 << 22)
298#define DMA_LISR_DMEIF3 (1 << 24)
299#define DMA_LISR_TEIF3 (1 << 25)
300#define DMA_LISR_HTIF3 (1 << 26)
301#define DMA_LISR_TCIF3 (1 << 27)
302
303/* --- DMA_HISR values ----------------------------------------------------- */
304
305#define DMA_HISR_FEIF4 (1 << 0)
306#define DMA_HISR_DMEIF4 (1 << 2)
307#define DMA_HISR_TEIF4 (1 << 3)
308#define DMA_HISR_HTIF4 (1 << 4)
309#define DMA_HISR_TCIF4 (1 << 5)
310
311#define DMA_HISR_FEIF5 (1 << 6)
312#define DMA_HISR_DMEIF5 (1 << 8)
313#define DMA_HISR_TEIF5 (1 << 9)
314#define DMA_HISR_HTIF5 (1 << 10)
315#define DMA_HISR_TCIF5 (1 << 11)
316
317#define DMA_HISR_FEIF6 (1 << 16)
318#define DMA_HISR_DMEIF6 (1 << 18)
319#define DMA_HISR_TEIF6 (1 << 19)
320#define DMA_HISR_HTIF6 (1 << 20)
321#define DMA_HISR_TCIF6 (1 << 21)
322
323#define DMA_HISR_FEIF7 (1 << 22)
324#define DMA_HISR_DMEIF7 (1 << 24)
325#define DMA_HISR_TEIF7 (1 << 25)
326#define DMA_HISR_HTIF7 (1 << 26)
327#define DMA_HISR_TCIF7 (1 << 27)
328
329/* --- DMA_LIFCR values ----------------------------------------------------- */
330
331#define DMA_LIFCR_CFEIF0 (1 << 0)
332#define DMA_LIFCR_CDMEIF0 (1 << 2)
333#define DMA_LIFCR_CTEIF0 (1 << 3)
334#define DMA_LIFCR_CHTIF0 (1 << 4)
335#define DMA_LIFCR_CTCIF0 (1 << 5)
336
337#define DMA_LIFCR_CFEIF1 (1 << 6)
338#define DMA_LIFCR_CDMEIF1 (1 << 8)
339#define DMA_LIFCR_CTEIF1 (1 << 9)
340#define DMA_LIFCR_CHTIF1 (1 << 10)
341#define DMA_LIFCR_CTCIF1 (1 << 11)
342
343#define DMA_LIFCR_CFEIF2 (1 << 16)
344#define DMA_LIFCR_CDMEIF2 (1 << 18)
345#define DMA_LIFCR_CTEIF2 (1 << 19)
346#define DMA_LIFCR_CHTIF2 (1 << 20)
347#define DMA_LIFCR_CTCIF2 (1 << 21)
348
349#define DMA_LIFCR_CFEIF3 (1 << 22)
350#define DMA_LIFCR_CDMEIF3 (1 << 24)
351#define DMA_LIFCR_CTEIF3 (1 << 25)
352#define DMA_LIFCR_CHTIF3 (1 << 26)
353#define DMA_LIFCR_CTCIF3 (1 << 27)
354
355/* --- DMA_HIFCR values ----------------------------------------------------- */
356
357#define DMA_HIFCR_CFEIF4 (1 << 0)
358#define DMA_HIFCR_CDMEIF4 (1 << 2)
359#define DMA_HIFCR_CTEIF4 (1 << 3)
360#define DMA_HIFCR_CHTIF4 (1 << 4)
361#define DMA_HIFCR_CTCIF4 (1 << 5)
362
363#define DMA_HIFCR_CFEIF5 (1 << 6)
364#define DMA_HIFCR_CDMEIF5 (1 << 8)
365#define DMA_HIFCR_CTEIF5 (1 << 9)
366#define DMA_HIFCR_CHTIF5 (1 << 10)
367#define DMA_HIFCR_CTCIF5 (1 << 11)
368
369#define DMA_HIFCR_CFEIF6 (1 << 16)
370#define DMA_HIFCR_CDMEIF6 (1 << 18)
371#define DMA_HIFCR_CTEIF6 (1 << 19)
372#define DMA_HIFCR_CHTIF6 (1 << 20)
373#define DMA_HIFCR_CTCIF6 (1 << 21)
374
375#define DMA_HIFCR_CFEIF7 (1 << 22)
376#define DMA_HIFCR_CDMEIF7 (1 << 24)
377#define DMA_HIFCR_CTEIF7 (1 << 25)
378#define DMA_HIFCR_CHTIF7 (1 << 26)
379#define DMA_HIFCR_CTCIF7 (1 << 27)
380
381/* --- DMA_SxCR values ----------------------------------------------------- */
382
383/* EN: Stream enable */
384#define DMA_SxCR_EN (1 << 0)
385/* DMEIE: Direct Mode error interrupt enable */
386#define DMA_SxCR_DMEIE (1 << 1)
387/* TEIE: Transfer error interrupt enable */
388#define DMA_SxCR_TEIE (1 << 2)
389/* HTIE: Half transfer interrupt enable */
390#define DMA_SxCR_HTIE (1 << 3)
391/* TCIE: Transfer complete interrupt enable */
392#define DMA_SxCR_TCIE (1 << 4)
393/* PFCTRL: Peripheral Flow Controller */
394#define DMA_SxCR_PFCTRL (1 << 5)
395
396/* DIR[7:6]: Data transfer direction */
397/** @defgroup dma_st_dir DMA Stream Data transfer direction
398@ingroup dma_defines
399
400@{*/
401#define DMA_SxCR_DIR_PERIPHERAL_TO_MEM (0 << 6)
402#define DMA_SxCR_DIR_MEM_TO_PERIPHERAL (1 << 6)
403#define DMA_SxCR_DIR_MEM_TO_MEM (2 << 6)
404/**@}*/
405#define DMA_SxCR_DIR_SHIFT 6
406#define DMA_SxCR_DIR_MASK (3 << 6)
407
408/* CIRC: Circular mode */
409#define DMA_SxCR_CIRC (1 << 8)
410/* PINC: Peripheral increment mode */
411#define DMA_SxCR_PINC (1 << 9)
412/* MINC: Memory increment mode */
413#define DMA_SxCR_MINC (1 << 10)
414
415/* PSIZE[12:11]: Peripheral size */
416/** @defgroup dma_st_perwidth DMA Stream Peripheral Word Width
417@ingroup STM32F4xx_dma_defines
418
419@{*/
420#define DMA_SxCR_PSIZE_8BIT (0 << 11)
421#define DMA_SxCR_PSIZE_16BIT (1 << 11)
422#define DMA_SxCR_PSIZE_32BIT (2 << 11)
423/**@}*/
424#define DMA_SxCR_PSIZE_SHIFT 11
425#define DMA_SxCR_PSIZE_MASK (3 << 11)
426
427/* MSIZE[14:13]: Memory size */
428/** @defgroup dma_st_memwidth DMA Stream Memory Word Width
429@ingroup STM32F4xx_dma_defines
430
431@{*/
432#define DMA_SxCR_MSIZE_8BIT (0 << 13)
433#define DMA_SxCR_MSIZE_16BIT (1 << 13)
434#define DMA_SxCR_MSIZE_32BIT (2 << 13)
435/**@}*/
436#define DMA_SxCR_MSIZE_SHIFT 13
437#define DMA_SxCR_MSIZE_MASK (3 << 13)
438
439/* PINCOS: Peripheral increment offset size */
440#define DMA_SxCR_PINCOS (1 << 15)
441
442/* PL[17:16]: Stream priority level */
443/** @defgroup dma_st_pri DMA Stream Priority Levels
444@ingroup dma_defines
445
446@{*/
447#define DMA_SxCR_PL_LOW (0 << 16)
448#define DMA_SxCR_PL_MEDIUM (1 << 16)
449#define DMA_SxCR_PL_HIGH (2 << 16)
450#define DMA_SxCR_PL_VERY_HIGH (3 << 16)
451/**@}*/
452#define DMA_SxCR_PL_SHIFT 16
453#define DMA_SxCR_PL_MASK (3 << 16)
454
455/* DBM: Double buffered mode */
456#define DMA_SxCR_DBM (1 << 18)
457/* CT: Current target (in double buffered mode) */
458#define DMA_SxCR_CT (1 << 19)
459
460/* Bit 20 reserved */
461
462/* PBURST[13:12]: Peripheral Burst Configuration */
463/** @defgroup dma_pburst DMA Peripheral Burst Length
464@ingroup dma_defines
465
466@{*/
467#define DMA_SxCR_PBURST_SINGLE (0 << 21)
468#define DMA_SxCR_PBURST_INCR4 (1 << 21)
469#define DMA_SxCR_PBURST_INCR8 (2 << 21)
470#define DMA_SxCR_PBURST_INCR16 (3 << 21)
471/**@}*/
472#define DMA_SxCR_PBURST_SHIFT 21
473#define DMA_SxCR_PBURST_MASK (3 << 21)
474
475/* MBURST[13:12]: Memory Burst Configuration */
476/** @defgroup dma_mburst DMA Memory Burst Length
477@ingroup STM32F4xx_dma_defines
478
479@{*/
480#define DMA_SxCR_MBURST_SINGLE (0 << 23)
481#define DMA_SxCR_MBURST_INCR4 (1 << 23)
482#define DMA_SxCR_MBURST_INCR8 (2 << 23)
483#define DMA_SxCR_MBURST_INCR16 (3 << 23)
484/**@}*/
485#define DMA_SxCR_MBURST_SHIFT 23
486#define DMA_SxCR_MBURST_MASK (3 << 23)
487
488/* CHSEL[25:27]: Channel Select */
489/** @defgroup dma_ch_sel DMA Channel Select
490@ingroup dma_defines
491
492@{*/
493#define DMA_SxCR_CHSEL_0 (0 << DMA_SxCR_CHSEL_SHIFT)
494#define DMA_SxCR_CHSEL_1 (1 << DMA_SxCR_CHSEL_SHIFT)
495#define DMA_SxCR_CHSEL_2 (2 << DMA_SxCR_CHSEL_SHIFT)
496#define DMA_SxCR_CHSEL_3 (3 << DMA_SxCR_CHSEL_SHIFT)
497#define DMA_SxCR_CHSEL_4 (4 << DMA_SxCR_CHSEL_SHIFT)
498#define DMA_SxCR_CHSEL_5 (5 << DMA_SxCR_CHSEL_SHIFT)
499#define DMA_SxCR_CHSEL_6 (6 << DMA_SxCR_CHSEL_SHIFT)
500#define DMA_SxCR_CHSEL_7 (7 << DMA_SxCR_CHSEL_SHIFT)
501/**@}*/
502#define DMA_SxCR_CHSEL_SHIFT 25
503#define DMA_SxCR_CHSEL_MASK (7 << 25)
504#define DMA_SxCR_CHSEL(n) ((n) << DMA_SxCR_CHSEL_SHIFT)
505
506/* Reserved [31:28] */
507
508/* --- DMA_SxNDTR values --------------------------------------------------- */
509
510/* DMA_SxNDTR[15:0]: Number of data register. */
511
512/* --- DMA_SxPAR values ---------------------------------------------------- */
513
514/* DMA_SxPAR[31:0]: Peripheral address register. */
515
516/* --- DMA_SxM0AR values --------------------------------------------------- */
517
518/* DMA_SxM0AR[31:0]: Memory 0 address register. */
519
520/* --- DMA_SxM1AR values --------------------------------------------------- */
521
522/* DMA_SxM1AR[31:0]: Memory 1 address register. */
523
524/* --- DMA_SxFCR values ---------------------------------------------------- */
525
526/* FTH[1:0]: FIFO Threshold selection */
527/** @defgroup dma_fifo_thresh FIFO Threshold selection
528@ingroup STM32F4xx_dma_defines
529
530@{*/
531#define DMA_SxFCR_FTH_1_4_FULL (0 << 0)
532#define DMA_SxFCR_FTH_2_4_FULL (1 << 0)
533#define DMA_SxFCR_FTH_3_4_FULL (2 << 0)
534#define DMA_SxFCR_FTH_4_4_FULL (3 << 0)
535/**@}*/
536#define DMA_SxFCR_FTH_SHIFT 0
537#define DMA_SxFCR_FTH_MASK (3 << 0)
538
539/* DMDIS: Direct Mode disable */
540#define DMA_SxFCR_DMDIS (1 << 2)
541
542/* FS[5:3]: FIFO Status */
543/** @defgroup dma_fifo_status FIFO Status
544@ingroup STM32F4xx_dma_defines
545
546@{*/
547#define DMA_SxFCR_FS_LT_1_4_FULL (0 << 0)
548#define DMA_SxFCR_FS_LT_2_4_FULL (1 << 0)
549#define DMA_SxFCR_FS_LT_3_4_FULL (2 << 0)
550#define DMA_SxFCR_FS_LT_4_4_FULL (3 << 0)
551#define DMA_SxFCR_FS_FULL (4 << 3)
552#define DMA_SxFCR_FS_EMPTY (5 << 3)
553/**@}*/
554#define DMA_SxFCR_FS_SHIFT 3
555#define DMA_SxFCR_FS_MASK (7 << 3)
556
557/* [6]: reserved */
558
559/* FEIE[7]: FIFO error interrupt enable */
560#define DMA_SxFCR_FEIE (1 << 7)
561
562/* [31:8]: Reserved */
563
564/* --- Function prototypes ------------------------------------------------- */
565
567
568/*
569 * Note: The F2 and F4 series have a completely new DMA peripheral with
570 * different configuration options.
571 */
572
573void dma_stream_reset(uint32_t dma, uint8_t stream);
574void dma_clear_interrupt_flags(uint32_t dma, uint8_t stream,
575 uint32_t interrupts);
576bool dma_get_interrupt_flag(uint32_t dma, uint8_t stream, uint32_t interrupt);
577void dma_set_transfer_mode(uint32_t dma, uint8_t stream, uint32_t direction);
578void dma_set_priority(uint32_t dma, uint8_t stream, uint32_t prio);
579void dma_set_memory_size(uint32_t dma, uint8_t stream, uint32_t mem_size);
580void dma_set_peripheral_size(uint32_t dma, uint8_t stream,
581 uint32_t peripheral_size);
582void dma_enable_memory_increment_mode(uint32_t dma, uint8_t stream);
583void dma_disable_memory_increment_mode(uint32_t dma, uint8_t stream);
584void dma_enable_peripheral_increment_mode(uint32_t dma, uint8_t stream);
585void dma_disable_peripheral_increment_mode(uint32_t dma, uint8_t stream);
586void dma_enable_fixed_peripheral_increment_mode(uint32_t dma, uint8_t stream);
587void dma_enable_circular_mode(uint32_t dma, uint8_t stream);
588void dma_channel_select(uint32_t dma, uint8_t stream, uint32_t channel);
589void dma_set_memory_burst(uint32_t dma, uint8_t stream, uint32_t burst);
590void dma_set_peripheral_burst(uint32_t dma, uint8_t stream, uint32_t burst);
591void dma_set_initial_target(uint32_t dma, uint8_t stream, uint8_t memory);
592uint8_t dma_get_target(uint32_t dma, uint8_t stream);
593void dma_enable_double_buffer_mode(uint32_t dma, uint8_t stream);
594void dma_disable_double_buffer_mode(uint32_t dma, uint8_t stream);
595void dma_set_peripheral_flow_control(uint32_t dma, uint8_t stream);
596void dma_set_dma_flow_control(uint32_t dma, uint8_t stream);
597void dma_enable_transfer_error_interrupt(uint32_t dma, uint8_t stream);
598void dma_disable_transfer_error_interrupt(uint32_t dma, uint8_t stream);
599void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t stream);
600void dma_disable_half_transfer_interrupt(uint32_t dma, uint8_t stream);
601void dma_enable_transfer_complete_interrupt(uint32_t dma, uint8_t stream);
602void dma_disable_transfer_complete_interrupt(uint32_t dma, uint8_t stream);
603uint32_t dma_fifo_status(uint32_t dma, uint8_t stream);
604void dma_enable_direct_mode_error_interrupt(uint32_t dma, uint8_t stream);
605void dma_disable_direct_mode_error_interrupt(uint32_t dma, uint8_t stream);
606void dma_enable_fifo_error_interrupt(uint32_t dma, uint8_t stream);
607void dma_disable_fifo_error_interrupt(uint32_t dma, uint8_t stream);
608void dma_enable_direct_mode(uint32_t dma, uint8_t stream);
609void dma_enable_fifo_mode(uint32_t dma, uint8_t stream);
610void dma_set_fifo_threshold(uint32_t dma, uint8_t stream, uint32_t threshold);
611void dma_enable_stream(uint32_t dma, uint8_t stream);
612void dma_disable_stream(uint32_t dma, uint8_t stream);
613void dma_set_peripheral_address(uint32_t dma, uint8_t stream, uint32_t address);
614void dma_set_memory_address(uint32_t dma, uint8_t stream, uint32_t address);
615void dma_set_memory_address_1(uint32_t dma, uint8_t stream, uint32_t address);
616uint16_t dma_get_number_of_data(uint32_t dma, uint8_t stream);
617void dma_set_number_of_data(uint32_t dma, uint8_t stream, uint16_t number);
618
620/**@}*/
621#endif
622/** @cond */
623#else
624#warning "dma_common_f24.h should not be included explicitly, only via dma.h"
625#endif
626/** @endcond */
627
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Enable Interrupt on Transfer Half Complete.
uint16_t dma_get_number_of_data(uint32_t dma, uint8_t stream)
DMA Stream Get the Transfer Block Size.
void dma_enable_transfer_complete_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Enable Interrupt on Transfer Complete.
void dma_enable_fixed_peripheral_increment_mode(uint32_t dma, uint8_t stream)
DMA Channel Enable Fixed Sized Peripheral Increment after Transfer.
void dma_set_memory_burst(uint32_t dma, uint8_t stream, uint32_t burst)
DMA Stream Set Memory Burst Configuration.
void dma_disable_transfer_error_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Disable Interrupt on Transfer Error.
void dma_set_transfer_mode(uint32_t dma, uint8_t stream, uint32_t direction)
DMA Stream Enable Transfer Direction.
void dma_channel_select(uint32_t dma, uint8_t stream, uint32_t channel)
DMA Stream Channel Select.
void dma_set_fifo_threshold(uint32_t dma, uint8_t stream, uint32_t threshold)
DMA Set FIFO Threshold.
void dma_enable_direct_mode_error_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Enable Interrupt on Direct Mode Error.
void dma_disable_direct_mode_error_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Disable Interrupt on Direct Mode Error.
void dma_set_peripheral_size(uint32_t dma, uint8_t stream, uint32_t peripheral_size)
DMA Stream Set Peripheral Word Width.
void dma_set_priority(uint32_t dma, uint8_t stream, uint32_t prio)
DMA Stream Set Priority.
void dma_set_memory_address_1(uint32_t dma, uint8_t stream, uint32_t address)
DMA Stream Set the Base Memory Address 1.
void dma_enable_peripheral_increment_mode(uint32_t dma, uint8_t stream)
DMA Channel Enable Variable Sized Peripheral Increment after Transfer.
void dma_disable_stream(uint32_t dma, uint8_t stream)
DMA Stream Disable.
void dma_enable_fifo_mode(uint32_t dma, uint8_t stream)
DMA Enable FIFO Mode.
void dma_enable_double_buffer_mode(uint32_t dma, uint8_t stream)
DMA Stream Enable Double Buffer Mode.
void dma_enable_direct_mode(uint32_t dma, uint8_t stream)
DMA Enable Direct Mode.
void dma_enable_transfer_error_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Enable Interrupt on Transfer Error.
void dma_set_memory_size(uint32_t dma, uint8_t stream, uint32_t mem_size)
DMA Stream Set Memory Word Width.
void dma_set_peripheral_burst(uint32_t dma, uint8_t stream, uint32_t burst)
DMA Stream Set Peripheral Burst Configuration.
void dma_set_peripheral_address(uint32_t dma, uint8_t stream, uint32_t address)
DMA Stream Set the Peripheral Address.
void dma_set_initial_target(uint32_t dma, uint8_t stream, uint8_t memory)
DMA Stream Set Initial Target Memory.
void dma_enable_fifo_error_interrupt(uint32_t dma, uint8_t stream)
DMA Enable Interrupt on FIFO Error.
void dma_stream_reset(uint32_t dma, uint8_t stream)
DMA Stream Reset.
bool dma_get_interrupt_flag(uint32_t dma, uint8_t stream, uint32_t interrupt)
DMA Stream Read Interrupt Flag.
uint8_t dma_get_target(uint32_t dma, uint8_t stream)
DMA Stream Read Current Memory Target.
void dma_enable_circular_mode(uint32_t dma, uint8_t stream)
DMA Stream Enable Memory Circular Mode.
void dma_disable_fifo_error_interrupt(uint32_t dma, uint8_t stream)
DMA Disable Interrupt on FIFO Error.
void dma_disable_half_transfer_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Disable Interrupt on Transfer Half Complete.
void dma_disable_transfer_complete_interrupt(uint32_t dma, uint8_t stream)
DMA Stream Disable Interrupt on Transfer Complete.
void dma_disable_memory_increment_mode(uint32_t dma, uint8_t stream)
DMA Channel Disable Memory Increment after Transfer.
uint32_t dma_fifo_status(uint32_t dma, uint8_t stream)
DMA Get FIFO Status.
void dma_set_number_of_data(uint32_t dma, uint8_t stream, uint16_t number)
DMA Stream Set the Transfer Block Size.
void dma_set_dma_flow_control(uint32_t dma, uint8_t stream)
DMA Stream Set DMA Flow Control.
void dma_enable_memory_increment_mode(uint32_t dma, uint8_t stream)
DMA Stream Enable Memory Increment after Transfer.
void dma_disable_double_buffer_mode(uint32_t dma, uint8_t stream)
DMA Stream Disable Double Buffer Mode.
void dma_disable_peripheral_increment_mode(uint32_t dma, uint8_t stream)
DMA Channel Disable Peripheral Increment after Transfer.
void dma_set_memory_address(uint32_t dma, uint8_t stream, uint32_t address)
DMA Stream Set the Base Memory Address 0.
void dma_clear_interrupt_flags(uint32_t dma, uint8_t stream, uint32_t interrupts)
DMA Stream Clear Interrupt Flag.
void dma_enable_stream(uint32_t dma, uint8_t stream)
DMA Stream Enable.
void dma_set_peripheral_flow_control(uint32_t dma, uint8_t stream)
DMA Stream Set Peripheral Flow Control.