01. DMA简介
5 q+ Q' b6 l% W# [# }9 @DMA,全称为:Direct Memory Access,即直接存储器访问。DMA 传输方式无需 CPU 直接控制传输,也没有中断处理方式那样保留现场和恢复现场的过程,通过硬件为 RAM 与 I/O 设备开辟一条直接传送数据的通路,能使 CPU 的效率大为提高。: A: P9 I# E1 X3 J
8 E, n1 h1 L7 J! s- @0 n
STM32F4 最多有 2 个 DMA 控制器(DMA1 和 DMA2),共 16 个数据流(每个控制器 8 个),每一个 DMA 控制器都用于管理一个或多个外设的存储器访问请求。每个数据流总共可以有多达 8个通道(或称请求)。每个数据流通道都有一个仲裁器,用于处理 DMA 请求间的优先级。
- { e: _5 q: T5 J/ O; l! ^/ u; p9 [
02. 相关类型
2 n1 c( a. @) oDMA Init structure definition
8 B4 ]) ]& S- U/ W
. j" k& d* e5 F) |$ N1 `- /** & \, K2 j* r9 e3 S, S6 o. X3 j4 B9 {
- * @brief DMA Init structure definition
# P- w9 q: z6 e - */
- g: c. R4 d, {, `; C' \
0 S7 W. B3 i# v* z4 q- typedef struct* P! x# A/ _6 \8 C8 p
- {
0 g6 ], B6 i/ `, K. Q _& S. g - uint32_t DMA_Channel; /*!< Specifies the channel used for the specified stream. " x+ H$ x( Q0 { W2 M _! t. g( q
- This parameter can be a value of @ref DMA_channel */ `1 _4 A3 v" X% @1 A0 _
: n3 o$ F6 ]. b- uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Streamx. */0 z0 `# H; K" \" [( |* [& ]# q
* k- Y" r) t: Q. ]3 r3 o6 E- uint32_t DMA_Memory0BaseAddr; /*!< Specifies the memory 0 base address for DMAy Streamx.
& _, Q1 L& L; k6 k6 y) ^) Q4 W. h - This memory is the default memory used when double buffer mode is7 J, K! i5 h. t! h- r; m. R4 W
- not enabled. */
! Y) ]3 k9 p$ }2 j$ G# D0 i
' j4 j+ p: D0 s) a4 \: ?- uint32_t DMA_DIR; /*!< Specifies if the data will be transferred from memory to peripheral, w; P9 }5 s" A* y0 ?7 `7 i* s
- from memory to memory or from peripheral to memory.6 J6 i2 g, f% s! e
- This parameter can be a value of @ref DMA_data_transfer_direction */+ P5 Y. [( W% \
+ v0 X& p+ U1 m: z. }" F- uint32_t DMA_BufferSize; /*!< Specifies the buffer size, in data unit, of the specified Stream.
2 m" z; A0 |) N& N2 n - The data unit is equal to the configuration set in DMA_PeripheralDataSize
# O- {: A; f' H- n8 ] - or DMA_MemoryDataSize members depending in the transfer direction. */
2 |$ \1 z' _/ v- f
! Y9 ^* y+ V9 h9 d( ^: l- uint32_t DMA_PeripheralInc; /*!< Specifies whether the Peripheral address register should be incremented or not.- P$ F7 a9 W" u2 g" }
- This parameter can be a value of @ref DMA_peripheral_incremented_mode */2 g2 w6 z6 H2 b# ^& U/ s* C
- ! }3 y4 s& k! c* j! }
- uint32_t DMA_MemoryInc; /*!< Specifies whether the memory address register should be incremented or not.
: b9 `4 L5 N# T6 W' E - This parameter can be a value of @ref DMA_memory_incremented_mode */7 G+ E6 w5 a- ~' p2 i: `# x
- / _' |/ ?3 P. X6 K
- uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.& U! e4 c4 S$ ?" ^ t$ y* Q/ D
- This parameter can be a value of @ref DMA_peripheral_data_size */& z; l4 M0 v: s# U7 c4 c
% u1 x$ h- h% |/ l2 n- uint32_t DMA_MemoryDataSize; /*!< Specifies the Memory data width.2 f4 q. H+ ^) h2 D; l
- This parameter can be a value of @ref DMA_memory_data_size *// \# f) j; t& r+ X0 Q. I( d) |2 R
- 4 @% ~, b" Y% H3 T1 ?5 ^9 G
- uint32_t DMA_Mode; /*!< Specifies the operation mode of the DMAy Streamx.
# T1 w( Q2 S8 I M+ V - This parameter can be a value of @ref DMA_circular_normal_mode0 Q, h" I2 L0 h- j+ J
- @note The circular buffer mode cannot be used if the memory-to-memory& e) e0 Z' }% y# [( q- u; W9 {
- data transfer is configured on the selected Stream */
. s& W* o/ S: j" Y- \ - # n* y& E1 o% H# e5 w# g, s5 t; }
- uint32_t DMA_Priority; /*!< Specifies the software priority for the DMAy Streamx.
: ~, }: ]/ L5 ^9 ^9 h5 g9 r1 B% j - This parameter can be a value of @ref DMA_priority_level */8 X0 e- k: s8 B5 ~$ Z
- & S2 Z- s, m# f5 p0 x/ ] s
- uint32_t DMA_FIFOMode; /*!< Specifies if the FIFO mode or Direct mode will be used for the specified Stream.; v' Q7 H1 j( k% b0 N" ^+ q7 ]
- This parameter can be a value of @ref DMA_fifo_direct_mode; e0 h' ]* ~( l4 ?/ q7 |+ G) n7 H
- @note The Direct mode (FIFO mode disabled) cannot be used if the , Q" @$ ]7 n' W: N
- memory-to-memory data transfer is configured on the selected Stream */
' F6 l3 P- W! ^* s% v7 X - $ X( }. i6 k, I5 C
- uint32_t DMA_FIFOThreshold; /*!< Specifies the FIFO threshold level., B: @" m5 u: n- w# u6 Z. P0 W) ~1 v
- This parameter can be a value of @ref DMA_fifo_threshold_level */& L) F" a9 T; u+ n, U
- % k2 Z1 J1 V0 \3 m9 M
- uint32_t DMA_MemoryBurst; /*!< Specifies the Burst transfer configuration for the memory transfers.
' p4 o, M! R/ H8 ]( v$ {! v - It specifies the amount of data to be transferred in a single non interruptable 4 O$ S, L6 ]' @1 s6 N1 L
- transaction. This parameter can be a value of @ref DMA_memory_burst
) d# j6 V2 d1 e, n2 v7 a" g0 L - @note The burst mode is possible only if the address Increment mode is enabled. */
5 @0 |$ e. N `, |0 A
- V! |1 e8 f) K; V* a1 ^3 y* I- uint32_t DMA_PeripheralBurst; /*!< Specifies the Burst transfer configuration for the peripheral transfers. - \7 Q8 }" x" _; G
- It specifies the amount of data to be transferred in a single non interruptable
9 M1 z. T& Q6 S; {: b - transaction. This parameter can be a value of @ref DMA_peripheral_burst
8 r% L+ B/ L, _# C& g# u" o7 v - @note The burst mode is possible only if the address Increment mode is enabled. */ 3 s- |2 G: i, o8 f( d
- }DMA_InitTypeDef;
复制代码 " U* T. m4 ~) x: E! a
DMA_Exported_Constants. J! s; Z$ Q" g! Y9 U
+ |6 p8 ?! j5 n7 a3 l4 ^/ W" J
- ** @defgroup DMA_Exported_Constants
8 z+ ^3 E& x& x# |' O% W - * @{5 O: t T- O- `' ]7 | U
- */
$ v2 R# m1 z8 Z, |7 v0 q3 }% R! t
' E' }- p% ?$ t9 @/ P- #define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Stream0) || \
: ^" I. A- f) [( n1 V - ((PERIPH) == DMA1_Stream1) || \
. u9 } Q2 f* h( q7 i5 v( ~6 `# s - ((PERIPH) == DMA1_Stream2) || \) {' Y' n) v6 ]( O
- ((PERIPH) == DMA1_Stream3) || \: o0 d" `8 [: Y$ H
- ((PERIPH) == DMA1_Stream4) || \
: T$ u% w8 E3 l& f V: e0 Q% o - ((PERIPH) == DMA1_Stream5) || \
^& {! c& F9 @. a j+ U - ((PERIPH) == DMA1_Stream6) || \) C; @( _+ ^8 X: [: z$ |& W/ P
- ((PERIPH) == DMA1_Stream7) || \
% Q, I5 o k/ e" U+ } - ((PERIPH) == DMA2_Stream0) || \
8 Q8 Y! x: k+ U+ n( X8 b! q! n - ((PERIPH) == DMA2_Stream1) || \" Z* W3 v5 L* w
- ((PERIPH) == DMA2_Stream2) || \2 V% h" b9 l( Y! v, ]5 q
- ((PERIPH) == DMA2_Stream3) || \
: r2 b; T) v/ i) r1 f) Y2 u6 v2 q - ((PERIPH) == DMA2_Stream4) || \
) W9 X9 ]4 K& n - ((PERIPH) == DMA2_Stream5) || \
$ l. Z) ~& H9 `' c - ((PERIPH) == DMA2_Stream6) || \8 e' @1 K$ z5 |2 M* O; V7 C1 S a' B
- ((PERIPH) == DMA2_Stream7))
. ^! j& L9 u1 [7 { T
7 Q3 o1 u" U# ^/ X1 s( v- Z+ T+ g- #define IS_DMA_ALL_CONTROLLER(CONTROLLER) (((CONTROLLER) == DMA1) || \
& Y* k/ f" u+ {9 E5 ? - ((CONTROLLER) == DMA2))
复制代码 ( t% V( x! j( n1 M) ^
DMA_channel
6 N+ ~: F& D. B8 d: l4 F1 L( N: i8 I+ l$ \/ d4 t* K* ]
- /** @defgroup DMA_channel
x) Z' G' S* |. y) E. b3 N, m9 E" C5 N - * @{0 z% r+ S; x9 C+ e# w
- */ 2 _6 j' u- b3 Z
- #define DMA_Channel_0 ((uint32_t)0x00000000)' C" [+ K8 b8 `$ _5 [5 \; ?% _1 Q ~
- #define DMA_Channel_1 ((uint32_t)0x02000000)
7 U+ J0 c( W/ q3 L7 d- ^# ?" e - #define DMA_Channel_2 ((uint32_t)0x04000000)5 ~' I4 }( y8 {. T2 w
- #define DMA_Channel_3 ((uint32_t)0x06000000)
9 u7 _# `+ T( U! F9 u. h - #define DMA_Channel_4 ((uint32_t)0x08000000)! M- S- p+ I" k( Q: s6 P6 d* q8 c
- #define DMA_Channel_5 ((uint32_t)0x0A000000)
K6 \& w" |( f8 Y7 h; Z - #define DMA_Channel_6 ((uint32_t)0x0C000000)( n) c' ]8 c3 x6 J* n! b) M
- #define DMA_Channel_7 ((uint32_t)0x0E000000)
6 a4 W( e# {8 F2 }9 h. a9 l
J+ k7 p$ \2 h- #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_Channel_0) || \/ G: ]# _8 g1 Y
- ((CHANNEL) == DMA_Channel_1) || \# V" o7 w# [( N7 P
- ((CHANNEL) == DMA_Channel_2) || \
4 \8 j2 q7 `: D; |# H: n0 {- C - ((CHANNEL) == DMA_Channel_3) || \
2 a7 b( T- y5 l' f" f - ((CHANNEL) == DMA_Channel_4) || \1 r; q' D/ W* q
- ((CHANNEL) == DMA_Channel_5) || \* r9 r2 o! h( t! G( V
- ((CHANNEL) == DMA_Channel_6) || \
: ~& g0 }1 E$ @- W1 t6 z: c1 l- ` - ((CHANNEL) == DMA_Channel_7))7 B; X. f6 U; B4 C& [5 A
复制代码
; J% P! }+ D/ N% yDMA_data_transfer_direction+ @3 V4 K$ d& ~( i; ?
$ |& P4 b: \' T# u% L6 u1 Z7 _
- /** @defgroup DMA_data_transfer_direction
$ O$ ?1 y# z% |/ j - * @{9 r7 o3 e1 ?3 ~% g3 v7 T" \2 p& v
- */ " U$ v# f- g1 C' u i
- #define DMA_DIR_PeripheralToMemory ((uint32_t)0x00000000)6 i$ v; @/ z5 H/ u
- #define DMA_DIR_MemoryToPeripheral ((uint32_t)0x00000040)
$ {6 f3 d6 F# F% V7 S& S - #define DMA_DIR_MemoryToMemory ((uint32_t)0x00000080)) I1 z* c3 _6 a- ^" _
: \5 B3 V' n; ]4 h- #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_DIR_PeripheralToMemory ) || \5 B8 _ Q; w6 B
- ((DIRECTION) == DMA_DIR_MemoryToPeripheral) || \& Y; t0 n: G/ m. V
- ((DIRECTION) == DMA_DIR_MemoryToMemory))
复制代码 ) y2 @; n0 m- a5 A4 g l% F
DMA_data_buffer_size3 @) w' d; R* I; Z2 c: N
# y6 I# `( K& d1 I: e! a) b1 x0 [7 k L# b- /** @defgroup DMA_data_buffer_size
8 X! X* _. a$ I5 }8 v- H" P - * @{
, V8 m( z3 r* f3 ^. w1 Y+ l - */
9 m' B( V* z8 y. Q1 B - #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
$ _, F6 V, n5 B0 W - 1# U) G* [7 h. H! Z P. M8 L6 N! W: ~
- 2
( h% ?% E+ q1 q3 v- d - 3 h* u* n$ `' Y1 |% t( J* U# y
- 4
/ B7 k0 u) q) W3 A/ F. K0 e+ N - DMA_peripheral_incremented_mode
7 W: H1 c. E3 v0 U" O& o
) D5 y- p& _- F3 {# w" w- /** @defgroup DMA_peripheral_incremented_mode
, J, `9 O- z0 F! w6 s$ b - * @{
+ g- @4 s; Y/ A - */
/ |# e, R! L, [0 v/ R- x' V - #define DMA_PeripheralInc_Enable ((uint32_t)0x00000200)# f6 @. y0 {/ x T- _ q6 S9 J
- #define DMA_PeripheralInc_Disable ((uint32_t)0x00000000); y+ @0 `0 B' c; [
- : o5 ?; x5 Q9 z4 o
- #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \
# `/ r% f7 V/ p5 g& ^/ H. F - ((STATE) == DMA_PeripheralInc_Disable))
复制代码 , \. S$ i- j+ n- i2 g
DMA_memory_incremented_mode- /** @defgroup DMA_memory_incremented_mode . L" h( `- x- d+ w. }7 [
- * @{+ r8 K$ q7 ^2 K& ]. y. b
- */
8 d* Z, [- T" c) j* X& D, n1 n4 x J - #define DMA_MemoryInc_Enable ((uint32_t)0x00000400)
1 l- i& K) i: ^% ?& w; _ - #define DMA_MemoryInc_Disable ((uint32_t)0x00000000)
7 M9 ?; @" t! E
6 C, @# Y. T) `- #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \9 @1 y$ i. @6 m
- ((STATE) == DMA_MemoryInc_Disable))
复制代码
; f& [5 {6 J& f' rDMA_peripheral_data_size1 T0 ^- n- w+ M
- /** @defgroup DMA_peripheral_data_size ; K5 U' J/ F# I
- * @{% W4 {0 x Y- Y6 `0 L( K" D
- */ / e4 o0 K! \; n
- #define DMA_PeripheralDataSize_Byte ((uint32_t)0x00000000) 7 k* k# M5 [5 }( z2 _3 m
- #define DMA_PeripheralDataSize_HalfWord ((uint32_t)0x00000800) . z# \* L1 ^& p; {# T' A7 }/ a* A" G
- #define DMA_PeripheralDataSize_Word ((uint32_t)0x00001000)
1 L9 n! [3 Q2 o2 ~, Q( j* E
& m$ S/ {- J! p% Q ^3 `0 c- #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte) || \
$ y, X# V8 j& s - ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \
. d! s4 T' l$ U- R0 d - ((SIZE) == DMA_PeripheralDataSize_Word))1 @+ i# x' V$ F9 x( X' t) x# M* q7 r
复制代码
6 @8 A3 ~ G; V! O: i( {* \DMA_memory_data_size- /** @defgroup DMA_memory_data_size ( e/ B: g4 I& L5 L: x# _
- * @{1 R2 V0 E& R" p' Z# z7 c N7 _
- */ / [+ K5 x% a7 t& _4 e% F
- #define DMA_MemoryDataSize_Byte ((uint32_t)0x00000000)
* V3 `+ X- R7 M6 u( f% ? - #define DMA_MemoryDataSize_HalfWord ((uint32_t)0x00002000)
3 F+ ]; V" [8 t+ i% t( U6 x - #define DMA_MemoryDataSize_Word ((uint32_t)0x00004000)- |. x7 X& @3 Z6 \
- 5 o9 l M& R5 J/ t
- #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte) || \. R/ n2 H0 k3 _) G
- ((SIZE) == DMA_MemoryDataSize_HalfWord) || \4 w& p. A+ R3 Z; I& j
- ((SIZE) == DMA_MemoryDataSize_Word ))
复制代码
4 e; O6 _6 ?# ? PDMA_circular_normal_mode
7 n4 _* h; } c1 h1 \: b- " k0 S1 w, P7 b8 ?( f
- /** @defgroup DMA_circular_normal_mode ( e5 ]- p9 l; U
- * @{
9 v! C" f8 t, H2 B3 @( ^9 `9 K - */
# {+ o5 d! r5 ~6 @# s g - #define DMA_Mode_Normal ((uint32_t)0x00000000)
8 f% g( x1 m( ^( o2 l - #define DMA_Mode_Circular ((uint32_t)0x00000100)3 q% M2 l- G4 f* y% R
- % B8 }) g& X7 E, j
- #define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Normal ) || \; P) Q. A }7 u
- ((MODE) == DMA_Mode_Circular))
7 H' [, K- C3 q
复制代码 ' \( j/ w* B# D+ L0 I
DMA_priority_level
$ c3 S* r: t5 y
% @: v7 I4 n3 Y ~9 d) D3 A' z- /** @defgroup DMA_priority_level 5 C5 ]/ F$ l, X
- * @{2 B* `: S) ]. v `) v2 Q8 J
- */ " p& z2 B5 ]- U7 B7 X# H& [
- #define DMA_Priority_Low ((uint32_t)0x00000000)
& E9 B5 c4 k& u0 z# e: g2 i - #define DMA_Priority_Medium ((uint32_t)0x00010000) / F. w& c' y+ ^) A
- #define DMA_Priority_High ((uint32_t)0x00020000)
+ g0 h+ t3 J# f$ h* i( @6 s( Q - #define DMA_Priority_VeryHigh ((uint32_t)0x00030000)) q& g) y; d1 R9 @
8 `+ t3 _( p4 a- #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_Low ) || \
$ B" A5 y8 S/ @3 _ - ((PRIORITY) == DMA_Priority_Medium) || \6 o/ ?6 ^/ f7 o m6 W3 k$ x6 {
- ((PRIORITY) == DMA_Priority_High) || \- o2 _8 @4 X5 v3 ]
- ((PRIORITY) == DMA_Priority_VeryHigh))
复制代码 ) N1 B/ T( G4 Y( F
DMA_fifo_direct_mode- /** @defgroup DMA_fifo_direct_mode
; l. C# L. G) G. ?' j v+ A$ p) Z - * @{
3 I7 \$ o. x6 v3 X+ W; X - */
4 @ `. y9 q; W- ^2 S - #define DMA_FIFOMode_Disable ((uint32_t)0x00000000) 7 M* h/ ]" v/ X0 ]
- #define DMA_FIFOMode_Enable ((uint32_t)0x00000004)9 I+ q( T4 }6 M. b4 T' n
! S' i" T9 X+ i9 E- #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMode_Disable ) || \" N7 l0 u$ q5 F6 H# q: M" a# ] ?
- ((STATE) == DMA_FIFOMode_Enable))
复制代码 ! a9 [4 l) M* j5 e, Y
DMA_fifo_threshold_level
5 r9 R/ p9 }2 E$ E& T6 x0 k
O5 O! z+ }8 O7 m7 l0 [9 ]- /** @defgroup DMA_fifo_threshold_level
0 l3 x' b$ _5 p# i, r5 c6 P - * @{
' q; i/ U) h% b1 W; p d7 i- e6 M - */
' ?( Z0 o* s9 c - #define DMA_FIFOThreshold_1QuarterFull ((uint32_t)0x00000000)- W$ b8 @% u* m$ i2 B1 T# A: Y2 x; z) U
- #define DMA_FIFOThreshold_HalfFull ((uint32_t)0x00000001) - g, m% Z+ V; z" z
- #define DMA_FIFOThreshold_3QuartersFull ((uint32_t)0x00000002)* y4 c7 |! k5 p$ N$ a$ E8 e5 \. N' M
- #define DMA_FIFOThreshold_Full ((uint32_t)0x00000003)$ y/ l2 N& K8 [
- / l% M2 C; T, a$ w7 Q0 U$ M5 i
- #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFOThreshold_1QuarterFull ) || \1 }! e4 [: k: l$ U
- ((THRESHOLD) == DMA_FIFOThreshold_HalfFull) || \
& I, ^: U: o/ `; K' k - ((THRESHOLD) == DMA_FIFOThreshold_3QuartersFull) || \6 x# d M3 M" T% A$ L% \
- ((THRESHOLD) == DMA_FIFOThreshold_Full))
复制代码
5 ?1 }$ ]% p$ e4 Z0 FDMA_memory_burst0 S& C6 `* l. u0 D0 ^) H- ?
! q n" H% z* s- /** @defgroup DMA_memory_burst 9 p/ _+ U3 ]$ N
- * @{
& W* ^- G1 Y5 v* {, U - */
* \. i% r; ~# R4 n) K0 z! e - #define DMA_MemoryBurst_Single ((uint32_t)0x00000000)- [5 d3 @+ ?$ T1 e* m, J* P( l
- #define DMA_MemoryBurst_INC4 ((uint32_t)0x00800000)
; ~5 B. h+ C) ]$ \7 B# i - #define DMA_MemoryBurst_INC8 ((uint32_t)0x01000000); o' m: A+ d5 q6 u
- #define DMA_MemoryBurst_INC16 ((uint32_t)0x01800000)
2 r5 S1 W, A* B- f
' c0 F' U: q( y- #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MemoryBurst_Single) || \# ?, Y9 [# G/ u4 i
- ((BURST) == DMA_MemoryBurst_INC4) || \
: R$ _8 |5 H' ?, t! a/ C0 U, T - ((BURST) == DMA_MemoryBurst_INC8) || \
( p" J! I K% f5 C - ((BURST) == DMA_MemoryBurst_INC16))
0 Q7 Y1 f& F* r0 a6 V
复制代码 2 z/ |& p/ Q- v& x
DMA_peripheral_burst+ \& Z( C6 v) \* Z8 h) u
0 }: U3 e1 f! Z
- /** @defgroup DMA_peripheral_burst
* X& t% M! z! R6 R8 K4 J - * @{
$ f" y& R: ^* U5 E - */ % D* H& |. {- {
- #define DMA_PeripheralBurst_Single ((uint32_t)0x00000000). `. o' I% [+ a3 J* \5 b) `
- #define DMA_PeripheralBurst_INC4 ((uint32_t)0x00200000)
/ w9 L6 A8 J6 b - #define DMA_PeripheralBurst_INC8 ((uint32_t)0x00400000). X8 F" `% C2 X9 }: ]
- #define DMA_PeripheralBurst_INC16 ((uint32_t)0x00600000)
2 u; W- i% d& E - & r, g& N3 l# Z3 J. k- L
- #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PeripheralBurst_Single) || \: H( ]6 c4 w* F( U( J; n
- ((BURST) == DMA_PeripheralBurst_INC4) || \
" Q1 u* t9 g7 t: c - ((BURST) == DMA_PeripheralBurst_INC8) || \" X" S5 q& O$ a* `# m* @
- ((BURST) == DMA_PeripheralBurst_INC16))3 K3 w3 V' L7 P4 G5 n. v" n) |
复制代码
5 s, `7 f: R0 k0 z' Y' ?/ T0 y# T/ H: `7 hDMA_fifo_status_level
) [) R( W3 K2 |/ V n) _$ t- G
) ~) F& ]7 r Q5 f# k7 |- /** @defgroup DMA_fifo_status_level 0 x- D7 h# S/ t9 T
- * @{
* D9 T: O* U1 [$ g - */
1 Y- v1 C! s+ Z8 Z - #define DMA_FIFOStatus_Less1QuarterFull ((uint32_t)0x00000000 << 3)
1 o3 c. Q/ } { - #define DMA_FIFOStatus_1QuarterFull ((uint32_t)0x00000001 << 3)
, m2 a, q- ~( A+ w+ l) I: _) n - #define DMA_FIFOStatus_HalfFull ((uint32_t)0x00000002 << 3) . s7 r/ N5 E2 b, \) v
- #define DMA_FIFOStatus_3QuartersFull ((uint32_t)0x00000003 << 3), V7 [( x7 R, K
- #define DMA_FIFOStatus_Empty ((uint32_t)0x00000004 << 3)3 ?, {$ ?7 `, s Z( P
- #define DMA_FIFOStatus_Full ((uint32_t)0x00000005 << 3)
% {2 g0 x u* _. d; o- u - 9 K' a4 L; M& W' E/ U- i6 n# K) K/ g
- #define IS_DMA_FIFO_STATUS(STATUS) (((STATUS) == DMA_FIFOStatus_Less1QuarterFull ) || \5 Z' L7 g- m0 c' a
- ((STATUS) == DMA_FIFOStatus_HalfFull) || \% W& Y) i3 M! h: s, b7 }
- ((STATUS) == DMA_FIFOStatus_1QuarterFull) || \5 G# d8 _5 t$ C+ b$ s
- ((STATUS) == DMA_FIFOStatus_3QuartersFull) || \% Q6 ?$ m& c! f) M- D
- ((STATUS) == DMA_FIFOStatus_Full) || \& `% s' K1 o; g! R
- ((STATUS) == DMA_FIFOStatus_Empty))
复制代码
& y! H$ Z4 |, C4 H1 kDMA_flags_definition- K, e/ j( k7 @
- G/ O- p \6 [: Q/ i- P4 a
- /** @defgroup DMA_flags_definition * n6 Y& l; }! B! q; H0 G
- * @{
' v# H# K( s( \: [5 R1 A& _/ k - */
6 {8 f/ v! x, J/ \ - #define DMA_FLAG_FEIF0 ((uint32_t)0x10800001)
/ |& a9 G+ }9 K7 H' P& O, S; A9 i - #define DMA_FLAG_DMEIF0 ((uint32_t)0x10800004)
0 _) ~8 G+ P4 y4 T8 y - #define DMA_FLAG_TEIF0 ((uint32_t)0x10000008)' z6 I; G0 C6 ~, [3 Q, G9 _
- #define DMA_FLAG_HTIF0 ((uint32_t)0x10000010)1 } p# W8 {' `0 |5 y
- #define DMA_FLAG_TCIF0 ((uint32_t)0x10000020)
0 A; w/ o; l9 w: o0 [7 u - #define DMA_FLAG_FEIF1 ((uint32_t)0x10000040)
2 v# u8 P. q5 | - #define DMA_FLAG_DMEIF1 ((uint32_t)0x10000100)3 r2 j- X8 N9 z0 \" S3 \" n
- #define DMA_FLAG_TEIF1 ((uint32_t)0x10000200)
; K1 ?3 `0 W7 e; R, Y3 v - #define DMA_FLAG_HTIF1 ((uint32_t)0x10000400)
6 z3 I- E F* N9 d% [% u - #define DMA_FLAG_TCIF1 ((uint32_t)0x10000800) n9 m4 |; U- E, A& G8 B( p
- #define DMA_FLAG_FEIF2 ((uint32_t)0x10010000)
% g" P4 i% l u% R% s5 X3 F6 P - #define DMA_FLAG_DMEIF2 ((uint32_t)0x10040000)
3 N0 a0 W2 W- R2 ]2 |5 ? - #define DMA_FLAG_TEIF2 ((uint32_t)0x10080000). B; V7 z" u7 o( W) O) S
- #define DMA_FLAG_HTIF2 ((uint32_t)0x10100000)
" {5 K2 _/ B, j - #define DMA_FLAG_TCIF2 ((uint32_t)0x10200000)
% o1 q9 `6 X' l: b$ `+ s - #define DMA_FLAG_FEIF3 ((uint32_t)0x10400000)* O: f: W g. r/ p' l( O" Z
- #define DMA_FLAG_DMEIF3 ((uint32_t)0x11000000)
, ^, {) e. c7 G' g% V3 f$ A - #define DMA_FLAG_TEIF3 ((uint32_t)0x12000000); d" I* T! d" {
- #define DMA_FLAG_HTIF3 ((uint32_t)0x14000000)
' W0 m8 F" K+ ~) |9 U# Q - #define DMA_FLAG_TCIF3 ((uint32_t)0x18000000)! u$ e$ G2 a; S
- #define DMA_FLAG_FEIF4 ((uint32_t)0x20000001)
1 ?1 {2 J3 e. I - #define DMA_FLAG_DMEIF4 ((uint32_t)0x20000004), G0 l( ]( Z5 O7 e
- #define DMA_FLAG_TEIF4 ((uint32_t)0x20000008)! q4 c. x; b5 L# U
- #define DMA_FLAG_HTIF4 ((uint32_t)0x20000010)) G0 p" f% j8 J
- #define DMA_FLAG_TCIF4 ((uint32_t)0x20000020)& g6 G0 ~$ ]* l
- #define DMA_FLAG_FEIF5 ((uint32_t)0x20000040)
( F: t* h) ?! v$ }, _8 L$ J8 r: J - #define DMA_FLAG_DMEIF5 ((uint32_t)0x20000100); S4 p# l" y4 U) }* j4 s j+ @0 M. R
- #define DMA_FLAG_TEIF5 ((uint32_t)0x20000200)
+ K% Q8 L& h* ^: ?( G - #define DMA_FLAG_HTIF5 ((uint32_t)0x20000400)9 H5 p1 t, M# y0 {4 q; R6 }
- #define DMA_FLAG_TCIF5 ((uint32_t)0x20000800)0 G* W6 z% D; J; ]; U+ }( r7 W7 s
- #define DMA_FLAG_FEIF6 ((uint32_t)0x20010000); t8 n; }5 b. @8 R: i" @7 ]' e6 J
- #define DMA_FLAG_DMEIF6 ((uint32_t)0x20040000)
3 b& ] M! [ `0 A2 @ - #define DMA_FLAG_TEIF6 ((uint32_t)0x20080000)0 Q) q B2 H4 l) l1 C1 L
- #define DMA_FLAG_HTIF6 ((uint32_t)0x20100000)# \# Y9 e' `2 j9 p- V
- #define DMA_FLAG_TCIF6 ((uint32_t)0x20200000)
) p* _ g$ A# @ - #define DMA_FLAG_FEIF7 ((uint32_t)0x20400000)
E! O. T G5 f3 F - #define DMA_FLAG_DMEIF7 ((uint32_t)0x21000000): n4 r6 ~* N: F, V3 c
- #define DMA_FLAG_TEIF7 ((uint32_t)0x22000000)6 o- ]5 U0 y! y0 |* v* i
- #define DMA_FLAG_HTIF7 ((uint32_t)0x24000000)5 [# @8 ?) ?# j, L4 P! w
- #define DMA_FLAG_TCIF7 ((uint32_t)0x28000000)
- M- i$ L. w) [3 s; D- O0 B - ' S$ ]5 W0 W- ?& T2 U8 V
- #define IS_DMA_CLEAR_FLAG(FLAG) ((((FLAG) & 0x30000000) != 0x30000000) && (((FLAG) & 0x30000000) != 0) && \: c7 F u4 `* b2 X1 _
- (((FLAG) & 0xC002F082) == 0x00) && ((FLAG) != 0x00))
) \' Z/ c( @* v, P6 L
: w& j7 Q+ B1 k- c. U- #define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA_FLAG_TCIF0) || ((FLAG) == DMA_FLAG_HTIF0) || \
: i' P% a1 N3 H - ((FLAG) == DMA_FLAG_TEIF0) || ((FLAG) == DMA_FLAG_DMEIF0) || \
4 O/ U4 |0 K3 m - ((FLAG) == DMA_FLAG_FEIF0) || ((FLAG) == DMA_FLAG_TCIF1) || \6 w# B/ }# E' E3 e* T! C0 T D7 C
- ((FLAG) == DMA_FLAG_HTIF1) || ((FLAG) == DMA_FLAG_TEIF1) || \) w+ L! k: b2 O& v1 h
- ((FLAG) == DMA_FLAG_DMEIF1) || ((FLAG) == DMA_FLAG_FEIF1) || \4 I4 H. g$ G4 y; R' H
- ((FLAG) == DMA_FLAG_TCIF2) || ((FLAG) == DMA_FLAG_HTIF2) || \
: A5 y4 d% @4 f' ^ - ((FLAG) == DMA_FLAG_TEIF2) || ((FLAG) == DMA_FLAG_DMEIF2) || \
1 ~, r$ D# U/ A0 U - ((FLAG) == DMA_FLAG_FEIF2) || ((FLAG) == DMA_FLAG_TCIF3) || \2 e V! k2 Q% i2 H8 ]* ]. l
- ((FLAG) == DMA_FLAG_HTIF3) || ((FLAG) == DMA_FLAG_TEIF3) || \: O1 R2 z: Q9 r6 n0 B0 \
- ((FLAG) == DMA_FLAG_DMEIF3) || ((FLAG) == DMA_FLAG_FEIF3) || \
8 C, {, d( U: P# h8 T - ((FLAG) == DMA_FLAG_TCIF4) || ((FLAG) == DMA_FLAG_HTIF4) || \
& B0 S3 D1 g7 m9 ? - ((FLAG) == DMA_FLAG_TEIF4) || ((FLAG) == DMA_FLAG_DMEIF4) || \
# c( Y- T) D/ i+ Z/ n; b - ((FLAG) == DMA_FLAG_FEIF4) || ((FLAG) == DMA_FLAG_TCIF5) || \$ x; J# r, U2 h/ p; j- W. f
- ((FLAG) == DMA_FLAG_HTIF5) || ((FLAG) == DMA_FLAG_TEIF5) || \# A& a4 j+ X, B& M6 Q
- ((FLAG) == DMA_FLAG_DMEIF5) || ((FLAG) == DMA_FLAG_FEIF5) || \
- o+ `" o* o' Y5 I* [. O) X s. o - ((FLAG) == DMA_FLAG_TCIF6) || ((FLAG) == DMA_FLAG_HTIF6) || \
6 Y* x$ _& |+ P: z$ `! t: T b& M - ((FLAG) == DMA_FLAG_TEIF6) || ((FLAG) == DMA_FLAG_DMEIF6) || \ X3 A, \8 \ Q+ @7 `: Q! ~: B0 W4 s
- ((FLAG) == DMA_FLAG_FEIF6) || ((FLAG) == DMA_FLAG_TCIF7) || \
9 B Y* W. y, [3 B0 q, ^ - ((FLAG) == DMA_FLAG_HTIF7) || ((FLAG) == DMA_FLAG_TEIF7) || \
; p' X$ k% d, Q- \1 ?. Z0 t3 h7 I - ((FLAG) == DMA_FLAG_DMEIF7) || ((FLAG) == DMA_FLAG_FEIF7))
复制代码
; U8 u& x" n1 X6 {& tDMA_interrupt_enable_definitions0 U+ W5 x; W4 i; l4 u
- /** @defgroup DMA_interrupt_enable_definitions ) E6 s, x$ x& ^* k8 D
- * @{
+ s+ ^. ~+ \& o0 T - */
# e I6 J% F& ?/ H, ^8 ~% J - #define DMA_IT_TC ((uint32_t)0x00000010)2 P, o! N2 t+ X: P$ \3 g A) T, B
- #define DMA_IT_HT ((uint32_t)0x00000008)
7 c3 S! m; {4 k" d8 \ - #define DMA_IT_TE ((uint32_t)0x00000004)0 Y* }3 P3 Z( J
- #define DMA_IT_DME ((uint32_t)0x00000002)4 ?& |, n! y3 Q! i D6 O) E
- #define DMA_IT_FE ((uint32_t)0x00000080)% [$ r7 g6 ^* X/ `5 z; w& `3 A
- * E2 b% D3 L A" u( o+ k
- #define IS_DMA_CONFIG_IT(IT) ((((IT) & 0xFFFFFF61) == 0x00) && ((IT) != 0x00))1 v0 ?+ ?: H( u$ m
复制代码
+ a+ i& i: v3 t$ X2 j `DMA_interrupts_definitions
) H1 `# [8 H8 N( f6 b" k/ W# u. _! w. O4 W
- /** @defgroup DMA_interrupts_definitions ( s3 O* b! T. Z6 u% {
- * @{
( s9 O6 \! C! b - */
0 }6 v- b7 N$ Q1 _- { - #define DMA_IT_FEIF0 ((uint32_t)0x90000001)& Q7 }# j! A( S4 |! N
- #define DMA_IT_DMEIF0 ((uint32_t)0x10001004)
# D6 R% I$ m" m% S3 ? - #define DMA_IT_TEIF0 ((uint32_t)0x10002008)
! I' V& W) T8 O/ K5 s - #define DMA_IT_HTIF0 ((uint32_t)0x10004010)3 w/ g; b4 Z' o. F; u7 d
- #define DMA_IT_TCIF0 ((uint32_t)0x10008020)6 w% j. V4 ]7 V/ K, }
- #define DMA_IT_FEIF1 ((uint32_t)0x90000040)1 [! E2 Y2 ]' W9 r
- #define DMA_IT_DMEIF1 ((uint32_t)0x10001100)9 v1 P4 G4 A/ F9 c
- #define DMA_IT_TEIF1 ((uint32_t)0x10002200)
# `8 y6 y& D. J8 }6 } - #define DMA_IT_HTIF1 ((uint32_t)0x10004400)
7 P A. B+ Z$ f/ m - #define DMA_IT_TCIF1 ((uint32_t)0x10008800)
# Z. F9 ^- W3 q% h; V& _7 a! b9 n - #define DMA_IT_FEIF2 ((uint32_t)0x90010000)- {% `$ ~ Z T2 i& ? n0 Y5 ^
- #define DMA_IT_DMEIF2 ((uint32_t)0x10041000)1 H u" g& P$ h. B6 J$ s
- #define DMA_IT_TEIF2 ((uint32_t)0x10082000)* Q8 V! c4 U4 J) t; I+ l
- #define DMA_IT_HTIF2 ((uint32_t)0x10104000)
+ F: j! s G) U1 \& H- W; x! \ - #define DMA_IT_TCIF2 ((uint32_t)0x10208000)0 K, y0 L% q& u! ]! i
- #define DMA_IT_FEIF3 ((uint32_t)0x90400000)
- r5 ~$ ?) N7 e7 M! V' i( [, g7 M - #define DMA_IT_DMEIF3 ((uint32_t)0x11001000)
. B& K& y1 _+ O2 C4 K, { - #define DMA_IT_TEIF3 ((uint32_t)0x12002000)
2 P: V. G0 f9 n* A) u& C1 z8 { - #define DMA_IT_HTIF3 ((uint32_t)0x14004000)
7 e4 O# k6 W' q1 Z9 ]5 f/ ` - #define DMA_IT_TCIF3 ((uint32_t)0x18008000)
- @' p" s4 q& f" C/ W - #define DMA_IT_FEIF4 ((uint32_t)0xA0000001)" J2 r" A/ j5 J4 n9 [2 S, [/ h
- #define DMA_IT_DMEIF4 ((uint32_t)0x20001004)
3 i* S: ^2 C8 L0 s: c, u - #define DMA_IT_TEIF4 ((uint32_t)0x20002008)
7 K/ j: c' O: }2 j, ~" P - #define DMA_IT_HTIF4 ((uint32_t)0x20004010)1 v" N9 X, F7 p- R6 u6 @
- #define DMA_IT_TCIF4 ((uint32_t)0x20008020)
9 x7 g, y4 K, ^. c P" x- R2 k - #define DMA_IT_FEIF5 ((uint32_t)0xA0000040)
9 f5 L/ ]+ W2 s - #define DMA_IT_DMEIF5 ((uint32_t)0x20001100)
- Y1 z, y7 `$ d3 Q' K; G5 e/ S - #define DMA_IT_TEIF5 ((uint32_t)0x20002200)7 P$ O$ A$ ^: t$ I
- #define DMA_IT_HTIF5 ((uint32_t)0x20004400)2 X* |* u; A8 f5 I
- #define DMA_IT_TCIF5 ((uint32_t)0x20008800)! H; h }: x$ u
- #define DMA_IT_FEIF6 ((uint32_t)0xA0010000)
. p* {( j# t1 M9 k - #define DMA_IT_DMEIF6 ((uint32_t)0x20041000)
; e/ C9 P1 }! A; ^) I+ J2 n - #define DMA_IT_TEIF6 ((uint32_t)0x20082000)$ K& r8 G( V- }3 k' f9 d* f, {
- #define DMA_IT_HTIF6 ((uint32_t)0x20104000)" ^# Z; n: r, j+ a4 M
- #define DMA_IT_TCIF6 ((uint32_t)0x20208000)
4 Q& n* L9 x6 _; }1 J - #define DMA_IT_FEIF7 ((uint32_t)0xA0400000)
( {% _5 Z: ~# F1 a8 } - #define DMA_IT_DMEIF7 ((uint32_t)0x21001000)5 S# K" F x* k- [: I. o# q% u* F
- #define DMA_IT_TEIF7 ((uint32_t)0x22002000)
2 }# [; d- s' N4 ?+ {' D3 U/ N+ Y - #define DMA_IT_HTIF7 ((uint32_t)0x24004000)
% F2 T5 x( x. [ - #define DMA_IT_TCIF7 ((uint32_t)0x28008000)+ M* x% W7 x q" k
- ( X+ \* _9 m8 ~& L( z% c8 c
- #define IS_DMA_CLEAR_IT(IT) ((((IT) & 0x30000000) != 0x30000000) && \: M5 T: _( J3 e! T' c8 U% ]
- (((IT) & 0x30000000) != 0) && ((IT) != 0x00) && \
" n- `, F- A+ B! g: W4 V- C6 Q# ]4 w% x - (((IT) & 0x40820082) == 0x00))
, f$ ~; q5 _! N# F. d
0 P( `0 A' Y; F- #define IS_DMA_GET_IT(IT) (((IT) == DMA_IT_TCIF0) || ((IT) == DMA_IT_HTIF0) || \
" t t+ W" h2 A( c( F - ((IT) == DMA_IT_TEIF0) || ((IT) == DMA_IT_DMEIF0) || \+ C% _& M% t+ _
- ((IT) == DMA_IT_FEIF0) || ((IT) == DMA_IT_TCIF1) || \
. g' |: ^7 Z) H' M9 c - ((IT) == DMA_IT_HTIF1) || ((IT) == DMA_IT_TEIF1) || \# {" B7 E! ^: _1 q6 `
- ((IT) == DMA_IT_DMEIF1)|| ((IT) == DMA_IT_FEIF1) || \
0 m# a! n, S, W: Q - ((IT) == DMA_IT_TCIF2) || ((IT) == DMA_IT_HTIF2) || \
. \5 @0 [. @# F2 O' S5 ? - ((IT) == DMA_IT_TEIF2) || ((IT) == DMA_IT_DMEIF2) || \0 c/ n# h3 Z7 K2 F; X0 A _
- ((IT) == DMA_IT_FEIF2) || ((IT) == DMA_IT_TCIF3) || \
6 a/ u/ I+ q/ [; B, V: F) i3 j0 I2 H - ((IT) == DMA_IT_HTIF3) || ((IT) == DMA_IT_TEIF3) || \6 t* X# w0 K6 K
- ((IT) == DMA_IT_DMEIF3)|| ((IT) == DMA_IT_FEIF3) || \
; K4 ?1 k% ^, O - ((IT) == DMA_IT_TCIF4) || ((IT) == DMA_IT_HTIF4) || \: T! I5 U$ l0 i
- ((IT) == DMA_IT_TEIF4) || ((IT) == DMA_IT_DMEIF4) || \
# a0 F9 G) q6 ]. ^1 R* s! D+ y) y - ((IT) == DMA_IT_FEIF4) || ((IT) == DMA_IT_TCIF5) || \! `7 r) Y: l) h- ?9 S1 R7 [" a x
- ((IT) == DMA_IT_HTIF5) || ((IT) == DMA_IT_TEIF5) || \
2 b8 U3 o' ?, y& w4 o6 g( {" Q) M4 t2 _ - ((IT) == DMA_IT_DMEIF5)|| ((IT) == DMA_IT_FEIF5) || \7 n6 F; z% ?; n2 m6 m, R9 _$ E
- ((IT) == DMA_IT_TCIF6) || ((IT) == DMA_IT_HTIF6) || \6 v- h0 {2 d: I8 T' b
- ((IT) == DMA_IT_TEIF6) || ((IT) == DMA_IT_DMEIF6) || \
& u" c7 w/ ~6 |' d2 E6 v3 A - ((IT) == DMA_IT_FEIF6) || ((IT) == DMA_IT_TCIF7) || \3 h9 z) y y6 P% v2 M
- ((IT) == DMA_IT_HTIF7) || ((IT) == DMA_IT_TEIF7) || \: U! B4 s5 w. |
- ((IT) == DMA_IT_DMEIF7)|| ((IT) == DMA_IT_FEIF7))
复制代码
1 z1 L# b: ]0 U4 A2 i" U( V1 QDMA_peripheral_increment_offset
4 n) m6 b8 v5 E3 g8 r) Z- /** @defgroup DMA_peripheral_increment_offset
y) K. C' w5 W' l3 f) D; a2 z# p - * @{
4 m: P! b. _* b# X. b* D - */ 3 ]+ O# G8 f2 ]* x
- #define DMA_PINCOS_Psize ((uint32_t)0x00000000)
$ o$ Q; R# S+ ]& R - #define DMA_PINCOS_WordAligned ((uint32_t)0x00008000): a- r) z6 m& m- h; Q f" g' p
9 j& V) a5 f+ p- g* \- #define IS_DMA_PINCOS_SIZE(SIZE) (((SIZE) == DMA_PINCOS_Psize) || \9 |. o+ P9 d- {6 p* U( s! G
- ((SIZE) == DMA_PINCOS_WordAligned))
复制代码 # s- D; R: Z1 T
controller_definitions- /** @defgroup DMA_flow_controller_definitions ! o7 B; J* Q7 u& T" E; P: {4 G2 E
- * @{
* w8 \9 ]8 m' `* r - */
( U. O: b0 v& o/ g% B - #define DMA_FlowCtrl_Memory ((uint32_t)0x00000000)2 N0 J+ D8 `6 [- b$ B* X$ r4 S
- #define DMA_FlowCtrl_Peripheral ((uint32_t)0x00000020)
* Q, j1 f3 Y) e
0 r; k9 p1 }4 c1 L. d- #define IS_DMA_FLOW_CTRL(CTRL) (((CTRL) == DMA_FlowCtrl_Memory) || \* e! G7 M+ z/ R% P; {. M& E
- ((CTRL) == DMA_FlowCtrl_Peripheral))
复制代码
3 q2 v9 K0 _1 _DMA_memory_targets_definitions
2 q$ X6 p" v" j) z$ Z7 w
5 y. f8 ?$ {. T, w- /** @defgroup DMA_memory_targets_definitions " w6 n4 o }7 C- R
- * @{% }8 y. P+ c6 d: o5 I
- */ ) ^ V7 U' Z4 _3 H
- #define DMA_Memory_0 ((uint32_t)0x00000000)
- a& O" J% m- I A - #define DMA_Memory_1 ((uint32_t)0x00080000)) S, X% Y$ G2 ?! F1 Z3 J
- ; X# n8 l6 ?7 \/ b
- #define IS_DMA_CURRENT_MEM(MEM) (((MEM) == DMA_Memory_0) || ((MEM) == DMA_Memory_1))
复制代码
* ^$ d6 E" D6 ^* w2 F% x0 m; z" c) i5 U1 D' v6 u$ J: j
03. 相关函数/ o% o8 {% E+ s Y
- /* Exported macro ------------------------------------------------------------*/
, X( D4 |3 w3 }8 ~( Q7 x; M1 k - /* Exported functions --------------------------------------------------------*/ ) p1 {/ \/ ^* C8 {. g8 ~
- , I0 K, W8 o( C+ e% M
- /* Function used to set the DMA configuration to the default reset state *****/
$ N) L5 `# k6 l- B' w - void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx);4 G2 G6 N- f+ B" ?
7 [" i4 J1 k; a5 T9 D0 }- /* Initialization and Configuration functions *********************************/
{* _0 b9 h5 _; i - void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct);
, m$ F0 G9 D; m7 b6 g6 x( } - void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);, r) ]$ V8 q, l9 P
- void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);
& V k, t5 f0 y/ A: O
8 D. H2 ~/ U8 P( N) i4 n- /* Optional Configuration functions *******************************************/, n- x8 [' [8 z6 |. h
- void DMA_PeriphIncOffsetSizeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_Pincos);
' ^7 w4 k8 @1 x - void DMA_FlowControllerConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FlowCtrl);
n, Z+ l) s$ I - % ~5 i/ [, h8 F L, q& m
- /* Data Counter functions *****************************************************/
' Z3 J0 S3 s) h. d - void DMA_SetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx, uint16_t Counter);
. X H* C8 u8 h( s* U/ G1 o$ g! b - uint16_t DMA_GetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx);, T) G. [; [' ?- r/ {' E4 J
- / ]. B9 h2 v, g1 ^
- /* Double Buffer mode functions ***********************************************/
8 V5 l0 k, y% ~* ~ - void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t Memory1BaseAddr,* o" o- u4 {/ d. Y; t2 Y$ e$ S
- uint32_t DMA_CurrentMemory);
. T3 N+ e# [. E) o4 y( q( Y - void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);' Z& f$ [' b7 s/ e% \% o
- void DMA_MemoryTargetConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t MemoryBaseAddr,
3 R s! D% [# {1 R# N8 f - uint32_t DMA_MemoryTarget);
" k1 k5 H; S. O) E7 f+ s7 t! c2 @ - uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef* DMAy_Streamx);2 z. V6 j0 U0 w4 `! K
- 0 k. }- Z+ g( T, i5 G
- /* Interrupts and flags management functions **********************************/
0 F+ J- Z- }" B! _ P8 K, } - FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef* DMAy_Streamx);0 H9 P; E, B( x1 s' R: }
- uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef* DMAy_Streamx);
/ S, B" q, } { - FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);; [, L2 T& z! b- Q
- void DMA_ClearFlag(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);# D8 ]. w) c7 V% p2 t; A
- void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState);
7 f ?9 [3 e1 C! B" I* i* D - ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);/ N0 Z4 L7 {+ f, N8 B k
- void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);; W, L7 y; A- d! l
. k. z- m" A# a% M1 _
复制代码 8 g; A( F" m4 x0 K" B! ^
04. 结构体封装4 @' A- q: G# [+ v) W5 g
- /**
% ` S+ ^3 F; b - * @brief DMA Controller8 I9 k; j7 }2 t4 x9 v% N" w; T( M
- */
. q' F/ ?1 M7 w) L3 J - # I4 U, ?' m. x5 D9 w( u
- typedef struct, _$ V4 i! w; p I' n
- {+ _! C2 ?0 p! {
- __IO uint32_t CR; /*!< DMA stream x configuration register */
# W7 Z2 g+ {+ s0 O - __IO uint32_t NDTR; /*!< DMA stream x number of data register *// K Y! Y1 W0 ^& e5 j/ o
- __IO uint32_t PAR; /*!< DMA stream x peripheral address register */4 M4 R: g7 p( l/ ~( L
- __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */
) ?* D0 B7 W) g3 H7 e. i - __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */, o; @! f' I( n' S
- __IO uint32_t FCR; /*!< DMA stream x FIFO control register */! A: o/ {/ G( U
- } DMA_Stream_TypeDef;+ T- `; l9 Q+ K+ k3 @! G
: f& N# Z% [7 x6 b# z- typedef struct: u% W+ m, ?) e' z. C
- {
9 p$ K2 Z. W% O! l- W- y - __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */6 r5 J% X% a- S- `7 L5 b
- __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */6 f4 K4 ^1 b$ O" P
- __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */3 w1 ^, S# P7 C$ h/ I5 A
- __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */% x- G" l) F( \0 A
- } DMA_TypeDef;
复制代码 . y* n* X: V5 W5 X+ x6 C
- I! S n( v. N1 B
6 [( s O: y! a9 t* H4 t8 M1 K3 b, f6 L+ S& K' ]
|