stm32f4xx_hal_dma.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_dma.h
  4. * @author MCD Application Team
  5. * @version V1.7.0
  6. * @date 17-February-2017
  7. * @brief Header file of DMA HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_HAL_DMA_H
  39. #define __STM32F4xx_HAL_DMA_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f4xx_hal_def.h"
  45. /** @addtogroup STM32F4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup DMA
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup DMA_Exported_Types DMA Exported Types
  53. * @brief DMA Exported Types
  54. * @{
  55. */
  56. /**
  57. * @brief DMA Configuration Structure definition
  58. */
  59. typedef struct
  60. {
  61. uint32_t Channel; /*!< Specifies the channel used for the specified stream.
  62. This parameter can be a value of @ref DMA_Channel_selection */
  63. uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
  64. from memory to memory or from peripheral to memory.
  65. This parameter can be a value of @ref DMA_Data_transfer_direction */
  66. uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
  67. This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
  68. uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not.
  69. This parameter can be a value of @ref DMA_Memory_incremented_mode */
  70. uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width.
  71. This parameter can be a value of @ref DMA_Peripheral_data_size */
  72. uint32_t MemDataAlignment; /*!< Specifies the Memory data width.
  73. This parameter can be a value of @ref DMA_Memory_data_size */
  74. uint32_t Mode; /*!< Specifies the operation mode of the DMAy Streamx.
  75. This parameter can be a value of @ref DMA_mode
  76. @note The circular buffer mode cannot be used if the memory-to-memory
  77. data transfer is configured on the selected Stream */
  78. uint32_t Priority; /*!< Specifies the software priority for the DMAy Streamx.
  79. This parameter can be a value of @ref DMA_Priority_level */
  80. uint32_t FIFOMode; /*!< Specifies if the FIFO mode or Direct mode will be used for the specified stream.
  81. This parameter can be a value of @ref DMA_FIFO_direct_mode
  82. @note The Direct mode (FIFO mode disabled) cannot be used if the
  83. memory-to-memory data transfer is configured on the selected stream */
  84. uint32_t FIFOThreshold; /*!< Specifies the FIFO threshold level.
  85. This parameter can be a value of @ref DMA_FIFO_threshold_level */
  86. uint32_t MemBurst; /*!< Specifies the Burst transfer configuration for the memory transfers.
  87. It specifies the amount of data to be transferred in a single non interruptible
  88. transaction.
  89. This parameter can be a value of @ref DMA_Memory_burst
  90. @note The burst mode is possible only if the address Increment mode is enabled. */
  91. uint32_t PeriphBurst; /*!< Specifies the Burst transfer configuration for the peripheral transfers.
  92. It specifies the amount of data to be transferred in a single non interruptible
  93. transaction.
  94. This parameter can be a value of @ref DMA_Peripheral_burst
  95. @note The burst mode is possible only if the address Increment mode is enabled. */
  96. }DMA_InitTypeDef;
  97. /**
  98. * @brief HAL DMA State structures definition
  99. */
  100. typedef enum
  101. {
  102. HAL_DMA_STATE_RESET = 0x00U, /*!< DMA not yet initialized or disabled */
  103. HAL_DMA_STATE_READY = 0x01U, /*!< DMA initialized and ready for use */
  104. HAL_DMA_STATE_BUSY = 0x02U, /*!< DMA process is ongoing */
  105. HAL_DMA_STATE_TIMEOUT = 0x03U, /*!< DMA timeout state */
  106. HAL_DMA_STATE_ERROR = 0x04U, /*!< DMA error state */
  107. HAL_DMA_STATE_ABORT = 0x05U, /*!< DMA Abort state */
  108. }HAL_DMA_StateTypeDef;
  109. /**
  110. * @brief HAL DMA Error Code structure definition
  111. */
  112. typedef enum
  113. {
  114. HAL_DMA_FULL_TRANSFER = 0x00U, /*!< Full transfer */
  115. HAL_DMA_HALF_TRANSFER = 0x01U /*!< Half Transfer */
  116. }HAL_DMA_LevelCompleteTypeDef;
  117. /**
  118. * @brief HAL DMA Error Code structure definition
  119. */
  120. typedef enum
  121. {
  122. HAL_DMA_XFER_CPLT_CB_ID = 0x00U, /*!< Full transfer */
  123. HAL_DMA_XFER_HALFCPLT_CB_ID = 0x01U, /*!< Half Transfer */
  124. HAL_DMA_XFER_M1CPLT_CB_ID = 0x02U, /*!< M1 Full Transfer */
  125. HAL_DMA_XFER_M1HALFCPLT_CB_ID = 0x03U, /*!< M1 Half Transfer */
  126. HAL_DMA_XFER_ERROR_CB_ID = 0x04U, /*!< Error */
  127. HAL_DMA_XFER_ABORT_CB_ID = 0x05U, /*!< Abort */
  128. HAL_DMA_XFER_ALL_CB_ID = 0x06U /*!< All */
  129. }HAL_DMA_CallbackIDTypeDef;
  130. /**
  131. * @brief DMA handle Structure definition
  132. */
  133. typedef struct __DMA_HandleTypeDef
  134. {
  135. DMA_Stream_TypeDef *Instance; /*!< Register base address */
  136. DMA_InitTypeDef Init; /*!< DMA communication parameters */
  137. HAL_LockTypeDef Lock; /*!< DMA locking object */
  138. __IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
  139. void *Parent; /*!< Parent object state */
  140. void (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
  141. void (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
  142. void (* XferM1CpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete Memory1 callback */
  143. void (* XferM1HalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer Half complete Memory1 callback */
  144. void (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
  145. void (* XferAbortCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer Abort callback */
  146. __IO uint32_t ErrorCode; /*!< DMA Error code */
  147. uint32_t StreamBaseAddress; /*!< DMA Stream Base Address */
  148. uint32_t StreamIndex; /*!< DMA Stream Index */
  149. }DMA_HandleTypeDef;
  150. /**
  151. * @}
  152. */
  153. /* Exported constants --------------------------------------------------------*/
  154. /** @defgroup DMA_Exported_Constants DMA Exported Constants
  155. * @brief DMA Exported constants
  156. * @{
  157. */
  158. /** @defgroup DMA_Error_Code DMA Error Code
  159. * @brief DMA Error Code
  160. * @{
  161. */
  162. #define HAL_DMA_ERROR_NONE 0x00000000U /*!< No error */
  163. #define HAL_DMA_ERROR_TE 0x00000001U /*!< Transfer error */
  164. #define HAL_DMA_ERROR_FE 0x00000002U /*!< FIFO error */
  165. #define HAL_DMA_ERROR_DME 0x00000004U /*!< Direct Mode error */
  166. #define HAL_DMA_ERROR_TIMEOUT 0x00000020U /*!< Timeout error */
  167. #define HAL_DMA_ERROR_PARAM 0x00000040U /*!< Parameter error */
  168. #define HAL_DMA_ERROR_NO_XFER 0x00000080U /*!< Abort requested with no Xfer ongoing */
  169. #define HAL_DMA_ERROR_NOT_SUPPORTED 0x00000100U /*!< Not supported mode */
  170. /**
  171. * @}
  172. */
  173. /** @defgroup DMA_Channel_selection DMA Channel selection
  174. * @brief DMA channel selection
  175. * @{
  176. */
  177. #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */
  178. #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */
  179. #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */
  180. #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */
  181. #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */
  182. #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */
  183. #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */
  184. #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */
  185. #if defined (DMA_SxCR_CHSEL_3)
  186. #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */
  187. #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */
  188. #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10 */
  189. #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11 */
  190. #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12 */
  191. #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13 */
  192. #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14 */
  193. #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15 */
  194. #endif /* DMA_SxCR_CHSEL_3 */
  195. /**
  196. * @}
  197. */
  198. /** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
  199. * @brief DMA data transfer direction
  200. * @{
  201. */
  202. #define DMA_PERIPH_TO_MEMORY 0x00000000U /*!< Peripheral to memory direction */
  203. #define DMA_MEMORY_TO_PERIPH ((uint32_t)DMA_SxCR_DIR_0) /*!< Memory to peripheral direction */
  204. #define DMA_MEMORY_TO_MEMORY ((uint32_t)DMA_SxCR_DIR_1) /*!< Memory to memory direction */
  205. /**
  206. * @}
  207. */
  208. /** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
  209. * @brief DMA peripheral incremented mode
  210. * @{
  211. */
  212. #define DMA_PINC_ENABLE ((uint32_t)DMA_SxCR_PINC) /*!< Peripheral increment mode enable */
  213. #define DMA_PINC_DISABLE 0x00000000U /*!< Peripheral increment mode disable */
  214. /**
  215. * @}
  216. */
  217. /** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
  218. * @brief DMA memory incremented mode
  219. * @{
  220. */
  221. #define DMA_MINC_ENABLE ((uint32_t)DMA_SxCR_MINC) /*!< Memory increment mode enable */
  222. #define DMA_MINC_DISABLE 0x00000000U /*!< Memory increment mode disable */
  223. /**
  224. * @}
  225. */
  226. /** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
  227. * @brief DMA peripheral data size
  228. * @{
  229. */
  230. #define DMA_PDATAALIGN_BYTE 0x00000000U /*!< Peripheral data alignment: Byte */
  231. #define DMA_PDATAALIGN_HALFWORD ((uint32_t)DMA_SxCR_PSIZE_0) /*!< Peripheral data alignment: HalfWord */
  232. #define DMA_PDATAALIGN_WORD ((uint32_t)DMA_SxCR_PSIZE_1) /*!< Peripheral data alignment: Word */
  233. /**
  234. * @}
  235. */
  236. /** @defgroup DMA_Memory_data_size DMA Memory data size
  237. * @brief DMA memory data size
  238. * @{
  239. */
  240. #define DMA_MDATAALIGN_BYTE 0x00000000U /*!< Memory data alignment: Byte */
  241. #define DMA_MDATAALIGN_HALFWORD ((uint32_t)DMA_SxCR_MSIZE_0) /*!< Memory data alignment: HalfWord */
  242. #define DMA_MDATAALIGN_WORD ((uint32_t)DMA_SxCR_MSIZE_1) /*!< Memory data alignment: Word */
  243. /**
  244. * @}
  245. */
  246. /** @defgroup DMA_mode DMA mode
  247. * @brief DMA mode
  248. * @{
  249. */
  250. #define DMA_NORMAL 0x00000000U /*!< Normal mode */
  251. #define DMA_CIRCULAR ((uint32_t)DMA_SxCR_CIRC) /*!< Circular mode */
  252. #define DMA_PFCTRL ((uint32_t)DMA_SxCR_PFCTRL) /*!< Peripheral flow control mode */
  253. /**
  254. * @}
  255. */
  256. /** @defgroup DMA_Priority_level DMA Priority level
  257. * @brief DMA priority levels
  258. * @{
  259. */
  260. #define DMA_PRIORITY_LOW 0x00000000U /*!< Priority level: Low */
  261. #define DMA_PRIORITY_MEDIUM ((uint32_t)DMA_SxCR_PL_0) /*!< Priority level: Medium */
  262. #define DMA_PRIORITY_HIGH ((uint32_t)DMA_SxCR_PL_1) /*!< Priority level: High */
  263. #define DMA_PRIORITY_VERY_HIGH ((uint32_t)DMA_SxCR_PL) /*!< Priority level: Very High */
  264. /**
  265. * @}
  266. */
  267. /** @defgroup DMA_FIFO_direct_mode DMA FIFO direct mode
  268. * @brief DMA FIFO direct mode
  269. * @{
  270. */
  271. #define DMA_FIFOMODE_DISABLE 0x00000000U /*!< FIFO mode disable */
  272. #define DMA_FIFOMODE_ENABLE ((uint32_t)DMA_SxFCR_DMDIS) /*!< FIFO mode enable */
  273. /**
  274. * @}
  275. */
  276. /** @defgroup DMA_FIFO_threshold_level DMA FIFO threshold level
  277. * @brief DMA FIFO level
  278. * @{
  279. */
  280. #define DMA_FIFO_THRESHOLD_1QUARTERFULL 0x00000000U /*!< FIFO threshold 1 quart full configuration */
  281. #define DMA_FIFO_THRESHOLD_HALFFULL ((uint32_t)DMA_SxFCR_FTH_0) /*!< FIFO threshold half full configuration */
  282. #define DMA_FIFO_THRESHOLD_3QUARTERSFULL ((uint32_t)DMA_SxFCR_FTH_1) /*!< FIFO threshold 3 quarts full configuration */
  283. #define DMA_FIFO_THRESHOLD_FULL ((uint32_t)DMA_SxFCR_FTH) /*!< FIFO threshold full configuration */
  284. /**
  285. * @}
  286. */
  287. /** @defgroup DMA_Memory_burst DMA Memory burst
  288. * @brief DMA memory burst
  289. * @{
  290. */
  291. #define DMA_MBURST_SINGLE 0x00000000U
  292. #define DMA_MBURST_INC4 ((uint32_t)DMA_SxCR_MBURST_0)
  293. #define DMA_MBURST_INC8 ((uint32_t)DMA_SxCR_MBURST_1)
  294. #define DMA_MBURST_INC16 ((uint32_t)DMA_SxCR_MBURST)
  295. /**
  296. * @}
  297. */
  298. /** @defgroup DMA_Peripheral_burst DMA Peripheral burst
  299. * @brief DMA peripheral burst
  300. * @{
  301. */
  302. #define DMA_PBURST_SINGLE 0x00000000U
  303. #define DMA_PBURST_INC4 ((uint32_t)DMA_SxCR_PBURST_0)
  304. #define DMA_PBURST_INC8 ((uint32_t)DMA_SxCR_PBURST_1)
  305. #define DMA_PBURST_INC16 ((uint32_t)DMA_SxCR_PBURST)
  306. /**
  307. * @}
  308. */
  309. /** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
  310. * @brief DMA interrupts definition
  311. * @{
  312. */
  313. #define DMA_IT_TC ((uint32_t)DMA_SxCR_TCIE)
  314. #define DMA_IT_HT ((uint32_t)DMA_SxCR_HTIE)
  315. #define DMA_IT_TE ((uint32_t)DMA_SxCR_TEIE)
  316. #define DMA_IT_DME ((uint32_t)DMA_SxCR_DMEIE)
  317. #define DMA_IT_FE 0x00000080U
  318. /**
  319. * @}
  320. */
  321. /** @defgroup DMA_flag_definitions DMA flag definitions
  322. * @brief DMA flag definitions
  323. * @{
  324. */
  325. #define DMA_FLAG_FEIF0_4 0x00800001U
  326. #define DMA_FLAG_DMEIF0_4 0x00800004U
  327. #define DMA_FLAG_TEIF0_4 0x00000008U
  328. #define DMA_FLAG_HTIF0_4 0x00000010U
  329. #define DMA_FLAG_TCIF0_4 0x00000020U
  330. #define DMA_FLAG_FEIF1_5 0x00000040U
  331. #define DMA_FLAG_DMEIF1_5 0x00000100U
  332. #define DMA_FLAG_TEIF1_5 0x00000200U
  333. #define DMA_FLAG_HTIF1_5 0x00000400U
  334. #define DMA_FLAG_TCIF1_5 0x00000800U
  335. #define DMA_FLAG_FEIF2_6 0x00010000U
  336. #define DMA_FLAG_DMEIF2_6 0x00040000U
  337. #define DMA_FLAG_TEIF2_6 0x00080000U
  338. #define DMA_FLAG_HTIF2_6 0x00100000U
  339. #define DMA_FLAG_TCIF2_6 0x00200000U
  340. #define DMA_FLAG_FEIF3_7 0x00400000U
  341. #define DMA_FLAG_DMEIF3_7 0x01000000U
  342. #define DMA_FLAG_TEIF3_7 0x02000000U
  343. #define DMA_FLAG_HTIF3_7 0x04000000U
  344. #define DMA_FLAG_TCIF3_7 0x08000000U
  345. /**
  346. * @}
  347. */
  348. /**
  349. * @}
  350. */
  351. /* Exported macro ------------------------------------------------------------*/
  352. /** @brief Reset DMA handle state
  353. * @param __HANDLE__: specifies the DMA handle.
  354. * @retval None
  355. */
  356. #define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
  357. /**
  358. * @brief Return the current DMA Stream FIFO filled level.
  359. * @param __HANDLE__: DMA handle
  360. * @retval The FIFO filling state.
  361. * - DMA_FIFOStatus_Less1QuarterFull: when FIFO is less than 1 quarter-full
  362. * and not empty.
  363. * - DMA_FIFOStatus_1QuarterFull: if more than 1 quarter-full.
  364. * - DMA_FIFOStatus_HalfFull: if more than 1 half-full.
  365. * - DMA_FIFOStatus_3QuartersFull: if more than 3 quarters-full.
  366. * - DMA_FIFOStatus_Empty: when FIFO is empty
  367. * - DMA_FIFOStatus_Full: when FIFO is full
  368. */
  369. #define __HAL_DMA_GET_FS(__HANDLE__) (((__HANDLE__)->Instance->FCR & (DMA_SxFCR_FS)))
  370. /**
  371. * @brief Enable the specified DMA Stream.
  372. * @param __HANDLE__: DMA handle
  373. * @retval None
  374. */
  375. #define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA_SxCR_EN)
  376. /**
  377. * @brief Disable the specified DMA Stream.
  378. * @param __HANDLE__: DMA handle
  379. * @retval None
  380. */
  381. #define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~DMA_SxCR_EN)
  382. /* Interrupt & Flag management */
  383. /**
  384. * @brief Return the current DMA Stream transfer complete flag.
  385. * @param __HANDLE__: DMA handle
  386. * @retval The specified transfer complete flag index.
  387. */
  388. #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
  389. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TCIF0_4 :\
  390. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TCIF0_4 :\
  391. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TCIF0_4 :\
  392. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TCIF0_4 :\
  393. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TCIF1_5 :\
  394. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TCIF1_5 :\
  395. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TCIF1_5 :\
  396. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TCIF1_5 :\
  397. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TCIF2_6 :\
  398. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TCIF2_6 :\
  399. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TCIF2_6 :\
  400. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TCIF2_6 :\
  401. DMA_FLAG_TCIF3_7)
  402. /**
  403. * @brief Return the current DMA Stream half transfer complete flag.
  404. * @param __HANDLE__: DMA handle
  405. * @retval The specified half transfer complete flag index.
  406. */
  407. #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
  408. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_HTIF0_4 :\
  409. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_HTIF0_4 :\
  410. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_HTIF0_4 :\
  411. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_HTIF0_4 :\
  412. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_HTIF1_5 :\
  413. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_HTIF1_5 :\
  414. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_HTIF1_5 :\
  415. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_HTIF1_5 :\
  416. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_HTIF2_6 :\
  417. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_HTIF2_6 :\
  418. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_HTIF2_6 :\
  419. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_HTIF2_6 :\
  420. DMA_FLAG_HTIF3_7)
  421. /**
  422. * @brief Return the current DMA Stream transfer error flag.
  423. * @param __HANDLE__: DMA handle
  424. * @retval The specified transfer error flag index.
  425. */
  426. #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
  427. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TEIF0_4 :\
  428. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TEIF0_4 :\
  429. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TEIF0_4 :\
  430. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TEIF0_4 :\
  431. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TEIF1_5 :\
  432. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TEIF1_5 :\
  433. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TEIF1_5 :\
  434. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TEIF1_5 :\
  435. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TEIF2_6 :\
  436. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TEIF2_6 :\
  437. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TEIF2_6 :\
  438. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TEIF2_6 :\
  439. DMA_FLAG_TEIF3_7)
  440. /**
  441. * @brief Return the current DMA Stream FIFO error flag.
  442. * @param __HANDLE__: DMA handle
  443. * @retval The specified FIFO error flag index.
  444. */
  445. #define __HAL_DMA_GET_FE_FLAG_INDEX(__HANDLE__)\
  446. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_FEIF0_4 :\
  447. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_FEIF0_4 :\
  448. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_FEIF0_4 :\
  449. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_FEIF0_4 :\
  450. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_FEIF1_5 :\
  451. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_FEIF1_5 :\
  452. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_FEIF1_5 :\
  453. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_FEIF1_5 :\
  454. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_FEIF2_6 :\
  455. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_FEIF2_6 :\
  456. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_FEIF2_6 :\
  457. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_FEIF2_6 :\
  458. DMA_FLAG_FEIF3_7)
  459. /**
  460. * @brief Return the current DMA Stream direct mode error flag.
  461. * @param __HANDLE__: DMA handle
  462. * @retval The specified direct mode error flag index.
  463. */
  464. #define __HAL_DMA_GET_DME_FLAG_INDEX(__HANDLE__)\
  465. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_DMEIF0_4 :\
  466. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_DMEIF0_4 :\
  467. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_DMEIF0_4 :\
  468. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_DMEIF0_4 :\
  469. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_DMEIF1_5 :\
  470. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_DMEIF1_5 :\
  471. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_DMEIF1_5 :\
  472. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_DMEIF1_5 :\
  473. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_DMEIF2_6 :\
  474. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_DMEIF2_6 :\
  475. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_DMEIF2_6 :\
  476. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_DMEIF2_6 :\
  477. DMA_FLAG_DMEIF3_7)
  478. /**
  479. * @brief Get the DMA Stream pending flags.
  480. * @param __HANDLE__: DMA handle
  481. * @param __FLAG__: Get the specified flag.
  482. * This parameter can be any combination of the following values:
  483. * @arg DMA_FLAG_TCIFx: Transfer complete flag.
  484. * @arg DMA_FLAG_HTIFx: Half transfer complete flag.
  485. * @arg DMA_FLAG_TEIFx: Transfer error flag.
  486. * @arg DMA_FLAG_DMEIFx: Direct mode error flag.
  487. * @arg DMA_FLAG_FEIFx: FIFO error flag.
  488. * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag.
  489. * @retval The state of FLAG (SET or RESET).
  490. */
  491. #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\
  492. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HISR & (__FLAG__)) :\
  493. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LISR & (__FLAG__)) :\
  494. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HISR & (__FLAG__)) : (DMA1->LISR & (__FLAG__)))
  495. /**
  496. * @brief Clear the DMA Stream pending flags.
  497. * @param __HANDLE__: DMA handle
  498. * @param __FLAG__: specifies the flag to clear.
  499. * This parameter can be any combination of the following values:
  500. * @arg DMA_FLAG_TCIFx: Transfer complete flag.
  501. * @arg DMA_FLAG_HTIFx: Half transfer complete flag.
  502. * @arg DMA_FLAG_TEIFx: Transfer error flag.
  503. * @arg DMA_FLAG_DMEIFx: Direct mode error flag.
  504. * @arg DMA_FLAG_FEIFx: FIFO error flag.
  505. * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag.
  506. * @retval None
  507. */
  508. #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  509. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HIFCR = (__FLAG__)) :\
  510. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LIFCR = (__FLAG__)) :\
  511. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HIFCR = (__FLAG__)) : (DMA1->LIFCR = (__FLAG__)))
  512. /**
  513. * @brief Enable the specified DMA Stream interrupts.
  514. * @param __HANDLE__: DMA handle
  515. * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
  516. * This parameter can be any combination of the following values:
  517. * @arg DMA_IT_TC: Transfer complete interrupt mask.
  518. * @arg DMA_IT_HT: Half transfer complete interrupt mask.
  519. * @arg DMA_IT_TE: Transfer error interrupt mask.
  520. * @arg DMA_IT_FE: FIFO error interrupt mask.
  521. * @arg DMA_IT_DME: Direct mode error interrupt.
  522. * @retval None
  523. */
  524. #define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
  525. ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) : ((__HANDLE__)->Instance->FCR |= (__INTERRUPT__)))
  526. /**
  527. * @brief Disable the specified DMA Stream interrupts.
  528. * @param __HANDLE__: DMA handle
  529. * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
  530. * This parameter can be any combination of the following values:
  531. * @arg DMA_IT_TC: Transfer complete interrupt mask.
  532. * @arg DMA_IT_HT: Half transfer complete interrupt mask.
  533. * @arg DMA_IT_TE: Transfer error interrupt mask.
  534. * @arg DMA_IT_FE: FIFO error interrupt mask.
  535. * @arg DMA_IT_DME: Direct mode error interrupt.
  536. * @retval None
  537. */
  538. #define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
  539. ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) : ((__HANDLE__)->Instance->FCR &= ~(__INTERRUPT__)))
  540. /**
  541. * @brief Check whether the specified DMA Stream interrupt is enabled or disabled.
  542. * @param __HANDLE__: DMA handle
  543. * @param __INTERRUPT__: specifies the DMA interrupt source to check.
  544. * This parameter can be one of the following values:
  545. * @arg DMA_IT_TC: Transfer complete interrupt mask.
  546. * @arg DMA_IT_HT: Half transfer complete interrupt mask.
  547. * @arg DMA_IT_TE: Transfer error interrupt mask.
  548. * @arg DMA_IT_FE: FIFO error interrupt mask.
  549. * @arg DMA_IT_DME: Direct mode error interrupt.
  550. * @retval The state of DMA_IT.
  551. */
  552. #define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
  553. ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) : \
  554. ((__HANDLE__)->Instance->FCR & (__INTERRUPT__)))
  555. /**
  556. * @brief Writes the number of data units to be transferred on the DMA Stream.
  557. * @param __HANDLE__: DMA handle
  558. * @param __COUNTER__: Number of data units to be transferred (from 0 to 65535)
  559. * Number of data items depends only on the Peripheral data format.
  560. *
  561. * @note If Peripheral data format is Bytes: number of data units is equal
  562. * to total number of bytes to be transferred.
  563. *
  564. * @note If Peripheral data format is Half-Word: number of data units is
  565. * equal to total number of bytes to be transferred / 2.
  566. *
  567. * @note If Peripheral data format is Word: number of data units is equal
  568. * to total number of bytes to be transferred / 4.
  569. *
  570. * @retval The number of remaining data units in the current DMAy Streamx transfer.
  571. */
  572. #define __HAL_DMA_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->NDTR = (uint16_t)(__COUNTER__))
  573. /**
  574. * @brief Returns the number of remaining data units in the current DMAy Streamx transfer.
  575. * @param __HANDLE__: DMA handle
  576. *
  577. * @retval The number of remaining data units in the current DMA Stream transfer.
  578. */
  579. #define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->NDTR)
  580. /* Include DMA HAL Extension module */
  581. #include "stm32f4xx_hal_dma_ex.h"
  582. /* Exported functions --------------------------------------------------------*/
  583. /** @defgroup DMA_Exported_Functions DMA Exported Functions
  584. * @brief DMA Exported functions
  585. * @{
  586. */
  587. /** @defgroup DMA_Exported_Functions_Group1 Initialization and de-initialization functions
  588. * @brief Initialization and de-initialization functions
  589. * @{
  590. */
  591. HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
  592. HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma);
  593. /**
  594. * @}
  595. */
  596. /** @defgroup DMA_Exported_Functions_Group2 I/O operation functions
  597. * @brief I/O operation functions
  598. * @{
  599. */
  600. HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
  601. HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
  602. HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
  603. HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
  604. HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout);
  605. void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
  606. HAL_StatusTypeDef HAL_DMA_CleanCallbacks(DMA_HandleTypeDef *hdma);
  607. HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)(DMA_HandleTypeDef *_hdma));
  608. HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID);
  609. /**
  610. * @}
  611. */
  612. /** @defgroup DMA_Exported_Functions_Group3 Peripheral State functions
  613. * @brief Peripheral State functions
  614. * @{
  615. */
  616. HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
  617. uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
  618. /**
  619. * @}
  620. */
  621. /**
  622. * @}
  623. */
  624. /* Private Constants -------------------------------------------------------------*/
  625. /** @defgroup DMA_Private_Constants DMA Private Constants
  626. * @brief DMA private defines and constants
  627. * @{
  628. */
  629. /**
  630. * @}
  631. */
  632. /* Private macros ------------------------------------------------------------*/
  633. /** @defgroup DMA_Private_Macros DMA Private Macros
  634. * @brief DMA private macros
  635. * @{
  636. */
  637. #if defined (DMA_SxCR_CHSEL_3)
  638. #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \
  639. ((CHANNEL) == DMA_CHANNEL_1) || \
  640. ((CHANNEL) == DMA_CHANNEL_2) || \
  641. ((CHANNEL) == DMA_CHANNEL_3) || \
  642. ((CHANNEL) == DMA_CHANNEL_4) || \
  643. ((CHANNEL) == DMA_CHANNEL_5) || \
  644. ((CHANNEL) == DMA_CHANNEL_6) || \
  645. ((CHANNEL) == DMA_CHANNEL_7) || \
  646. ((CHANNEL) == DMA_CHANNEL_8) || \
  647. ((CHANNEL) == DMA_CHANNEL_9) || \
  648. ((CHANNEL) == DMA_CHANNEL_10)|| \
  649. ((CHANNEL) == DMA_CHANNEL_11)|| \
  650. ((CHANNEL) == DMA_CHANNEL_12)|| \
  651. ((CHANNEL) == DMA_CHANNEL_13)|| \
  652. ((CHANNEL) == DMA_CHANNEL_14)|| \
  653. ((CHANNEL) == DMA_CHANNEL_15))
  654. #else
  655. #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \
  656. ((CHANNEL) == DMA_CHANNEL_1) || \
  657. ((CHANNEL) == DMA_CHANNEL_2) || \
  658. ((CHANNEL) == DMA_CHANNEL_3) || \
  659. ((CHANNEL) == DMA_CHANNEL_4) || \
  660. ((CHANNEL) == DMA_CHANNEL_5) || \
  661. ((CHANNEL) == DMA_CHANNEL_6) || \
  662. ((CHANNEL) == DMA_CHANNEL_7))
  663. #endif /* DMA_SxCR_CHSEL_3 */
  664. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
  665. ((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
  666. ((DIRECTION) == DMA_MEMORY_TO_MEMORY))
  667. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x01U) && ((SIZE) < 0x10000U))
  668. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
  669. ((STATE) == DMA_PINC_DISABLE))
  670. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
  671. ((STATE) == DMA_MINC_DISABLE))
  672. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
  673. ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
  674. ((SIZE) == DMA_PDATAALIGN_WORD))
  675. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
  676. ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
  677. ((SIZE) == DMA_MDATAALIGN_WORD ))
  678. #define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
  679. ((MODE) == DMA_CIRCULAR) || \
  680. ((MODE) == DMA_PFCTRL))
  681. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
  682. ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
  683. ((PRIORITY) == DMA_PRIORITY_HIGH) || \
  684. ((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
  685. #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMODE_DISABLE ) || \
  686. ((STATE) == DMA_FIFOMODE_ENABLE))
  687. #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFO_THRESHOLD_1QUARTERFULL ) || \
  688. ((THRESHOLD) == DMA_FIFO_THRESHOLD_HALFFULL) || \
  689. ((THRESHOLD) == DMA_FIFO_THRESHOLD_3QUARTERSFULL) || \
  690. ((THRESHOLD) == DMA_FIFO_THRESHOLD_FULL))
  691. #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MBURST_SINGLE) || \
  692. ((BURST) == DMA_MBURST_INC4) || \
  693. ((BURST) == DMA_MBURST_INC8) || \
  694. ((BURST) == DMA_MBURST_INC16))
  695. #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PBURST_SINGLE) || \
  696. ((BURST) == DMA_PBURST_INC4) || \
  697. ((BURST) == DMA_PBURST_INC8) || \
  698. ((BURST) == DMA_PBURST_INC16))
  699. /**
  700. * @}
  701. */
  702. /* Private functions ---------------------------------------------------------*/
  703. /** @defgroup DMA_Private_Functions DMA Private Functions
  704. * @brief DMA private functions
  705. * @{
  706. */
  707. /**
  708. * @}
  709. */
  710. /**
  711. * @}
  712. */
  713. /**
  714. * @}
  715. */
  716. #ifdef __cplusplus
  717. }
  718. #endif
  719. #endif /* __STM32F4xx_HAL_DMA_H */
  720. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/