stm32f2xx_dma.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_dma.h
  4. * @author MCD Application Team
  5. * @version V1.1.3
  6. * @date 31-December-2021
  7. * @brief This file contains all the functions prototypes for the DMA firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2012 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F2xx_DMA_H
  23. #define __STM32F2xx_DMA_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f2xx.h"
  29. /** @addtogroup STM32F2xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup DMA
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /**
  37. * @brief DMA Init structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t DMA_Channel; /*!< Specifies the channel used for the specified stream.
  42. This parameter can be a value of @ref DMA_channel */
  43. uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Streamx. */
  44. uint32_t DMA_Memory0BaseAddr; /*!< Specifies the memory 0 base address for DMAy Streamx.
  45. This memory is the default memory used when double buffer mode is
  46. not enabled. */
  47. uint32_t DMA_DIR; /*!< Specifies if the data will be transferred from memory to peripheral,
  48. from memory to memory or from peripheral to memory.
  49. This parameter can be a value of @ref DMA_data_transfer_direction */
  50. uint32_t DMA_BufferSize; /*!< Specifies the buffer size, in data unit, of the specified Stream.
  51. The data unit is equal to the configuration set in DMA_PeripheralDataSize
  52. or DMA_MemoryDataSize members depending in the transfer direction. */
  53. uint32_t DMA_PeripheralInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
  54. This parameter can be a value of @ref DMA_peripheral_incremented_mode */
  55. uint32_t DMA_MemoryInc; /*!< Specifies whether the memory address register should be incremented or not.
  56. This parameter can be a value of @ref DMA_memory_incremented_mode */
  57. uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.
  58. This parameter can be a value of @ref DMA_peripheral_data_size */
  59. uint32_t DMA_MemoryDataSize; /*!< Specifies the Memory data width.
  60. This parameter can be a value of @ref DMA_memory_data_size */
  61. uint32_t DMA_Mode; /*!< Specifies the operation mode of the DMAy Streamx.
  62. This parameter can be a value of @ref DMA_circular_normal_mode
  63. @note The circular buffer mode cannot be used if the memory-to-memory
  64. data transfer is configured on the selected Stream */
  65. uint32_t DMA_Priority; /*!< Specifies the software priority for the DMAy Streamx.
  66. This parameter can be a value of @ref DMA_priority_level */
  67. uint32_t DMA_FIFOMode; /*!< Specifies if the FIFO mode or Direct mode will be used for the specified Stream.
  68. This parameter can be a value of @ref DMA_fifo_direct_mode
  69. @note The Direct mode (FIFO mode disabled) cannot be used if the
  70. memory-to-memory data transfer is configured on the selected Stream */
  71. uint32_t DMA_FIFOThreshold; /*!< Specifies the FIFO threshold level.
  72. This parameter can be a value of @ref DMA_fifo_threshold_level */
  73. uint32_t DMA_MemoryBurst; /*!< Specifies the Burst transfer configuration for the memory transfers.
  74. It specifies the amount of data to be transferred in a single non interruptable
  75. transaction. This parameter can be a value of @ref DMA_memory_burst
  76. @note The burst mode is possible only if the address Increment mode is enabled. */
  77. uint32_t DMA_PeripheralBurst; /*!< Specifies the Burst transfer configuration for the peripheral transfers.
  78. It specifies the amount of data to be transferred in a single non interruptable
  79. transaction. This parameter can be a value of @ref DMA_peripheral_burst
  80. @note The burst mode is possible only if the address Increment mode is enabled. */
  81. }DMA_InitTypeDef;
  82. /* Exported constants --------------------------------------------------------*/
  83. /** @defgroup DMA_Exported_Constants
  84. * @{
  85. */
  86. #define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Stream0) || \
  87. ((PERIPH) == DMA1_Stream1) || \
  88. ((PERIPH) == DMA1_Stream2) || \
  89. ((PERIPH) == DMA1_Stream3) || \
  90. ((PERIPH) == DMA1_Stream4) || \
  91. ((PERIPH) == DMA1_Stream5) || \
  92. ((PERIPH) == DMA1_Stream6) || \
  93. ((PERIPH) == DMA1_Stream7) || \
  94. ((PERIPH) == DMA2_Stream0) || \
  95. ((PERIPH) == DMA2_Stream1) || \
  96. ((PERIPH) == DMA2_Stream2) || \
  97. ((PERIPH) == DMA2_Stream3) || \
  98. ((PERIPH) == DMA2_Stream4) || \
  99. ((PERIPH) == DMA2_Stream5) || \
  100. ((PERIPH) == DMA2_Stream6) || \
  101. ((PERIPH) == DMA2_Stream7))
  102. #define IS_DMA_ALL_CONTROLLER(CONTROLLER) (((CONTROLLER) == DMA1) || \
  103. ((CONTROLLER) == DMA2))
  104. /** @defgroup DMA_channel
  105. * @{
  106. */
  107. #define DMA_Channel_0 ((uint32_t)0x00000000)
  108. #define DMA_Channel_1 ((uint32_t)0x02000000)
  109. #define DMA_Channel_2 ((uint32_t)0x04000000)
  110. #define DMA_Channel_3 ((uint32_t)0x06000000)
  111. #define DMA_Channel_4 ((uint32_t)0x08000000)
  112. #define DMA_Channel_5 ((uint32_t)0x0A000000)
  113. #define DMA_Channel_6 ((uint32_t)0x0C000000)
  114. #define DMA_Channel_7 ((uint32_t)0x0E000000)
  115. #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_Channel_0) || \
  116. ((CHANNEL) == DMA_Channel_1) || \
  117. ((CHANNEL) == DMA_Channel_2) || \
  118. ((CHANNEL) == DMA_Channel_3) || \
  119. ((CHANNEL) == DMA_Channel_4) || \
  120. ((CHANNEL) == DMA_Channel_5) || \
  121. ((CHANNEL) == DMA_Channel_6) || \
  122. ((CHANNEL) == DMA_Channel_7))
  123. /**
  124. * @}
  125. */
  126. /** @defgroup DMA_data_transfer_direction
  127. * @{
  128. */
  129. #define DMA_DIR_PeripheralToMemory ((uint32_t)0x00000000)
  130. #define DMA_DIR_MemoryToPeripheral ((uint32_t)0x00000040)
  131. #define DMA_DIR_MemoryToMemory ((uint32_t)0x00000080)
  132. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_DIR_PeripheralToMemory ) || \
  133. ((DIRECTION) == DMA_DIR_MemoryToPeripheral) || \
  134. ((DIRECTION) == DMA_DIR_MemoryToMemory))
  135. /**
  136. * @}
  137. */
  138. /** @defgroup DMA_data_buffer_size
  139. * @{
  140. */
  141. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
  142. /**
  143. * @}
  144. */
  145. /** @defgroup DMA_peripheral_incremented_mode
  146. * @{
  147. */
  148. #define DMA_PeripheralInc_Enable ((uint32_t)0x00000200)
  149. #define DMA_PeripheralInc_Disable ((uint32_t)0x00000000)
  150. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \
  151. ((STATE) == DMA_PeripheralInc_Disable))
  152. /**
  153. * @}
  154. */
  155. /** @defgroup DMA_memory_incremented_mode
  156. * @{
  157. */
  158. #define DMA_MemoryInc_Enable ((uint32_t)0x00000400)
  159. #define DMA_MemoryInc_Disable ((uint32_t)0x00000000)
  160. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \
  161. ((STATE) == DMA_MemoryInc_Disable))
  162. /**
  163. * @}
  164. */
  165. /** @defgroup DMA_peripheral_data_size
  166. * @{
  167. */
  168. #define DMA_PeripheralDataSize_Byte ((uint32_t)0x00000000)
  169. #define DMA_PeripheralDataSize_HalfWord ((uint32_t)0x00000800)
  170. #define DMA_PeripheralDataSize_Word ((uint32_t)0x00001000)
  171. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte) || \
  172. ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \
  173. ((SIZE) == DMA_PeripheralDataSize_Word))
  174. /**
  175. * @}
  176. */
  177. /** @defgroup DMA_memory_data_size
  178. * @{
  179. */
  180. #define DMA_MemoryDataSize_Byte ((uint32_t)0x00000000)
  181. #define DMA_MemoryDataSize_HalfWord ((uint32_t)0x00002000)
  182. #define DMA_MemoryDataSize_Word ((uint32_t)0x00004000)
  183. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte) || \
  184. ((SIZE) == DMA_MemoryDataSize_HalfWord) || \
  185. ((SIZE) == DMA_MemoryDataSize_Word ))
  186. /**
  187. * @}
  188. */
  189. /** @defgroup DMA_circular_normal_mode
  190. * @{
  191. */
  192. #define DMA_Mode_Normal ((uint32_t)0x00000000)
  193. #define DMA_Mode_Circular ((uint32_t)0x00000100)
  194. #define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Normal ) || \
  195. ((MODE) == DMA_Mode_Circular))
  196. /**
  197. * @}
  198. */
  199. /** @defgroup DMA_priority_level
  200. * @{
  201. */
  202. #define DMA_Priority_Low ((uint32_t)0x00000000)
  203. #define DMA_Priority_Medium ((uint32_t)0x00010000)
  204. #define DMA_Priority_High ((uint32_t)0x00020000)
  205. #define DMA_Priority_VeryHigh ((uint32_t)0x00030000)
  206. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_Low ) || \
  207. ((PRIORITY) == DMA_Priority_Medium) || \
  208. ((PRIORITY) == DMA_Priority_High) || \
  209. ((PRIORITY) == DMA_Priority_VeryHigh))
  210. /**
  211. * @}
  212. */
  213. /** @defgroup DMA_fifo_direct_mode
  214. * @{
  215. */
  216. #define DMA_FIFOMode_Disable ((uint32_t)0x00000000)
  217. #define DMA_FIFOMode_Enable ((uint32_t)0x00000004)
  218. #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMode_Disable ) || \
  219. ((STATE) == DMA_FIFOMode_Enable))
  220. /**
  221. * @}
  222. */
  223. /** @defgroup DMA_fifo_threshold_level
  224. * @{
  225. */
  226. #define DMA_FIFOThreshold_1QuarterFull ((uint32_t)0x00000000)
  227. #define DMA_FIFOThreshold_HalfFull ((uint32_t)0x00000001)
  228. #define DMA_FIFOThreshold_3QuartersFull ((uint32_t)0x00000002)
  229. #define DMA_FIFOThreshold_Full ((uint32_t)0x00000003)
  230. #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFOThreshold_1QuarterFull ) || \
  231. ((THRESHOLD) == DMA_FIFOThreshold_HalfFull) || \
  232. ((THRESHOLD) == DMA_FIFOThreshold_3QuartersFull) || \
  233. ((THRESHOLD) == DMA_FIFOThreshold_Full))
  234. /**
  235. * @}
  236. */
  237. /** @defgroup DMA_memory_burst
  238. * @{
  239. */
  240. #define DMA_MemoryBurst_Single ((uint32_t)0x00000000)
  241. #define DMA_MemoryBurst_INC4 ((uint32_t)0x00800000)
  242. #define DMA_MemoryBurst_INC8 ((uint32_t)0x01000000)
  243. #define DMA_MemoryBurst_INC16 ((uint32_t)0x01800000)
  244. #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MemoryBurst_Single) || \
  245. ((BURST) == DMA_MemoryBurst_INC4) || \
  246. ((BURST) == DMA_MemoryBurst_INC8) || \
  247. ((BURST) == DMA_MemoryBurst_INC16))
  248. /**
  249. * @}
  250. */
  251. /** @defgroup DMA_peripheral_burst
  252. * @{
  253. */
  254. #define DMA_PeripheralBurst_Single ((uint32_t)0x00000000)
  255. #define DMA_PeripheralBurst_INC4 ((uint32_t)0x00200000)
  256. #define DMA_PeripheralBurst_INC8 ((uint32_t)0x00400000)
  257. #define DMA_PeripheralBurst_INC16 ((uint32_t)0x00600000)
  258. #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PeripheralBurst_Single) || \
  259. ((BURST) == DMA_PeripheralBurst_INC4) || \
  260. ((BURST) == DMA_PeripheralBurst_INC8) || \
  261. ((BURST) == DMA_PeripheralBurst_INC16))
  262. /**
  263. * @}
  264. */
  265. /** @defgroup DMA_fifo_status_level
  266. * @{
  267. */
  268. #define DMA_FIFOStatus_Less1QuarterFull ((uint32_t)0x00000000 << 3)
  269. #define DMA_FIFOStatus_1QuarterFull ((uint32_t)0x00000001 << 3)
  270. #define DMA_FIFOStatus_HalfFull ((uint32_t)0x00000002 << 3)
  271. #define DMA_FIFOStatus_3QuartersFull ((uint32_t)0x00000003 << 3)
  272. #define DMA_FIFOStatus_Empty ((uint32_t)0x00000004 << 3)
  273. #define DMA_FIFOStatus_Full ((uint32_t)0x00000005 << 3)
  274. #define IS_DMA_FIFO_STATUS(STATUS) (((STATUS) == DMA_FIFOStatus_Less1QuarterFull ) || \
  275. ((STATUS) == DMA_FIFOStatus_HalfFull) || \
  276. ((STATUS) == DMA_FIFOStatus_1QuarterFull) || \
  277. ((STATUS) == DMA_FIFOStatus_3QuartersFull) || \
  278. ((STATUS) == DMA_FIFOStatus_Full) || \
  279. ((STATUS) == DMA_FIFOStatus_Empty))
  280. /**
  281. * @}
  282. */
  283. /** @defgroup DMA_flags_definition
  284. * @{
  285. */
  286. #define DMA_FLAG_FEIF0 ((uint32_t)0x10800001)
  287. #define DMA_FLAG_DMEIF0 ((uint32_t)0x10800004)
  288. #define DMA_FLAG_TEIF0 ((uint32_t)0x10000008)
  289. #define DMA_FLAG_HTIF0 ((uint32_t)0x10000010)
  290. #define DMA_FLAG_TCIF0 ((uint32_t)0x10000020)
  291. #define DMA_FLAG_FEIF1 ((uint32_t)0x10000040)
  292. #define DMA_FLAG_DMEIF1 ((uint32_t)0x10000100)
  293. #define DMA_FLAG_TEIF1 ((uint32_t)0x10000200)
  294. #define DMA_FLAG_HTIF1 ((uint32_t)0x10000400)
  295. #define DMA_FLAG_TCIF1 ((uint32_t)0x10000800)
  296. #define DMA_FLAG_FEIF2 ((uint32_t)0x10010000)
  297. #define DMA_FLAG_DMEIF2 ((uint32_t)0x10040000)
  298. #define DMA_FLAG_TEIF2 ((uint32_t)0x10080000)
  299. #define DMA_FLAG_HTIF2 ((uint32_t)0x10100000)
  300. #define DMA_FLAG_TCIF2 ((uint32_t)0x10200000)
  301. #define DMA_FLAG_FEIF3 ((uint32_t)0x10400000)
  302. #define DMA_FLAG_DMEIF3 ((uint32_t)0x11000000)
  303. #define DMA_FLAG_TEIF3 ((uint32_t)0x12000000)
  304. #define DMA_FLAG_HTIF3 ((uint32_t)0x14000000)
  305. #define DMA_FLAG_TCIF3 ((uint32_t)0x18000000)
  306. #define DMA_FLAG_FEIF4 ((uint32_t)0x20000001)
  307. #define DMA_FLAG_DMEIF4 ((uint32_t)0x20000004)
  308. #define DMA_FLAG_TEIF4 ((uint32_t)0x20000008)
  309. #define DMA_FLAG_HTIF4 ((uint32_t)0x20000010)
  310. #define DMA_FLAG_TCIF4 ((uint32_t)0x20000020)
  311. #define DMA_FLAG_FEIF5 ((uint32_t)0x20000040)
  312. #define DMA_FLAG_DMEIF5 ((uint32_t)0x20000100)
  313. #define DMA_FLAG_TEIF5 ((uint32_t)0x20000200)
  314. #define DMA_FLAG_HTIF5 ((uint32_t)0x20000400)
  315. #define DMA_FLAG_TCIF5 ((uint32_t)0x20000800)
  316. #define DMA_FLAG_FEIF6 ((uint32_t)0x20010000)
  317. #define DMA_FLAG_DMEIF6 ((uint32_t)0x20040000)
  318. #define DMA_FLAG_TEIF6 ((uint32_t)0x20080000)
  319. #define DMA_FLAG_HTIF6 ((uint32_t)0x20100000)
  320. #define DMA_FLAG_TCIF6 ((uint32_t)0x20200000)
  321. #define DMA_FLAG_FEIF7 ((uint32_t)0x20400000)
  322. #define DMA_FLAG_DMEIF7 ((uint32_t)0x21000000)
  323. #define DMA_FLAG_TEIF7 ((uint32_t)0x22000000)
  324. #define DMA_FLAG_HTIF7 ((uint32_t)0x24000000)
  325. #define DMA_FLAG_TCIF7 ((uint32_t)0x28000000)
  326. #define IS_DMA_CLEAR_FLAG(FLAG) ((((FLAG) & 0x30000000) != 0x30000000) && (((FLAG) & 0x30000000) != 0) && \
  327. (((FLAG) & 0xC082F082) == 0x00) && ((FLAG) != 0x00))
  328. #define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA_FLAG_TCIF0) || ((FLAG) == DMA_FLAG_HTIF0) || \
  329. ((FLAG) == DMA_FLAG_TEIF0) || ((FLAG) == DMA_FLAG_DMEIF0) || \
  330. ((FLAG) == DMA_FLAG_FEIF0) || ((FLAG) == DMA_FLAG_TCIF1) || \
  331. ((FLAG) == DMA_FLAG_HTIF1) || ((FLAG) == DMA_FLAG_TEIF1) || \
  332. ((FLAG) == DMA_FLAG_DMEIF1) || ((FLAG) == DMA_FLAG_FEIF1) || \
  333. ((FLAG) == DMA_FLAG_TCIF2) || ((FLAG) == DMA_FLAG_HTIF2) || \
  334. ((FLAG) == DMA_FLAG_TEIF2) || ((FLAG) == DMA_FLAG_DMEIF2) || \
  335. ((FLAG) == DMA_FLAG_FEIF2) || ((FLAG) == DMA_FLAG_TCIF3) || \
  336. ((FLAG) == DMA_FLAG_HTIF3) || ((FLAG) == DMA_FLAG_TEIF3) || \
  337. ((FLAG) == DMA_FLAG_DMEIF3) || ((FLAG) == DMA_FLAG_FEIF3) || \
  338. ((FLAG) == DMA_FLAG_TCIF4) || ((FLAG) == DMA_FLAG_HTIF4) || \
  339. ((FLAG) == DMA_FLAG_TEIF4) || ((FLAG) == DMA_FLAG_DMEIF4) || \
  340. ((FLAG) == DMA_FLAG_FEIF4) || ((FLAG) == DMA_FLAG_TCIF5) || \
  341. ((FLAG) == DMA_FLAG_HTIF5) || ((FLAG) == DMA_FLAG_TEIF5) || \
  342. ((FLAG) == DMA_FLAG_DMEIF5) || ((FLAG) == DMA_FLAG_FEIF5) || \
  343. ((FLAG) == DMA_FLAG_TCIF6) || ((FLAG) == DMA_FLAG_HTIF6) || \
  344. ((FLAG) == DMA_FLAG_TEIF6) || ((FLAG) == DMA_FLAG_DMEIF6) || \
  345. ((FLAG) == DMA_FLAG_FEIF6) || ((FLAG) == DMA_FLAG_TCIF7) || \
  346. ((FLAG) == DMA_FLAG_HTIF7) || ((FLAG) == DMA_FLAG_TEIF7) || \
  347. ((FLAG) == DMA_FLAG_DMEIF7) || ((FLAG) == DMA_FLAG_FEIF7))
  348. /**
  349. * @}
  350. */
  351. /** @defgroup DMA_interrupt_enable_definitions
  352. * @{
  353. */
  354. #define DMA_IT_TC ((uint32_t)0x00000010)
  355. #define DMA_IT_HT ((uint32_t)0x00000008)
  356. #define DMA_IT_TE ((uint32_t)0x00000004)
  357. #define DMA_IT_DME ((uint32_t)0x00000002)
  358. #define DMA_IT_FE ((uint32_t)0x00000080)
  359. #define IS_DMA_CONFIG_IT(IT) ((((IT) & 0xFFFFFF61) == 0x00) && ((IT) != 0x00))
  360. /**
  361. * @}
  362. */
  363. /** @defgroup DMA_interrupts_definitions
  364. * @{
  365. */
  366. #define DMA_IT_FEIF0 ((uint32_t)0x90000001)
  367. #define DMA_IT_DMEIF0 ((uint32_t)0x10001004)
  368. #define DMA_IT_TEIF0 ((uint32_t)0x10002008)
  369. #define DMA_IT_HTIF0 ((uint32_t)0x10004010)
  370. #define DMA_IT_TCIF0 ((uint32_t)0x10008020)
  371. #define DMA_IT_FEIF1 ((uint32_t)0x90000040)
  372. #define DMA_IT_DMEIF1 ((uint32_t)0x10001100)
  373. #define DMA_IT_TEIF1 ((uint32_t)0x10002200)
  374. #define DMA_IT_HTIF1 ((uint32_t)0x10004400)
  375. #define DMA_IT_TCIF1 ((uint32_t)0x10008800)
  376. #define DMA_IT_FEIF2 ((uint32_t)0x90010000)
  377. #define DMA_IT_DMEIF2 ((uint32_t)0x10041000)
  378. #define DMA_IT_TEIF2 ((uint32_t)0x10082000)
  379. #define DMA_IT_HTIF2 ((uint32_t)0x10104000)
  380. #define DMA_IT_TCIF2 ((uint32_t)0x10208000)
  381. #define DMA_IT_FEIF3 ((uint32_t)0x90400000)
  382. #define DMA_IT_DMEIF3 ((uint32_t)0x11001000)
  383. #define DMA_IT_TEIF3 ((uint32_t)0x12002000)
  384. #define DMA_IT_HTIF3 ((uint32_t)0x14004000)
  385. #define DMA_IT_TCIF3 ((uint32_t)0x18008000)
  386. #define DMA_IT_FEIF4 ((uint32_t)0xA0000001)
  387. #define DMA_IT_DMEIF4 ((uint32_t)0x20001004)
  388. #define DMA_IT_TEIF4 ((uint32_t)0x20002008)
  389. #define DMA_IT_HTIF4 ((uint32_t)0x20004010)
  390. #define DMA_IT_TCIF4 ((uint32_t)0x20008020)
  391. #define DMA_IT_FEIF5 ((uint32_t)0xA0000040)
  392. #define DMA_IT_DMEIF5 ((uint32_t)0x20001100)
  393. #define DMA_IT_TEIF5 ((uint32_t)0x20002200)
  394. #define DMA_IT_HTIF5 ((uint32_t)0x20004400)
  395. #define DMA_IT_TCIF5 ((uint32_t)0x20008800)
  396. #define DMA_IT_FEIF6 ((uint32_t)0xA0010000)
  397. #define DMA_IT_DMEIF6 ((uint32_t)0x20041000)
  398. #define DMA_IT_TEIF6 ((uint32_t)0x20082000)
  399. #define DMA_IT_HTIF6 ((uint32_t)0x20104000)
  400. #define DMA_IT_TCIF6 ((uint32_t)0x20208000)
  401. #define DMA_IT_FEIF7 ((uint32_t)0xA0400000)
  402. #define DMA_IT_DMEIF7 ((uint32_t)0x21001000)
  403. #define DMA_IT_TEIF7 ((uint32_t)0x22002000)
  404. #define DMA_IT_HTIF7 ((uint32_t)0x24004000)
  405. #define DMA_IT_TCIF7 ((uint32_t)0x28008000)
  406. #define IS_DMA_CLEAR_IT(IT) ((((IT) & 0x30000000) != 0x30000000) && \
  407. (((IT) & 0x30000000) != 0) && ((IT) != 0x00) && \
  408. (((IT) & 0x40820082) == 0x00))
  409. #define IS_DMA_GET_IT(IT) (((IT) == DMA_IT_TCIF0) || ((IT) == DMA_IT_HTIF0) || \
  410. ((IT) == DMA_IT_TEIF0) || ((IT) == DMA_IT_DMEIF0) || \
  411. ((IT) == DMA_IT_FEIF0) || ((IT) == DMA_IT_TCIF1) || \
  412. ((IT) == DMA_IT_HTIF1) || ((IT) == DMA_IT_TEIF1) || \
  413. ((IT) == DMA_IT_DMEIF1)|| ((IT) == DMA_IT_FEIF1) || \
  414. ((IT) == DMA_IT_TCIF2) || ((IT) == DMA_IT_HTIF2) || \
  415. ((IT) == DMA_IT_TEIF2) || ((IT) == DMA_IT_DMEIF2) || \
  416. ((IT) == DMA_IT_FEIF2) || ((IT) == DMA_IT_TCIF3) || \
  417. ((IT) == DMA_IT_HTIF3) || ((IT) == DMA_IT_TEIF3) || \
  418. ((IT) == DMA_IT_DMEIF3)|| ((IT) == DMA_IT_FEIF3) || \
  419. ((IT) == DMA_IT_TCIF4) || ((IT) == DMA_IT_HTIF4) || \
  420. ((IT) == DMA_IT_TEIF4) || ((IT) == DMA_IT_DMEIF4) || \
  421. ((IT) == DMA_IT_FEIF4) || ((IT) == DMA_IT_TCIF5) || \
  422. ((IT) == DMA_IT_HTIF5) || ((IT) == DMA_IT_TEIF5) || \
  423. ((IT) == DMA_IT_DMEIF5)|| ((IT) == DMA_IT_FEIF5) || \
  424. ((IT) == DMA_IT_TCIF6) || ((IT) == DMA_IT_HTIF6) || \
  425. ((IT) == DMA_IT_TEIF6) || ((IT) == DMA_IT_DMEIF6) || \
  426. ((IT) == DMA_IT_FEIF6) || ((IT) == DMA_IT_TCIF7) || \
  427. ((IT) == DMA_IT_HTIF7) || ((IT) == DMA_IT_TEIF7) || \
  428. ((IT) == DMA_IT_DMEIF7)|| ((IT) == DMA_IT_FEIF7))
  429. /**
  430. * @}
  431. */
  432. /** @defgroup DMA_peripheral_increment_offset
  433. * @{
  434. */
  435. #define DMA_PINCOS_Psize ((uint32_t)0x00000000)
  436. #define DMA_PINCOS_WordAligned ((uint32_t)0x00008000)
  437. #define IS_DMA_PINCOS_SIZE(SIZE) (((SIZE) == DMA_PINCOS_Psize) || \
  438. ((SIZE) == DMA_PINCOS_WordAligned))
  439. /**
  440. * @}
  441. */
  442. /** @defgroup DMA_flow_controller_definitions
  443. * @{
  444. */
  445. #define DMA_FlowCtrl_Memory ((uint32_t)0x00000000)
  446. #define DMA_FlowCtrl_Peripheral ((uint32_t)0x00000020)
  447. #define IS_DMA_FLOW_CTRL(CTRL) (((CTRL) == DMA_FlowCtrl_Memory) || \
  448. ((CTRL) == DMA_FlowCtrl_Peripheral))
  449. /**
  450. * @}
  451. */
  452. /** @defgroup DMA_memory_targets_definitions
  453. * @{
  454. */
  455. #define DMA_Memory_0 ((uint32_t)0x00000000)
  456. #define DMA_Memory_1 ((uint32_t)0x00080000)
  457. #define IS_DMA_CURRENT_MEM(MEM) (((MEM) == DMA_Memory_0) || ((MEM) == DMA_Memory_1))
  458. /**
  459. * @}
  460. */
  461. /**
  462. * @}
  463. */
  464. /* Exported macro ------------------------------------------------------------*/
  465. /* Exported functions --------------------------------------------------------*/
  466. /* Function used to set the DMA configuration to the default reset state *****/
  467. void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx);
  468. /* Initialization and Configuration functions *********************************/
  469. void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct);
  470. void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);
  471. void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);
  472. /* Optional Configuration functions *******************************************/
  473. void DMA_PeriphIncOffsetSizeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_Pincos);
  474. void DMA_FlowControllerConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FlowCtrl);
  475. /* Data Counter functions *****************************************************/
  476. void DMA_SetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx, uint16_t Counter);
  477. uint16_t DMA_GetCurrDataCounter(DMA_Stream_TypeDef* DMAy_Streamx);
  478. /* Double Buffer mode functions ***********************************************/
  479. void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t Memory1BaseAddr,
  480. uint32_t DMA_CurrentMemory);
  481. void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);
  482. void DMA_MemoryTargetConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t MemoryBaseAddr,
  483. uint32_t DMA_MemoryTarget);
  484. uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef* DMAy_Streamx);
  485. /* Interrupts and flags management functions **********************************/
  486. FunctionalState DMA_GetCmdStatus(DMA_Stream_TypeDef* DMAy_Streamx);
  487. uint32_t DMA_GetFIFOStatus(DMA_Stream_TypeDef* DMAy_Streamx);
  488. FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);
  489. void DMA_ClearFlag(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG);
  490. void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState);
  491. ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);
  492. void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT);
  493. #ifdef __cplusplus
  494. }
  495. #endif
  496. #endif /*__STM32F2xx_DMA_H */
  497. /**
  498. * @}
  499. */
  500. /**
  501. * @}
  502. */