stm32f4xx_dma.h 28 KB

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