stm32f4xx_hal_dma.h 39 KB

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