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

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

[复制链接]
STMCU小助手 发布时间:2022-3-28 22:00
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
  1. /** , A1 J; @: y& s# S
  2.   * @brief  DMA Init structure definition' Z5 |2 D, {: U/ ]" D9 r
  3.   */
    4 |3 i2 N8 ?' f* [3 r
  4. 2 m1 s; A; |- O' E, g& F
  5. typedef struct# V$ @) w" D- J5 e! [1 f
  6. {
    ( e4 D5 S$ S% e" `) q1 L* W
  7.   uint32_t DMA_Channel;            /*!< Specifies the channel used for the specified stream.
    ; V7 M7 y( e% h: e' |( }
  8.                                         This parameter can be a value of @ref DMA_channel */+ ^8 ?- r" F& q- W% U# a

  9. ; }; e9 ?5 q# \
  10.   uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Streamx. */
    . d& k1 S7 Z1 j
  11. " r& g# T! j$ k& S% a8 ~+ n7 ]
  12.   uint32_t DMA_Memory0BaseAddr;    /*!< Specifies the memory 0 base address for DMAy Streamx. + @/ _0 }+ v. d1 V$ b* b
  13.                                         This memory is the default memory used when double buffer mode is
    + P2 a, `6 k, I. f# ~5 u5 h! y
  14.                                         not enabled. */
    4 K8 w+ j) W6 I
  15. ; j2 V! R) m+ v0 |8 Y7 e0 D6 q5 _
  16.   uint32_t DMA_DIR;                /*!< Specifies if the data will be transferred from memory to peripheral, ; v: M: u2 c+ A
  17.                                         from memory to memory or from peripheral to memory.% B8 k/ k$ _4 _! h/ V9 t
  18.                                         This parameter can be a value of @ref DMA_data_transfer_direction */
    ) z$ _& `. q0 p2 @* S/ P5 f
  19. 5 w; `0 D6 Y( V( y4 l
  20.   uint32_t DMA_BufferSize;         /*!< Specifies the buffer size, in data unit, of the specified Stream. % v' J9 n. |% _3 m8 q# @. P
  21.                                         The data unit is equal to the configuration set in DMA_PeripheralDataSize
    2 O1 s5 j1 ]: V4 P+ B9 H
  22.                                         or DMA_MemoryDataSize members depending in the transfer direction. */
    2 }' _: f2 @4 i6 e. e# D

  23. - K0 ^5 B- P7 V( p& o3 `
  24.   uint32_t DMA_PeripheralInc;      /*!< Specifies whether the Peripheral address register should be incremented or not.
    4 T5 {& P) V* z$ O' c4 F6 E
  25.                                         This parameter can be a value of @ref DMA_peripheral_incremented_mode */
    ; G7 d* H. ~6 N: R

  26. ! S8 V) ~$ I% S' Q1 y! p
  27.   uint32_t DMA_MemoryInc;          /*!< Specifies whether the memory address register should be incremented or not.( k, ]) C, r( z! P+ [
  28.                                         This parameter can be a value of @ref DMA_memory_incremented_mode */0 q% x: c) R- a8 [/ g

  29. 8 L9 \" v: N! ~" M! Q, ^
  30.   uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.7 j2 `0 a6 C. ~) V5 V& S% H6 K1 A
  31.                                         This parameter can be a value of @ref DMA_peripheral_data_size */  ^( G- P$ ~$ W. A- k/ x
  32. & M9 [6 B8 I3 z" R2 `1 U  d- y- E
  33.   uint32_t DMA_MemoryDataSize;     /*!< Specifies the Memory data width.
    3 K7 y9 k. ^1 V! P1 \: [% k
  34.                                         This parameter can be a value of @ref DMA_memory_data_size */, X; ?* M: F0 r

  35. ' [. `3 P$ q; H  K+ u
  36.   uint32_t DMA_Mode;               /*!< Specifies the operation mode of the DMAy Streamx.
    ! t7 G3 t8 l! n% q0 P
  37.                                         This parameter can be a value of @ref DMA_circular_normal_mode
    0 B9 r9 |; ^" {7 g
  38.                                         @note The circular buffer mode cannot be used if the memory-to-memory8 g/ ~2 D8 X' Z) P) l! q/ s7 [
  39.                                               data transfer is configured on the selected Stream */
    + G1 V. f4 \- w; {3 c+ J5 F

  40. % L+ x% z% e1 g( p+ w6 m1 M5 @- x
  41.   uint32_t DMA_Priority;           /*!< Specifies the software priority for the DMAy Streamx.( g4 ]: j" I, @/ [* _. {, @
  42.                                         This parameter can be a value of @ref DMA_priority_level */; x4 C; B' b* @9 D  Y4 J
  43. 7 U) R, Z; I" u+ ~1 h& P6 ?
  44.   uint32_t DMA_FIFOMode;          /*!< Specifies if the FIFO mode or Direct mode will be used for the specified Stream.2 `7 m2 A; \$ z
  45.                                         This parameter can be a value of @ref DMA_fifo_direct_mode" x5 s/ L) \0 C3 P
  46.                                         @note The Direct mode (FIFO mode disabled) cannot be used if the * m4 q. B+ H) a. [3 ?
  47.                                                memory-to-memory data transfer is configured on the selected Stream */+ s  t, t" @) F% l. q1 H
  48. 9 N. t9 }% i  A; A, \( t8 _# T
  49.   uint32_t DMA_FIFOThreshold;      /*!< Specifies the FIFO threshold level.8 g- ~" h, P% `+ a  I9 n( ~
  50.                                         This parameter can be a value of @ref DMA_fifo_threshold_level */
    0 L  K' `; F0 L4 E$ h* t

  51. % L& {# N2 ], d
  52.   uint32_t DMA_MemoryBurst;        /*!< Specifies the Burst transfer configuration for the memory transfers.
    : w, Y5 s% J6 E* o" t
  53.                                         It specifies the amount of data to be transferred in a single non interruptable
    % d2 U- s0 ?" Y# `" ]& \2 o0 B
  54.                                         transaction. This parameter can be a value of @ref DMA_memory_burst
    ; \( H9 ^1 F7 i5 }% B
  55.                                         @note The burst mode is possible only if the address Increment mode is enabled. */
    ; y1 S4 m! W* I* j2 U, F* i: q

  56. ' h7 S& [' n; ~: i0 ]8 k+ ^
  57.   uint32_t DMA_PeripheralBurst;    /*!< Specifies the Burst transfer configuration for the peripheral transfers. 4 Z+ e/ @0 j7 }- ]# h
  58.                                         It specifies the amount of data to be transferred in a single non interruptable
    # j) n" ^0 [% |) }; @9 y( J
  59.                                         transaction. This parameter can be a value of @ref DMA_peripheral_burst
    - n7 u; a- b" D. D/ Y
  60.                                         @note The burst mode is possible only if the address Increment mode is enabled. */  3 W+ J8 Y; B5 T; ?
  61. }DMA_InitTypeDef;
复制代码

  c9 t8 E7 `4 D7 _DMA_Exported_Constants0 m) v6 ?- x' N
. q" W5 H/ V2 e
  1. ** @defgroup DMA_Exported_Constants, P" O9 z) [$ `3 ]
  2.   * @{
    7 t( B2 A; k' o2 k- U8 ?. M
  3.   */' A: I3 }! T, X! ]
  4. : _$ F- |1 K$ k: Y* I
  5. #define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Stream0) || \
    . ~& m1 |3 L' ]) J* B
  6.                                    ((PERIPH) == DMA1_Stream1) || \' o& i8 I8 j8 u9 t: k( s
  7.                                    ((PERIPH) == DMA1_Stream2) || \, C6 B0 Z8 I. n9 y0 i7 |
  8.                                    ((PERIPH) == DMA1_Stream3) || \5 V" g; K4 l4 {  i( f
  9.                                    ((PERIPH) == DMA1_Stream4) || \
    9 p8 z4 j! H* O  F; H
  10.                                    ((PERIPH) == DMA1_Stream5) || \' u" i; e! k5 R2 ~; R- j- e+ o
  11.                                    ((PERIPH) == DMA1_Stream6) || \  C. [( Y  o8 T4 `# _
  12.                                    ((PERIPH) == DMA1_Stream7) || \
    7 m- i- S. ?9 B7 j# o  x7 I
  13.                                    ((PERIPH) == DMA2_Stream0) || \
    : \) ^% D$ O' |  U/ h( o
  14.                                    ((PERIPH) == DMA2_Stream1) || \
    1 Z9 D0 w; B. A) H: t
  15.                                    ((PERIPH) == DMA2_Stream2) || \8 e9 [4 A% A& J
  16.                                    ((PERIPH) == DMA2_Stream3) || \2 k4 d. R9 ]! y# X! @' r
  17.                                    ((PERIPH) == DMA2_Stream4) || \
    ) y/ D7 Q8 n4 K2 N& F% s
  18.                                    ((PERIPH) == DMA2_Stream5) || \
    2 H/ I9 [  P, n& W0 e# s8 N+ i
  19.                                    ((PERIPH) == DMA2_Stream6) || \
    * }- l& o+ ~+ y! v
  20.                                    ((PERIPH) == DMA2_Stream7))
    . t3 j5 q$ b* \

  21. $ k: b* L0 ~9 D0 p
  22. #define IS_DMA_ALL_CONTROLLER(CONTROLLER) (((CONTROLLER) == DMA1) || \& v9 U* f# W6 c# A
  23.                                            ((CONTROLLER) == DMA2))
复制代码
, {/ {& l6 t6 x' m* ~% f; x
DMA_channel
0 z1 h  x  l0 ?( u
5 Q# y) `! U  i- I3 Y
  1. /** @defgroup DMA_channel
    ) O7 ?3 u( i" o! P" n7 o$ V
  2.   * @{
    ' E4 S% ^$ s& }* F" W: N! i1 }
  3.   */ ; O* v% z' q/ `; w# k7 ~6 d2 }
  4. #define DMA_Channel_0                     ((uint32_t)0x00000000)- |6 \  ~( F8 Q6 ?
  5. #define DMA_Channel_1                     ((uint32_t)0x02000000)
    8 ~" i( S# A) O- h8 J3 \9 P
  6. #define DMA_Channel_2                     ((uint32_t)0x04000000)
    ! z+ _! D: J! O
  7. #define DMA_Channel_3                     ((uint32_t)0x06000000)
    / d  P; F* i1 Y! z
  8. #define DMA_Channel_4                     ((uint32_t)0x08000000)  W! W7 i! l5 @
  9. #define DMA_Channel_5                     ((uint32_t)0x0A000000)1 g9 K& @- @* L% E! p3 v: s
  10. #define DMA_Channel_6                     ((uint32_t)0x0C000000): z: H6 c' D+ o2 {% F' [, I
  11. #define DMA_Channel_7                     ((uint32_t)0x0E000000)
      c5 n) m: |  F8 B+ R
  12. . k8 R3 N( W. [: n2 p) Z6 H
  13. #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_Channel_0) || \8 _- r7 @( y5 I  r1 q! ^3 z) j5 U, e6 w
  14.                                  ((CHANNEL) == DMA_Channel_1) || \
    7 b" t& A4 L2 g4 u. O! Y) y
  15.                                  ((CHANNEL) == DMA_Channel_2) || \
    2 @. S: g+ K" {! F- ^* a' u
  16.                                  ((CHANNEL) == DMA_Channel_3) || \9 N4 b( r1 r+ m; J& X( ~3 u
  17.                                  ((CHANNEL) == DMA_Channel_4) || \
    ( E% p- ]9 E+ W, U
  18.                                  ((CHANNEL) == DMA_Channel_5) || \& |8 ?6 f! z* L6 u& M
  19.                                  ((CHANNEL) == DMA_Channel_6) || \& W% b; Z6 m8 }1 _: R  k: a$ I, p
  20.                                  ((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. @
  1. /** @defgroup DMA_data_transfer_direction
    6 u5 ~2 X( L6 S7 G
  2.   * @{
      C" l# o7 T1 O: J& d# r7 J% J- m
  3.   */ 0 F3 Q* u' ~8 X' c7 r  E
  4. #define DMA_DIR_PeripheralToMemory        ((uint32_t)0x00000000)" c1 ^, Q' r* c, h
  5. #define DMA_DIR_MemoryToPeripheral        ((uint32_t)0x00000040)
    - [7 k/ |5 x& m
  6. #define DMA_DIR_MemoryToMemory            ((uint32_t)0x00000080)6 p/ d4 M& c8 o/ }6 E  J
  7. ! E$ s$ d: C: c- Z' \3 f: M6 _2 W7 ?
  8. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_DIR_PeripheralToMemory ) || \
    ) k- w; }) d! W
  9.                                      ((DIRECTION) == DMA_DIR_MemoryToPeripheral)  || \: h2 K  n8 S, `5 K* _7 A2 j
  10.                                      ((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
  1. /** @defgroup DMA_data_buffer_size
    9 p7 |. H' i4 Z& Y, z  a
  2.   * @{7 r% o/ j- d5 C3 N+ v# K0 D- |  l
  3.   */
    7 m" Q. d9 Y/ \( I% ~% u0 W0 F; D
  4. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
    . A7 L" F# l! G3 ~
  5. 1
    5 j* ^; ^3 D& j7 X3 @
  6. 2, f( B0 J  r) w( K$ h
  7. 3& {% z) ]4 x* M5 j0 F& j9 Y; e4 q
  8. 4
    ) n# ~' \. Y. g) Z4 m
  9. DMA_peripheral_incremented_mode
    ' ^% e6 ^- r5 f9 v  q6 a0 l# d6 M

  10.   _: E0 N, R0 X" r$ h8 M0 o/ A5 i
  11. /** @defgroup DMA_peripheral_incremented_mode ' a  b% E# H1 d6 \
  12.   * @{4 }# r) M" J! S# a2 X' M
  13.   */
    / F& u" J9 J4 F1 l8 \
  14. #define DMA_PeripheralInc_Enable          ((uint32_t)0x00000200), z( z1 x2 U: f& s/ ~
  15. #define DMA_PeripheralInc_Disable         ((uint32_t)0x00000000)
    9 b% `# |9 x8 L' j2 k) q
  16. 1 `, m+ ?' U; J. J) m- [
  17. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \
    2 v* M+ O, F5 W
  18.                                             ((STATE) == DMA_PeripheralInc_Disable))
复制代码
, s, `& B3 W' \6 E7 p# E
DMA_memory_incremented_mode
  1. /** @defgroup DMA_memory_incremented_mode 5 p8 d/ \! B  c/ k! _
  2.   * @{7 G- k* K0 {4 N1 b  d2 q% Q" x- X
  3.   */ & X/ K. I# \$ Z5 T. O3 O
  4. #define DMA_MemoryInc_Enable              ((uint32_t)0x00000400). x2 D. j& S4 s* u- N
  5. #define DMA_MemoryInc_Disable             ((uint32_t)0x00000000)
    3 d; {& ?7 l/ P: n' z/ f! c6 v/ A

  6. + i1 k5 x; `" D
  7. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \% s3 M' H8 e, o" w
  8.                                         ((STATE) == DMA_MemoryInc_Disable))
复制代码

& z) C# L& f* x* m8 dDMA_peripheral_data_size
8 ?4 l+ z1 {, S; t
  1. /** @defgroup DMA_peripheral_data_size
    ) Q( d; c- z  a
  2.   * @{- }3 I* ?/ ^6 M, b. m: c$ F
  3.   */
    8 n7 r! W8 X9 s* K# B* @
  4. #define DMA_PeripheralDataSize_Byte       ((uint32_t)0x00000000) , B+ P  d( q4 F# `
  5. #define DMA_PeripheralDataSize_HalfWord   ((uint32_t)0x00000800)
    , q' h8 ^) w; i3 N  e
  6. #define DMA_PeripheralDataSize_Word       ((uint32_t)0x00001000). z8 P2 X. Z+ F7 ?: Z* p9 ~
  7. / j7 J+ d' [/ n6 M; C" k
  8. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte)  || \
    - Q3 X4 H. p  Z! t
  9.                                            ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \8 T1 g) r  \+ ~2 U0 f' e
  10.                                            ((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
  1. /** @defgroup DMA_memory_data_size 7 z1 N  _# ^# S; \% @
  2.   * @{
    * e  I- z& `: z# H! l. t
  3.   */ + ^/ q' i$ ?% ^0 F  {- U6 }
  4. #define DMA_MemoryDataSize_Byte           ((uint32_t)0x00000000)
    ' w. y/ P/ H  W. F
  5. #define DMA_MemoryDataSize_HalfWord       ((uint32_t)0x00002000) ! w* ?% |" N) r2 L1 Q6 i
  6. #define DMA_MemoryDataSize_Word           ((uint32_t)0x00004000)! ~% s- S: w( L3 I. P
  7. / J' n5 g% B/ i' M
  8. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte)  || \
    1 W, Y2 |* @7 u! J3 }# k2 `; Q
  9.                                        ((SIZE) == DMA_MemoryDataSize_HalfWord) || \
    / I# Q. ~% v5 M) ?
  10.                                        ((SIZE) == DMA_MemoryDataSize_Word ))
复制代码

" m9 Q& M- H0 y4 q8 p9 B! LDMA_circular_normal_mode0 Z4 I% _% {* b) w
  1. % O9 L- E7 V  h* y6 c6 t  }
  2. /** @defgroup DMA_circular_normal_mode 8 J/ w# a; U+ ~9 D# F; O0 D/ Y
  3.   * @{( U' q. c/ f6 e# p6 r
  4.   */
    / C# y& _/ _2 t$ ?( X. |9 _6 ?
  5. #define DMA_Mode_Normal                   ((uint32_t)0x00000000) " s# Y- e$ c8 \: V8 f8 y6 T" s
  6. #define DMA_Mode_Circular                 ((uint32_t)0x00000100)
    4 c, D1 M8 Y. w! V# h
  7. + W. s& a: g( S" s) b4 e( z
  8. #define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Normal ) || \
    5 s: V" e. z  l
  9.                            ((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
  1. /** @defgroup DMA_priority_level + A! `: W% O0 q$ k' a4 p7 y
  2.   * @{
    ' [# [4 E4 j# h/ P" d+ t
  3.   */ - M' C; @; T3 l6 K) g1 Q$ p- U
  4. #define DMA_Priority_Low                  ((uint32_t)0x00000000)
    3 [( T6 `/ ]$ [3 I" c0 [4 \
  5. #define DMA_Priority_Medium               ((uint32_t)0x00010000) & U2 ^- A3 \3 x
  6. #define DMA_Priority_High                 ((uint32_t)0x00020000)
    % R3 D* N8 D3 F# Q& V' N
  7. #define DMA_Priority_VeryHigh             ((uint32_t)0x00030000)
    - Z  l3 ^: p( E  ~5 J4 O

  8. % E  R; J# y6 q. \
  9. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_Low )   || \
    8 w' h- Z; _2 e
  10.                                    ((PRIORITY) == DMA_Priority_Medium) || \9 s  u/ h/ _$ d; [
  11.                                    ((PRIORITY) == DMA_Priority_High)   || \$ ?/ H% d- B8 i; T: a
  12.                                    ((PRIORITY) == DMA_Priority_VeryHigh))
复制代码
* E0 {, R0 R0 S+ }+ o) e! u
DMA_fifo_direct_mode
  1. /** @defgroup DMA_fifo_direct_mode ' }: H! S+ s2 ~' i) K. y
  2.   * @{
    # Q) x  Z; t+ M* g" Y# o
  3.   */
    . }! \# b$ Z" {/ R$ v9 v1 P" X
  4. #define DMA_FIFOMode_Disable              ((uint32_t)0x00000000) 2 w8 N/ r/ w2 D
  5. #define DMA_FIFOMode_Enable               ((uint32_t)0x00000004)' t  r2 F, _  \; g; @7 F9 i
  6. ; p/ I1 j5 W( Q$ e4 o
  7. #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMode_Disable ) || \
    & u& c6 a5 @( v0 U% `1 r
  8.                                        ((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
  1. /** @defgroup DMA_fifo_threshold_level
    $ k) E+ ^% H3 G$ V1 B+ b* S
  2.   * @{
    ) N  p" @; g! p! ^1 _
  3.   */
    1 s9 q. _) ~( R) `  \
  4. #define DMA_FIFOThreshold_1QuarterFull    ((uint32_t)0x00000000): @) S9 s/ m) t  K# ~2 O
  5. #define DMA_FIFOThreshold_HalfFull        ((uint32_t)0x00000001)
    3 u! U. G2 J" ?$ d$ B6 X
  6. #define DMA_FIFOThreshold_3QuartersFull   ((uint32_t)0x00000002)0 @) M4 |5 l0 {/ X" x
  7. #define DMA_FIFOThreshold_Full            ((uint32_t)0x00000003)6 N5 c. j$ y# F
  8. 9 H/ G, D+ ?3 L; ~" \
  9. #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFOThreshold_1QuarterFull ) || \
    ' R& P- U1 B0 g- t! r5 V1 p
  10.                                           ((THRESHOLD) == DMA_FIFOThreshold_HalfFull)      || \; Z) d8 \# K8 U9 G9 i1 ~  B
  11.                                           ((THRESHOLD) == DMA_FIFOThreshold_3QuartersFull) || \2 \+ x, U  P: `& c1 C, p
  12.                                           ((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
  1. /** @defgroup DMA_memory_burst 8 h; n2 e8 P1 \4 e+ B. L
  2.   * @{# a+ z2 I! g+ e* B. S4 I
  3.   */ ) h6 V: S! S% w5 |
  4. #define DMA_MemoryBurst_Single            ((uint32_t)0x00000000), z4 B( b* x" q# J7 E/ T, `
  5. #define DMA_MemoryBurst_INC4              ((uint32_t)0x00800000)  $ n$ ?0 v! i0 L
  6. #define DMA_MemoryBurst_INC8              ((uint32_t)0x01000000)1 ]# t4 c8 q& P% \+ Z( w
  7. #define DMA_MemoryBurst_INC16             ((uint32_t)0x01800000)
    % ^* r6 Z& B7 O# L+ [/ C# Q+ |
  8. " [0 y$ l/ O6 a) d5 h
  9. #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MemoryBurst_Single) || \9 p2 h# y/ G8 n8 ~9 ]5 o: g2 M
  10.                                     ((BURST) == DMA_MemoryBurst_INC4)  || \
    3 T; `6 u$ ~+ B) t4 b. J  [: D
  11.                                     ((BURST) == DMA_MemoryBurst_INC8)  || \
    - ^( t7 t7 r, {
  12.                                     ((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
  1. /** @defgroup DMA_peripheral_burst 1 I) p. r( s" L# g
  2.   * @{  ?% A6 q& O6 L
  3.   */
    ' m5 Y8 @4 @7 d; C
  4. #define DMA_PeripheralBurst_Single        ((uint32_t)0x00000000)) O/ v7 _2 B5 i8 h  W% a
  5. #define DMA_PeripheralBurst_INC4          ((uint32_t)0x00200000)  
    1 m+ {% T+ g5 ~7 H' P  ?
  6. #define DMA_PeripheralBurst_INC8          ((uint32_t)0x00400000)
    " L8 h- O8 o1 [  y
  7. #define DMA_PeripheralBurst_INC16         ((uint32_t)0x00600000)
    / J1 \' e5 R+ k
  8. $ B0 p9 h0 f# r) c/ k' ^3 c( h
  9. #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PeripheralBurst_Single) || \: K# U$ E  K$ m- q
  10.                                         ((BURST) == DMA_PeripheralBurst_INC4)  || \
    / _: `- c  l" w3 f
  11.                                         ((BURST) == DMA_PeripheralBurst_INC8)  || \# _  |( Y" ]5 n" H2 x$ Y
  12.                                         ((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
  1. /** @defgroup DMA_fifo_status_level
    6 y( p7 {5 t/ l) m, L& k' e
  2.   * @{
    ' L4 d- k5 ~3 V
  3.   */
    . ^" C6 K7 D$ R& F5 S
  4. #define DMA_FIFOStatus_Less1QuarterFull   ((uint32_t)0x00000000 << 3)' Z4 [* j4 u2 c
  5. #define DMA_FIFOStatus_1QuarterFull       ((uint32_t)0x00000001 << 3)7 {3 Z7 V% a' G2 f& ]/ p) i$ w! o
  6. #define DMA_FIFOStatus_HalfFull           ((uint32_t)0x00000002 << 3) - ]: g: M- P' E0 C+ F. d
  7. #define DMA_FIFOStatus_3QuartersFull      ((uint32_t)0x00000003 << 3)
    8 ^1 i0 ?! |/ z; @9 L( q
  8. #define DMA_FIFOStatus_Empty              ((uint32_t)0x00000004 << 3)
    1 R/ p' i. b+ b7 a1 L, l
  9. #define DMA_FIFOStatus_Full               ((uint32_t)0x00000005 << 3)
    & E$ ?" }+ n! q1 I" e

  10. 8 Z+ s8 t' l2 [; U; L9 p8 \
  11. #define IS_DMA_FIFO_STATUS(STATUS) (((STATUS) == DMA_FIFOStatus_Less1QuarterFull ) || \  ~' S6 d$ B" P, G  a2 A
  12.                                     ((STATUS) == DMA_FIFOStatus_HalfFull)          || \
    % u1 G: C4 i. t" _- E  t- h
  13.                                     ((STATUS) == DMA_FIFOStatus_1QuarterFull)      || \* t  W$ P+ N& {( ^, M
  14.                                     ((STATUS) == DMA_FIFOStatus_3QuartersFull)     || \* ?- q  z; j; u8 U4 _7 i
  15.                                     ((STATUS) == DMA_FIFOStatus_Full)              || \
    & j. A# A3 Y5 Y# I" I: X; ^! J
  16.                                     ((STATUS) == DMA_FIFOStatus_Empty))
复制代码
: m) I: G* Z( Y1 Q
DMA_flags_definition! J" Z/ K- e+ U
, i* S3 c8 |$ l- {
  1. /** @defgroup DMA_flags_definition
    4 ^2 n' F5 a" Q0 d
  2.   * @{
    4 V' t2 J& q4 H( \; v, i2 A6 g
  3.   */+ Y; ?) c2 j" U  m7 u' q& W- R
  4. #define DMA_FLAG_FEIF0                    ((uint32_t)0x10800001)
    " \7 v: ?* S6 S6 y# M) g- x7 C$ @; w. I
  5. #define DMA_FLAG_DMEIF0                   ((uint32_t)0x10800004)
    % |* W5 d7 d4 k0 J4 i  r
  6. #define DMA_FLAG_TEIF0                    ((uint32_t)0x10000008)# U8 a0 ?1 h4 K8 b1 O
  7. #define DMA_FLAG_HTIF0                    ((uint32_t)0x10000010): Z) `$ r# x: n* k; c- j
  8. #define DMA_FLAG_TCIF0                    ((uint32_t)0x10000020)
    ) y8 U9 J  @7 M9 a
  9. #define DMA_FLAG_FEIF1                    ((uint32_t)0x10000040)( m( H, j  l/ X. V, w/ I$ i# H
  10. #define DMA_FLAG_DMEIF1                   ((uint32_t)0x10000100)- K; u; t. R7 S, a
  11. #define DMA_FLAG_TEIF1                    ((uint32_t)0x10000200)5 i. I8 z4 X, Q
  12. #define DMA_FLAG_HTIF1                    ((uint32_t)0x10000400)) H6 l( J, e7 n
  13. #define DMA_FLAG_TCIF1                    ((uint32_t)0x10000800): J/ M- c$ s7 o3 J; I% G# L
  14. #define DMA_FLAG_FEIF2                    ((uint32_t)0x10010000)
    ) j4 H3 X- Q. j
  15. #define DMA_FLAG_DMEIF2                   ((uint32_t)0x10040000)
    8 k" ?  N$ y! V
  16. #define DMA_FLAG_TEIF2                    ((uint32_t)0x10080000)
    # Z* R* }* R$ n2 \3 t: @# H3 ^
  17. #define DMA_FLAG_HTIF2                    ((uint32_t)0x10100000)
    + I/ V2 `. G+ g, [: s
  18. #define DMA_FLAG_TCIF2                    ((uint32_t)0x10200000)' G# L% _7 C/ F  P% T
  19. #define DMA_FLAG_FEIF3                    ((uint32_t)0x10400000)& ]: J' f: J* l2 J" b
  20. #define DMA_FLAG_DMEIF3                   ((uint32_t)0x11000000)
    5 D, C  X# a5 S2 \  v
  21. #define DMA_FLAG_TEIF3                    ((uint32_t)0x12000000): R  n' k) N! T$ L- Y! g" U6 y
  22. #define DMA_FLAG_HTIF3                    ((uint32_t)0x14000000)% W6 E5 m' I* a0 n- T  G
  23. #define DMA_FLAG_TCIF3                    ((uint32_t)0x18000000)
    " W7 n- F0 w8 x- Q% K5 p$ F/ R
  24. #define DMA_FLAG_FEIF4                    ((uint32_t)0x20000001)3 h6 t- a$ l; V7 h5 y
  25. #define DMA_FLAG_DMEIF4                   ((uint32_t)0x20000004); w+ k; C0 m- f3 o0 m$ W9 @
  26. #define DMA_FLAG_TEIF4                    ((uint32_t)0x20000008)
    , Z6 e& p0 ?' O" R5 w5 V- }
  27. #define DMA_FLAG_HTIF4                    ((uint32_t)0x20000010)5 W; X( [( e) G+ Y6 g
  28. #define DMA_FLAG_TCIF4                    ((uint32_t)0x20000020)
    5 e& s* c5 [% R, B1 B7 B1 j
  29. #define DMA_FLAG_FEIF5                    ((uint32_t)0x20000040)
    ; S  k* B, W+ W& t( C* i
  30. #define DMA_FLAG_DMEIF5                   ((uint32_t)0x20000100)
    % _" e7 b8 Q5 h; S  u
  31. #define DMA_FLAG_TEIF5                    ((uint32_t)0x20000200)& m  a7 o9 B1 p6 ^. n. ~- {. H
  32. #define DMA_FLAG_HTIF5                    ((uint32_t)0x20000400)
    * X' i7 L# S& u5 p# L% G3 T* S
  33. #define DMA_FLAG_TCIF5                    ((uint32_t)0x20000800)) o$ ?/ [8 T5 w* i& R
  34. #define DMA_FLAG_FEIF6                    ((uint32_t)0x20010000)% P) b  g. V8 N  K& d8 ?: ^3 p
  35. #define DMA_FLAG_DMEIF6                   ((uint32_t)0x20040000)8 N" W8 P7 Y$ [# Y  p9 B- j1 d
  36. #define DMA_FLAG_TEIF6                    ((uint32_t)0x20080000)" h* p# q# D6 g! y9 S/ ?
  37. #define DMA_FLAG_HTIF6                    ((uint32_t)0x20100000)% ]% K4 z; Y. H* C7 B  M
  38. #define DMA_FLAG_TCIF6                    ((uint32_t)0x20200000)# o, K  U4 d5 I3 Z" s) M8 }% a
  39. #define DMA_FLAG_FEIF7                    ((uint32_t)0x20400000)
    8 P( O; o3 i/ T" r( E
  40. #define DMA_FLAG_DMEIF7                   ((uint32_t)0x21000000)
    : s0 V' k# D: W+ _2 @) t) h
  41. #define DMA_FLAG_TEIF7                    ((uint32_t)0x22000000)
    ) Y& Y7 K: ]- {6 B) z
  42. #define DMA_FLAG_HTIF7                    ((uint32_t)0x24000000)# _$ r9 u# _" I) F5 ?, G" N
  43. #define DMA_FLAG_TCIF7                    ((uint32_t)0x28000000)
    - b! V( n* h# A, g4 c4 a6 }7 X

  44. - h4 P- ^* X. ]3 q. G$ X
  45. #define IS_DMA_CLEAR_FLAG(FLAG) ((((FLAG) & 0x30000000) != 0x30000000) && (((FLAG) & 0x30000000) != 0) && \
    - k4 T* c! P  t  ~' K" {
  46.                                  (((FLAG) & 0xC002F082) == 0x00) && ((FLAG) != 0x00))
    $ j9 B* C+ p- d
  47. 9 T8 H: ]: C" Q0 ^5 z
  48. #define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA_FLAG_TCIF0)  || ((FLAG) == DMA_FLAG_HTIF0)  || \
    ) A2 e+ \8 L. {+ ?
  49.                                ((FLAG) == DMA_FLAG_TEIF0)  || ((FLAG) == DMA_FLAG_DMEIF0) || \4 s+ J9 P9 C* |3 A* F  i: t! e- J& H
  50.                                ((FLAG) == DMA_FLAG_FEIF0)  || ((FLAG) == DMA_FLAG_TCIF1)  || \
    : p7 c, M( }' Y( K
  51.                                ((FLAG) == DMA_FLAG_HTIF1)  || ((FLAG) == DMA_FLAG_TEIF1)  || \5 w4 l6 u; M+ \3 P! l. K" u7 H
  52.                                ((FLAG) == DMA_FLAG_DMEIF1) || ((FLAG) == DMA_FLAG_FEIF1)  || \  G# s8 E) ^; u) n% p' V/ ]
  53.                                ((FLAG) == DMA_FLAG_TCIF2)  || ((FLAG) == DMA_FLAG_HTIF2)  || \
    , V. `! N0 e1 e1 |4 C$ y- N" k4 m8 x
  54.                                ((FLAG) == DMA_FLAG_TEIF2)  || ((FLAG) == DMA_FLAG_DMEIF2) || \5 {5 N2 J4 @$ Z0 `0 P7 u
  55.                                ((FLAG) == DMA_FLAG_FEIF2)  || ((FLAG) == DMA_FLAG_TCIF3)  || \, L# ^% L- V' h5 ~3 Z
  56.                                ((FLAG) == DMA_FLAG_HTIF3)  || ((FLAG) == DMA_FLAG_TEIF3)  || \
    3 b% M  u" i, `- ?1 W/ y
  57.                                ((FLAG) == DMA_FLAG_DMEIF3) || ((FLAG) == DMA_FLAG_FEIF3)  || \1 O, q) h1 ?  e% U$ W6 S
  58.                                ((FLAG) == DMA_FLAG_TCIF4)  || ((FLAG) == DMA_FLAG_HTIF4)  || \1 C5 q8 j. ]3 c% h
  59.                                ((FLAG) == DMA_FLAG_TEIF4)  || ((FLAG) == DMA_FLAG_DMEIF4) || \
    . v0 W7 R3 Y+ f
  60.                                ((FLAG) == DMA_FLAG_FEIF4)  || ((FLAG) == DMA_FLAG_TCIF5)  || \& ]0 d5 N" U9 c3 U7 x
  61.                                ((FLAG) == DMA_FLAG_HTIF5)  || ((FLAG) == DMA_FLAG_TEIF5)  || \
    - i7 G) ]8 G- ?
  62.                                ((FLAG) == DMA_FLAG_DMEIF5) || ((FLAG) == DMA_FLAG_FEIF5)  || \: ^; Y) p+ f% b0 \4 V8 N* O
  63.                                ((FLAG) == DMA_FLAG_TCIF6)  || ((FLAG) == DMA_FLAG_HTIF6)  || \
    4 v5 [' B3 Q7 ^$ w
  64.                                ((FLAG) == DMA_FLAG_TEIF6)  || ((FLAG) == DMA_FLAG_DMEIF6) || \
    , Q* i) z% t) B- b. w8 C
  65.                                ((FLAG) == DMA_FLAG_FEIF6)  || ((FLAG) == DMA_FLAG_TCIF7)  || \. A  I& h$ f' g
  66.                                ((FLAG) == DMA_FLAG_HTIF7)  || ((FLAG) == DMA_FLAG_TEIF7)  || \
    ) G) B: {/ ]5 O! [6 K
  67.                                ((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
  1. /** @defgroup DMA_interrupt_enable_definitions
    4 u) Y7 {! r" F! L
  2.   * @{, f& F: Y! G* O
  3.   */
    : n  H5 ]3 f4 J; Q! R( \5 C
  4. #define DMA_IT_TC                         ((uint32_t)0x00000010)
    : H" F# [6 D" A" m
  5. #define DMA_IT_HT                         ((uint32_t)0x00000008)  j! F& ?4 I) h! e' c
  6. #define DMA_IT_TE                         ((uint32_t)0x00000004)* J  c  \' \" m9 R& y- ?
  7. #define DMA_IT_DME                        ((uint32_t)0x00000002)
    ! e# k: Y- \: Q8 f" p
  8. #define DMA_IT_FE                         ((uint32_t)0x00000080)
    3 d; ]: b. J! ?1 z- J$ M7 B  X4 j

  9. ( @% H% w, N2 [$ a2 U
  10. #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
  1. /** @defgroup DMA_interrupts_definitions
    ( |  c- F2 K5 @; u/ f% c9 m, O
  2.   * @{
    0 e6 E0 \3 E& P- l$ ^
  3.   */ ; _. f( Y) K" G3 ?! B! j1 {
  4. #define DMA_IT_FEIF0                      ((uint32_t)0x90000001)
    ' s  D' j8 \. c2 I3 C
  5. #define DMA_IT_DMEIF0                     ((uint32_t)0x10001004)
    % z5 T% e+ J0 C* C
  6. #define DMA_IT_TEIF0                      ((uint32_t)0x10002008)
    ! x( O. \4 n4 p* S% l+ f) x- t! [' i
  7. #define DMA_IT_HTIF0                      ((uint32_t)0x10004010)
    . }* V/ P8 Z9 ?* ]7 w
  8. #define DMA_IT_TCIF0                      ((uint32_t)0x10008020)
    $ c+ q+ ]. [& l5 Y
  9. #define DMA_IT_FEIF1                      ((uint32_t)0x90000040)
    ) q+ N5 H" ]' O! M6 g
  10. #define DMA_IT_DMEIF1                     ((uint32_t)0x10001100)
    : @# f  g! \4 x: ~  K% b2 r
  11. #define DMA_IT_TEIF1                      ((uint32_t)0x10002200)! x; ]2 ^+ s# p$ }. y
  12. #define DMA_IT_HTIF1                      ((uint32_t)0x10004400)
    8 a& }" o. T' S
  13. #define DMA_IT_TCIF1                      ((uint32_t)0x10008800): {$ A& h2 J* w/ o' ^
  14. #define DMA_IT_FEIF2                      ((uint32_t)0x90010000)
    2 O" M3 d) y/ [
  15. #define DMA_IT_DMEIF2                     ((uint32_t)0x10041000). o, G; }2 |4 G* w
  16. #define DMA_IT_TEIF2                      ((uint32_t)0x10082000)
    ) j* x/ ~  t# J" ~. B
  17. #define DMA_IT_HTIF2                      ((uint32_t)0x10104000)
    6 l7 @; q: b& ~
  18. #define DMA_IT_TCIF2                      ((uint32_t)0x10208000)4 T+ Q0 r$ [% b/ T
  19. #define DMA_IT_FEIF3                      ((uint32_t)0x90400000)
    * z! S" T! L/ i. {6 K
  20. #define DMA_IT_DMEIF3                     ((uint32_t)0x11001000)
    8 P$ y" K2 n0 L4 o) G2 ]( P
  21. #define DMA_IT_TEIF3                      ((uint32_t)0x12002000)
    1 X# K7 `4 a+ }; O4 w9 W
  22. #define DMA_IT_HTIF3                      ((uint32_t)0x14004000)
    6 y) @+ ~1 m: y$ D; \
  23. #define DMA_IT_TCIF3                      ((uint32_t)0x18008000)5 B% m8 D& b  c: R7 g
  24. #define DMA_IT_FEIF4                      ((uint32_t)0xA0000001): m4 t- J3 |9 O5 _
  25. #define DMA_IT_DMEIF4                     ((uint32_t)0x20001004)( O% v! e$ }$ D+ X  I/ m* |1 y8 C
  26. #define DMA_IT_TEIF4                      ((uint32_t)0x20002008)
      y5 c/ F, z# `
  27. #define DMA_IT_HTIF4                      ((uint32_t)0x20004010)
    7 z) V8 H' u" Y: X% O$ n  f) z
  28. #define DMA_IT_TCIF4                      ((uint32_t)0x20008020); Q- G7 j' ^# m, Q  |
  29. #define DMA_IT_FEIF5                      ((uint32_t)0xA0000040). y  v( {3 Q6 G( }: B) R
  30. #define DMA_IT_DMEIF5                     ((uint32_t)0x20001100)
    . x- K' _( M# o) ?
  31. #define DMA_IT_TEIF5                      ((uint32_t)0x20002200): J# z/ q4 \: F/ p3 K
  32. #define DMA_IT_HTIF5                      ((uint32_t)0x20004400)
      I/ M: [( u. s1 F( f4 n. h2 J( m
  33. #define DMA_IT_TCIF5                      ((uint32_t)0x20008800)
    , e; O# @6 a. r' v
  34. #define DMA_IT_FEIF6                      ((uint32_t)0xA0010000)
    7 J+ W4 t" z) M) e, m
  35. #define DMA_IT_DMEIF6                     ((uint32_t)0x20041000)
    ; S6 h+ ]* k/ d- e2 j) ~
  36. #define DMA_IT_TEIF6                      ((uint32_t)0x20082000)
    8 |% \7 ]8 g$ x, n& A8 D8 {' f
  37. #define DMA_IT_HTIF6                      ((uint32_t)0x20104000): _; O6 X9 ?' M/ T! G- [0 W
  38. #define DMA_IT_TCIF6                      ((uint32_t)0x20208000)
    $ o$ n8 K$ I/ s8 r7 D
  39. #define DMA_IT_FEIF7                      ((uint32_t)0xA0400000)/ V8 o) q- b0 D; i( M9 \
  40. #define DMA_IT_DMEIF7                     ((uint32_t)0x21001000)! E* k( c0 M6 @; L
  41. #define DMA_IT_TEIF7                      ((uint32_t)0x22002000)4 e) ~8 R+ Z+ I& p, I( a
  42. #define DMA_IT_HTIF7                      ((uint32_t)0x24004000)! Y- J, g1 d- v/ r& @
  43. #define DMA_IT_TCIF7                      ((uint32_t)0x28008000)
    " _2 m8 l) g$ @$ R# M* t: B6 J- i

  44. 2 {8 _) b+ N: f) a
  45. #define IS_DMA_CLEAR_IT(IT) ((((IT) & 0x30000000) != 0x30000000) && \
    9 C% g. g. d/ q. s+ g# H
  46.                              (((IT) & 0x30000000) != 0) && ((IT) != 0x00) && \/ l+ A+ r; {) K" \% U' `
  47.                              (((IT) & 0x40820082) == 0x00))6 F; q: t6 [8 I
  48.   o( z8 `# ~2 s# f" I
  49. #define IS_DMA_GET_IT(IT) (((IT) == DMA_IT_TCIF0) || ((IT) == DMA_IT_HTIF0)  || \1 e2 Q# ?: _! C. q6 {) ?9 s' T
  50.                            ((IT) == DMA_IT_TEIF0) || ((IT) == DMA_IT_DMEIF0) || \' T9 k# r9 |; k0 T5 ?+ o
  51.                            ((IT) == DMA_IT_FEIF0) || ((IT) == DMA_IT_TCIF1)  || \" @8 H1 K1 u0 k5 P9 ^, n9 S" N
  52.                            ((IT) == DMA_IT_HTIF1) || ((IT) == DMA_IT_TEIF1)  || \" o& V# ]$ K* z
  53.                            ((IT) == DMA_IT_DMEIF1)|| ((IT) == DMA_IT_FEIF1)  || \9 a3 m' f, ^( ~) y
  54.                            ((IT) == DMA_IT_TCIF2) || ((IT) == DMA_IT_HTIF2)  || \
    : D+ ]# r& [, x( h$ @! x; `# k( \7 v! H
  55.                            ((IT) == DMA_IT_TEIF2) || ((IT) == DMA_IT_DMEIF2) || \6 B2 t: c( L" P' q
  56.                            ((IT) == DMA_IT_FEIF2) || ((IT) == DMA_IT_TCIF3)  || \
    " G' S8 D# c9 u
  57.                            ((IT) == DMA_IT_HTIF3) || ((IT) == DMA_IT_TEIF3)  || \
    $ D; z; v7 X; o: J: b4 q" N
  58.                            ((IT) == DMA_IT_DMEIF3)|| ((IT) == DMA_IT_FEIF3)  || \6 ~; h' f: H5 @# j1 r1 Q+ a
  59.                            ((IT) == DMA_IT_TCIF4) || ((IT) == DMA_IT_HTIF4)  || \
    2 {8 r' _) c9 X' U% @4 o, v$ Q
  60.                            ((IT) == DMA_IT_TEIF4) || ((IT) == DMA_IT_DMEIF4) || \
    $ D5 b% R& e# F2 B' b. G
  61.                            ((IT) == DMA_IT_FEIF4) || ((IT) == DMA_IT_TCIF5)  || \
    / D2 P  r2 e- A) s: F; q
  62.                            ((IT) == DMA_IT_HTIF5) || ((IT) == DMA_IT_TEIF5)  || \  }- s* D* {2 x& k2 @4 ~; ~
  63.                            ((IT) == DMA_IT_DMEIF5)|| ((IT) == DMA_IT_FEIF5)  || \
      m, k/ p0 l" Q' T7 l$ r5 h
  64.                            ((IT) == DMA_IT_TCIF6) || ((IT) == DMA_IT_HTIF6)  || \3 A5 Y8 M8 C9 I! M" X
  65.                            ((IT) == DMA_IT_TEIF6) || ((IT) == DMA_IT_DMEIF6) || \& p- }# }1 H7 c% O4 M2 |
  66.                            ((IT) == DMA_IT_FEIF6) || ((IT) == DMA_IT_TCIF7)  || \4 ]* L7 o% ~0 h4 a& L
  67.                            ((IT) == DMA_IT_HTIF7) || ((IT) == DMA_IT_TEIF7)  || \
    % N5 a& E( _% f5 ?
  68.                            ((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
  1. /** @defgroup DMA_peripheral_increment_offset
    . H1 R. u- B/ j% V5 s9 b5 n
  2.   * @{
    ) e+ ^0 V2 g' C0 a1 ^# v  Y) A
  3.   */ ) q' v$ o+ B) r% i
  4. #define DMA_PINCOS_Psize                  ((uint32_t)0x00000000)
    $ k( E+ Y( k! ?+ X7 ?0 Y! g. s5 N3 w& w
  5. #define DMA_PINCOS_WordAligned            ((uint32_t)0x00008000)' L. R4 A7 Q& q# B

  6. ) h6 X/ d& Z* y; L$ ]0 g; ~
  7. #define IS_DMA_PINCOS_SIZE(SIZE) (((SIZE) == DMA_PINCOS_Psize) || \6 R/ j- {6 b$ |* B
  8.                                   ((SIZE) == DMA_PINCOS_WordAligned))
复制代码

" y4 W! y, z& W+ y# g$ h; Zcontroller_definitions
  1. /** @defgroup DMA_flow_controller_definitions
    0 }' F; @. |4 j! t
  2.   * @{
    0 |( t7 W& Y9 X; y3 s; v
  3.   */ $ E0 C* P1 o4 f) x$ }
  4. #define DMA_FlowCtrl_Memory               ((uint32_t)0x00000000)
    ' v8 B4 `: Z9 p4 p% n1 B% O% ~
  5. #define DMA_FlowCtrl_Peripheral           ((uint32_t)0x00000020)
    2 \: Q* W1 |5 v6 W- ]  f

  6. 1 Q4 R/ g7 F5 N3 g% \7 f, W# R
  7. #define IS_DMA_FLOW_CTRL(CTRL) (((CTRL) == DMA_FlowCtrl_Memory) || \; |0 s1 h* H) U( B2 j8 e" V
  8.                                 ((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 {
  1. /** @defgroup DMA_memory_targets_definitions * R7 T- ^2 n- Q8 J+ K
  2.   * @{
    & f- h' ]; `- ^- N0 u( V
  3.   */ 7 R. X9 W) |$ B' G% x' N% d2 v
  4. #define DMA_Memory_0                      ((uint32_t)0x00000000)) Q- ~+ J* {8 W  [. a/ C: x
  5. #define DMA_Memory_1                      ((uint32_t)0x00080000)
    ) U. l0 R9 E- @" u

  6. * V3 a* u! O& l
  7. #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
  1. /* Exported macro ------------------------------------------------------------*/
    * z. o7 d4 a' U6 U
  2. /* Exported functions --------------------------------------------------------*/
    2 F1 _: T1 j( G& \' N3 b+ q( h
  3. ; U/ k) c4 _# I# h2 ]2 D" f. s
  4. /*  Function used to set the DMA configuration to the default reset state *****/
    7 V; E* D, V& g- D
  5. void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx);& k2 [' g3 x- T3 V; A& x3 v0 n
  6. ! g! }$ Z( r; b4 Q, x
  7. /* Initialization and Configuration functions *********************************/
    ( ^( u7 s& `9 ?; Y5 W* _- \
  8. void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct);" |0 d; T. M$ s* l  r
  9. void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);4 u9 x( w; s: h7 S5 M: i/ f
  10. void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);5 @$ F" f6 G9 y; I' l/ b8 T5 [
  11. * f( Z8 r9 i4 @% k4 k/ }& t
  12. /* Optional Configuration functions *******************************************/
    * u* Y2 d# l  q+ r
  13. void DMA_PeriphIncOffsetSizeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_Pincos);
    $ S2 j( ?: c( L+ M! t# O
  14. void DMA_FlowControllerConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FlowCtrl);
    1 _, t# ~/ v. g7 y
  15. * T6 D& o  l" C
  16. /* Data Counter functions *****************************************************/& D7 Z; g. g" q* `
  17. void DMA_SetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx, uint16_t Counter);
    ( E3 j$ r" n; N8 b& Q
  18. uint16_t DMA_GetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx);8 C# h; n( ~' b; c% ~

  19. 1 U# Q0 R6 N' \% S2 }! I& ?
  20. /* Double Buffer mode functions ***********************************************/
    - V, y/ r" ^, J
  21. void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t Memory1BaseAddr,4 l% J6 {4 L- c  {
  22.                                 uint32_t DMA_CurrentMemory);/ |  q* g2 @; Z: r* `
  23. void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);) l' X& K8 B4 `7 j
  24. void DMA_MemoryTargetConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t MemoryBaseAddr,( c# a0 X, y/ N4 ~* _5 z0 I
  25.                             uint32_t DMA_MemoryTarget);" I% @4 g* a; I2 ?
  26. uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef* DMAy_Streamx);4 B+ }( O% v! L+ ^/ N' w# h

  27. 6 r( c8 x; K( ?5 p1 G, H
  28. /* Interrupts and flags management functions **********************************/
    - {' X/ Q' E8 ~0 ]
  29. FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef* DMAy_Streamx);5 ^# d; R5 Y# j' X4 ^$ x. Z
  30. uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef* DMAy_Streamx);/ ?7 `6 u' X% W/ }
  31. FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);
    8 c0 c/ N* U  v2 J5 x3 M
  32. void DMA_ClearFlag(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);8 Y+ O$ L7 H5 |* {3 C; }
  33. void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState);4 Z* Q1 L7 f2 x3 d9 `
  34. ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);
    % G: N! S" z% F1 `3 Y5 a' H  x
  35. void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);' K1 V! A" O% `6 c4 d. u

  36.   ]. Z1 D7 ~% Z% k& ^0 \
复制代码

% S7 C: ]) Y" M6 U04. 结构体封装
& w# f: j4 `: H3 \& Y( s9 X. `8 U
  1. /**
    7 T4 N0 h1 H/ n! v  J; W% f
  2.   * @brief DMA Controller
    5 z4 w7 g: }+ O2 w3 J
  3.   */& E. I$ n; v$ ~, w7 S6 [. o

  4. ! `" E, ~) {- L6 m
  5. typedef struct
    * v6 X& a) s% R/ n
  6. {" g9 j% R  U4 g6 p
  7.   __IO uint32_t CR;     /*!< DMA stream x configuration register      */
    : e) Y0 ?; P/ j  q
  8.   __IO uint32_t NDTR;   /*!< DMA stream x number of data register     */4 x' E0 t6 w" i& N
  9.   __IO uint32_t PAR;    /*!< DMA stream x peripheral address register *// n4 B/ l% j, {* h
  10.   __IO uint32_t M0AR;   /*!< DMA stream x memory 0 address register   */3 e9 g, h- t4 D& \5 @/ x
  11.   __IO uint32_t M1AR;   /*!< DMA stream x memory 1 address register   */
    / L9 W. `( E8 n
  12.   __IO uint32_t FCR;    /*!< DMA stream x FIFO control register       */- N* {( n; Y; S. A8 |. ]
  13. } DMA_Stream_TypeDef;
    . }, P9 w; h- F0 E+ s; Q, m: A
  14. 8 Y" J- Q* F) R) `  T
  15. typedef struct% S" U& i& Z2 P  Z5 G
  16. {% N. H9 \6 P2 t/ a" O# q! v
  17.   __IO uint32_t LISR;   /*!< DMA low interrupt status register,      Address offset: 0x00 */
    % T8 d  v9 b" q0 \/ _
  18.   __IO uint32_t HISR;   /*!< DMA high interrupt status register,     Address offset: 0x04 *// J. X; m% L4 I( A) P. s2 E: [
  19.   __IO uint32_t LIFCR;  /*!< DMA low interrupt flag clear register,  Address offset: 0x08 *// W: {7 \' o3 Z# L: D5 j8 `  E, ^
  20.   __IO uint32_t HIFCR;  /*!< DMA high interrupt flag clear register, Address offset: 0x0C */: u& M8 _5 ]8 K
  21. } 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
赞 收藏 评论0 发布时间:2022-3-28 22:00

举报

0个回答

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版