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