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

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

[复制链接]
STMCU小助手 发布时间:2022-3-28 22:00
01. DMA简介
5 q+ Q' b6 l% W# [# }9 @DMA,全称为:Direct Memory Access,即直接存储器访问。DMA 传输方式无需 CPU 直接控制传输,也没有中断处理方式那样保留现场和恢复现场的过程,通过硬件为 RAM 与 I/O 设备开辟一条直接传送数据的通路,能使 CPU 的效率大为提高。: A: P9 I# E1 X3 J
8 E, n1 h1 L7 J! s- @0 n
STM32F4 最多有 2 个 DMA 控制器(DMA1 和 DMA2),共 16 个数据流(每个控制器 8 个),每一个 DMA 控制器都用于管理一个或多个外设的存储器访问请求。每个数据流总共可以有多达 8个通道(或称请求)。每个数据流通道都有一个仲裁器,用于处理 DMA 请求间的优先级。
- {  e: _5 q: T5 J/ O; l! ^/ u; p9 [
02. 相关类型
2 n1 c( a. @) oDMA Init structure definition
8 B4 ]) ]& S- U/ W
. j" k& d* e5 F) |$ N1 `
  1. /** & \, K2 j* r9 e3 S, S6 o. X3 j4 B9 {
  2.   * @brief  DMA Init structure definition
    # P- w9 q: z6 e
  3.   */
    - g: c. R4 d, {, `; C' \

  4. 0 S7 W. B3 i# v* z4 q
  5. typedef struct* P! x# A/ _6 \8 C8 p
  6. {
    0 g6 ], B6 i/ `, K. Q  _& S. g
  7.   uint32_t DMA_Channel;            /*!< Specifies the channel used for the specified stream. " x+ H$ x( Q0 {  W2 M  _! t. g( q
  8.                                         This parameter can be a value of @ref DMA_channel */  `1 _4 A3 v" X% @1 A0 _

  9. : n3 o$ F6 ]. b
  10.   uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Streamx. */0 z0 `# H; K" \" [( |* [& ]# q

  11. * k- Y" r) t: Q. ]3 r3 o6 E
  12.   uint32_t DMA_Memory0BaseAddr;    /*!< Specifies the memory 0 base address for DMAy Streamx.
    & _, Q1 L& L; k6 k6 y) ^) Q4 W. h
  13.                                         This memory is the default memory used when double buffer mode is7 J, K! i5 h. t! h- r; m. R4 W
  14.                                         not enabled. */
    ! Y) ]3 k9 p$ }2 j$ G# D0 i

  15. ' j4 j+ p: D0 s) a4 \: ?
  16.   uint32_t DMA_DIR;                /*!< Specifies if the data will be transferred from memory to peripheral,   w; P9 }5 s" A* y0 ?7 `7 i* s
  17.                                         from memory to memory or from peripheral to memory.6 J6 i2 g, f% s! e
  18.                                         This parameter can be a value of @ref DMA_data_transfer_direction */+ P5 Y. [( W% \

  19. + v0 X& p+ U1 m: z. }" F
  20.   uint32_t DMA_BufferSize;         /*!< Specifies the buffer size, in data unit, of the specified Stream.
    2 m" z; A0 |) N& N2 n
  21.                                         The data unit is equal to the configuration set in DMA_PeripheralDataSize
    # O- {: A; f' H- n8 ]
  22.                                         or DMA_MemoryDataSize members depending in the transfer direction. */
    2 |$ \1 z' _/ v- f

  23. ! Y9 ^* y+ V9 h9 d( ^: l
  24.   uint32_t DMA_PeripheralInc;      /*!< Specifies whether the Peripheral address register should be incremented or not.- P$ F7 a9 W" u2 g" }
  25.                                         This parameter can be a value of @ref DMA_peripheral_incremented_mode */2 g2 w6 z6 H2 b# ^& U/ s* C
  26. ! }3 y4 s& k! c* j! }
  27.   uint32_t DMA_MemoryInc;          /*!< Specifies whether the memory address register should be incremented or not.
    : b9 `4 L5 N# T6 W' E
  28.                                         This parameter can be a value of @ref DMA_memory_incremented_mode */7 G+ E6 w5 a- ~' p2 i: `# x
  29. / _' |/ ?3 P. X6 K
  30.   uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.& U! e4 c4 S$ ?" ^  t$ y* Q/ D
  31.                                         This parameter can be a value of @ref DMA_peripheral_data_size */& z; l4 M0 v: s# U7 c4 c

  32. % u1 x$ h- h% |/ l2 n
  33.   uint32_t DMA_MemoryDataSize;     /*!< Specifies the Memory data width.2 f4 q. H+ ^) h2 D; l
  34.                                         This parameter can be a value of @ref DMA_memory_data_size *// \# f) j; t& r+ X0 Q. I( d) |2 R
  35. 4 @% ~, b" Y% H3 T1 ?5 ^9 G
  36.   uint32_t DMA_Mode;               /*!< Specifies the operation mode of the DMAy Streamx.
    # T1 w( Q2 S8 I  M+ V
  37.                                         This parameter can be a value of @ref DMA_circular_normal_mode0 Q, h" I2 L0 h- j+ J
  38.                                         @note The circular buffer mode cannot be used if the memory-to-memory& e) e0 Z' }% y# [( q- u; W9 {
  39.                                               data transfer is configured on the selected Stream */
    . s& W* o/ S: j" Y- \
  40. # n* y& E1 o% H# e5 w# g, s5 t; }
  41.   uint32_t DMA_Priority;           /*!< Specifies the software priority for the DMAy Streamx.
    : ~, }: ]/ L5 ^9 ^9 h5 g9 r1 B% j
  42.                                         This parameter can be a value of @ref DMA_priority_level */8 X0 e- k: s8 B5 ~$ Z
  43. & S2 Z- s, m# f5 p0 x/ ]  s
  44.   uint32_t DMA_FIFOMode;          /*!< Specifies if the FIFO mode or Direct mode will be used for the specified Stream.; v' Q7 H1 j( k% b0 N" ^+ q7 ]
  45.                                         This parameter can be a value of @ref DMA_fifo_direct_mode; e0 h' ]* ~( l4 ?/ q7 |+ G) n7 H
  46.                                         @note The Direct mode (FIFO mode disabled) cannot be used if the , Q" @$ ]7 n' W: N
  47.                                                memory-to-memory data transfer is configured on the selected Stream */
    ' F6 l3 P- W! ^* s% v7 X
  48. $ X( }. i6 k, I5 C
  49.   uint32_t DMA_FIFOThreshold;      /*!< Specifies the FIFO threshold level., B: @" m5 u: n- w# u6 Z. P0 W) ~1 v
  50.                                         This parameter can be a value of @ref DMA_fifo_threshold_level */& L) F" a9 T; u+ n, U
  51. % k2 Z1 J1 V0 \3 m9 M
  52.   uint32_t DMA_MemoryBurst;        /*!< Specifies the Burst transfer configuration for the memory transfers.
    ' p4 o, M! R/ H8 ]( v$ {! v
  53.                                         It specifies the amount of data to be transferred in a single non interruptable 4 O$ S, L6 ]' @1 s6 N1 L
  54.                                         transaction. This parameter can be a value of @ref DMA_memory_burst
    ) d# j6 V2 d1 e, n2 v7 a" g0 L
  55.                                         @note The burst mode is possible only if the address Increment mode is enabled. */
    5 @0 |$ e. N  `, |0 A

  56. - V! |1 e8 f) K; V* a1 ^3 y* I
  57.   uint32_t DMA_PeripheralBurst;    /*!< Specifies the Burst transfer configuration for the peripheral transfers. - \7 Q8 }" x" _; G
  58.                                         It specifies the amount of data to be transferred in a single non interruptable
    9 M1 z. T& Q6 S; {: b
  59.                                         transaction. This parameter can be a value of @ref DMA_peripheral_burst
    8 r% L+ B/ L, _# C& g# u" o7 v
  60.                                         @note The burst mode is possible only if the address Increment mode is enabled. */  3 s- |2 G: i, o8 f( d
  61. }DMA_InitTypeDef;
复制代码
" U* T. m4 ~) x: E! a
DMA_Exported_Constants. J! s; Z$ Q" g! Y9 U
+ |6 p8 ?! j5 n7 a3 l4 ^/ W" J
  1. ** @defgroup DMA_Exported_Constants
    8 z+ ^3 E& x& x# |' O% W
  2.   * @{5 O: t  T- O- `' ]7 |  U
  3.   */
    $ v2 R# m1 z8 Z, |7 v0 q3 }% R! t

  4. ' E' }- p% ?$ t9 @/ P
  5. #define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Stream0) || \
    : ^" I. A- f) [( n1 V
  6.                                    ((PERIPH) == DMA1_Stream1) || \
    . u9 }  Q2 f* h( q7 i5 v( ~6 `# s
  7.                                    ((PERIPH) == DMA1_Stream2) || \) {' Y' n) v6 ]( O
  8.                                    ((PERIPH) == DMA1_Stream3) || \: o0 d" `8 [: Y$ H
  9.                                    ((PERIPH) == DMA1_Stream4) || \
    : T$ u% w8 E3 l& f  V: e0 Q% o
  10.                                    ((PERIPH) == DMA1_Stream5) || \
      ^& {! c& F9 @. a  j+ U
  11.                                    ((PERIPH) == DMA1_Stream6) || \) C; @( _+ ^8 X: [: z$ |& W/ P
  12.                                    ((PERIPH) == DMA1_Stream7) || \
    % Q, I5 o  k/ e" U+ }
  13.                                    ((PERIPH) == DMA2_Stream0) || \
    8 Q8 Y! x: k+ U+ n( X8 b! q! n
  14.                                    ((PERIPH) == DMA2_Stream1) || \" Z* W3 v5 L* w
  15.                                    ((PERIPH) == DMA2_Stream2) || \2 V% h" b9 l( Y! v, ]5 q
  16.                                    ((PERIPH) == DMA2_Stream3) || \
    : r2 b; T) v/ i) r1 f) Y2 u6 v2 q
  17.                                    ((PERIPH) == DMA2_Stream4) || \
    ) W9 X9 ]4 K& n
  18.                                    ((PERIPH) == DMA2_Stream5) || \
    $ l. Z) ~& H9 `' c
  19.                                    ((PERIPH) == DMA2_Stream6) || \8 e' @1 K$ z5 |2 M* O; V7 C1 S  a' B
  20.                                    ((PERIPH) == DMA2_Stream7))
    . ^! j& L9 u1 [7 {  T

  21. 7 Q3 o1 u" U# ^/ X1 s( v- Z+ T+ g
  22. #define IS_DMA_ALL_CONTROLLER(CONTROLLER) (((CONTROLLER) == DMA1) || \
    & Y* k/ f" u+ {9 E5 ?
  23.                                            ((CONTROLLER) == DMA2))
复制代码
( t% V( x! j( n1 M) ^
DMA_channel

6 N+ ~: F& D. B8 d: l4 F1 L( N: i8 I+ l$ \/ d4 t* K* ]
  1. /** @defgroup DMA_channel
      x) Z' G' S* |. y) E. b3 N, m9 E" C5 N
  2.   * @{0 z% r+ S; x9 C+ e# w
  3.   */ 2 _6 j' u- b3 Z
  4. #define DMA_Channel_0                     ((uint32_t)0x00000000)' C" [+ K8 b8 `$ _5 [5 \; ?% _1 Q  ~
  5. #define DMA_Channel_1                     ((uint32_t)0x02000000)
    7 U+ J0 c( W/ q3 L7 d- ^# ?" e
  6. #define DMA_Channel_2                     ((uint32_t)0x04000000)5 ~' I4 }( y8 {. T2 w
  7. #define DMA_Channel_3                     ((uint32_t)0x06000000)
    9 u7 _# `+ T( U! F9 u. h
  8. #define DMA_Channel_4                     ((uint32_t)0x08000000)! M- S- p+ I" k( Q: s6 P6 d* q8 c
  9. #define DMA_Channel_5                     ((uint32_t)0x0A000000)
      K6 \& w" |( f8 Y7 h; Z
  10. #define DMA_Channel_6                     ((uint32_t)0x0C000000)( n) c' ]8 c3 x6 J* n! b) M
  11. #define DMA_Channel_7                     ((uint32_t)0x0E000000)
    6 a4 W( e# {8 F2 }9 h. a9 l

  12.   J+ k7 p$ \2 h
  13. #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_Channel_0) || \/ G: ]# _8 g1 Y
  14.                                  ((CHANNEL) == DMA_Channel_1) || \# V" o7 w# [( N7 P
  15.                                  ((CHANNEL) == DMA_Channel_2) || \
    4 \8 j2 q7 `: D; |# H: n0 {- C
  16.                                  ((CHANNEL) == DMA_Channel_3) || \
    2 a7 b( T- y5 l' f" f
  17.                                  ((CHANNEL) == DMA_Channel_4) || \1 r; q' D/ W* q
  18.                                  ((CHANNEL) == DMA_Channel_5) || \* r9 r2 o! h( t! G( V
  19.                                  ((CHANNEL) == DMA_Channel_6) || \
    : ~& g0 }1 E$ @- W1 t6 z: c1 l- `
  20.                                  ((CHANNEL) == DMA_Channel_7))7 B; X. f6 U; B4 C& [5 A
复制代码

; J% P! }+ D/ N% yDMA_data_transfer_direction+ @3 V4 K$ d& ~( i; ?
$ |& P4 b: \' T# u% L6 u1 Z7 _
  1. /** @defgroup DMA_data_transfer_direction
    $ O$ ?1 y# z% |/ j
  2.   * @{9 r7 o3 e1 ?3 ~% g3 v7 T" \2 p& v
  3.   */ " U$ v# f- g1 C' u  i
  4. #define DMA_DIR_PeripheralToMemory        ((uint32_t)0x00000000)6 i$ v; @/ z5 H/ u
  5. #define DMA_DIR_MemoryToPeripheral        ((uint32_t)0x00000040)
    $ {6 f3 d6 F# F% V7 S& S
  6. #define DMA_DIR_MemoryToMemory            ((uint32_t)0x00000080)) I1 z* c3 _6 a- ^" _

  7. : \5 B3 V' n; ]4 h
  8. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_DIR_PeripheralToMemory ) || \5 B8 _  Q; w6 B
  9.                                      ((DIRECTION) == DMA_DIR_MemoryToPeripheral)  || \& Y; t0 n: G/ m. V
  10.                                      ((DIRECTION) == DMA_DIR_MemoryToMemory))
复制代码
) y2 @; n0 m- a5 A4 g  l% F
DMA_data_buffer_size3 @) w' d; R* I; Z2 c: N

# y6 I# `( K& d1 I: e! a) b1 x0 [7 k  L# b
  1. /** @defgroup DMA_data_buffer_size
    8 X! X* _. a$ I5 }8 v- H" P
  2.   * @{
    , V8 m( z3 r* f3 ^. w1 Y+ l
  3.   */
    9 m' B( V* z8 y. Q1 B
  4. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
    $ _, F6 V, n5 B0 W
  5. 1# U) G* [7 h. H! Z  P. M8 L6 N! W: ~
  6. 2
    ( h% ?% E+ q1 q3 v- d
  7. 3  h* u* n$ `' Y1 |% t( J* U# y
  8. 4
    / B7 k0 u) q) W3 A/ F. K0 e+ N
  9. DMA_peripheral_incremented_mode
    7 W: H1 c. E3 v0 U" O& o

  10. ) D5 y- p& _- F3 {# w" w
  11. /** @defgroup DMA_peripheral_incremented_mode
    , J, `9 O- z0 F! w6 s$ b
  12.   * @{
    + g- @4 s; Y/ A
  13.   */
    / |# e, R! L, [0 v/ R- x' V
  14. #define DMA_PeripheralInc_Enable          ((uint32_t)0x00000200)# f6 @. y0 {/ x  T- _  q6 S9 J
  15. #define DMA_PeripheralInc_Disable         ((uint32_t)0x00000000); y+ @0 `0 B' c; [
  16. : o5 ?; x5 Q9 z4 o
  17. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \
    # `/ r% f7 V/ p5 g& ^/ H. F
  18.                                             ((STATE) == DMA_PeripheralInc_Disable))
复制代码
, \. S$ i- j+ n- i2 g
DMA_memory_incremented_mode
  1. /** @defgroup DMA_memory_incremented_mode . L" h( `- x- d+ w. }7 [
  2.   * @{+ r8 K$ q7 ^2 K& ]. y. b
  3.   */
    8 d* Z, [- T" c) j* X& D, n1 n4 x  J
  4. #define DMA_MemoryInc_Enable              ((uint32_t)0x00000400)
    1 l- i& K) i: ^% ?& w; _
  5. #define DMA_MemoryInc_Disable             ((uint32_t)0x00000000)
    7 M9 ?; @" t! E

  6. 6 C, @# Y. T) `
  7. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \9 @1 y$ i. @6 m
  8.                                         ((STATE) == DMA_MemoryInc_Disable))
复制代码

; f& [5 {6 J& f' rDMA_peripheral_data_size1 T0 ^- n- w+ M
  1. /** @defgroup DMA_peripheral_data_size ; K5 U' J/ F# I
  2.   * @{% W4 {0 x  Y- Y6 `0 L( K" D
  3.   */ / e4 o0 K! \; n
  4. #define DMA_PeripheralDataSize_Byte       ((uint32_t)0x00000000) 7 k* k# M5 [5 }( z2 _3 m
  5. #define DMA_PeripheralDataSize_HalfWord   ((uint32_t)0x00000800) . z# \* L1 ^& p; {# T' A7 }/ a* A" G
  6. #define DMA_PeripheralDataSize_Word       ((uint32_t)0x00001000)
    1 L9 n! [3 Q2 o2 ~, Q( j* E

  7. & m$ S/ {- J! p% Q  ^3 `0 c
  8. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte)  || \
    $ y, X# V8 j& s
  9.                                            ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \
    . d! s4 T' l$ U- R0 d
  10.                                            ((SIZE) == DMA_PeripheralDataSize_Word))1 @+ i# x' V$ F9 x( X' t) x# M* q7 r
复制代码

6 @8 A3 ~  G; V! O: i( {* \DMA_memory_data_size
  1. /** @defgroup DMA_memory_data_size ( e/ B: g4 I& L5 L: x# _
  2.   * @{1 R2 V0 E& R" p' Z# z7 c  N7 _
  3.   */ / [+ K5 x% a7 t& _4 e% F
  4. #define DMA_MemoryDataSize_Byte           ((uint32_t)0x00000000)
    * V3 `+ X- R7 M6 u( f% ?
  5. #define DMA_MemoryDataSize_HalfWord       ((uint32_t)0x00002000)
    3 F+ ]; V" [8 t+ i% t( U6 x
  6. #define DMA_MemoryDataSize_Word           ((uint32_t)0x00004000)- |. x7 X& @3 Z6 \
  7. 5 o9 l  M& R5 J/ t
  8. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte)  || \. R/ n2 H0 k3 _) G
  9.                                        ((SIZE) == DMA_MemoryDataSize_HalfWord) || \4 w& p. A+ R3 Z; I& j
  10.                                        ((SIZE) == DMA_MemoryDataSize_Word ))
复制代码

4 e; O6 _6 ?# ?  PDMA_circular_normal_mode
7 n4 _* h; }  c1 h1 \: b
  1. " k0 S1 w, P7 b8 ?( f
  2. /** @defgroup DMA_circular_normal_mode ( e5 ]- p9 l; U
  3.   * @{
    9 v! C" f8 t, H2 B3 @( ^9 `9 K
  4.   */
    # {+ o5 d! r5 ~6 @# s  g
  5. #define DMA_Mode_Normal                   ((uint32_t)0x00000000)
    8 f% g( x1 m( ^( o2 l
  6. #define DMA_Mode_Circular                 ((uint32_t)0x00000100)3 q% M2 l- G4 f* y% R
  7. % B8 }) g& X7 E, j
  8. #define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Normal ) || \; P) Q. A  }7 u
  9.                            ((MODE) == DMA_Mode_Circular))
    7 H' [, K- C3 q
复制代码
' \( j/ w* B# D+ L0 I
DMA_priority_level

$ c3 S* r: t5 y
% @: v7 I4 n3 Y  ~9 d) D3 A' z
  1. /** @defgroup DMA_priority_level 5 C5 ]/ F$ l, X
  2.   * @{2 B* `: S) ]. v  `) v2 Q8 J
  3.   */ " p& z2 B5 ]- U7 B7 X# H& [
  4. #define DMA_Priority_Low                  ((uint32_t)0x00000000)
    & E9 B5 c4 k& u0 z# e: g2 i
  5. #define DMA_Priority_Medium               ((uint32_t)0x00010000) / F. w& c' y+ ^) A
  6. #define DMA_Priority_High                 ((uint32_t)0x00020000)
    + g0 h+ t3 J# f$ h* i( @6 s( Q
  7. #define DMA_Priority_VeryHigh             ((uint32_t)0x00030000)) q& g) y; d1 R9 @

  8. 8 `+ t3 _( p4 a
  9. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_Low )   || \
    $ B" A5 y8 S/ @3 _
  10.                                    ((PRIORITY) == DMA_Priority_Medium) || \6 o/ ?6 ^/ f7 o  m6 W3 k$ x6 {
  11.                                    ((PRIORITY) == DMA_Priority_High)   || \- o2 _8 @4 X5 v3 ]
  12.                                    ((PRIORITY) == DMA_Priority_VeryHigh))
复制代码
) N1 B/ T( G4 Y( F
DMA_fifo_direct_mode
  1. /** @defgroup DMA_fifo_direct_mode
    ; l. C# L. G) G. ?' j  v+ A$ p) Z
  2.   * @{
    3 I7 \$ o. x6 v3 X+ W; X
  3.   */
    4 @  `. y9 q; W- ^2 S
  4. #define DMA_FIFOMode_Disable              ((uint32_t)0x00000000) 7 M* h/ ]" v/ X0 ]
  5. #define DMA_FIFOMode_Enable               ((uint32_t)0x00000004)9 I+ q( T4 }6 M. b4 T' n

  6. ! S' i" T9 X+ i9 E
  7. #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMode_Disable ) || \" N7 l0 u$ q5 F6 H# q: M" a# ]  ?
  8.                                        ((STATE) == DMA_FIFOMode_Enable))
复制代码
! a9 [4 l) M* j5 e, Y
DMA_fifo_threshold_level

5 r9 R/ p9 }2 E$ E& T6 x0 k
  O5 O! z+ }8 O7 m7 l0 [9 ]
  1. /** @defgroup DMA_fifo_threshold_level
    0 l3 x' b$ _5 p# i, r5 c6 P
  2.   * @{
    ' q; i/ U) h% b1 W; p  d7 i- e6 M
  3.   */
    ' ?( Z0 o* s9 c
  4. #define DMA_FIFOThreshold_1QuarterFull    ((uint32_t)0x00000000)- W$ b8 @% u* m$ i2 B1 T# A: Y2 x; z) U
  5. #define DMA_FIFOThreshold_HalfFull        ((uint32_t)0x00000001) - g, m% Z+ V; z" z
  6. #define DMA_FIFOThreshold_3QuartersFull   ((uint32_t)0x00000002)* y4 c7 |! k5 p$ N$ a$ E8 e5 \. N' M
  7. #define DMA_FIFOThreshold_Full            ((uint32_t)0x00000003)$ y/ l2 N& K8 [
  8. / l% M2 C; T, a$ w7 Q0 U$ M5 i
  9. #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFOThreshold_1QuarterFull ) || \1 }! e4 [: k: l$ U
  10.                                           ((THRESHOLD) == DMA_FIFOThreshold_HalfFull)      || \
    & I, ^: U: o/ `; K' k
  11.                                           ((THRESHOLD) == DMA_FIFOThreshold_3QuartersFull) || \6 x# d  M3 M" T% A$ L% \
  12.                                           ((THRESHOLD) == DMA_FIFOThreshold_Full))
复制代码

5 ?1 }$ ]% p$ e4 Z0 FDMA_memory_burst
0 S& C6 `* l. u0 D0 ^) H- ?

! q  n" H% z* s
  1. /** @defgroup DMA_memory_burst 9 p/ _+ U3 ]$ N
  2.   * @{
    & W* ^- G1 Y5 v* {, U
  3.   */
    * \. i% r; ~# R4 n) K0 z! e
  4. #define DMA_MemoryBurst_Single            ((uint32_t)0x00000000)- [5 d3 @+ ?$ T1 e* m, J* P( l
  5. #define DMA_MemoryBurst_INC4              ((uint32_t)0x00800000)  
    ; ~5 B. h+ C) ]$ \7 B# i
  6. #define DMA_MemoryBurst_INC8              ((uint32_t)0x01000000); o' m: A+ d5 q6 u
  7. #define DMA_MemoryBurst_INC16             ((uint32_t)0x01800000)
    2 r5 S1 W, A* B- f

  8. ' c0 F' U: q( y
  9. #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MemoryBurst_Single) || \# ?, Y9 [# G/ u4 i
  10.                                     ((BURST) == DMA_MemoryBurst_INC4)  || \
    : R$ _8 |5 H' ?, t! a/ C0 U, T
  11.                                     ((BURST) == DMA_MemoryBurst_INC8)  || \
    ( p" J! I  K% f5 C
  12.                                     ((BURST) == DMA_MemoryBurst_INC16))
    0 Q7 Y1 f& F* r0 a6 V
复制代码
2 z/ |& p/ Q- v& x
DMA_peripheral_burst+ \& Z( C6 v) \* Z8 h) u
0 }: U3 e1 f! Z
  1. /** @defgroup DMA_peripheral_burst
    * X& t% M! z! R6 R8 K4 J
  2.   * @{
    $ f" y& R: ^* U5 E
  3.   */ % D* H& |. {- {
  4. #define DMA_PeripheralBurst_Single        ((uint32_t)0x00000000). `. o' I% [+ a3 J* \5 b) `
  5. #define DMA_PeripheralBurst_INC4          ((uint32_t)0x00200000)  
    / w9 L6 A8 J6 b
  6. #define DMA_PeripheralBurst_INC8          ((uint32_t)0x00400000). X8 F" `% C2 X9 }: ]
  7. #define DMA_PeripheralBurst_INC16         ((uint32_t)0x00600000)
    2 u; W- i% d& E
  8. & r, g& N3 l# Z3 J. k- L
  9. #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PeripheralBurst_Single) || \: H( ]6 c4 w* F( U( J; n
  10.                                         ((BURST) == DMA_PeripheralBurst_INC4)  || \
    " Q1 u* t9 g7 t: c
  11.                                         ((BURST) == DMA_PeripheralBurst_INC8)  || \" X" S5 q& O$ a* `# m* @
  12.                                         ((BURST) == DMA_PeripheralBurst_INC16))3 K3 w3 V' L7 P4 G5 n. v" n) |
复制代码

5 s, `7 f: R0 k0 z' Y' ?/ T0 y# T/ H: `7 hDMA_fifo_status_level
) [) R( W3 K2 |/ V  n) _$ t- G
) ~) F& ]7 r  Q5 f# k7 |
  1. /** @defgroup DMA_fifo_status_level 0 x- D7 h# S/ t9 T
  2.   * @{
    * D9 T: O* U1 [$ g
  3.   */
    1 Y- v1 C! s+ Z8 Z
  4. #define DMA_FIFOStatus_Less1QuarterFull   ((uint32_t)0x00000000 << 3)
    1 o3 c. Q/ }  {
  5. #define DMA_FIFOStatus_1QuarterFull       ((uint32_t)0x00000001 << 3)
    , m2 a, q- ~( A+ w+ l) I: _) n
  6. #define DMA_FIFOStatus_HalfFull           ((uint32_t)0x00000002 << 3) . s7 r/ N5 E2 b, \) v
  7. #define DMA_FIFOStatus_3QuartersFull      ((uint32_t)0x00000003 << 3), V7 [( x7 R, K
  8. #define DMA_FIFOStatus_Empty              ((uint32_t)0x00000004 << 3)3 ?, {$ ?7 `, s  Z( P
  9. #define DMA_FIFOStatus_Full               ((uint32_t)0x00000005 << 3)
    % {2 g0 x  u* _. d; o- u
  10. 9 K' a4 L; M& W' E/ U- i6 n# K) K/ g
  11. #define IS_DMA_FIFO_STATUS(STATUS) (((STATUS) == DMA_FIFOStatus_Less1QuarterFull ) || \5 Z' L7 g- m0 c' a
  12.                                     ((STATUS) == DMA_FIFOStatus_HalfFull)          || \% W& Y) i3 M! h: s, b7 }
  13.                                     ((STATUS) == DMA_FIFOStatus_1QuarterFull)      || \5 G# d8 _5 t$ C+ b$ s
  14.                                     ((STATUS) == DMA_FIFOStatus_3QuartersFull)     || \% Q6 ?$ m& c! f) M- D
  15.                                     ((STATUS) == DMA_FIFOStatus_Full)              || \& `% s' K1 o; g! R
  16.                                     ((STATUS) == DMA_FIFOStatus_Empty))
复制代码

& y! H$ Z4 |, C4 H1 kDMA_flags_definition- K, e/ j( k7 @
- G/ O- p  \6 [: Q/ i- P4 a
  1. /** @defgroup DMA_flags_definition * n6 Y& l; }! B! q; H0 G
  2.   * @{
    ' v# H# K( s( \: [5 R1 A& _/ k
  3.   */
    6 {8 f/ v! x, J/ \
  4. #define DMA_FLAG_FEIF0                    ((uint32_t)0x10800001)
    / |& a9 G+ }9 K7 H' P& O, S; A9 i
  5. #define DMA_FLAG_DMEIF0                   ((uint32_t)0x10800004)
    0 _) ~8 G+ P4 y4 T8 y
  6. #define DMA_FLAG_TEIF0                    ((uint32_t)0x10000008)' z6 I; G0 C6 ~, [3 Q, G9 _
  7. #define DMA_FLAG_HTIF0                    ((uint32_t)0x10000010)1 }  p# W8 {' `0 |5 y
  8. #define DMA_FLAG_TCIF0                    ((uint32_t)0x10000020)
    0 A; w/ o; l9 w: o0 [7 u
  9. #define DMA_FLAG_FEIF1                    ((uint32_t)0x10000040)
    2 v# u8 P. q5 |
  10. #define DMA_FLAG_DMEIF1                   ((uint32_t)0x10000100)3 r2 j- X8 N9 z0 \" S3 \" n
  11. #define DMA_FLAG_TEIF1                    ((uint32_t)0x10000200)
    ; K1 ?3 `0 W7 e; R, Y3 v
  12. #define DMA_FLAG_HTIF1                    ((uint32_t)0x10000400)
    6 z3 I- E  F* N9 d% [% u
  13. #define DMA_FLAG_TCIF1                    ((uint32_t)0x10000800)  n9 m4 |; U- E, A& G8 B( p
  14. #define DMA_FLAG_FEIF2                    ((uint32_t)0x10010000)
    % g" P4 i% l  u% R% s5 X3 F6 P
  15. #define DMA_FLAG_DMEIF2                   ((uint32_t)0x10040000)
    3 N0 a0 W2 W- R2 ]2 |5 ?
  16. #define DMA_FLAG_TEIF2                    ((uint32_t)0x10080000). B; V7 z" u7 o( W) O) S
  17. #define DMA_FLAG_HTIF2                    ((uint32_t)0x10100000)
    " {5 K2 _/ B, j
  18. #define DMA_FLAG_TCIF2                    ((uint32_t)0x10200000)
    % o1 q9 `6 X' l: b$ `+ s
  19. #define DMA_FLAG_FEIF3                    ((uint32_t)0x10400000)* O: f: W  g. r/ p' l( O" Z
  20. #define DMA_FLAG_DMEIF3                   ((uint32_t)0x11000000)
    , ^, {) e. c7 G' g% V3 f$ A
  21. #define DMA_FLAG_TEIF3                    ((uint32_t)0x12000000); d" I* T! d" {
  22. #define DMA_FLAG_HTIF3                    ((uint32_t)0x14000000)
    ' W0 m8 F" K+ ~) |9 U# Q
  23. #define DMA_FLAG_TCIF3                    ((uint32_t)0x18000000)! u$ e$ G2 a; S
  24. #define DMA_FLAG_FEIF4                    ((uint32_t)0x20000001)
    1 ?1 {2 J3 e. I
  25. #define DMA_FLAG_DMEIF4                   ((uint32_t)0x20000004), G0 l( ]( Z5 O7 e
  26. #define DMA_FLAG_TEIF4                    ((uint32_t)0x20000008)! q4 c. x; b5 L# U
  27. #define DMA_FLAG_HTIF4                    ((uint32_t)0x20000010)) G0 p" f% j8 J
  28. #define DMA_FLAG_TCIF4                    ((uint32_t)0x20000020)& g6 G0 ~$ ]* l
  29. #define DMA_FLAG_FEIF5                    ((uint32_t)0x20000040)
    ( F: t* h) ?! v$ }, _8 L$ J8 r: J
  30. #define DMA_FLAG_DMEIF5                   ((uint32_t)0x20000100); S4 p# l" y4 U) }* j4 s  j+ @0 M. R
  31. #define DMA_FLAG_TEIF5                    ((uint32_t)0x20000200)
    + K% Q8 L& h* ^: ?( G
  32. #define DMA_FLAG_HTIF5                    ((uint32_t)0x20000400)9 H5 p1 t, M# y0 {4 q; R6 }
  33. #define DMA_FLAG_TCIF5                    ((uint32_t)0x20000800)0 G* W6 z% D; J; ]; U+ }( r7 W7 s
  34. #define DMA_FLAG_FEIF6                    ((uint32_t)0x20010000); t8 n; }5 b. @8 R: i" @7 ]' e6 J
  35. #define DMA_FLAG_DMEIF6                   ((uint32_t)0x20040000)
    3 b& ]  M! [  `0 A2 @
  36. #define DMA_FLAG_TEIF6                    ((uint32_t)0x20080000)0 Q) q  B2 H4 l) l1 C1 L
  37. #define DMA_FLAG_HTIF6                    ((uint32_t)0x20100000)# \# Y9 e' `2 j9 p- V
  38. #define DMA_FLAG_TCIF6                    ((uint32_t)0x20200000)
    ) p* _  g$ A# @
  39. #define DMA_FLAG_FEIF7                    ((uint32_t)0x20400000)
      E! O. T  G5 f3 F
  40. #define DMA_FLAG_DMEIF7                   ((uint32_t)0x21000000): n4 r6 ~* N: F, V3 c
  41. #define DMA_FLAG_TEIF7                    ((uint32_t)0x22000000)6 o- ]5 U0 y! y0 |* v* i
  42. #define DMA_FLAG_HTIF7                    ((uint32_t)0x24000000)5 [# @8 ?) ?# j, L4 P! w
  43. #define DMA_FLAG_TCIF7                    ((uint32_t)0x28000000)
    - M- i$ L. w) [3 s; D- O0 B
  44. ' S$ ]5 W0 W- ?& T2 U8 V
  45. #define IS_DMA_CLEAR_FLAG(FLAG) ((((FLAG) & 0x30000000) != 0x30000000) && (((FLAG) & 0x30000000) != 0) && \: c7 F  u4 `* b2 X1 _
  46.                                  (((FLAG) & 0xC002F082) == 0x00) && ((FLAG) != 0x00))
    ) \' Z/ c( @* v, P6 L

  47. : w& j7 Q+ B1 k- c. U
  48. #define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA_FLAG_TCIF0)  || ((FLAG) == DMA_FLAG_HTIF0)  || \
    : i' P% a1 N3 H
  49.                                ((FLAG) == DMA_FLAG_TEIF0)  || ((FLAG) == DMA_FLAG_DMEIF0) || \
    4 O/ U4 |0 K3 m
  50.                                ((FLAG) == DMA_FLAG_FEIF0)  || ((FLAG) == DMA_FLAG_TCIF1)  || \6 w# B/ }# E' E3 e* T! C0 T  D7 C
  51.                                ((FLAG) == DMA_FLAG_HTIF1)  || ((FLAG) == DMA_FLAG_TEIF1)  || \) w+ L! k: b2 O& v1 h
  52.                                ((FLAG) == DMA_FLAG_DMEIF1) || ((FLAG) == DMA_FLAG_FEIF1)  || \4 I4 H. g$ G4 y; R' H
  53.                                ((FLAG) == DMA_FLAG_TCIF2)  || ((FLAG) == DMA_FLAG_HTIF2)  || \
    : A5 y4 d% @4 f' ^
  54.                                ((FLAG) == DMA_FLAG_TEIF2)  || ((FLAG) == DMA_FLAG_DMEIF2) || \
    1 ~, r$ D# U/ A0 U
  55.                                ((FLAG) == DMA_FLAG_FEIF2)  || ((FLAG) == DMA_FLAG_TCIF3)  || \2 e  V! k2 Q% i2 H8 ]* ]. l
  56.                                ((FLAG) == DMA_FLAG_HTIF3)  || ((FLAG) == DMA_FLAG_TEIF3)  || \: O1 R2 z: Q9 r6 n0 B0 \
  57.                                ((FLAG) == DMA_FLAG_DMEIF3) || ((FLAG) == DMA_FLAG_FEIF3)  || \
    8 C, {, d( U: P# h8 T
  58.                                ((FLAG) == DMA_FLAG_TCIF4)  || ((FLAG) == DMA_FLAG_HTIF4)  || \
    & B0 S3 D1 g7 m9 ?
  59.                                ((FLAG) == DMA_FLAG_TEIF4)  || ((FLAG) == DMA_FLAG_DMEIF4) || \
    # c( Y- T) D/ i+ Z/ n; b
  60.                                ((FLAG) == DMA_FLAG_FEIF4)  || ((FLAG) == DMA_FLAG_TCIF5)  || \$ x; J# r, U2 h/ p; j- W. f
  61.                                ((FLAG) == DMA_FLAG_HTIF5)  || ((FLAG) == DMA_FLAG_TEIF5)  || \# A& a4 j+ X, B& M6 Q
  62.                                ((FLAG) == DMA_FLAG_DMEIF5) || ((FLAG) == DMA_FLAG_FEIF5)  || \
    - o+ `" o* o' Y5 I* [. O) X  s. o
  63.                                ((FLAG) == DMA_FLAG_TCIF6)  || ((FLAG) == DMA_FLAG_HTIF6)  || \
    6 Y* x$ _& |+ P: z$ `! t: T  b& M
  64.                                ((FLAG) == DMA_FLAG_TEIF6)  || ((FLAG) == DMA_FLAG_DMEIF6) || \  X3 A, \8 \  Q+ @7 `: Q! ~: B0 W4 s
  65.                                ((FLAG) == DMA_FLAG_FEIF6)  || ((FLAG) == DMA_FLAG_TCIF7)  || \
    9 B  Y* W. y, [3 B0 q, ^
  66.                                ((FLAG) == DMA_FLAG_HTIF7)  || ((FLAG) == DMA_FLAG_TEIF7)  || \
    ; p' X$ k% d, Q- \1 ?. Z0 t3 h7 I
  67.                                ((FLAG) == DMA_FLAG_DMEIF7) || ((FLAG) == DMA_FLAG_FEIF7))
复制代码

; U8 u& x" n1 X6 {& tDMA_interrupt_enable_definitions
0 U+ W5 x; W4 i; l4 u
  1. /** @defgroup DMA_interrupt_enable_definitions ) E6 s, x$ x& ^* k8 D
  2.   * @{
    + s+ ^. ~+ \& o0 T
  3.   */
    # e  I6 J% F& ?/ H, ^8 ~% J
  4. #define DMA_IT_TC                         ((uint32_t)0x00000010)2 P, o! N2 t+ X: P$ \3 g  A) T, B
  5. #define DMA_IT_HT                         ((uint32_t)0x00000008)
    7 c3 S! m; {4 k" d8 \
  6. #define DMA_IT_TE                         ((uint32_t)0x00000004)0 Y* }3 P3 Z( J
  7. #define DMA_IT_DME                        ((uint32_t)0x00000002)4 ?& |, n! y3 Q! i  D6 O) E
  8. #define DMA_IT_FE                         ((uint32_t)0x00000080)% [$ r7 g6 ^* X/ `5 z; w& `3 A
  9. * E2 b% D3 L  A" u( o+ k
  10. #define IS_DMA_CONFIG_IT(IT) ((((IT) & 0xFFFFFF61) == 0x00) && ((IT) != 0x00))1 v0 ?+ ?: H( u$ m
复制代码

+ a+ i& i: v3 t$ X2 j  `DMA_interrupts_definitions
) H1 `# [8 H8 N( f6 b" k/ W# u. _! w. O4 W
  1. /** @defgroup DMA_interrupts_definitions ( s3 O* b! T. Z6 u% {
  2.   * @{
    ( s9 O6 \! C! b
  3.   */
    0 }6 v- b7 N$ Q1 _- {
  4. #define DMA_IT_FEIF0                      ((uint32_t)0x90000001)& Q7 }# j! A( S4 |! N
  5. #define DMA_IT_DMEIF0                     ((uint32_t)0x10001004)
    # D6 R% I$ m" m% S3 ?
  6. #define DMA_IT_TEIF0                      ((uint32_t)0x10002008)
    ! I' V& W) T8 O/ K5 s
  7. #define DMA_IT_HTIF0                      ((uint32_t)0x10004010)3 w/ g; b4 Z' o. F; u7 d
  8. #define DMA_IT_TCIF0                      ((uint32_t)0x10008020)6 w% j. V4 ]7 V/ K, }
  9. #define DMA_IT_FEIF1                      ((uint32_t)0x90000040)1 [! E2 Y2 ]' W9 r
  10. #define DMA_IT_DMEIF1                     ((uint32_t)0x10001100)9 v1 P4 G4 A/ F9 c
  11. #define DMA_IT_TEIF1                      ((uint32_t)0x10002200)
    # `8 y6 y& D. J8 }6 }
  12. #define DMA_IT_HTIF1                      ((uint32_t)0x10004400)
    7 P  A. B+ Z$ f/ m
  13. #define DMA_IT_TCIF1                      ((uint32_t)0x10008800)
    # Z. F9 ^- W3 q% h; V& _7 a! b9 n
  14. #define DMA_IT_FEIF2                      ((uint32_t)0x90010000)- {% `$ ~  Z  T2 i& ?  n0 Y5 ^
  15. #define DMA_IT_DMEIF2                     ((uint32_t)0x10041000)1 H  u" g& P$ h. B6 J$ s
  16. #define DMA_IT_TEIF2                      ((uint32_t)0x10082000)* Q8 V! c4 U4 J) t; I+ l
  17. #define DMA_IT_HTIF2                      ((uint32_t)0x10104000)
    + F: j! s  G) U1 \& H- W; x! \
  18. #define DMA_IT_TCIF2                      ((uint32_t)0x10208000)0 K, y0 L% q& u! ]! i
  19. #define DMA_IT_FEIF3                      ((uint32_t)0x90400000)
    - r5 ~$ ?) N7 e7 M! V' i( [, g7 M
  20. #define DMA_IT_DMEIF3                     ((uint32_t)0x11001000)
    . B& K& y1 _+ O2 C4 K, {
  21. #define DMA_IT_TEIF3                      ((uint32_t)0x12002000)
    2 P: V. G0 f9 n* A) u& C1 z8 {
  22. #define DMA_IT_HTIF3                      ((uint32_t)0x14004000)
    7 e4 O# k6 W' q1 Z9 ]5 f/ `
  23. #define DMA_IT_TCIF3                      ((uint32_t)0x18008000)
    - @' p" s4 q& f" C/ W
  24. #define DMA_IT_FEIF4                      ((uint32_t)0xA0000001)" J2 r" A/ j5 J4 n9 [2 S, [/ h
  25. #define DMA_IT_DMEIF4                     ((uint32_t)0x20001004)
    3 i* S: ^2 C8 L0 s: c, u
  26. #define DMA_IT_TEIF4                      ((uint32_t)0x20002008)
    7 K/ j: c' O: }2 j, ~" P
  27. #define DMA_IT_HTIF4                      ((uint32_t)0x20004010)1 v" N9 X, F7 p- R6 u6 @
  28. #define DMA_IT_TCIF4                      ((uint32_t)0x20008020)
    9 x7 g, y4 K, ^. c  P" x- R2 k
  29. #define DMA_IT_FEIF5                      ((uint32_t)0xA0000040)
    9 f5 L/ ]+ W2 s
  30. #define DMA_IT_DMEIF5                     ((uint32_t)0x20001100)
    - Y1 z, y7 `$ d3 Q' K; G5 e/ S
  31. #define DMA_IT_TEIF5                      ((uint32_t)0x20002200)7 P$ O$ A$ ^: t$ I
  32. #define DMA_IT_HTIF5                      ((uint32_t)0x20004400)2 X* |* u; A8 f5 I
  33. #define DMA_IT_TCIF5                      ((uint32_t)0x20008800)! H; h  }: x$ u
  34. #define DMA_IT_FEIF6                      ((uint32_t)0xA0010000)
    . p* {( j# t1 M9 k
  35. #define DMA_IT_DMEIF6                     ((uint32_t)0x20041000)
    ; e/ C9 P1 }! A; ^) I+ J2 n
  36. #define DMA_IT_TEIF6                      ((uint32_t)0x20082000)$ K& r8 G( V- }3 k' f9 d* f, {
  37. #define DMA_IT_HTIF6                      ((uint32_t)0x20104000)" ^# Z; n: r, j+ a4 M
  38. #define DMA_IT_TCIF6                      ((uint32_t)0x20208000)
    4 Q& n* L9 x6 _; }1 J
  39. #define DMA_IT_FEIF7                      ((uint32_t)0xA0400000)
    ( {% _5 Z: ~# F1 a8 }
  40. #define DMA_IT_DMEIF7                     ((uint32_t)0x21001000)5 S# K" F  x* k- [: I. o# q% u* F
  41. #define DMA_IT_TEIF7                      ((uint32_t)0x22002000)
    2 }# [; d- s' N4 ?+ {' D3 U/ N+ Y
  42. #define DMA_IT_HTIF7                      ((uint32_t)0x24004000)
    % F2 T5 x( x. [
  43. #define DMA_IT_TCIF7                      ((uint32_t)0x28008000)+ M* x% W7 x  q" k
  44. ( X+ \* _9 m8 ~& L( z% c8 c
  45. #define IS_DMA_CLEAR_IT(IT) ((((IT) & 0x30000000) != 0x30000000) && \: M5 T: _( J3 e! T' c8 U% ]
  46.                              (((IT) & 0x30000000) != 0) && ((IT) != 0x00) && \
    " n- `, F- A+ B! g: W4 V- C6 Q# ]4 w% x
  47.                              (((IT) & 0x40820082) == 0x00))
    , f$ ~; q5 _! N# F. d

  48. 0 P( `0 A' Y; F
  49. #define IS_DMA_GET_IT(IT) (((IT) == DMA_IT_TCIF0) || ((IT) == DMA_IT_HTIF0)  || \
    " t  t+ W" h2 A( c( F
  50.                            ((IT) == DMA_IT_TEIF0) || ((IT) == DMA_IT_DMEIF0) || \+ C% _& M% t+ _
  51.                            ((IT) == DMA_IT_FEIF0) || ((IT) == DMA_IT_TCIF1)  || \
    . g' |: ^7 Z) H' M9 c
  52.                            ((IT) == DMA_IT_HTIF1) || ((IT) == DMA_IT_TEIF1)  || \# {" B7 E! ^: _1 q6 `
  53.                            ((IT) == DMA_IT_DMEIF1)|| ((IT) == DMA_IT_FEIF1)  || \
    0 m# a! n, S, W: Q
  54.                            ((IT) == DMA_IT_TCIF2) || ((IT) == DMA_IT_HTIF2)  || \
    . \5 @0 [. @# F2 O' S5 ?
  55.                            ((IT) == DMA_IT_TEIF2) || ((IT) == DMA_IT_DMEIF2) || \0 c/ n# h3 Z7 K2 F; X0 A  _
  56.                            ((IT) == DMA_IT_FEIF2) || ((IT) == DMA_IT_TCIF3)  || \
    6 a/ u/ I+ q/ [; B, V: F) i3 j0 I2 H
  57.                            ((IT) == DMA_IT_HTIF3) || ((IT) == DMA_IT_TEIF3)  || \6 t* X# w0 K6 K
  58.                            ((IT) == DMA_IT_DMEIF3)|| ((IT) == DMA_IT_FEIF3)  || \
    ; K4 ?1 k% ^, O
  59.                            ((IT) == DMA_IT_TCIF4) || ((IT) == DMA_IT_HTIF4)  || \: T! I5 U$ l0 i
  60.                            ((IT) == DMA_IT_TEIF4) || ((IT) == DMA_IT_DMEIF4) || \
    # a0 F9 G) q6 ]. ^1 R* s! D+ y) y
  61.                            ((IT) == DMA_IT_FEIF4) || ((IT) == DMA_IT_TCIF5)  || \! `7 r) Y: l) h- ?9 S1 R7 [" a  x
  62.                            ((IT) == DMA_IT_HTIF5) || ((IT) == DMA_IT_TEIF5)  || \
    2 b8 U3 o' ?, y& w4 o6 g( {" Q) M4 t2 _
  63.                            ((IT) == DMA_IT_DMEIF5)|| ((IT) == DMA_IT_FEIF5)  || \7 n6 F; z% ?; n2 m6 m, R9 _$ E
  64.                            ((IT) == DMA_IT_TCIF6) || ((IT) == DMA_IT_HTIF6)  || \6 v- h0 {2 d: I8 T' b
  65.                            ((IT) == DMA_IT_TEIF6) || ((IT) == DMA_IT_DMEIF6) || \
    & u" c7 w/ ~6 |' d2 E6 v3 A
  66.                            ((IT) == DMA_IT_FEIF6) || ((IT) == DMA_IT_TCIF7)  || \3 h9 z) y  y6 P% v2 M
  67.                            ((IT) == DMA_IT_HTIF7) || ((IT) == DMA_IT_TEIF7)  || \: U! B4 s5 w. |
  68.                            ((IT) == DMA_IT_DMEIF7)|| ((IT) == DMA_IT_FEIF7))
复制代码

1 z1 L# b: ]0 U4 A2 i" U( V1 QDMA_peripheral_increment_offset

4 n) m6 b8 v5 E3 g8 r) Z
  1. /** @defgroup DMA_peripheral_increment_offset
      y) K. C' w5 W' l3 f) D; a2 z# p
  2.   * @{
    4 m: P! b. _* b# X. b* D
  3.   */ 3 ]+ O# G8 f2 ]* x
  4. #define DMA_PINCOS_Psize                  ((uint32_t)0x00000000)
    $ o$ Q; R# S+ ]& R
  5. #define DMA_PINCOS_WordAligned            ((uint32_t)0x00008000): a- r) z6 m& m- h; Q  f" g' p

  6. 9 j& V) a5 f+ p- g* \
  7. #define IS_DMA_PINCOS_SIZE(SIZE) (((SIZE) == DMA_PINCOS_Psize) || \9 |. o+ P9 d- {6 p* U( s! G
  8.                                   ((SIZE) == DMA_PINCOS_WordAligned))
复制代码
# s- D; R: Z1 T
controller_definitions
  1. /** @defgroup DMA_flow_controller_definitions ! o7 B; J* Q7 u& T" E; P: {4 G2 E
  2.   * @{
    * w8 \9 ]8 m' `* r
  3.   */
    ( U. O: b0 v& o/ g% B
  4. #define DMA_FlowCtrl_Memory               ((uint32_t)0x00000000)2 N0 J+ D8 `6 [- b$ B* X$ r4 S
  5. #define DMA_FlowCtrl_Peripheral           ((uint32_t)0x00000020)
    * Q, j1 f3 Y) e

  6. 0 r; k9 p1 }4 c1 L. d
  7. #define IS_DMA_FLOW_CTRL(CTRL) (((CTRL) == DMA_FlowCtrl_Memory) || \* e! G7 M+ z/ R% P; {. M& E
  8.                                 ((CTRL) == DMA_FlowCtrl_Peripheral))
复制代码

3 q2 v9 K0 _1 _DMA_memory_targets_definitions
2 q$ X6 p" v" j) z$ Z7 w

5 y. f8 ?$ {. T, w
  1. /** @defgroup DMA_memory_targets_definitions " w6 n4 o  }7 C- R
  2.   * @{% }8 y. P+ c6 d: o5 I
  3.   */ ) ^  V7 U' Z4 _3 H
  4. #define DMA_Memory_0                      ((uint32_t)0x00000000)
    - a& O" J% m- I  A
  5. #define DMA_Memory_1                      ((uint32_t)0x00080000)) S, X% Y$ G2 ?! F1 Z3 J
  6. ; X# n8 l6 ?7 \/ b
  7. #define IS_DMA_CURRENT_MEM(MEM) (((MEM) == DMA_Memory_0) || ((MEM) == DMA_Memory_1))
复制代码

* ^$ d6 E" D6 ^* w2 F% x0 m; z" c) i5 U1 D' v6 u$ J: j
03. 相关函数
/ o% o8 {% E+ s  Y
  1. /* Exported macro ------------------------------------------------------------*/
    , X( D4 |3 w3 }8 ~( Q7 x; M1 k
  2. /* Exported functions --------------------------------------------------------*/ ) p1 {/ \/ ^* C8 {. g8 ~
  3. , I0 K, W8 o( C+ e% M
  4. /*  Function used to set the DMA configuration to the default reset state *****/
    $ N) L5 `# k6 l- B' w
  5. void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx);4 G2 G6 N- f+ B" ?

  6. 7 [" i4 J1 k; a5 T9 D0 }
  7. /* Initialization and Configuration functions *********************************/
      {* _0 b9 h5 _; i
  8. void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct);
    , m$ F0 G9 D; m7 b6 g6 x( }
  9. void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);, r) ]$ V8 q, l9 P
  10. void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);
    & V  k, t5 f0 y/ A: O

  11. 8 D. H2 ~/ U8 P( N) i4 n
  12. /* Optional Configuration functions *******************************************/, n- x8 [' [8 z6 |. h
  13. void DMA_PeriphIncOffsetSizeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_Pincos);
    ' ^7 w4 k8 @1 x
  14. void DMA_FlowControllerConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FlowCtrl);
      n, Z+ l) s$ I
  15. % ~5 i/ [, h8 F  L, q& m
  16. /* Data Counter functions *****************************************************/
    ' Z3 J0 S3 s) h. d
  17. void DMA_SetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx, uint16_t Counter);
    . X  H* C8 u8 h( s* U/ G1 o$ g! b
  18. uint16_t DMA_GetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx);, T) G. [; [' ?- r/ {' E4 J
  19. / ]. B9 h2 v, g1 ^
  20. /* Double Buffer mode functions ***********************************************/
    8 V5 l0 k, y% ~* ~
  21. void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t Memory1BaseAddr,* o" o- u4 {/ d. Y; t2 Y$ e$ S
  22.                                 uint32_t DMA_CurrentMemory);
    . T3 N+ e# [. E) o4 y( q( Y
  23. void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);' Z& f$ [' b7 s/ e% \% o
  24. void DMA_MemoryTargetConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t MemoryBaseAddr,
    3 R  s! D% [# {1 R# N8 f
  25.                             uint32_t DMA_MemoryTarget);
    " k1 k5 H; S. O) E7 f+ s7 t! c2 @
  26. uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef* DMAy_Streamx);2 z. V6 j0 U0 w4 `! K
  27. 0 k. }- Z+ g( T, i5 G
  28. /* Interrupts and flags management functions **********************************/
    0 F+ J- Z- }" B! _  P8 K, }
  29. FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef* DMAy_Streamx);0 H9 P; E, B( x1 s' R: }
  30. uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef* DMAy_Streamx);
    / S, B" q, }  {
  31. FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);; [, L2 T& z! b- Q
  32. void DMA_ClearFlag(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);# D8 ]. w) c7 V% p2 t; A
  33. void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState);
    7 f  ?9 [3 e1 C! B" I* i* D
  34. ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);/ N0 Z4 L7 {+ f, N8 B  k
  35. void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);; W, L7 y; A- d! l

  36. . k. z- m" A# a% M1 _
复制代码
8 g; A( F" m4 x0 K" B! ^
04. 结构体封装
4 @' A- q: G# [+ v) W5 g
  1. /**
    % `  S+ ^3 F; b
  2.   * @brief DMA Controller8 I9 k; j7 }2 t4 x9 v% N" w; T( M
  3.   */
    . q' F/ ?1 M7 w) L3 J
  4. # I4 U, ?' m. x5 D9 w( u
  5. typedef struct, _$ V4 i! w; p  I' n
  6. {+ _! C2 ?0 p! {
  7.   __IO uint32_t CR;     /*!< DMA stream x configuration register      */
    # W7 Z2 g+ {+ s0 O
  8.   __IO uint32_t NDTR;   /*!< DMA stream x number of data register     *// K  Y! Y1 W0 ^& e5 j/ o
  9.   __IO uint32_t PAR;    /*!< DMA stream x peripheral address register */4 M4 R: g7 p( l/ ~( L
  10.   __IO uint32_t M0AR;   /*!< DMA stream x memory 0 address register   */
    ) ?* D0 B7 W) g3 H7 e. i
  11.   __IO uint32_t M1AR;   /*!< DMA stream x memory 1 address register   */, o; @! f' I( n' S
  12.   __IO uint32_t FCR;    /*!< DMA stream x FIFO control register       */! A: o/ {/ G( U
  13. } DMA_Stream_TypeDef;+ T- `; l9 Q+ K+ k3 @! G

  14. : f& N# Z% [7 x6 b# z
  15. typedef struct: u% W+ m, ?) e' z. C
  16. {
    9 p$ K2 Z. W% O! l- W- y
  17.   __IO uint32_t LISR;   /*!< DMA low interrupt status register,      Address offset: 0x00 */6 r5 J% X% a- S- `7 L5 b
  18.   __IO uint32_t HISR;   /*!< DMA high interrupt status register,     Address offset: 0x04 */6 f4 K4 ^1 b$ O" P
  19.   __IO uint32_t LIFCR;  /*!< DMA low interrupt flag clear register,  Address offset: 0x08 */3 w1 ^, S# P7 C$ h/ I5 A
  20.   __IO uint32_t HIFCR;  /*!< DMA high interrupt flag clear register, Address offset: 0x0C */% x- G" l) F( \0 A
  21. } DMA_TypeDef;
复制代码
. y* n* X: V5 W5 X+ x6 C

- I! S  n( v. N1 B
6 [( s  O: y! a9 t* H4 t8 M1 K3 b, f6 L+ S& K' ]
赞 收藏 评论0 发布时间:2022-3-28 22:00

举报

0个回答

所属标签

相似技术帖

官网相关资源

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