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