你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【经验分享】STM32 DMA相关函数和类型

[复制链接]
STMCU小助手 发布时间:2022-3-28 22:00
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) @- ]
  1. /** $ ]+ z/ E# M* H0 R/ m, w3 O
  2.   * @brief  DMA Init structure definition
    - a- U& E9 G" w
  3.   */
    0 t; n/ e5 [4 a0 `. r& x8 K$ }. n
  4. ) n! s  P2 N! Y
  5. typedef struct
    9 c+ m* E& ~7 p1 W4 i
  6. {0 F: K8 t/ `& Q6 T7 S/ }4 ^7 p+ e5 g- d
  7.   uint32_t DMA_Channel;            /*!< Specifies the channel used for the specified stream. 4 k, f7 [$ @5 b5 N. C9 k& J, C4 t
  8.                                         This parameter can be a value of @ref DMA_channel */
    ; @1 S7 j  [- X& ]1 N& q
  9. : m6 U6 ]0 L- l$ o7 Q( L$ H* _
  10.   uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Streamx. */  b$ O6 H6 T$ q$ R* u$ }. g  M
  11. 5 K6 `" P+ a8 D  @1 k2 ^6 v# _" t
  12.   uint32_t DMA_Memory0BaseAddr;    /*!< Specifies the memory 0 base address for DMAy Streamx. ; P, o( w% Y; h, k9 Z, M! ?5 S1 Q
  13.                                         This memory is the default memory used when double buffer mode is
    . |7 G4 H( M0 S4 ~
  14.                                         not enabled. */
    6 U+ ^6 e$ ?9 Z  C9 K" l) t; h6 L
  15. 8 N0 y. r( ]! q" n  v* A! I
  16.   uint32_t DMA_DIR;                /*!< Specifies if the data will be transferred from memory to peripheral,
    ' ?, o. t# m0 C1 R
  17.                                         from memory to memory or from peripheral to memory.
    0 g4 c, l3 K& z$ y( N, m
  18.                                         This parameter can be a value of @ref DMA_data_transfer_direction */
    ; I  G! N) v5 X8 o1 P. A

  19. 5 W; |; S* V) t# c
  20.   uint32_t DMA_BufferSize;         /*!< Specifies the buffer size, in data unit, of the specified Stream.
    : z' P" S- c2 q+ i9 i6 H
  21.                                         The data unit is equal to the configuration set in DMA_PeripheralDataSize
    - q* Z) a' |1 K3 Z) `. D! i
  22.                                         or DMA_MemoryDataSize members depending in the transfer direction. */
    " w  z) w% L8 V6 M

  23. 0 C+ w* m# i2 G/ k* l
  24.   uint32_t DMA_PeripheralInc;      /*!< Specifies whether the Peripheral address register should be incremented or not.
    ; I2 y- c9 c$ J" Y1 E! B
  25.                                         This parameter can be a value of @ref DMA_peripheral_incremented_mode */6 a- o. w+ l$ o. O! B

  26. + U5 c* v# f  R) R7 e1 V8 r: U: F
  27.   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
  28.                                         This parameter can be a value of @ref DMA_memory_incremented_mode */
    . T  B& H$ J. o2 r3 e" O( `
  29. $ a' }9 B3 ~# \! |% g" l
  30.   uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.' F0 W0 ^; k' j, [7 s7 f$ G; }. u
  31.                                         This parameter can be a value of @ref DMA_peripheral_data_size */
    ( r" Z" }# n* e# {
  32. 2 d, b% W( q/ @7 R+ z3 d" V
  33.   uint32_t DMA_MemoryDataSize;     /*!< Specifies the Memory data width.
    8 u5 ]) b3 C# z, q2 H
  34.                                         This parameter can be a value of @ref DMA_memory_data_size */! k) B8 o  m9 k( D7 O) l
  35. : m; }" z9 A# [3 s
  36.   uint32_t DMA_Mode;               /*!< Specifies the operation mode of the DMAy Streamx.% n. U2 s. l: _0 d
  37.                                         This parameter can be a value of @ref DMA_circular_normal_mode
    * Y4 q3 h4 ~( v
  38.                                         @note The circular buffer mode cannot be used if the memory-to-memory
    1 B, S8 ~+ v* V) p) d# c: d( e3 C
  39.                                               data transfer is configured on the selected Stream */: T4 I, L  ?0 f$ B# j% [% Y

  40. 9 l3 m1 e2 v7 [# R9 j
  41.   uint32_t DMA_Priority;           /*!< Specifies the software priority for the DMAy Streamx.$ J. z% _) G3 q1 y; y
  42.                                         This parameter can be a value of @ref DMA_priority_level */1 R$ l* m# J. ]  ]
  43. : e" o: a6 R% d/ H& B+ p6 h7 s2 P
  44.   uint32_t DMA_FIFOMode;          /*!< Specifies if the FIFO mode or Direct mode will be used for the specified Stream.: L2 H' E4 f" F) |
  45.                                         This parameter can be a value of @ref DMA_fifo_direct_mode
    8 a: N: R; u$ B% @- J& b" m$ f0 T
  46.                                         @note The Direct mode (FIFO mode disabled) cannot be used if the " }" W- H5 ]  g  d
  47.                                                memory-to-memory data transfer is configured on the selected Stream */
    , K* I5 w" A9 k( L. a

  48. # m: J+ n8 N$ b7 }+ F9 ]
  49.   uint32_t DMA_FIFOThreshold;      /*!< Specifies the FIFO threshold level.+ M4 R. q- I! c% N
  50.                                         This parameter can be a value of @ref DMA_fifo_threshold_level */
    3 r. e. K( Y& j! W4 K( k1 G# ]6 G

  51. 8 F1 p- L+ r! l/ @- M1 ?
  52.   uint32_t DMA_MemoryBurst;        /*!< Specifies the Burst transfer configuration for the memory transfers. 1 j  K. ~/ {8 V& }# K
  53.                                         It specifies the amount of data to be transferred in a single non interruptable
    1 k$ o5 b$ w, N( I: ~; K
  54.                                         transaction. This parameter can be a value of @ref DMA_memory_burst + B8 _# N9 a0 ]: V! u; K
  55.                                         @note The burst mode is possible only if the address Increment mode is enabled. */, F0 o! m$ m9 V9 c8 m# V  U
  56. , I3 D5 S1 r8 ]2 w  V& ?7 V+ A
  57.   uint32_t DMA_PeripheralBurst;    /*!< Specifies the Burst transfer configuration for the peripheral transfers.
    6 |! O( P+ u* z
  58.                                         It specifies the amount of data to be transferred in a single non interruptable
    2 Q6 e! z; z% n4 G* m  N- w
  59.                                         transaction. This parameter can be a value of @ref DMA_peripheral_burst+ k: z% X, C8 U' F% Z& @6 x* B
  60.                                         @note The burst mode is possible only if the address Increment mode is enabled. */  
    * M2 {6 `; O( n! D
  61. }DMA_InitTypeDef;
复制代码

" [  ]- O6 K, K! j4 ZDMA_Exported_Constants
; L1 T' f" h+ I9 l3 r; D% D% i, u  ^
  1. ** @defgroup DMA_Exported_Constants
    - S2 Q+ A9 i* c) }, {. g* e
  2.   * @{
    ! N& v/ ]1 T" _* K) V2 `
  3.   */
    % B% I" y+ ?$ ?1 r6 Y/ k/ k' S

  4. ) T# r5 v- \2 H& |3 h
  5. #define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Stream0) || \' ?+ w) `! \. n, }
  6.                                    ((PERIPH) == DMA1_Stream1) || \+ G: {0 b/ u6 N$ e
  7.                                    ((PERIPH) == DMA1_Stream2) || \
    7 L/ v+ n* X# z" \/ G9 J
  8.                                    ((PERIPH) == DMA1_Stream3) || \& I0 G) h* r/ x- g
  9.                                    ((PERIPH) == DMA1_Stream4) || \' ]2 B3 u* |7 j, |! d8 }6 I
  10.                                    ((PERIPH) == DMA1_Stream5) || \. m% H% X8 i3 T) I  X
  11.                                    ((PERIPH) == DMA1_Stream6) || \
    6 Z$ M  S% g6 Z5 X6 u* k
  12.                                    ((PERIPH) == DMA1_Stream7) || \. j- b- y, {" s( P) r5 `
  13.                                    ((PERIPH) == DMA2_Stream0) || \
    ' U% f. ]- r; t- P8 q+ h
  14.                                    ((PERIPH) == DMA2_Stream1) || \( I' M# J* Y) s& Y
  15.                                    ((PERIPH) == DMA2_Stream2) || \! k7 l, i2 B- F/ N; S2 `; Q
  16.                                    ((PERIPH) == DMA2_Stream3) || \
    * `, H* s9 L8 @% E# E
  17.                                    ((PERIPH) == DMA2_Stream4) || \: n+ }4 z  r$ \& o
  18.                                    ((PERIPH) == DMA2_Stream5) || \
    ! z: A. s8 Z$ T7 V* S% ]3 `
  19.                                    ((PERIPH) == DMA2_Stream6) || \& s- i0 n9 Y: h7 c
  20.                                    ((PERIPH) == DMA2_Stream7))* y, N" @5 X0 Y$ t  J1 L( s

  21. 9 n7 M5 |( v- b  H2 p, P. M
  22. #define IS_DMA_ALL_CONTROLLER(CONTROLLER) (((CONTROLLER) == DMA1) || \
    ) L. S# M$ k! I. u
  23.                                            ((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
  1. /** @defgroup DMA_channel
    8 ^) S8 M/ i/ A4 Y5 Z, e- e
  2.   * @{
    * {3 z& M3 R3 [) i4 _( z$ |( Z
  3.   */ 2 G8 v6 r' E: ^, j4 i* w* q$ V9 l
  4. #define DMA_Channel_0                     ((uint32_t)0x00000000)
    2 d" F+ O7 O4 d( G6 s1 F9 \
  5. #define DMA_Channel_1                     ((uint32_t)0x02000000)
    ! N" G" G4 z" t9 d0 ]- x
  6. #define DMA_Channel_2                     ((uint32_t)0x04000000)& m: z: ]9 w+ Z, F# c
  7. #define DMA_Channel_3                     ((uint32_t)0x06000000)
    7 b0 }- V: d- w: L2 U
  8. #define DMA_Channel_4                     ((uint32_t)0x08000000)4 i' T- [& z3 K7 m2 W# B4 g7 x
  9. #define DMA_Channel_5                     ((uint32_t)0x0A000000)2 t4 Q1 T; o) n& I7 I: O/ w
  10. #define DMA_Channel_6                     ((uint32_t)0x0C000000)
    & V: {/ Z8 N0 X2 \
  11. #define DMA_Channel_7                     ((uint32_t)0x0E000000)
    " j. m% N8 V3 Q0 c; d3 ^
  12. 7 M% i$ z( B0 d) J0 J; H; W
  13. #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_Channel_0) || \, j# l( }3 O- u0 p' d" u
  14.                                  ((CHANNEL) == DMA_Channel_1) || \) t' L$ D1 M# A4 n3 g
  15.                                  ((CHANNEL) == DMA_Channel_2) || \
    * b6 V5 w' z' n! |2 ?! A$ s
  16.                                  ((CHANNEL) == DMA_Channel_3) || \
    * o2 e% d5 `) E  ^
  17.                                  ((CHANNEL) == DMA_Channel_4) || \$ y( H) A, s' _, h  G$ U
  18.                                  ((CHANNEL) == DMA_Channel_5) || \* n0 h, E: |* q
  19.                                  ((CHANNEL) == DMA_Channel_6) || \2 }. A& L( |" |0 G8 }3 V
  20.                                  ((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
  1. /** @defgroup DMA_data_transfer_direction . Z6 V0 r# q# T3 \# E% S
  2.   * @{# s) A1 g, A+ j; O9 c' }1 k
  3.   */ 1 l; f5 J( C* a( p; V) w8 C
  4. #define DMA_DIR_PeripheralToMemory        ((uint32_t)0x00000000)
    " w9 |, T1 z5 b. }. E7 ~
  5. #define DMA_DIR_MemoryToPeripheral        ((uint32_t)0x00000040) 0 M: e6 D0 i8 x! w
  6. #define DMA_DIR_MemoryToMemory            ((uint32_t)0x00000080)
    / h0 c  n# i) u; Z
  7. ; b0 R; Y) P5 [0 d2 R4 Y
  8. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_DIR_PeripheralToMemory ) || \
    3 b8 n# w9 w7 J' L3 J3 h% z0 I
  9.                                      ((DIRECTION) == DMA_DIR_MemoryToPeripheral)  || \6 ?8 N+ u4 L. A6 m
  10.                                      ((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
  1. /** @defgroup DMA_data_buffer_size 7 h5 J, |7 ]+ f# o/ N- X) \
  2.   * @{* u) D$ }8 U- X* h9 G
  3.   */
    " n3 v4 Z; ?$ L
  4. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
    * D, N2 I; r- i4 r9 e' [
  5. 14 @+ D6 L5 U0 A+ j3 ?8 Y
  6. 2' D/ D" j; U* q5 z/ U: C- V
  7. 3
    / e: u( B6 ^; I+ I* J: w
  8. 4
    . Z3 p) C7 B5 s. M2 ?- ^" A1 S
  9. DMA_peripheral_incremented_mode6 z) D' q0 M2 Y$ I+ r7 n# p

  10. 4 W, A0 Z9 H6 {9 n( _4 e% v
  11. /** @defgroup DMA_peripheral_incremented_mode
    . {* O. |, E! i" t/ w
  12.   * @{
    $ ^, I/ s0 j  f7 o
  13.   */ ' J! t; B' S7 L* o  x5 L
  14. #define DMA_PeripheralInc_Enable          ((uint32_t)0x00000200)
    / w& Y% D+ m) N3 g
  15. #define DMA_PeripheralInc_Disable         ((uint32_t)0x00000000)+ L8 A4 _  J, P( H( {! w" d
  16. 7 J, b2 ~& z" s9 S+ A+ t
  17. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \
    $ x9 J1 g/ e8 t; a. u
  18.                                             ((STATE) == DMA_PeripheralInc_Disable))
复制代码
) R% c( X7 j, d% p  b
DMA_memory_incremented_mode
  1. /** @defgroup DMA_memory_incremented_mode ) T8 U  d( E4 u
  2.   * @{' ~' G( j0 V2 K8 F1 f% c) `/ T( W8 e
  3.   */ 4 e2 n6 ~5 b$ e: l
  4. #define DMA_MemoryInc_Enable              ((uint32_t)0x00000400)
    1 P6 E$ Q1 g9 d9 Q
  5. #define DMA_MemoryInc_Disable             ((uint32_t)0x00000000)
    $ I! c8 _! i; ]
  6. - J4 E/ C6 G- ]( u0 G  ^" D( h8 O1 ~
  7. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \
    0 p9 k: ]# }1 ?, B7 J) d3 {
  8.                                         ((STATE) == DMA_MemoryInc_Disable))
复制代码
9 C; J& t2 }2 W& T. J. f
DMA_peripheral_data_size
6 ?* T* D: q4 W6 z
  1. /** @defgroup DMA_peripheral_data_size   j0 [; v& V# h0 r8 l
  2.   * @{
    1 L4 M4 g! K$ h- |' b. B% w
  3.   */ $ `$ I7 q. ^9 }! i2 i
  4. #define DMA_PeripheralDataSize_Byte       ((uint32_t)0x00000000)
    1 O. ]* M/ O; R; Z5 \
  5. #define DMA_PeripheralDataSize_HalfWord   ((uint32_t)0x00000800)
    % h4 h9 a5 T5 G$ ^  ~" f4 g
  6. #define DMA_PeripheralDataSize_Word       ((uint32_t)0x00001000)1 b$ X  t& ~3 O6 H; N+ D
  7. , V" Y1 D; B- S, d2 D
  8. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte)  || \1 F! d+ D" B9 P' M% C5 `" y% i
  9.                                            ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \
    & }3 ?7 L" A, G3 E7 u, {
  10.                                            ((SIZE) == DMA_PeripheralDataSize_Word))
    6 ]4 e1 X( v! d
复制代码

4 o" y* p1 P/ F5 A' ?) ~$ cDMA_memory_data_size
  1. /** @defgroup DMA_memory_data_size
    ' z3 ^- Z. v2 ~0 \
  2.   * @{
    $ `) O  [5 o" c. h5 z4 E
  3.   */
    " _: E6 o4 p8 D! L* N& v3 i
  4. #define DMA_MemoryDataSize_Byte           ((uint32_t)0x00000000) & f% T7 @% @7 o
  5. #define DMA_MemoryDataSize_HalfWord       ((uint32_t)0x00002000) , v7 t3 H  S* m1 O9 @* ]
  6. #define DMA_MemoryDataSize_Word           ((uint32_t)0x00004000)+ y1 C* ]) O' h( f6 g( ]
  7. / E# t7 y1 [+ [2 p' d
  8. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte)  || \
    ( \2 s4 o4 l7 {' }, f
  9.                                        ((SIZE) == DMA_MemoryDataSize_HalfWord) || \
    5 o* w3 E" [5 b+ }
  10.                                        ((SIZE) == DMA_MemoryDataSize_Word ))
复制代码

: R# Z5 e, l# `DMA_circular_normal_mode
7 w) D% T  W' h" x0 H7 I" B

  1. 7 ~) _+ J# v! j9 ^5 m
  2. /** @defgroup DMA_circular_normal_mode & s8 U# x! t, C0 W, s6 m0 U) X, E
  3.   * @{, T) d3 r: I1 f  x4 G% a4 F
  4.   */ 0 v* T3 i; d8 M( I
  5. #define DMA_Mode_Normal                   ((uint32_t)0x00000000) $ ?2 E/ R0 d! G* u! z  d. U
  6. #define DMA_Mode_Circular                 ((uint32_t)0x00000100)) i2 R1 q  e- o; O2 d! J8 G

  7. / t) c( ^: p, a
  8. #define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Normal ) || \
    8 q% \; }! R- L* n- c, n$ J
  9.                            ((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
  1. /** @defgroup DMA_priority_level
    ! _6 U, l1 Y- \: s1 G0 I
  2.   * @{
    + ?# {4 W* b; Z2 Y: I
  3.   */   X3 M: k1 s% F' R2 q
  4. #define DMA_Priority_Low                  ((uint32_t)0x00000000)) F4 o& _9 o3 u2 T9 t
  5. #define DMA_Priority_Medium               ((uint32_t)0x00010000) 2 M0 [3 N' v, j3 Y& g1 A
  6. #define DMA_Priority_High                 ((uint32_t)0x00020000)/ m) P3 b2 \2 }. n. }2 k5 K
  7. #define DMA_Priority_VeryHigh             ((uint32_t)0x00030000)' J7 R. {- c: V0 A+ l
  8. ( V- h. A7 `; m$ v8 r4 }& t, m
  9. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_Low )   || \
    8 l" H4 P# I2 H3 U
  10.                                    ((PRIORITY) == DMA_Priority_Medium) || \* E5 H  p2 h9 l8 {) R: U* t
  11.                                    ((PRIORITY) == DMA_Priority_High)   || \3 R$ ^4 i( {3 \9 r
  12.                                    ((PRIORITY) == DMA_Priority_VeryHigh))
复制代码
6 s# ~8 d+ c4 P" `
DMA_fifo_direct_mode
  1. /** @defgroup DMA_fifo_direct_mode " L" a! ?# ]! y
  2.   * @{, E+ A9 C' P$ G8 a
  3.   */ # L9 t/ _; D) y. o. l# Z
  4. #define DMA_FIFOMode_Disable              ((uint32_t)0x00000000)
    - ~7 g+ u+ l" c$ Z1 s
  5. #define DMA_FIFOMode_Enable               ((uint32_t)0x00000004)4 p2 R& W" h! B; L1 |$ j0 h

  6. " M8 p0 `1 b3 {. g7 Z3 ^- E; K
  7. #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMode_Disable ) || \& W) N6 u7 _& T" O
  8.                                        ((STATE) == DMA_FIFOMode_Enable))
复制代码

% _# ]; v+ [& }) T& TDMA_fifo_threshold_level
' [, H1 r9 i$ H0 |; b% i5 _
/ t) N1 x: e: q+ d9 j( Z
  1. /** @defgroup DMA_fifo_threshold_level ! }/ L6 L  }- j9 j* O0 i
  2.   * @{
    7 ~* v% V' I) e% p
  3.   */ . X8 U. C; C/ R9 b% u& _
  4. #define DMA_FIFOThreshold_1QuarterFull    ((uint32_t)0x00000000)" s2 `1 D1 M- z0 @( ]2 }
  5. #define DMA_FIFOThreshold_HalfFull        ((uint32_t)0x00000001)
    & }3 w' q, @0 J1 c! c$ d
  6. #define DMA_FIFOThreshold_3QuartersFull   ((uint32_t)0x00000002)
    + G8 i$ z& [. F
  7. #define DMA_FIFOThreshold_Full            ((uint32_t)0x00000003), C: ^- H( K  v( x* Z
  8. . P; [+ ]; S: I" h' H4 F
  9. #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFOThreshold_1QuarterFull ) || \
    $ O+ h/ K% h/ \; _) h6 J  A. P
  10.                                           ((THRESHOLD) == DMA_FIFOThreshold_HalfFull)      || \# y8 J% F: h# Y7 n
  11.                                           ((THRESHOLD) == DMA_FIFOThreshold_3QuartersFull) || \. U8 s; h2 B( T. k6 l7 i9 j8 K3 o
  12.                                           ((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
  1. /** @defgroup DMA_memory_burst / K9 a, K( h. v  P" A. I& }. n
  2.   * @{: h% h9 P; d) ]' E2 C, ~- L
  3.   */
    ' z- O8 ^# G6 f0 }1 n
  4. #define DMA_MemoryBurst_Single            ((uint32_t)0x00000000)
    3 `& S* g  i8 `5 D$ M" `6 M0 X* C
  5. #define DMA_MemoryBurst_INC4              ((uint32_t)0x00800000)  
    4 u% \" ^5 F6 x" r
  6. #define DMA_MemoryBurst_INC8              ((uint32_t)0x01000000): @5 W1 R3 |* F6 A4 r
  7. #define DMA_MemoryBurst_INC16             ((uint32_t)0x01800000)
    2 W1 k0 G+ B7 G0 a5 C' W

  8. ' [) j7 N8 Q7 B( O7 k
  9. #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MemoryBurst_Single) || \7 p9 v. y0 i* k% Z4 a4 Y
  10.                                     ((BURST) == DMA_MemoryBurst_INC4)  || \! U3 E. p( n/ N8 J0 O
  11.                                     ((BURST) == DMA_MemoryBurst_INC8)  || \8 H4 |+ @8 P  P, t0 R
  12.                                     ((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 ]
  1. /** @defgroup DMA_peripheral_burst ; W+ d, }6 P6 P+ f; p
  2.   * @{0 O* }0 L* B. u; z
  3.   */ 5 e2 [) \' q- L& X: i7 ^3 i
  4. #define DMA_PeripheralBurst_Single        ((uint32_t)0x00000000); {* d: m0 g* x( G8 R: x  N
  5. #define DMA_PeripheralBurst_INC4          ((uint32_t)0x00200000)  
    " W3 J  l% y  f; I: Z7 h2 N
  6. #define DMA_PeripheralBurst_INC8          ((uint32_t)0x00400000)
    ( W5 Z0 @! @) J+ X! k) m+ a( k
  7. #define DMA_PeripheralBurst_INC16         ((uint32_t)0x00600000)
    ) z0 R1 b0 h" r- l
  8. ; m- S1 w8 S6 p
  9. #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PeripheralBurst_Single) || \: I0 G9 h8 B5 D3 F
  10.                                         ((BURST) == DMA_PeripheralBurst_INC4)  || \
      {+ A. A" V, `1 ~
  11.                                         ((BURST) == DMA_PeripheralBurst_INC8)  || \5 ^2 r4 Z7 q5 H( ]& s, }
  12.                                         ((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
  1. /** @defgroup DMA_fifo_status_level
    1 W9 u# E2 d( J) {
  2.   * @{
    + d" h" q& r* Y1 q! Z
  3.   */! c* I5 C8 X) K1 f1 `9 ?
  4. #define DMA_FIFOStatus_Less1QuarterFull   ((uint32_t)0x00000000 << 3)
    * S$ Q) U, {' e4 w4 C. |6 U
  5. #define DMA_FIFOStatus_1QuarterFull       ((uint32_t)0x00000001 << 3)
    7 s% v5 A4 U, P( {
  6. #define DMA_FIFOStatus_HalfFull           ((uint32_t)0x00000002 << 3) / F- w6 n$ t9 C' A
  7. #define DMA_FIFOStatus_3QuartersFull      ((uint32_t)0x00000003 << 3)
    ' w, S0 L# t, z; u' G+ U! G2 g# ~
  8. #define DMA_FIFOStatus_Empty              ((uint32_t)0x00000004 << 3)
    5 A# w  C' O- Z
  9. #define DMA_FIFOStatus_Full               ((uint32_t)0x00000005 << 3)" g1 v6 o) E/ y- f  q% h
  10. ; f9 o, o1 I( |) R- F8 o, [
  11. #define IS_DMA_FIFO_STATUS(STATUS) (((STATUS) == DMA_FIFOStatus_Less1QuarterFull ) || \" p6 M' s0 V" b
  12.                                     ((STATUS) == DMA_FIFOStatus_HalfFull)          || \
    6 Q- o8 E" K- f' x3 {  ]
  13.                                     ((STATUS) == DMA_FIFOStatus_1QuarterFull)      || \/ H" {/ ~* J+ }$ r3 j+ j
  14.                                     ((STATUS) == DMA_FIFOStatus_3QuartersFull)     || \
    4 C" _& s) }' H4 y' A0 o# G1 w
  15.                                     ((STATUS) == DMA_FIFOStatus_Full)              || \
    % D/ V- y8 r: P7 E# A, Y
  16.                                     ((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
  1. /** @defgroup DMA_flags_definition 5 J1 }) s) U) Y( c: `
  2.   * @{0 \0 [8 }3 {) m5 E5 D7 n- u
  3.   */
    * m3 V& B4 r/ Z0 k& ^) w) [: ]
  4. #define DMA_FLAG_FEIF0                    ((uint32_t)0x10800001). g) O6 n% e& X  A3 e6 v( F: Z
  5. #define DMA_FLAG_DMEIF0                   ((uint32_t)0x10800004)+ F( m( _: M8 j+ ?; `
  6. #define DMA_FLAG_TEIF0                    ((uint32_t)0x10000008)5 A- S# q* W. W' a
  7. #define DMA_FLAG_HTIF0                    ((uint32_t)0x10000010)
    ( Y# z# M6 u; L) m) R
  8. #define DMA_FLAG_TCIF0                    ((uint32_t)0x10000020)
    7 x4 A8 [1 _' S* N
  9. #define DMA_FLAG_FEIF1                    ((uint32_t)0x10000040)
    3 E3 J. f7 Z; o" U5 l5 v# i8 K* T# J
  10. #define DMA_FLAG_DMEIF1                   ((uint32_t)0x10000100)
    " G& X: D; m# f  A/ @7 y
  11. #define DMA_FLAG_TEIF1                    ((uint32_t)0x10000200)1 r, H4 Y1 I6 `  r, n0 b
  12. #define DMA_FLAG_HTIF1                    ((uint32_t)0x10000400)
    ' w, }2 Q( K5 w( L" ^! {
  13. #define DMA_FLAG_TCIF1                    ((uint32_t)0x10000800)
    * X( a2 K0 b$ {' {, E' F
  14. #define DMA_FLAG_FEIF2                    ((uint32_t)0x10010000)
    4 s# X3 ?2 ~$ e- T
  15. #define DMA_FLAG_DMEIF2                   ((uint32_t)0x10040000)
    1 Y2 g% t. c" a2 C1 ~
  16. #define DMA_FLAG_TEIF2                    ((uint32_t)0x10080000)
    6 a; Q  x1 p% @% k
  17. #define DMA_FLAG_HTIF2                    ((uint32_t)0x10100000)
    ) x5 v, l" r5 p9 n
  18. #define DMA_FLAG_TCIF2                    ((uint32_t)0x10200000)* M! R7 _5 h! g, j3 [2 p- q* O
  19. #define DMA_FLAG_FEIF3                    ((uint32_t)0x10400000)' G% X: m: c! m7 S4 ?6 n0 M% r" b; j) D
  20. #define DMA_FLAG_DMEIF3                   ((uint32_t)0x11000000)3 \+ L9 x* t2 C+ B. l
  21. #define DMA_FLAG_TEIF3                    ((uint32_t)0x12000000)
    1 w: x5 `  H/ X' j3 ~) f
  22. #define DMA_FLAG_HTIF3                    ((uint32_t)0x14000000)& H  H* W3 S5 O0 i1 u* h1 s8 X
  23. #define DMA_FLAG_TCIF3                    ((uint32_t)0x18000000): F; r) i% |4 y! m$ E4 }3 |5 W8 G' d" D
  24. #define DMA_FLAG_FEIF4                    ((uint32_t)0x20000001)/ k# [0 x, t# A: G9 e$ p
  25. #define DMA_FLAG_DMEIF4                   ((uint32_t)0x20000004)( Y) e* S7 C9 I( ?9 \
  26. #define DMA_FLAG_TEIF4                    ((uint32_t)0x20000008)3 d) y& |' b5 u/ }* V, |
  27. #define DMA_FLAG_HTIF4                    ((uint32_t)0x20000010)1 x* b& g; _5 C- S6 H/ L% f
  28. #define DMA_FLAG_TCIF4                    ((uint32_t)0x20000020)( \  N4 o* ~9 _
  29. #define DMA_FLAG_FEIF5                    ((uint32_t)0x20000040)
    - r% k! M* r4 V2 P7 b8 P) D
  30. #define DMA_FLAG_DMEIF5                   ((uint32_t)0x20000100)
    / S; Y, N! d, X9 l3 O5 i0 k  V2 V( w2 v: v
  31. #define DMA_FLAG_TEIF5                    ((uint32_t)0x20000200)
    6 ^/ {( Y, s  Y4 G
  32. #define DMA_FLAG_HTIF5                    ((uint32_t)0x20000400), [# f5 |( h; M; ]$ X, ~" U, y+ q& Y
  33. #define DMA_FLAG_TCIF5                    ((uint32_t)0x20000800)/ l0 J$ W0 E1 [. c" E
  34. #define DMA_FLAG_FEIF6                    ((uint32_t)0x20010000)
    2 q( V" j0 j' G/ {
  35. #define DMA_FLAG_DMEIF6                   ((uint32_t)0x20040000)" P, K. v6 s% O' D# Z/ q% `+ p
  36. #define DMA_FLAG_TEIF6                    ((uint32_t)0x20080000)+ V- k& |" t  Q' @
  37. #define DMA_FLAG_HTIF6                    ((uint32_t)0x20100000)9 ]+ X4 r. u% j  c7 Q
  38. #define DMA_FLAG_TCIF6                    ((uint32_t)0x20200000)+ ~% }0 @8 P/ y+ @7 W
  39. #define DMA_FLAG_FEIF7                    ((uint32_t)0x20400000): f' a9 Y# J' y( B
  40. #define DMA_FLAG_DMEIF7                   ((uint32_t)0x21000000)
    ) D& T1 |1 w- B) n* Z
  41. #define DMA_FLAG_TEIF7                    ((uint32_t)0x22000000)
    + B- p/ o7 d, t' @" ]
  42. #define DMA_FLAG_HTIF7                    ((uint32_t)0x24000000)
    ( r1 U+ S+ V; h" c" z
  43. #define DMA_FLAG_TCIF7                    ((uint32_t)0x28000000)* R! R8 e! Q/ z

  44. ' m# {9 T+ h- J1 F2 k
  45. #define IS_DMA_CLEAR_FLAG(FLAG) ((((FLAG) & 0x30000000) != 0x30000000) && (((FLAG) & 0x30000000) != 0) && \3 {% l; v' i7 i2 z2 c  C* J
  46.                                  (((FLAG) & 0xC002F082) == 0x00) && ((FLAG) != 0x00))
    1 {5 [* B& x2 m! O( a

  47. 7 U% ?7 g4 c  p
  48. #define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA_FLAG_TCIF0)  || ((FLAG) == DMA_FLAG_HTIF0)  || \7 g* ~7 _, \2 ~. m8 U! h5 ?
  49.                                ((FLAG) == DMA_FLAG_TEIF0)  || ((FLAG) == DMA_FLAG_DMEIF0) || \
    * J, f" w  v9 p/ h( O
  50.                                ((FLAG) == DMA_FLAG_FEIF0)  || ((FLAG) == DMA_FLAG_TCIF1)  || \5 T& T0 Q( k4 V' b" M' Z
  51.                                ((FLAG) == DMA_FLAG_HTIF1)  || ((FLAG) == DMA_FLAG_TEIF1)  || \
    ' L- }" X) ^8 [& v0 _6 V9 }5 z0 K
  52.                                ((FLAG) == DMA_FLAG_DMEIF1) || ((FLAG) == DMA_FLAG_FEIF1)  || \! {4 V* V: g: Z8 o: w3 o9 A
  53.                                ((FLAG) == DMA_FLAG_TCIF2)  || ((FLAG) == DMA_FLAG_HTIF2)  || \
    8 Z+ s  G" Y; }3 F  x& L( q5 J
  54.                                ((FLAG) == DMA_FLAG_TEIF2)  || ((FLAG) == DMA_FLAG_DMEIF2) || \8 j; V0 T: ~) H2 z2 @2 |
  55.                                ((FLAG) == DMA_FLAG_FEIF2)  || ((FLAG) == DMA_FLAG_TCIF3)  || \$ K# E' M" t, h1 S
  56.                                ((FLAG) == DMA_FLAG_HTIF3)  || ((FLAG) == DMA_FLAG_TEIF3)  || \: u+ ?7 w! N, T' W4 |9 M
  57.                                ((FLAG) == DMA_FLAG_DMEIF3) || ((FLAG) == DMA_FLAG_FEIF3)  || \
    ! {5 j! l3 _, G' q
  58.                                ((FLAG) == DMA_FLAG_TCIF4)  || ((FLAG) == DMA_FLAG_HTIF4)  || \
    ( R8 j2 F( k3 ^- {
  59.                                ((FLAG) == DMA_FLAG_TEIF4)  || ((FLAG) == DMA_FLAG_DMEIF4) || \3 Z' Y# W6 E) F/ }# M. L
  60.                                ((FLAG) == DMA_FLAG_FEIF4)  || ((FLAG) == DMA_FLAG_TCIF5)  || \  l! e  E3 J% N( M6 y
  61.                                ((FLAG) == DMA_FLAG_HTIF5)  || ((FLAG) == DMA_FLAG_TEIF5)  || \
    ; Z- f1 J3 ?, j& A) i
  62.                                ((FLAG) == DMA_FLAG_DMEIF5) || ((FLAG) == DMA_FLAG_FEIF5)  || \- D9 l. l  w5 q: k
  63.                                ((FLAG) == DMA_FLAG_TCIF6)  || ((FLAG) == DMA_FLAG_HTIF6)  || \
    ' f6 F4 B; _0 X8 C" I! _
  64.                                ((FLAG) == DMA_FLAG_TEIF6)  || ((FLAG) == DMA_FLAG_DMEIF6) || \6 {2 \5 @+ Q' \) j; |+ a
  65.                                ((FLAG) == DMA_FLAG_FEIF6)  || ((FLAG) == DMA_FLAG_TCIF7)  || \; d" G& a* N, J0 l; D  u. n  M9 W
  66.                                ((FLAG) == DMA_FLAG_HTIF7)  || ((FLAG) == DMA_FLAG_TEIF7)  || \
    - k4 u+ j, l0 V
  67.                                ((FLAG) == DMA_FLAG_DMEIF7) || ((FLAG) == DMA_FLAG_FEIF7))
复制代码

% n9 |; S* n: H# [( u' TDMA_interrupt_enable_definitions
$ s0 K# G- |% R
  1. /** @defgroup DMA_interrupt_enable_definitions 2 I: b. J& b5 B( {% y
  2.   * @{
    7 y2 O8 G# Z0 c. ?& o  D3 Y6 L. |
  3.   */ 2 V1 z4 p+ D. k2 H  O
  4. #define DMA_IT_TC                         ((uint32_t)0x00000010)% \/ A2 p3 [3 S( P$ L; B
  5. #define DMA_IT_HT                         ((uint32_t)0x00000008)6 }$ `6 d; @, T- L# n& o
  6. #define DMA_IT_TE                         ((uint32_t)0x00000004)
    : F0 d) [5 ~; T4 d
  7. #define DMA_IT_DME                        ((uint32_t)0x00000002)
    # a2 ]0 `; m+ v* }8 X
  8. #define DMA_IT_FE                         ((uint32_t)0x00000080)/ c4 r% G. c* ~+ s+ e! x# ~' l- ^

  9. 0 O$ y. y5 J9 R( I/ p
  10. #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
  1. /** @defgroup DMA_interrupts_definitions
    : h% T% U& X8 i) s6 `) K
  2.   * @{5 a2 @0 Z- x' A, p) d& {
  3.   */ , o; j7 p& F9 y* u/ X* c
  4. #define DMA_IT_FEIF0                      ((uint32_t)0x90000001)2 D) e& C$ [! n& \
  5. #define DMA_IT_DMEIF0                     ((uint32_t)0x10001004)0 U; Q- f' s' e
  6. #define DMA_IT_TEIF0                      ((uint32_t)0x10002008)' b$ g9 v  J6 {: h! o
  7. #define DMA_IT_HTIF0                      ((uint32_t)0x10004010)+ g+ _. L1 M/ [% ?1 d1 v1 ?
  8. #define DMA_IT_TCIF0                      ((uint32_t)0x10008020)0 v" E' x! P1 a. \0 C' Y, s- J! I" E+ P5 G
  9. #define DMA_IT_FEIF1                      ((uint32_t)0x90000040)
    " W- J' D8 }2 f9 l+ Z
  10. #define DMA_IT_DMEIF1                     ((uint32_t)0x10001100)
    + p8 X) N' o& p5 j4 e: s
  11. #define DMA_IT_TEIF1                      ((uint32_t)0x10002200)% M2 N5 O% m( V. `: g
  12. #define DMA_IT_HTIF1                      ((uint32_t)0x10004400)
    ' |" c: P5 d* v6 n) }
  13. #define DMA_IT_TCIF1                      ((uint32_t)0x10008800)6 a+ e1 a) d+ a5 A, G
  14. #define DMA_IT_FEIF2                      ((uint32_t)0x90010000)7 X5 o) \" O1 {5 |7 q5 K
  15. #define DMA_IT_DMEIF2                     ((uint32_t)0x10041000)% @, c; n9 C9 I5 o  Q& {
  16. #define DMA_IT_TEIF2                      ((uint32_t)0x10082000)$ h/ T+ x+ i2 w' [. J
  17. #define DMA_IT_HTIF2                      ((uint32_t)0x10104000)
    6 x1 @0 i" y3 }( [
  18. #define DMA_IT_TCIF2                      ((uint32_t)0x10208000)( K' s3 B% |- b) K" X
  19. #define DMA_IT_FEIF3                      ((uint32_t)0x90400000)
      z1 h- n8 q3 i- G
  20. #define DMA_IT_DMEIF3                     ((uint32_t)0x11001000)
    6 T4 F' J# f. D3 J- H" M
  21. #define DMA_IT_TEIF3                      ((uint32_t)0x12002000)
    # ?5 a$ D, W/ V' A  i( F) Y- f
  22. #define DMA_IT_HTIF3                      ((uint32_t)0x14004000)
    . ~6 C/ x  H4 a- b" Z
  23. #define DMA_IT_TCIF3                      ((uint32_t)0x18008000)
      F2 w' U! i& q7 g1 E2 W
  24. #define DMA_IT_FEIF4                      ((uint32_t)0xA0000001)' {  x9 h# C. v3 A, ~2 Y" i9 c
  25. #define DMA_IT_DMEIF4                     ((uint32_t)0x20001004)
    9 ~' P+ h. M2 h
  26. #define DMA_IT_TEIF4                      ((uint32_t)0x20002008)" ^  O; g( s* H: N/ S6 N
  27. #define DMA_IT_HTIF4                      ((uint32_t)0x20004010)$ u0 y/ s: g7 E
  28. #define DMA_IT_TCIF4                      ((uint32_t)0x20008020)% |: @" B( D& t2 v4 y
  29. #define DMA_IT_FEIF5                      ((uint32_t)0xA0000040)7 N; q. z4 _: B# c( V
  30. #define DMA_IT_DMEIF5                     ((uint32_t)0x20001100)
    + Z* Q" j2 W- p6 p
  31. #define DMA_IT_TEIF5                      ((uint32_t)0x20002200)
    4 q+ R5 v0 S# P) h/ H5 a
  32. #define DMA_IT_HTIF5                      ((uint32_t)0x20004400)
    & O; c0 {( U. _! O/ N# M
  33. #define DMA_IT_TCIF5                      ((uint32_t)0x20008800)
    % e7 Y5 \, S& X! ?/ T1 ?  C
  34. #define DMA_IT_FEIF6                      ((uint32_t)0xA0010000)
    5 ]) t& ?7 [5 Z
  35. #define DMA_IT_DMEIF6                     ((uint32_t)0x20041000)
    8 E1 g) e' y1 j6 r- {! l
  36. #define DMA_IT_TEIF6                      ((uint32_t)0x20082000)! S3 S4 c* L$ N, q7 v+ y3 w
  37. #define DMA_IT_HTIF6                      ((uint32_t)0x20104000)2 R% [5 z4 r5 t
  38. #define DMA_IT_TCIF6                      ((uint32_t)0x20208000)
    / K  A$ S: }( u4 V) `# O( x
  39. #define DMA_IT_FEIF7                      ((uint32_t)0xA0400000): [1 y! P6 ~5 ]
  40. #define DMA_IT_DMEIF7                     ((uint32_t)0x21001000)
    % a7 R0 N# G9 _& y
  41. #define DMA_IT_TEIF7                      ((uint32_t)0x22002000)
    # L, S- S8 P6 @9 Z- k* y
  42. #define DMA_IT_HTIF7                      ((uint32_t)0x24004000)4 F$ h4 C/ Q; H9 F1 J$ X
  43. #define DMA_IT_TCIF7                      ((uint32_t)0x28008000)
    8 }3 D$ |- h$ o( n

  44. 3 f, {0 T4 P: C' B
  45. #define IS_DMA_CLEAR_IT(IT) ((((IT) & 0x30000000) != 0x30000000) && \
    " D4 I% B' F/ \$ [  C8 ~, ]
  46.                              (((IT) & 0x30000000) != 0) && ((IT) != 0x00) && \1 f7 Z3 |. f* F" T1 r% M  }' a- Q
  47.                              (((IT) & 0x40820082) == 0x00))
    : |, j5 y& @" m) X$ c9 b& C1 q
  48. . S: b; G* d8 N9 X0 X
  49. #define IS_DMA_GET_IT(IT) (((IT) == DMA_IT_TCIF0) || ((IT) == DMA_IT_HTIF0)  || \8 k2 A# Q6 @% c2 Q: o5 f
  50.                            ((IT) == DMA_IT_TEIF0) || ((IT) == DMA_IT_DMEIF0) || \
    # b1 G/ Y! ]2 |! i
  51.                            ((IT) == DMA_IT_FEIF0) || ((IT) == DMA_IT_TCIF1)  || \
    : a7 g0 ^$ ]) P
  52.                            ((IT) == DMA_IT_HTIF1) || ((IT) == DMA_IT_TEIF1)  || \+ m0 I" u& [  D8 L$ g
  53.                            ((IT) == DMA_IT_DMEIF1)|| ((IT) == DMA_IT_FEIF1)  || \
    ) A( ^$ Z3 J) T6 v+ `( l5 e
  54.                            ((IT) == DMA_IT_TCIF2) || ((IT) == DMA_IT_HTIF2)  || \
    ; a% @& h  d. w- b! P1 F/ t7 W4 x
  55.                            ((IT) == DMA_IT_TEIF2) || ((IT) == DMA_IT_DMEIF2) || \2 }6 S  u0 R7 j8 l0 X6 P' x& ^
  56.                            ((IT) == DMA_IT_FEIF2) || ((IT) == DMA_IT_TCIF3)  || \/ n4 B5 u0 c& j* w8 h
  57.                            ((IT) == DMA_IT_HTIF3) || ((IT) == DMA_IT_TEIF3)  || \
    5 ?' }5 w; i0 K7 v  Y+ e) h/ S
  58.                            ((IT) == DMA_IT_DMEIF3)|| ((IT) == DMA_IT_FEIF3)  || \* C) j/ f4 z$ L. F# ~3 x6 U
  59.                            ((IT) == DMA_IT_TCIF4) || ((IT) == DMA_IT_HTIF4)  || \8 |0 [# V5 q2 X4 p
  60.                            ((IT) == DMA_IT_TEIF4) || ((IT) == DMA_IT_DMEIF4) || \
    " }. F1 m( O9 L( g. K$ ~
  61.                            ((IT) == DMA_IT_FEIF4) || ((IT) == DMA_IT_TCIF5)  || \
    1 K# n# D4 @, p5 R
  62.                            ((IT) == DMA_IT_HTIF5) || ((IT) == DMA_IT_TEIF5)  || \
    # v2 z) U, ]( i5 e, S4 B
  63.                            ((IT) == DMA_IT_DMEIF5)|| ((IT) == DMA_IT_FEIF5)  || \! n' F, A7 T$ o' b
  64.                            ((IT) == DMA_IT_TCIF6) || ((IT) == DMA_IT_HTIF6)  || \
    , o" o5 r( Q9 m5 H, @- Q, b# K% }
  65.                            ((IT) == DMA_IT_TEIF6) || ((IT) == DMA_IT_DMEIF6) || \
    5 I6 f& H( [5 X' z' t
  66.                            ((IT) == DMA_IT_FEIF6) || ((IT) == DMA_IT_TCIF7)  || \
    / o7 N- ]- M4 k" O7 p/ u' }2 Z
  67.                            ((IT) == DMA_IT_HTIF7) || ((IT) == DMA_IT_TEIF7)  || \
    9 @! B- a8 Q& H9 r' J  \* Z
  68.                            ((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
  1. /** @defgroup DMA_peripheral_increment_offset
    0 v" @+ L! h! O3 t, v: K+ i
  2.   * @{
    3 D( k% N/ G% Q1 C. p5 X/ a
  3.   */ ) r& l% v" A6 A
  4. #define DMA_PINCOS_Psize                  ((uint32_t)0x00000000)6 h5 f8 i- \4 _; ?( h4 X& n) A8 C; w
  5. #define DMA_PINCOS_WordAligned            ((uint32_t)0x00008000)3 V3 f$ p: O/ B& \8 A  K6 q

  6. / S' |1 l4 L6 h
  7. #define IS_DMA_PINCOS_SIZE(SIZE) (((SIZE) == DMA_PINCOS_Psize) || \
    : ?& s6 a8 W5 Y4 |) n2 G
  8.                                   ((SIZE) == DMA_PINCOS_WordAligned))
复制代码

! s8 R1 ~$ s, E# ~1 b- e8 icontroller_definitions
  1. /** @defgroup DMA_flow_controller_definitions
    ( E* [0 h' B* {0 E) Z
  2.   * @{+ f# X1 |0 p9 n7 k9 r" v7 x0 j
  3.   */
    $ m0 z, R+ r8 l- a% n% ~1 O+ W9 ?
  4. #define DMA_FlowCtrl_Memory               ((uint32_t)0x00000000)
    / a/ x5 N% N3 R! ]( y
  5. #define DMA_FlowCtrl_Peripheral           ((uint32_t)0x00000020)1 H& z6 z( R, Y

  6. 9 s; X" |7 d6 P; c$ f& T6 Q
  7. #define IS_DMA_FLOW_CTRL(CTRL) (((CTRL) == DMA_FlowCtrl_Memory) || \
    * n7 E+ ?' T2 S3 Y
  8.                                 ((CTRL) == DMA_FlowCtrl_Peripheral))
复制代码

5 i" Y; K- @% YDMA_memory_targets_definitions
+ Q% T2 K1 _& ?  n

- x7 ?6 R8 s- ^7 {  X
  1. /** @defgroup DMA_memory_targets_definitions
    8 j7 Y$ l$ s+ F' r, _. `9 [" o
  2.   * @{% @4 K# E9 B8 D( l: m4 \
  3.   */ / y; B! ]0 d+ `* @; w; @
  4. #define DMA_Memory_0                      ((uint32_t)0x00000000)
    9 @; j7 C7 Y6 B; l
  5. #define DMA_Memory_1                      ((uint32_t)0x00080000)
    4 r. b; l/ f+ N& Y, M

  6. # |/ ^, l4 I- }4 k, D
  7. #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
  1. /* Exported macro ------------------------------------------------------------*/' {6 K- A; u$ E( s4 X& Q0 @
  2. /* Exported functions --------------------------------------------------------*/ , Y) S* W$ D0 W& q
  3. 5 X5 h+ K9 v1 r5 X) }: |- B$ f1 T
  4. /*  Function used to set the DMA configuration to the default reset state *****/
    6 j3 {6 A0 \" S/ T3 i/ U! X
  5. void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx);
    5 v3 d/ @+ y7 r% Q7 E

  6. 6 I  F6 c3 z( L$ A
  7. /* Initialization and Configuration functions *********************************/) U# h: C; x; U1 v" R! R( Q+ u
  8. void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct);9 s% c$ q; b( h' p) ~6 V- k' ?
  9. void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);5 w+ i1 K) ^* T
  10. void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);6 C6 r: A$ y+ ]) G
  11. " X8 x" B6 k' _8 d/ ?: d+ z4 [
  12. /* Optional Configuration functions *******************************************/4 R2 l6 l( X  ]5 }0 L( ]4 g  x" w
  13. void DMA_PeriphIncOffsetSizeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_Pincos);
    * m* S8 {( e0 p- R5 \% l
  14. void DMA_FlowControllerConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FlowCtrl);# f% N: \1 T# i- i: T* S
  15. ( T$ B7 y0 v1 w* O
  16. /* Data Counter functions *****************************************************/
    $ ~6 b! {) R) [, d! k
  17. void DMA_SetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx, uint16_t Counter);
    ; O. u+ |% Q% y4 e" U
  18. uint16_t DMA_GetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx);
    - d, N+ {( k  [$ f" C
  19.   _7 R2 K9 I7 F9 k5 w, \
  20. /* Double Buffer mode functions ***********************************************/
    6 D$ M* w& n" v$ _, [' \* c
  21. void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t Memory1BaseAddr,6 m9 f+ a! g) l7 t$ @
  22.                                 uint32_t DMA_CurrentMemory);' [. @7 a; G; g/ c
  23. void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);
    3 W0 ^# Z( W; n: j9 ^) p3 r) G
  24. void DMA_MemoryTargetConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t MemoryBaseAddr,1 [2 V- A$ @# p6 f& V. j7 E, S7 e
  25.                             uint32_t DMA_MemoryTarget);
    * Y) u  D+ A3 B5 w& h
  26. uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef* DMAy_Streamx);  `6 K& v  `% V
  27. 8 J3 b: y8 R) C6 B) f0 r
  28. /* Interrupts and flags management functions **********************************/
    ' R2 l$ I/ I& F7 O
  29. FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef* DMAy_Streamx);0 b2 m8 D2 O* C6 t2 k" T* H
  30. uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef* DMAy_Streamx);
    5 ?$ v' g6 ^" T; d$ o9 Z) Z9 e6 W
  31. FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);5 c8 W9 H/ o; F8 l
  32. void DMA_ClearFlag(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);
      S: y! Q3 F3 ~  E) s1 j3 c
  33. void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState);
    . Y7 h9 U0 [3 |3 a4 @  F
  34. ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);
    9 G, _, X  T' d$ @, K
  35. void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);
    0 K" G, N. z7 y7 W

  36. " ]: m: G- A6 s1 N, s$ D. N
复制代码

" C. W/ i2 A! P. b04. 结构体封装

7 S" `3 o! N3 M/ h
  1. /** , U" b7 f* E* z- F7 x1 x' t
  2.   * @brief DMA Controller
    / t& A. R% D* ]1 @4 {/ f$ O" \
  3.   */
    + k8 n# V. c# m) }/ i: Q
  4. & p4 X7 J9 k# {% p+ T7 [) f
  5. typedef struct/ u" s- k8 W* o( W
  6. {; ^. h9 s1 U) u- `7 y; D
  7.   __IO uint32_t CR;     /*!< DMA stream x configuration register      */8 `: d, b+ d  M+ H  [# q
  8.   __IO uint32_t NDTR;   /*!< DMA stream x number of data register     */
    * _6 R. \" p4 {& E* u0 }: N7 _0 i
  9.   __IO uint32_t PAR;    /*!< DMA stream x peripheral address register *// h7 {% P) O% }1 T  c
  10.   __IO uint32_t M0AR;   /*!< DMA stream x memory 0 address register   */
      `/ d1 ~8 K4 Y& _
  11.   __IO uint32_t M1AR;   /*!< DMA stream x memory 1 address register   */& G$ ?( |" l. b+ R( j; a! v6 U  H
  12.   __IO uint32_t FCR;    /*!< DMA stream x FIFO control register       */
    ' A5 K' i5 O. D$ a
  13. } DMA_Stream_TypeDef;
    ; l9 X, {- [" u0 P. E8 ?# L+ a5 y  B
  14. ) ]& k  \; o6 T' `0 e- e. K
  15. typedef struct
    % {& q  W6 J2 o+ b
  16. {. r. ~: s$ o* d# v% m
  17.   __IO uint32_t LISR;   /*!< DMA low interrupt status register,      Address offset: 0x00 */
    , a+ H8 _/ E: u4 z( L7 T. f3 D
  18.   __IO uint32_t HISR;   /*!< DMA high interrupt status register,     Address offset: 0x04 */4 G, m0 c( Y& g; ~3 S% M2 h
  19.   __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
  20.   __IO uint32_t HIFCR;  /*!< DMA high interrupt flag clear register, Address offset: 0x0C */8 w8 j$ h( u+ Z4 O# w7 C9 x
  21. } 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
收藏 评论0 发布时间:2022-3-28 22:00

举报

0个回答

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版