stm32h7xx_hal_dma.h 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_dma.h
  4. * @author MCD Application Team
  5. * @brief Header file of DMA HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32H7xx_HAL_DMA_H
  20. #define STM32H7xx_HAL_DMA_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h7xx_hal_def.h"
  26. /** @addtogroup STM32H7xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup DMA
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup DMA_Exported_Types DMA Exported Types
  34. * @brief DMA Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief DMA Configuration Structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t Request; /*!< Specifies the request selected for the specified stream.
  43. This parameter can be a value of @ref DMA_Request_selection */
  44. uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
  45. from memory to memory or from peripheral to memory.
  46. This parameter can be a value of @ref DMA_Data_transfer_direction */
  47. uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
  48. This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
  49. uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not.
  50. This parameter can be a value of @ref DMA_Memory_incremented_mode */
  51. uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width.
  52. This parameter can be a value of @ref DMA_Peripheral_data_size */
  53. uint32_t MemDataAlignment; /*!< Specifies the Memory data width.
  54. This parameter can be a value of @ref DMA_Memory_data_size */
  55. uint32_t Mode; /*!< Specifies the operation mode of the DMAy Streamx.
  56. This parameter can be a value of @ref DMA_mode
  57. @note The circular buffer mode cannot be used if the memory-to-memory
  58. data transfer is configured on the selected Stream */
  59. uint32_t Priority; /*!< Specifies the software priority for the DMAy Streamx.
  60. This parameter can be a value of @ref DMA_Priority_level */
  61. uint32_t FIFOMode; /*!< Specifies if the FIFO mode or Direct mode will be used for the specified stream.
  62. This parameter can be a value of @ref DMA_FIFO_direct_mode
  63. @note The Direct mode (FIFO mode disabled) cannot be used if the
  64. memory-to-memory data transfer is configured on the selected stream */
  65. uint32_t FIFOThreshold; /*!< Specifies the FIFO threshold level.
  66. This parameter can be a value of @ref DMA_FIFO_threshold_level */
  67. uint32_t MemBurst; /*!< Specifies the Burst transfer configuration for the memory transfers.
  68. It specifies the amount of data to be transferred in a single non interruptible
  69. transaction.
  70. This parameter can be a value of @ref DMA_Memory_burst
  71. @note The burst mode is possible only if the address Increment mode is enabled. */
  72. uint32_t PeriphBurst; /*!< Specifies the Burst transfer configuration for the peripheral transfers.
  73. It specifies the amount of data to be transferred in a single non interruptible
  74. transaction.
  75. This parameter can be a value of @ref DMA_Peripheral_burst
  76. @note The burst mode is possible only if the address Increment mode is enabled. */
  77. }DMA_InitTypeDef;
  78. /**
  79. * @brief HAL DMA State structures definition
  80. */
  81. typedef enum
  82. {
  83. HAL_DMA_STATE_RESET = 0x00U, /*!< DMA not yet initialized or disabled */
  84. HAL_DMA_STATE_READY = 0x01U, /*!< DMA initialized and ready for use */
  85. HAL_DMA_STATE_BUSY = 0x02U, /*!< DMA process is ongoing */
  86. HAL_DMA_STATE_ERROR = 0x03U, /*!< DMA error state */
  87. HAL_DMA_STATE_ABORT = 0x04U, /*!< DMA Abort state */
  88. }HAL_DMA_StateTypeDef;
  89. /**
  90. * @brief HAL DMA Transfer complete level structure definition
  91. */
  92. typedef enum
  93. {
  94. HAL_DMA_FULL_TRANSFER = 0x00U, /*!< Full transfer */
  95. HAL_DMA_HALF_TRANSFER = 0x01U, /*!< Half Transfer */
  96. }HAL_DMA_LevelCompleteTypeDef;
  97. /**
  98. * @brief HAL DMA Callbacks IDs structure definition
  99. */
  100. typedef enum
  101. {
  102. HAL_DMA_XFER_CPLT_CB_ID = 0x00U, /*!< Full transfer */
  103. HAL_DMA_XFER_HALFCPLT_CB_ID = 0x01U, /*!< Half Transfer */
  104. HAL_DMA_XFER_M1CPLT_CB_ID = 0x02U, /*!< M1 Full Transfer */
  105. HAL_DMA_XFER_M1HALFCPLT_CB_ID = 0x03U, /*!< M1 Half Transfer */
  106. HAL_DMA_XFER_ERROR_CB_ID = 0x04U, /*!< Error */
  107. HAL_DMA_XFER_ABORT_CB_ID = 0x05U, /*!< Abort */
  108. HAL_DMA_XFER_ALL_CB_ID = 0x06U /*!< All */
  109. }HAL_DMA_CallbackIDTypeDef;
  110. /**
  111. * @brief DMA handle Structure definition
  112. */
  113. typedef struct __DMA_HandleTypeDef
  114. {
  115. void *Instance; /*!< Register base address */
  116. DMA_InitTypeDef Init; /*!< DMA communication parameters */
  117. HAL_LockTypeDef Lock; /*!< DMA locking object */
  118. __IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
  119. void *Parent; /*!< Parent object state */
  120. void (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
  121. void (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
  122. void (* XferM1CpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete Memory1 callback */
  123. void (* XferM1HalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer Half complete Memory1 callback */
  124. void (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
  125. void (* XferAbortCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer Abort callback */
  126. __IO uint32_t ErrorCode; /*!< DMA Error code */
  127. uint32_t StreamBaseAddress; /*!< DMA Stream Base Address */
  128. uint32_t StreamIndex; /*!< DMA Stream Index */
  129. DMAMUX_Channel_TypeDef *DMAmuxChannel; /*!< DMAMUX Channel Base Address */
  130. DMAMUX_ChannelStatus_TypeDef *DMAmuxChannelStatus; /*!< DMAMUX Channels Status Base Address */
  131. uint32_t DMAmuxChannelStatusMask; /*!< DMAMUX Channel Status Mask */
  132. DMAMUX_RequestGen_TypeDef *DMAmuxRequestGen; /*!< DMAMUX request generator Base Address */
  133. DMAMUX_RequestGenStatus_TypeDef *DMAmuxRequestGenStatus; /*!< DMAMUX request generator Status Address */
  134. uint32_t DMAmuxRequestGenStatusMask; /*!< DMAMUX request generator Status mask */
  135. }DMA_HandleTypeDef;
  136. /**
  137. * @}
  138. */
  139. /* Exported constants --------------------------------------------------------*/
  140. /** @defgroup DMA_Exported_Constants DMA Exported Constants
  141. * @brief DMA Exported constants
  142. * @{
  143. */
  144. /** @defgroup DMA_Error_Code DMA Error Code
  145. * @brief DMA Error Code
  146. * @{
  147. */
  148. #define HAL_DMA_ERROR_NONE (0x00000000U) /*!< No error */
  149. #define HAL_DMA_ERROR_TE (0x00000001U) /*!< Transfer error */
  150. #define HAL_DMA_ERROR_FE (0x00000002U) /*!< FIFO error */
  151. #define HAL_DMA_ERROR_DME (0x00000004U) /*!< Direct Mode error */
  152. #define HAL_DMA_ERROR_TIMEOUT (0x00000020U) /*!< Timeout error */
  153. #define HAL_DMA_ERROR_PARAM (0x00000040U) /*!< Parameter error */
  154. #define HAL_DMA_ERROR_NO_XFER (0x00000080U) /*!< Abort requested with no Xfer ongoing */
  155. #define HAL_DMA_ERROR_NOT_SUPPORTED (0x00000100U) /*!< Not supported mode */
  156. #define HAL_DMA_ERROR_SYNC (0x00000200U) /*!< DMAMUX sync overrun error */
  157. #define HAL_DMA_ERROR_REQGEN (0x00000400U) /*!< DMAMUX request generator overrun error */
  158. #define HAL_DMA_ERROR_BUSY (0x00000800U) /*!< DMA Busy error */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup DMA_Request_selection DMA Request selection
  163. * @brief DMA Request selection
  164. * @{
  165. */
  166. /* DMAMUX1 requests */
  167. #define DMA_REQUEST_MEM2MEM 0U /*!< memory to memory transfer */
  168. #define DMA_REQUEST_GENERATOR0 1U /*!< DMAMUX1 request generator 0 */
  169. #define DMA_REQUEST_GENERATOR1 2U /*!< DMAMUX1 request generator 1 */
  170. #define DMA_REQUEST_GENERATOR2 3U /*!< DMAMUX1 request generator 2 */
  171. #define DMA_REQUEST_GENERATOR3 4U /*!< DMAMUX1 request generator 3 */
  172. #define DMA_REQUEST_GENERATOR4 5U /*!< DMAMUX1 request generator 4 */
  173. #define DMA_REQUEST_GENERATOR5 6U /*!< DMAMUX1 request generator 5 */
  174. #define DMA_REQUEST_GENERATOR6 7U /*!< DMAMUX1 request generator 6 */
  175. #define DMA_REQUEST_GENERATOR7 8U /*!< DMAMUX1 request generator 7 */
  176. #define DMA_REQUEST_ADC1 9U /*!< DMAMUX1 ADC1 request */
  177. #define DMA_REQUEST_ADC2 10U /*!< DMAMUX1 ADC2 request */
  178. #define DMA_REQUEST_TIM1_CH1 11U /*!< DMAMUX1 TIM1 CH1 request */
  179. #define DMA_REQUEST_TIM1_CH2 12U /*!< DMAMUX1 TIM1 CH2 request */
  180. #define DMA_REQUEST_TIM1_CH3 13U /*!< DMAMUX1 TIM1 CH3 request */
  181. #define DMA_REQUEST_TIM1_CH4 14U /*!< DMAMUX1 TIM1 CH4 request */
  182. #define DMA_REQUEST_TIM1_UP 15U /*!< DMAMUX1 TIM1 UP request */
  183. #define DMA_REQUEST_TIM1_TRIG 16U /*!< DMAMUX1 TIM1 TRIG request */
  184. #define DMA_REQUEST_TIM1_COM 17U /*!< DMAMUX1 TIM1 COM request */
  185. #define DMA_REQUEST_TIM2_CH1 18U /*!< DMAMUX1 TIM2 CH1 request */
  186. #define DMA_REQUEST_TIM2_CH2 19U /*!< DMAMUX1 TIM2 CH2 request */
  187. #define DMA_REQUEST_TIM2_CH3 20U /*!< DMAMUX1 TIM2 CH3 request */
  188. #define DMA_REQUEST_TIM2_CH4 21U /*!< DMAMUX1 TIM2 CH4 request */
  189. #define DMA_REQUEST_TIM2_UP 22U /*!< DMAMUX1 TIM2 UP request */
  190. #define DMA_REQUEST_TIM3_CH1 23U /*!< DMAMUX1 TIM3 CH1 request */
  191. #define DMA_REQUEST_TIM3_CH2 24U /*!< DMAMUX1 TIM3 CH2 request */
  192. #define DMA_REQUEST_TIM3_CH3 25U /*!< DMAMUX1 TIM3 CH3 request */
  193. #define DMA_REQUEST_TIM3_CH4 26U /*!< DMAMUX1 TIM3 CH4 request */
  194. #define DMA_REQUEST_TIM3_UP 27U /*!< DMAMUX1 TIM3 UP request */
  195. #define DMA_REQUEST_TIM3_TRIG 28U /*!< DMAMUX1 TIM3 TRIG request */
  196. #define DMA_REQUEST_TIM4_CH1 29U /*!< DMAMUX1 TIM4 CH1 request */
  197. #define DMA_REQUEST_TIM4_CH2 30U /*!< DMAMUX1 TIM4 CH2 request */
  198. #define DMA_REQUEST_TIM4_CH3 31U /*!< DMAMUX1 TIM4 CH3 request */
  199. #define DMA_REQUEST_TIM4_UP 32U /*!< DMAMUX1 TIM4 UP request */
  200. #define DMA_REQUEST_I2C1_RX 33U /*!< DMAMUX1 I2C1 RX request */
  201. #define DMA_REQUEST_I2C1_TX 34U /*!< DMAMUX1 I2C1 TX request */
  202. #define DMA_REQUEST_I2C2_RX 35U /*!< DMAMUX1 I2C2 RX request */
  203. #define DMA_REQUEST_I2C2_TX 36U /*!< DMAMUX1 I2C2 TX request */
  204. #define DMA_REQUEST_SPI1_RX 37U /*!< DMAMUX1 SPI1 RX request */
  205. #define DMA_REQUEST_SPI1_TX 38U /*!< DMAMUX1 SPI1 TX request */
  206. #define DMA_REQUEST_SPI2_RX 39U /*!< DMAMUX1 SPI2 RX request */
  207. #define DMA_REQUEST_SPI2_TX 40U /*!< DMAMUX1 SPI2 TX request */
  208. #define DMA_REQUEST_USART1_RX 41U /*!< DMAMUX1 USART1 RX request */
  209. #define DMA_REQUEST_USART1_TX 42U /*!< DMAMUX1 USART1 TX request */
  210. #define DMA_REQUEST_USART2_RX 43U /*!< DMAMUX1 USART2 RX request */
  211. #define DMA_REQUEST_USART2_TX 44U /*!< DMAMUX1 USART2 TX request */
  212. #define DMA_REQUEST_USART3_RX 45U /*!< DMAMUX1 USART3 RX request */
  213. #define DMA_REQUEST_USART3_TX 46U /*!< DMAMUX1 USART3 TX request */
  214. #define DMA_REQUEST_TIM8_CH1 47U /*!< DMAMUX1 TIM8 CH1 request */
  215. #define DMA_REQUEST_TIM8_CH2 48U /*!< DMAMUX1 TIM8 CH2 request */
  216. #define DMA_REQUEST_TIM8_CH3 49U /*!< DMAMUX1 TIM8 CH3 request */
  217. #define DMA_REQUEST_TIM8_CH4 50U /*!< DMAMUX1 TIM8 CH4 request */
  218. #define DMA_REQUEST_TIM8_UP 51U /*!< DMAMUX1 TIM8 UP request */
  219. #define DMA_REQUEST_TIM8_TRIG 52U /*!< DMAMUX1 TIM8 TRIG request */
  220. #define DMA_REQUEST_TIM8_COM 53U /*!< DMAMUX1 TIM8 COM request */
  221. #define DMA_REQUEST_TIM5_CH1 55U /*!< DMAMUX1 TIM5 CH1 request */
  222. #define DMA_REQUEST_TIM5_CH2 56U /*!< DMAMUX1 TIM5 CH2 request */
  223. #define DMA_REQUEST_TIM5_CH3 57U /*!< DMAMUX1 TIM5 CH3 request */
  224. #define DMA_REQUEST_TIM5_CH4 58U /*!< DMAMUX1 TIM5 CH4 request */
  225. #define DMA_REQUEST_TIM5_UP 59U /*!< DMAMUX1 TIM5 UP request */
  226. #define DMA_REQUEST_TIM5_TRIG 60U /*!< DMAMUX1 TIM5 TRIG request */
  227. #define DMA_REQUEST_SPI3_RX 61U /*!< DMAMUX1 SPI3 RX request */
  228. #define DMA_REQUEST_SPI3_TX 62U /*!< DMAMUX1 SPI3 TX request */
  229. #define DMA_REQUEST_UART4_RX 63U /*!< DMAMUX1 UART4 RX request */
  230. #define DMA_REQUEST_UART4_TX 64U /*!< DMAMUX1 UART4 TX request */
  231. #define DMA_REQUEST_UART5_RX 65U /*!< DMAMUX1 UART5 RX request */
  232. #define DMA_REQUEST_UART5_TX 66U /*!< DMAMUX1 UART5 TX request */
  233. #define DMA_REQUEST_DAC1_CH1 67U /*!< DMAMUX1 DAC1 Channel 1 request */
  234. #define DMA_REQUEST_DAC1_CH2 68U /*!< DMAMUX1 DAC1 Channel 2 request */
  235. #define DMA_REQUEST_TIM6_UP 69U /*!< DMAMUX1 TIM6 UP request */
  236. #define DMA_REQUEST_TIM7_UP 70U /*!< DMAMUX1 TIM7 UP request */
  237. #define DMA_REQUEST_USART6_RX 71U /*!< DMAMUX1 USART6 RX request */
  238. #define DMA_REQUEST_USART6_TX 72U /*!< DMAMUX1 USART6 TX request */
  239. #define DMA_REQUEST_I2C3_RX 73U /*!< DMAMUX1 I2C3 RX request */
  240. #define DMA_REQUEST_I2C3_TX 74U /*!< DMAMUX1 I2C3 TX request */
  241. #if defined (PSSI)
  242. #define DMA_REQUEST_DCMI_PSSI 75U /*!< DMAMUX1 DCMI/PSSI request */
  243. #define DMA_REQUEST_DCMI DMA_REQUEST_DCMI_PSSI /* Legacy define */
  244. #else
  245. #define DMA_REQUEST_DCMI 75U /*!< DMAMUX1 DCMI request */
  246. #endif /* PSSI */
  247. #define DMA_REQUEST_CRYP_IN 76U /*!< DMAMUX1 CRYP IN request */
  248. #define DMA_REQUEST_CRYP_OUT 77U /*!< DMAMUX1 CRYP OUT request */
  249. #define DMA_REQUEST_HASH_IN 78U /*!< DMAMUX1 HASH IN request */
  250. #define DMA_REQUEST_UART7_RX 79U /*!< DMAMUX1 UART7 RX request */
  251. #define DMA_REQUEST_UART7_TX 80U /*!< DMAMUX1 UART7 TX request */
  252. #define DMA_REQUEST_UART8_RX 81U /*!< DMAMUX1 UART8 RX request */
  253. #define DMA_REQUEST_UART8_TX 82U /*!< DMAMUX1 UART8 TX request */
  254. #define DMA_REQUEST_SPI4_RX 83U /*!< DMAMUX1 SPI4 RX request */
  255. #define DMA_REQUEST_SPI4_TX 84U /*!< DMAMUX1 SPI4 TX request */
  256. #define DMA_REQUEST_SPI5_RX 85U /*!< DMAMUX1 SPI5 RX request */
  257. #define DMA_REQUEST_SPI5_TX 86U /*!< DMAMUX1 SPI5 TX request */
  258. #define DMA_REQUEST_SAI1_A 87U /*!< DMAMUX1 SAI1 A request */
  259. #define DMA_REQUEST_SAI1_B 88U /*!< DMAMUX1 SAI1 B request */
  260. #if defined(SAI2)
  261. #define DMA_REQUEST_SAI2_A 89U /*!< DMAMUX1 SAI2 A request */
  262. #define DMA_REQUEST_SAI2_B 90U /*!< DMAMUX1 SAI2 B request */
  263. #endif /* SAI2 */
  264. #define DMA_REQUEST_SWPMI_RX 91U /*!< DMAMUX1 SWPMI RX request */
  265. #define DMA_REQUEST_SWPMI_TX 92U /*!< DMAMUX1 SWPMI TX request */
  266. #define DMA_REQUEST_SPDIF_RX_DT 93U /*!< DMAMUX1 SPDIF RXDT request*/
  267. #define DMA_REQUEST_SPDIF_RX_CS 94U /*!< DMAMUX1 SPDIF RXCS request*/
  268. #if defined(HRTIM1)
  269. #define DMA_REQUEST_HRTIM_MASTER 95U /*!< DMAMUX1 HRTIM1 Master request 1 */
  270. #define DMA_REQUEST_HRTIM_TIMER_A 96U /*!< DMAMUX1 HRTIM1 Timer A request 2 */
  271. #define DMA_REQUEST_HRTIM_TIMER_B 97U /*!< DMAMUX1 HRTIM1 Timer B request 3 */
  272. #define DMA_REQUEST_HRTIM_TIMER_C 98U /*!< DMAMUX1 HRTIM1 Timer C request 4 */
  273. #define DMA_REQUEST_HRTIM_TIMER_D 99U /*!< DMAMUX1 HRTIM1 Timer D request 5 */
  274. #define DMA_REQUEST_HRTIM_TIMER_E 100U /*!< DMAMUX1 HRTIM1 Timer E request 6*/
  275. #endif /* HRTIM1 */
  276. #define DMA_REQUEST_DFSDM1_FLT0 101U /*!< DMAMUX1 DFSDM Filter0 request */
  277. #define DMA_REQUEST_DFSDM1_FLT1 102U /*!< DMAMUX1 DFSDM Filter1 request */
  278. #define DMA_REQUEST_DFSDM1_FLT2 103U /*!< DMAMUX1 DFSDM Filter2 request */
  279. #define DMA_REQUEST_DFSDM1_FLT3 104U /*!< DMAMUX1 DFSDM Filter3 request */
  280. #define DMA_REQUEST_TIM15_CH1 105U /*!< DMAMUX1 TIM15 CH1 request */
  281. #define DMA_REQUEST_TIM15_UP 106U /*!< DMAMUX1 TIM15 UP request */
  282. #define DMA_REQUEST_TIM15_TRIG 107U /*!< DMAMUX1 TIM15 TRIG request */
  283. #define DMA_REQUEST_TIM15_COM 108U /*!< DMAMUX1 TIM15 COM request */
  284. #define DMA_REQUEST_TIM16_CH1 109U /*!< DMAMUX1 TIM16 CH1 request */
  285. #define DMA_REQUEST_TIM16_UP 110U /*!< DMAMUX1 TIM16 UP request */
  286. #define DMA_REQUEST_TIM17_CH1 111U /*!< DMAMUX1 TIM17 CH1 request */
  287. #define DMA_REQUEST_TIM17_UP 112U /*!< DMAMUX1 TIM17 UP request */
  288. #if defined(SAI3)
  289. #define DMA_REQUEST_SAI3_A 113U /*!< DMAMUX1 SAI3 A request */
  290. #define DMA_REQUEST_SAI3_B 114U /*!< DMAMUX1 SAI3 B request */
  291. #endif /* SAI3 */
  292. #if defined(ADC3)
  293. #define DMA_REQUEST_ADC3 115U /*!< DMAMUX1 ADC3 request */
  294. #endif /* ADC3 */
  295. #if defined(UART9)
  296. #define DMA_REQUEST_UART9_RX 116U /*!< DMAMUX1 UART9 request */
  297. #define DMA_REQUEST_UART9_TX 117U /*!< DMAMUX1 UART9 request */
  298. #endif /* UART9 */
  299. #if defined(USART10)
  300. #define DMA_REQUEST_USART10_RX 118U /*!< DMAMUX1 USART10 request */
  301. #define DMA_REQUEST_USART10_TX 119U /*!< DMAMUX1 USART10 request */
  302. #endif /* USART10 */
  303. #if defined(FMAC)
  304. #define DMA_REQUEST_FMAC_READ 120U /*!< DMAMUX1 FMAC Read request */
  305. #define DMA_REQUEST_FMAC_WRITE 121U /*!< DMAMUX1 FMAC Write request */
  306. #endif /* FMAC */
  307. #if defined(CORDIC)
  308. #define DMA_REQUEST_CORDIC_READ 122U /*!< DMAMUX1 CORDIC Read request */
  309. #define DMA_REQUEST_CORDIC_WRITE 123U /*!< DMAMUX1 CORDIC Write request */
  310. #endif /* CORDIC */
  311. #if defined(I2C5)
  312. #define DMA_REQUEST_I2C5_RX 124U /*!< DMAMUX1 I2C5 RX request */
  313. #define DMA_REQUEST_I2C5_TX 125U /*!< DMAMUX1 I2C5 TX request */
  314. #endif /* I2C5 */
  315. #if defined(TIM23)
  316. #define DMA_REQUEST_TIM23_CH1 126U /*!< DMAMUX1 TIM23 CH1 request */
  317. #define DMA_REQUEST_TIM23_CH2 127U /*!< DMAMUX1 TIM23 CH2 request */
  318. #define DMA_REQUEST_TIM23_CH3 128U /*!< DMAMUX1 TIM23 CH3 request */
  319. #define DMA_REQUEST_TIM23_CH4 129U /*!< DMAMUX1 TIM23 CH4 request */
  320. #define DMA_REQUEST_TIM23_UP 130U /*!< DMAMUX1 TIM23 UP request */
  321. #define DMA_REQUEST_TIM23_TRIG 131U /*!< DMAMUX1 TIM23 TRIG request */
  322. #endif /* TIM23 */
  323. #if defined(TIM24)
  324. #define DMA_REQUEST_TIM24_CH1 132U /*!< DMAMUX1 TIM24 CH1 request */
  325. #define DMA_REQUEST_TIM24_CH2 133U /*!< DMAMUX1 TIM24 CH2 request */
  326. #define DMA_REQUEST_TIM24_CH3 134U /*!< DMAMUX1 TIM24 CH3 request */
  327. #define DMA_REQUEST_TIM24_CH4 135U /*!< DMAMUX1 TIM24 CH4 request */
  328. #define DMA_REQUEST_TIM24_UP 136U /*!< DMAMUX1 TIM24 UP request */
  329. #define DMA_REQUEST_TIM24_TRIG 137U /*!< DMAMUX1 TIM24 TRIG request */
  330. #endif /* TIM24 */
  331. /* DMAMUX2 requests */
  332. #define BDMA_REQUEST_MEM2MEM 0U /*!< memory to memory transfer */
  333. #define BDMA_REQUEST_GENERATOR0 1U /*!< DMAMUX2 request generator 0 */
  334. #define BDMA_REQUEST_GENERATOR1 2U /*!< DMAMUX2 request generator 1 */
  335. #define BDMA_REQUEST_GENERATOR2 3U /*!< DMAMUX2 request generator 2 */
  336. #define BDMA_REQUEST_GENERATOR3 4U /*!< DMAMUX2 request generator 3 */
  337. #define BDMA_REQUEST_GENERATOR4 5U /*!< DMAMUX2 request generator 4 */
  338. #define BDMA_REQUEST_GENERATOR5 6U /*!< DMAMUX2 request generator 5 */
  339. #define BDMA_REQUEST_GENERATOR6 7U /*!< DMAMUX2 request generator 6 */
  340. #define BDMA_REQUEST_GENERATOR7 8U /*!< DMAMUX2 request generator 7 */
  341. #define BDMA_REQUEST_LPUART1_RX 9U /*!< DMAMUX2 LP_UART1_RX request */
  342. #define BDMA_REQUEST_LPUART1_TX 10U /*!< DMAMUX2 LP_UART1_TX request */
  343. #define BDMA_REQUEST_SPI6_RX 11U /*!< DMAMUX2 SPI6 RX request */
  344. #define BDMA_REQUEST_SPI6_TX 12U /*!< DMAMUX2 SPI6 TX request */
  345. #define BDMA_REQUEST_I2C4_RX 13U /*!< DMAMUX2 I2C4 RX request */
  346. #define BDMA_REQUEST_I2C4_TX 14U /*!< DMAMUX2 I2C4 TX request */
  347. #if defined(SAI4)
  348. #define BDMA_REQUEST_SAI4_A 15U /*!< DMAMUX2 SAI4 A request */
  349. #define BDMA_REQUEST_SAI4_B 16U /*!< DMAMUX2 SAI4 B request */
  350. #endif /* SAI4 */
  351. #if defined(ADC3)
  352. #define BDMA_REQUEST_ADC3 17U /*!< DMAMUX2 ADC3 request */
  353. #endif /* ADC3 */
  354. #if defined(DAC2)
  355. #define BDMA_REQUEST_DAC2_CH1 17U /*!< DMAMUX2 DAC2 CH1 request */
  356. #endif /* DAC2 */
  357. #if defined(DFSDM2_Channel0)
  358. #define BDMA_REQUEST_DFSDM2_FLT0 18U /*!< DMAMUX2 DFSDM2 request */
  359. #endif /* DFSDM1_Channel0 */
  360. /**
  361. * @}
  362. */
  363. /** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
  364. * @brief DMA data transfer direction
  365. * @{
  366. */
  367. #define DMA_PERIPH_TO_MEMORY ((uint32_t)0x00000000U) /*!< Peripheral to memory direction */
  368. #define DMA_MEMORY_TO_PERIPH ((uint32_t)DMA_SxCR_DIR_0) /*!< Memory to peripheral direction */
  369. #define DMA_MEMORY_TO_MEMORY ((uint32_t)DMA_SxCR_DIR_1) /*!< Memory to memory direction */
  370. /**
  371. * @}
  372. */
  373. /** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
  374. * @brief DMA peripheral incremented mode
  375. * @{
  376. */
  377. #define DMA_PINC_ENABLE ((uint32_t)DMA_SxCR_PINC) /*!< Peripheral increment mode enable */
  378. #define DMA_PINC_DISABLE ((uint32_t)0x00000000U) /*!< Peripheral increment mode disable */
  379. /**
  380. * @}
  381. */
  382. /** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
  383. * @brief DMA memory incremented mode
  384. * @{
  385. */
  386. #define DMA_MINC_ENABLE ((uint32_t)DMA_SxCR_MINC) /*!< Memory increment mode enable */
  387. #define DMA_MINC_DISABLE ((uint32_t)0x00000000U) /*!< Memory increment mode disable */
  388. /**
  389. * @}
  390. */
  391. /** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
  392. * @brief DMA peripheral data size
  393. * @{
  394. */
  395. #define DMA_PDATAALIGN_BYTE ((uint32_t)0x00000000U) /*!< Peripheral data alignment: Byte */
  396. #define DMA_PDATAALIGN_HALFWORD ((uint32_t)DMA_SxCR_PSIZE_0) /*!< Peripheral data alignment: HalfWord */
  397. #define DMA_PDATAALIGN_WORD ((uint32_t)DMA_SxCR_PSIZE_1) /*!< Peripheral data alignment: Word */
  398. /**
  399. * @}
  400. */
  401. /** @defgroup DMA_Memory_data_size DMA Memory data size
  402. * @brief DMA memory data size
  403. * @{
  404. */
  405. #define DMA_MDATAALIGN_BYTE ((uint32_t)0x00000000U) /*!< Memory data alignment: Byte */
  406. #define DMA_MDATAALIGN_HALFWORD ((uint32_t)DMA_SxCR_MSIZE_0) /*!< Memory data alignment: HalfWord */
  407. #define DMA_MDATAALIGN_WORD ((uint32_t)DMA_SxCR_MSIZE_1) /*!< Memory data alignment: Word */
  408. /**
  409. * @}
  410. */
  411. /** @defgroup DMA_mode DMA mode
  412. * @brief DMA mode
  413. * @{
  414. */
  415. #define DMA_NORMAL ((uint32_t)0x00000000U) /*!< Normal mode */
  416. #define DMA_CIRCULAR ((uint32_t)DMA_SxCR_CIRC) /*!< Circular mode */
  417. #define DMA_PFCTRL ((uint32_t)DMA_SxCR_PFCTRL) /*!< Peripheral flow control mode */
  418. #define DMA_DOUBLE_BUFFER_M0 ((uint32_t)DMA_SxCR_DBM) /*!< Double buffer mode with first target memory M0 */
  419. #define DMA_DOUBLE_BUFFER_M1 ((uint32_t)(DMA_SxCR_DBM | DMA_SxCR_CT)) /*!< Double buffer mode with first target memory M1 */
  420. /**
  421. * @}
  422. */
  423. /** @defgroup DMA_Priority_level DMA Priority level
  424. * @brief DMA priority levels
  425. * @{
  426. */
  427. #define DMA_PRIORITY_LOW ((uint32_t)0x00000000U) /*!< Priority level: Low */
  428. #define DMA_PRIORITY_MEDIUM ((uint32_t)DMA_SxCR_PL_0) /*!< Priority level: Medium */
  429. #define DMA_PRIORITY_HIGH ((uint32_t)DMA_SxCR_PL_1) /*!< Priority level: High */
  430. #define DMA_PRIORITY_VERY_HIGH ((uint32_t)DMA_SxCR_PL) /*!< Priority level: Very High */
  431. /**
  432. * @}
  433. */
  434. /** @defgroup DMA_FIFO_direct_mode DMA FIFO direct mode
  435. * @brief DMA FIFO direct mode
  436. * @{
  437. */
  438. #define DMA_FIFOMODE_DISABLE ((uint32_t)0x00000000U) /*!< FIFO mode disable */
  439. #define DMA_FIFOMODE_ENABLE ((uint32_t)DMA_SxFCR_DMDIS) /*!< FIFO mode enable */
  440. /**
  441. * @}
  442. */
  443. /** @defgroup DMA_FIFO_threshold_level DMA FIFO threshold level
  444. * @brief DMA FIFO level
  445. * @{
  446. */
  447. #define DMA_FIFO_THRESHOLD_1QUARTERFULL ((uint32_t)0x00000000U) /*!< FIFO threshold 1 quart full configuration */
  448. #define DMA_FIFO_THRESHOLD_HALFFULL ((uint32_t)DMA_SxFCR_FTH_0) /*!< FIFO threshold half full configuration */
  449. #define DMA_FIFO_THRESHOLD_3QUARTERSFULL ((uint32_t)DMA_SxFCR_FTH_1) /*!< FIFO threshold 3 quarts full configuration */
  450. #define DMA_FIFO_THRESHOLD_FULL ((uint32_t)DMA_SxFCR_FTH) /*!< FIFO threshold full configuration */
  451. /**
  452. * @}
  453. */
  454. /** @defgroup DMA_Memory_burst DMA Memory burst
  455. * @brief DMA memory burst
  456. * @{
  457. */
  458. #define DMA_MBURST_SINGLE ((uint32_t)0x00000000U)
  459. #define DMA_MBURST_INC4 ((uint32_t)DMA_SxCR_MBURST_0)
  460. #define DMA_MBURST_INC8 ((uint32_t)DMA_SxCR_MBURST_1)
  461. #define DMA_MBURST_INC16 ((uint32_t)DMA_SxCR_MBURST)
  462. /**
  463. * @}
  464. */
  465. /** @defgroup DMA_Peripheral_burst DMA Peripheral burst
  466. * @brief DMA peripheral burst
  467. * @{
  468. */
  469. #define DMA_PBURST_SINGLE ((uint32_t)0x00000000U)
  470. #define DMA_PBURST_INC4 ((uint32_t)DMA_SxCR_PBURST_0)
  471. #define DMA_PBURST_INC8 ((uint32_t)DMA_SxCR_PBURST_1)
  472. #define DMA_PBURST_INC16 ((uint32_t)DMA_SxCR_PBURST)
  473. /**
  474. * @}
  475. */
  476. /** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
  477. * @brief DMA interrupts definition
  478. * @{
  479. */
  480. #define DMA_IT_TC ((uint32_t)DMA_SxCR_TCIE)
  481. #define DMA_IT_HT ((uint32_t)DMA_SxCR_HTIE)
  482. #define DMA_IT_TE ((uint32_t)DMA_SxCR_TEIE)
  483. #define DMA_IT_DME ((uint32_t)DMA_SxCR_DMEIE)
  484. #define DMA_IT_FE ((uint32_t)0x00000080U)
  485. /**
  486. * @}
  487. */
  488. /** @defgroup DMA_flag_definitions DMA flag definitions
  489. * @brief DMA flag definitions
  490. * @{
  491. */
  492. #define DMA_FLAG_FEIF0_4 ((uint32_t)0x00000001U)
  493. #define DMA_FLAG_DMEIF0_4 ((uint32_t)0x00000004U)
  494. #define DMA_FLAG_TEIF0_4 ((uint32_t)0x00000008U)
  495. #define DMA_FLAG_HTIF0_4 ((uint32_t)0x00000010U)
  496. #define DMA_FLAG_TCIF0_4 ((uint32_t)0x00000020U)
  497. #define DMA_FLAG_FEIF1_5 ((uint32_t)0x00000040U)
  498. #define DMA_FLAG_DMEIF1_5 ((uint32_t)0x00000100U)
  499. #define DMA_FLAG_TEIF1_5 ((uint32_t)0x00000200U)
  500. #define DMA_FLAG_HTIF1_5 ((uint32_t)0x00000400U)
  501. #define DMA_FLAG_TCIF1_5 ((uint32_t)0x00000800U)
  502. #define DMA_FLAG_FEIF2_6 ((uint32_t)0x00010000U)
  503. #define DMA_FLAG_DMEIF2_6 ((uint32_t)0x00040000U)
  504. #define DMA_FLAG_TEIF2_6 ((uint32_t)0x00080000U)
  505. #define DMA_FLAG_HTIF2_6 ((uint32_t)0x00100000U)
  506. #define DMA_FLAG_TCIF2_6 ((uint32_t)0x00200000U)
  507. #define DMA_FLAG_FEIF3_7 ((uint32_t)0x00400000U)
  508. #define DMA_FLAG_DMEIF3_7 ((uint32_t)0x01000000U)
  509. #define DMA_FLAG_TEIF3_7 ((uint32_t)0x02000000U)
  510. #define DMA_FLAG_HTIF3_7 ((uint32_t)0x04000000U)
  511. #define DMA_FLAG_TCIF3_7 ((uint32_t)0x08000000U)
  512. /**
  513. * @}
  514. */
  515. /** @defgroup BDMA_flag_definitions BDMA flag definitions
  516. * @brief BDMA flag definitions
  517. * @{
  518. */
  519. #define BDMA_FLAG_GL0 ((uint32_t)0x00000001)
  520. #define BDMA_FLAG_TC0 ((uint32_t)0x00000002)
  521. #define BDMA_FLAG_HT0 ((uint32_t)0x00000004)
  522. #define BDMA_FLAG_TE0 ((uint32_t)0x00000008)
  523. #define BDMA_FLAG_GL1 ((uint32_t)0x00000010)
  524. #define BDMA_FLAG_TC1 ((uint32_t)0x00000020)
  525. #define BDMA_FLAG_HT1 ((uint32_t)0x00000040)
  526. #define BDMA_FLAG_TE1 ((uint32_t)0x00000080)
  527. #define BDMA_FLAG_GL2 ((uint32_t)0x00000100)
  528. #define BDMA_FLAG_TC2 ((uint32_t)0x00000200)
  529. #define BDMA_FLAG_HT2 ((uint32_t)0x00000400)
  530. #define BDMA_FLAG_TE2 ((uint32_t)0x00000800)
  531. #define BDMA_FLAG_GL3 ((uint32_t)0x00001000)
  532. #define BDMA_FLAG_TC3 ((uint32_t)0x00002000)
  533. #define BDMA_FLAG_HT3 ((uint32_t)0x00004000)
  534. #define BDMA_FLAG_TE3 ((uint32_t)0x00008000)
  535. #define BDMA_FLAG_GL4 ((uint32_t)0x00010000)
  536. #define BDMA_FLAG_TC4 ((uint32_t)0x00020000)
  537. #define BDMA_FLAG_HT4 ((uint32_t)0x00040000)
  538. #define BDMA_FLAG_TE4 ((uint32_t)0x00080000)
  539. #define BDMA_FLAG_GL5 ((uint32_t)0x00100000)
  540. #define BDMA_FLAG_TC5 ((uint32_t)0x00200000)
  541. #define BDMA_FLAG_HT5 ((uint32_t)0x00400000)
  542. #define BDMA_FLAG_TE5 ((uint32_t)0x00800000)
  543. #define BDMA_FLAG_GL6 ((uint32_t)0x01000000)
  544. #define BDMA_FLAG_TC6 ((uint32_t)0x02000000)
  545. #define BDMA_FLAG_HT6 ((uint32_t)0x04000000)
  546. #define BDMA_FLAG_TE6 ((uint32_t)0x08000000)
  547. #define BDMA_FLAG_GL7 ((uint32_t)0x10000000)
  548. #define BDMA_FLAG_TC7 ((uint32_t)0x20000000)
  549. #define BDMA_FLAG_HT7 ((uint32_t)0x40000000)
  550. #define BDMA_FLAG_TE7 ((uint32_t)0x80000000)
  551. /**
  552. * @}
  553. */
  554. /**
  555. * @}
  556. */
  557. /* Exported macro ------------------------------------------------------------*/
  558. /** @defgroup DMA_Exported_Macros DMA Exported Macros
  559. * @{
  560. */
  561. /** @brief Reset DMA handle state
  562. * @param __HANDLE__: specifies the DMA handle.
  563. * @retval None
  564. */
  565. #define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
  566. /**
  567. * @brief Return the current DMA Stream FIFO filled level.
  568. * @param __HANDLE__: DMA handle
  569. * @retval The FIFO filling state.
  570. * - DMA_FIFOStatus_Less1QuarterFull: when FIFO is less than 1 quarter-full
  571. * and not empty.
  572. * - DMA_FIFOStatus_1QuarterFull: if more than 1 quarter-full.
  573. * - DMA_FIFOStatus_HalfFull: if more than 1 half-full.
  574. * - DMA_FIFOStatus_3QuartersFull: if more than 3 quarters-full.
  575. * - DMA_FIFOStatus_Empty: when FIFO is empty
  576. * - DMA_FIFOStatus_Full: when FIFO is full
  577. */
  578. #define __HAL_DMA_GET_FS(__HANDLE__) ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))? (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->FCR & (DMA_SxFCR_FS)) : 0)
  579. /**
  580. * @brief Enable the specified DMA Stream.
  581. * @param __HANDLE__: DMA handle
  582. * @retval None
  583. */
  584. #define __HAL_DMA_ENABLE(__HANDLE__) \
  585. ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))? (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->CR |= DMA_SxCR_EN) : \
  586. (((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CCR |= BDMA_CCR_EN))
  587. /**
  588. * @brief Disable the specified DMA Stream.
  589. * @param __HANDLE__: DMA handle
  590. * @retval None
  591. */
  592. #define __HAL_DMA_DISABLE(__HANDLE__) \
  593. ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))? (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->CR &= ~DMA_SxCR_EN) : \
  594. (((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CCR &= ~BDMA_CCR_EN))
  595. /* Interrupt & Flag management */
  596. /**
  597. * @brief Return the current DMA Stream transfer complete flag.
  598. * @param __HANDLE__: DMA handle
  599. * @retval The specified transfer complete flag index.
  600. */
  601. #if defined(BDMA1)
  602. #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
  603. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TCIF0_4 :\
  604. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TCIF0_4 :\
  605. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TCIF0_4 :\
  606. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TCIF0_4 :\
  607. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TCIF1_5 :\
  608. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TCIF1_5 :\
  609. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TCIF1_5 :\
  610. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TCIF1_5 :\
  611. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TCIF2_6 :\
  612. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TCIF2_6 :\
  613. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TCIF2_6 :\
  614. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TCIF2_6 :\
  615. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_TCIF3_7 :\
  616. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_TCIF3_7 :\
  617. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_TCIF3_7 :\
  618. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_TCIF3_7 :\
  619. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel0))? BDMA_FLAG_TC0 :\
  620. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel0))? BDMA_FLAG_TC0 :\
  621. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel1))? BDMA_FLAG_TC1 :\
  622. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel1))? BDMA_FLAG_TC1 :\
  623. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel2))? BDMA_FLAG_TC2 :\
  624. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel2))? BDMA_FLAG_TC2 :\
  625. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel3))? BDMA_FLAG_TC3 :\
  626. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel3))? BDMA_FLAG_TC3 :\
  627. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel4))? BDMA_FLAG_TC4 :\
  628. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel4))? BDMA_FLAG_TC4 :\
  629. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel5))? BDMA_FLAG_TC5 :\
  630. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel5))? BDMA_FLAG_TC5 :\
  631. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel6))? BDMA_FLAG_TC6 :\
  632. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel6))? BDMA_FLAG_TC6 :\
  633. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel7))? BDMA_FLAG_TC7 :\
  634. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel7))? BDMA_FLAG_TC7 :\
  635. (uint32_t)0x00000000)
  636. #else
  637. #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
  638. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TCIF0_4 :\
  639. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TCIF0_4 :\
  640. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TCIF0_4 :\
  641. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TCIF0_4 :\
  642. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TCIF1_5 :\
  643. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TCIF1_5 :\
  644. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TCIF1_5 :\
  645. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TCIF1_5 :\
  646. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TCIF2_6 :\
  647. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TCIF2_6 :\
  648. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TCIF2_6 :\
  649. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TCIF2_6 :\
  650. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_TCIF3_7 :\
  651. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_TCIF3_7 :\
  652. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_TCIF3_7 :\
  653. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_TCIF3_7 :\
  654. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel0))? BDMA_FLAG_TC0 :\
  655. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel1))? BDMA_FLAG_TC1 :\
  656. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel2))? BDMA_FLAG_TC2 :\
  657. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel3))? BDMA_FLAG_TC3 :\
  658. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel4))? BDMA_FLAG_TC4 :\
  659. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel5))? BDMA_FLAG_TC5 :\
  660. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel6))? BDMA_FLAG_TC6 :\
  661. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel7))? BDMA_FLAG_TC7 :\
  662. (uint32_t)0x00000000)
  663. #endif /* BDMA1 */
  664. /**
  665. * @brief Return the current DMA Stream half transfer complete flag.
  666. * @param __HANDLE__: DMA handle
  667. * @retval The specified half transfer complete flag index.
  668. */
  669. #if defined(BDMA1)
  670. #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
  671. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_HTIF0_4 :\
  672. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_HTIF0_4 :\
  673. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_HTIF0_4 :\
  674. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_HTIF0_4 :\
  675. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_HTIF1_5 :\
  676. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_HTIF1_5 :\
  677. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_HTIF1_5 :\
  678. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_HTIF1_5 :\
  679. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_HTIF2_6 :\
  680. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_HTIF2_6 :\
  681. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_HTIF2_6 :\
  682. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_HTIF2_6 :\
  683. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_HTIF3_7 :\
  684. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_HTIF3_7 :\
  685. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_HTIF3_7 :\
  686. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_HTIF3_7 :\
  687. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel0))? BDMA_FLAG_HT0 :\
  688. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel0))? BDMA_FLAG_HT0 :\
  689. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel1))? BDMA_FLAG_HT1 :\
  690. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel1))? BDMA_FLAG_HT1 :\
  691. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel2))? BDMA_FLAG_HT2 :\
  692. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel2))? BDMA_FLAG_HT2 :\
  693. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel3))? BDMA_FLAG_HT3 :\
  694. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel3))? BDMA_FLAG_HT3 :\
  695. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel4))? BDMA_FLAG_HT4 :\
  696. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel4))? BDMA_FLAG_HT4 :\
  697. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel5))? BDMA_FLAG_HT5 :\
  698. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel5))? BDMA_FLAG_HT5 :\
  699. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel6))? BDMA_FLAG_HT6 :\
  700. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel6))? BDMA_FLAG_HT6 :\
  701. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel7))? BDMA_FLAG_HT7 :\
  702. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel7))? BDMA_FLAG_HT7 :\
  703. (uint32_t)0x00000000)
  704. #else
  705. #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
  706. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_HTIF0_4 :\
  707. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_HTIF0_4 :\
  708. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_HTIF0_4 :\
  709. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_HTIF0_4 :\
  710. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_HTIF1_5 :\
  711. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_HTIF1_5 :\
  712. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_HTIF1_5 :\
  713. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_HTIF1_5 :\
  714. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_HTIF2_6 :\
  715. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_HTIF2_6 :\
  716. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_HTIF2_6 :\
  717. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_HTIF2_6 :\
  718. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_HTIF3_7 :\
  719. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_HTIF3_7 :\
  720. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_HTIF3_7 :\
  721. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_HTIF3_7 :\
  722. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel0))? BDMA_FLAG_HT0 :\
  723. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel1))? BDMA_FLAG_HT1 :\
  724. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel2))? BDMA_FLAG_HT2 :\
  725. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel3))? BDMA_FLAG_HT3 :\
  726. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel4))? BDMA_FLAG_HT4 :\
  727. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel5))? BDMA_FLAG_HT5 :\
  728. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel6))? BDMA_FLAG_HT6 :\
  729. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel7))? BDMA_FLAG_HT7 :\
  730. (uint32_t)0x00000000)
  731. #endif /* BDMA1 */
  732. /**
  733. * @brief Return the current DMA Stream transfer error flag.
  734. * @param __HANDLE__: DMA handle
  735. * @retval The specified transfer error flag index.
  736. */
  737. #if defined(BDMA1)
  738. #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
  739. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TEIF0_4 :\
  740. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TEIF0_4 :\
  741. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TEIF0_4 :\
  742. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TEIF0_4 :\
  743. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TEIF1_5 :\
  744. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TEIF1_5 :\
  745. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TEIF1_5 :\
  746. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TEIF1_5 :\
  747. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TEIF2_6 :\
  748. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TEIF2_6 :\
  749. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TEIF2_6 :\
  750. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TEIF2_6 :\
  751. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_TEIF3_7 :\
  752. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_TEIF3_7 :\
  753. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_TEIF3_7 :\
  754. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_TEIF3_7 :\
  755. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel0))? BDMA_FLAG_TE0 :\
  756. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel0))? BDMA_FLAG_TE0 :\
  757. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel1))? BDMA_FLAG_TE1 :\
  758. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel1))? BDMA_FLAG_TE1 :\
  759. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel2))? BDMA_FLAG_TE2 :\
  760. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel2))? BDMA_FLAG_TE2 :\
  761. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel3))? BDMA_FLAG_TE3 :\
  762. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel3))? BDMA_FLAG_TE3 :\
  763. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel4))? BDMA_FLAG_TE4 :\
  764. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel4))? BDMA_FLAG_TE4 :\
  765. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel5))? BDMA_FLAG_TE5 :\
  766. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel5))? BDMA_FLAG_TE5 :\
  767. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel6))? BDMA_FLAG_TE6 :\
  768. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel6))? BDMA_FLAG_TE6 :\
  769. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel7))? BDMA_FLAG_TE7 :\
  770. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel7))? BDMA_FLAG_TE7 :\
  771. (uint32_t)0x00000000)
  772. #else
  773. #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
  774. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_TEIF0_4 :\
  775. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_TEIF0_4 :\
  776. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_TEIF0_4 :\
  777. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_TEIF0_4 :\
  778. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_TEIF1_5 :\
  779. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_TEIF1_5 :\
  780. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_TEIF1_5 :\
  781. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_TEIF1_5 :\
  782. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_TEIF2_6 :\
  783. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_TEIF2_6 :\
  784. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_TEIF2_6 :\
  785. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_TEIF2_6 :\
  786. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_TEIF3_7 :\
  787. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_TEIF3_7 :\
  788. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_TEIF3_7 :\
  789. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_TEIF3_7 :\
  790. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel0))? BDMA_FLAG_TE0 :\
  791. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel1))? BDMA_FLAG_TE1 :\
  792. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel2))? BDMA_FLAG_TE2 :\
  793. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel3))? BDMA_FLAG_TE3 :\
  794. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel4))? BDMA_FLAG_TE4 :\
  795. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel5))? BDMA_FLAG_TE5 :\
  796. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel6))? BDMA_FLAG_TE6 :\
  797. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel7))? BDMA_FLAG_TE7 :\
  798. (uint32_t)0x00000000)
  799. #endif /* BDMA1 */
  800. /**
  801. * @brief Return the current DMA Stream FIFO error flag.
  802. * @param __HANDLE__: DMA handle
  803. * @retval The specified FIFO error flag index.
  804. */
  805. #define __HAL_DMA_GET_FE_FLAG_INDEX(__HANDLE__)\
  806. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_FEIF0_4 :\
  807. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_FEIF0_4 :\
  808. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_FEIF0_4 :\
  809. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_FEIF0_4 :\
  810. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_FEIF1_5 :\
  811. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_FEIF1_5 :\
  812. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_FEIF1_5 :\
  813. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_FEIF1_5 :\
  814. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_FEIF2_6 :\
  815. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_FEIF2_6 :\
  816. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_FEIF2_6 :\
  817. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_FEIF2_6 :\
  818. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_FEIF3_7 :\
  819. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_FEIF3_7 :\
  820. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_FEIF3_7 :\
  821. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_FEIF3_7 :\
  822. (uint32_t)0x00000000)
  823. /**
  824. * @brief Return the current DMA Stream direct mode error flag.
  825. * @param __HANDLE__: DMA handle
  826. * @retval The specified direct mode error flag index.
  827. */
  828. #define __HAL_DMA_GET_DME_FLAG_INDEX(__HANDLE__)\
  829. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream0))? DMA_FLAG_DMEIF0_4 :\
  830. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream0))? DMA_FLAG_DMEIF0_4 :\
  831. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream4))? DMA_FLAG_DMEIF0_4 :\
  832. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream4))? DMA_FLAG_DMEIF0_4 :\
  833. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream1))? DMA_FLAG_DMEIF1_5 :\
  834. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream1))? DMA_FLAG_DMEIF1_5 :\
  835. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream5))? DMA_FLAG_DMEIF1_5 :\
  836. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream5))? DMA_FLAG_DMEIF1_5 :\
  837. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream2))? DMA_FLAG_DMEIF2_6 :\
  838. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream2))? DMA_FLAG_DMEIF2_6 :\
  839. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream6))? DMA_FLAG_DMEIF2_6 :\
  840. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream6))? DMA_FLAG_DMEIF2_6 :\
  841. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream3))? DMA_FLAG_DMEIF3_7 :\
  842. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream3))? DMA_FLAG_DMEIF3_7 :\
  843. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Stream7))? DMA_FLAG_DMEIF3_7 :\
  844. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Stream7))? DMA_FLAG_DMEIF3_7 :\
  845. (uint32_t)0x00000000)
  846. /**
  847. * @brief Returns the current BDMA Channel Global interrupt flag.
  848. * @param __HANDLE__: DMA handle
  849. * @retval The specified transfer error flag index.
  850. */
  851. #if defined(BDMA1)
  852. #define __HAL_BDMA_GET_GI_FLAG_INDEX(__HANDLE__)\
  853. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel0))? BDMA_ISR_GIF0 :\
  854. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel0))? BDMA_ISR_GIF0 :\
  855. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel1))? BDMA_ISR_GIF1 :\
  856. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel1))? BDMA_ISR_GIF1 :\
  857. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel2))? BDMA_ISR_GIF2 :\
  858. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel2))? BDMA_ISR_GIF2 :\
  859. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel3))? BDMA_ISR_GIF3 :\
  860. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel3))? BDMA_ISR_GIF3 :\
  861. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel4))? BDMA_ISR_GIF4 :\
  862. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel4))? BDMA_ISR_GIF4 :\
  863. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel5))? BDMA_ISR_GIF5 :\
  864. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel5))? BDMA_ISR_GIF5 :\
  865. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel6))? BDMA_ISR_GIF6 :\
  866. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel6))? BDMA_ISR_GIF6 :\
  867. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA1_Channel7))? BDMA_ISR_GIF7 :\
  868. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA2_Channel7))? BDMA_ISR_GIF7 :\
  869. (uint32_t)0x00000000)
  870. #else
  871. #define __HAL_BDMA_GET_GI_FLAG_INDEX(__HANDLE__)\
  872. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel0))? BDMA_ISR_GIF0 :\
  873. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel1))? BDMA_ISR_GIF1 :\
  874. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel2))? BDMA_ISR_GIF2 :\
  875. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel3))? BDMA_ISR_GIF3 :\
  876. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel4))? BDMA_ISR_GIF4 :\
  877. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel5))? BDMA_ISR_GIF5 :\
  878. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel6))? BDMA_ISR_GIF6 :\
  879. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)BDMA_Channel7))? BDMA_ISR_GIF7 :\
  880. (uint32_t)0x00000000)
  881. #endif /* BDMA1 */
  882. /**
  883. * @brief Get the DMA Stream pending flags.
  884. * @param __HANDLE__: DMA handle
  885. * @param __FLAG__: Get the specified flag.
  886. * This parameter can be any combination of the following values:
  887. * @arg DMA_FLAG_TCIFx: Transfer complete flag.
  888. * @arg DMA_FLAG_HTIFx: Half transfer complete flag.
  889. * @arg DMA_FLAG_TEIFx: Transfer error flag.
  890. * @arg DMA_FLAG_DMEIFx: Direct mode error flag.
  891. * @arg DMA_FLAG_FEIFx: FIFO error flag.
  892. * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag.
  893. * @retval The state of FLAG (SET or RESET).
  894. */
  895. #if defined(BDMA1)
  896. #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\
  897. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)BDMA1_Channel7)? (BDMA2->ISR & (__FLAG__)) :\
  898. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream7 )? (BDMA1->ISR & (__FLAG__)) :\
  899. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3 )? (DMA2->HISR & (__FLAG__)) :\
  900. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7 )? (DMA2->LISR & (__FLAG__)) :\
  901. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3 )? (DMA1->HISR & (__FLAG__)) : (DMA1->LISR & (__FLAG__)))
  902. #else
  903. #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\
  904. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream7)? (BDMA->ISR & (__FLAG__)) :\
  905. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HISR & (__FLAG__)) :\
  906. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LISR & (__FLAG__)) :\
  907. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HISR & (__FLAG__)) : (DMA1->LISR & (__FLAG__)))
  908. #endif /* BDMA1 */
  909. /**
  910. * @brief Clear the DMA Stream pending flags.
  911. * @param __HANDLE__: DMA handle
  912. * @param __FLAG__: specifies the flag to clear.
  913. * This parameter can be any combination of the following values:
  914. * @arg DMA_FLAG_TCIFx: Transfer complete flag.
  915. * @arg DMA_FLAG_HTIFx: Half transfer complete flag.
  916. * @arg DMA_FLAG_TEIFx: Transfer error flag.
  917. * @arg DMA_FLAG_DMEIFx: Direct mode error flag.
  918. * @arg DMA_FLAG_FEIFx: FIFO error flag.
  919. * Where x can be 0_4, 1_5, 2_6 or 3_7 to select the DMA Stream flag.
  920. * @retval None
  921. */
  922. #if defined(BDMA1)
  923. #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  924. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)BDMA1_Channel7)? (BDMA2->IFCR = (__FLAG__)) :\
  925. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream7)? (BDMA1->IFCR = (__FLAG__)) :\
  926. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HIFCR = (__FLAG__)) :\
  927. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LIFCR = (__FLAG__)) :\
  928. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HIFCR = (__FLAG__)) : (DMA1->LIFCR = (__FLAG__)))
  929. #else
  930. #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  931. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream7)? (BDMA->IFCR = (__FLAG__)) :\
  932. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA2_Stream3)? (DMA2->HIFCR = (__FLAG__)) :\
  933. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream7)? (DMA2->LIFCR = (__FLAG__)) :\
  934. ((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Stream3)? (DMA1->HIFCR = (__FLAG__)) : (DMA1->LIFCR = (__FLAG__)))
  935. #endif /* BDMA1 */
  936. #define DMA_TO_BDMA_IT(__DMA_IT__) \
  937. ((((__DMA_IT__) & (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE)) == (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE)) ? (BDMA_CCR_TCIE | BDMA_CCR_HTIE |BDMA_CCR_TEIE) :\
  938. (((__DMA_IT__) & (DMA_IT_TC | DMA_IT_HT)) == (DMA_IT_TC | DMA_IT_HT)) ? (BDMA_CCR_TCIE | BDMA_CCR_HTIE) :\
  939. (((__DMA_IT__) & (DMA_IT_HT | DMA_IT_TE)) == (DMA_IT_HT | DMA_IT_TE)) ? (BDMA_CCR_HTIE |BDMA_CCR_TEIE) :\
  940. (((__DMA_IT__) & (DMA_IT_TC | DMA_IT_TE)) == (DMA_IT_TC | DMA_IT_TE)) ? (BDMA_CCR_TCIE |BDMA_CCR_TEIE) :\
  941. ((__DMA_IT__) == DMA_IT_TC) ? BDMA_CCR_TCIE :\
  942. ((__DMA_IT__) == DMA_IT_HT) ? BDMA_CCR_HTIE :\
  943. ((__DMA_IT__) == DMA_IT_TE) ? BDMA_CCR_TEIE :\
  944. (uint32_t)0x00000000)
  945. #define __HAL_BDMA_CHANNEL_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
  946. (((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CCR |= (DMA_TO_BDMA_IT(__INTERRUPT__)))
  947. #define __HAL_DMA_STREAM_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
  948. (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->CR |= (__INTERRUPT__)) : (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->FCR |= (__INTERRUPT__)))
  949. /**
  950. * @brief Enable the specified DMA Stream interrupts.
  951. * @param __HANDLE__: DMA handle
  952. * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
  953. * This parameter can be one of the following values:
  954. * @arg DMA_IT_TC: Transfer complete interrupt mask.
  955. * @arg DMA_IT_HT: Half transfer complete interrupt mask.
  956. * @arg DMA_IT_TE: Transfer error interrupt mask.
  957. * @arg DMA_IT_FE: FIFO error interrupt mask.
  958. * @arg DMA_IT_DME: Direct mode error interrupt.
  959. * @retval None
  960. */
  961. #define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))?\
  962. (__HAL_DMA_STREAM_ENABLE_IT((__HANDLE__), (__INTERRUPT__))) :\
  963. (__HAL_BDMA_CHANNEL_ENABLE_IT((__HANDLE__), (__INTERRUPT__))))
  964. #define __HAL_BDMA_CHANNEL_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CCR &= ~(DMA_TO_BDMA_IT(__INTERRUPT__)))
  965. #define __HAL_DMA_STREAM_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
  966. (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->CR &= ~(__INTERRUPT__)) : (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->FCR &= ~(__INTERRUPT__)))
  967. /**
  968. * @brief Disable the specified DMA Stream interrupts.
  969. * @param __HANDLE__: DMA handle
  970. * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
  971. * This parameter can be one of the following values:
  972. * @arg DMA_IT_TC: Transfer complete interrupt mask.
  973. * @arg DMA_IT_HT: Half transfer complete interrupt mask.
  974. * @arg DMA_IT_TE: Transfer error interrupt mask.
  975. * @arg DMA_IT_FE: FIFO error interrupt mask.
  976. * @arg DMA_IT_DME: Direct mode error interrupt.
  977. * @retval None
  978. */
  979. #define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))?\
  980. (__HAL_DMA_STREAM_DISABLE_IT((__HANDLE__), (__INTERRUPT__))) :\
  981. (__HAL_BDMA_CHANNEL_DISABLE_IT((__HANDLE__), (__INTERRUPT__))))
  982. #define __HAL_BDMA_CHANNEL_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CCR & (DMA_TO_BDMA_IT(__INTERRUPT__))))
  983. #define __HAL_DMA_STREAM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) != DMA_IT_FE)? \
  984. (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->CR & (__INTERRUPT__)) : \
  985. (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->FCR & (__INTERRUPT__)))
  986. /**
  987. * @brief Check whether the specified DMA Stream interrupt is enabled or not.
  988. * @param __HANDLE__: DMA handle
  989. * @param __INTERRUPT__: specifies the DMA interrupt source to check.
  990. * This parameter can be one of the following values:
  991. * @arg DMA_IT_TC: Transfer complete interrupt mask.
  992. * @arg DMA_IT_HT: Half transfer complete interrupt mask.
  993. * @arg DMA_IT_TE: Transfer error interrupt mask.
  994. * @arg DMA_IT_FE: FIFO error interrupt mask.
  995. * @arg DMA_IT_DME: Direct mode error interrupt.
  996. * @retval The state of DMA_IT.
  997. */
  998. #define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))? \
  999. (__HAL_DMA_STREAM_GET_IT_SOURCE((__HANDLE__), (__INTERRUPT__))) :\
  1000. (__HAL_BDMA_CHANNEL_GET_IT_SOURCE((__HANDLE__), (__INTERRUPT__))))
  1001. /**
  1002. * @brief Writes the number of data units to be transferred on the DMA Stream.
  1003. * @param __HANDLE__: DMA handle
  1004. * @param __COUNTER__: Number of data units to be transferred (from 0 to 65535)
  1005. * Number of data items depends only on the Peripheral data format.
  1006. *
  1007. * @note If Peripheral data format is Bytes: number of data units is equal
  1008. * to total number of bytes to be transferred.
  1009. *
  1010. * @note If Peripheral data format is Half-Word: number of data units is
  1011. * equal to total number of bytes to be transferred / 2.
  1012. *
  1013. * @note If Peripheral data format is Word: number of data units is equal
  1014. * to total number of bytes to be transferred / 4.
  1015. *
  1016. * @retval The number of remaining data units in the current DMAy Streamx transfer.
  1017. */
  1018. #define __HAL_DMA_SET_COUNTER(__HANDLE__, __COUNTER__) ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))? \
  1019. (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->NDTR = (uint16_t)(__COUNTER__)) :\
  1020. (((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CNDTR = (uint16_t)(__COUNTER__)))
  1021. /**
  1022. * @brief Returns the number of remaining data units in the current DMAy Streamx transfer.
  1023. * @param __HANDLE__: DMA handle
  1024. *
  1025. * @retval The number of remaining data units in the current DMA Stream transfer.
  1026. */
  1027. #define __HAL_DMA_GET_COUNTER(__HANDLE__) ((IS_DMA_STREAM_INSTANCE((__HANDLE__)->Instance))? \
  1028. (((DMA_Stream_TypeDef *)(__HANDLE__)->Instance)->NDTR) :\
  1029. (((BDMA_Channel_TypeDef *)(__HANDLE__)->Instance)->CNDTR))
  1030. /**
  1031. * @}
  1032. */
  1033. /* Include DMA HAL Extension module */
  1034. #include "stm32h7xx_hal_dma_ex.h"
  1035. /* Exported functions --------------------------------------------------------*/
  1036. /** @defgroup DMA_Exported_Functions DMA Exported Functions
  1037. * @brief DMA Exported functions
  1038. * @{
  1039. */
  1040. /** @defgroup DMA_Exported_Functions_Group1 Initialization and de-initialization functions
  1041. * @brief Initialization and de-initialization functions
  1042. * @{
  1043. */
  1044. HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
  1045. HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma);
  1046. /**
  1047. * @}
  1048. */
  1049. /** @defgroup DMA_Exported_Functions_Group2 I/O operation functions
  1050. * @brief I/O operation functions
  1051. * @{
  1052. */
  1053. HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
  1054. HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
  1055. HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
  1056. HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
  1057. HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, HAL_DMA_LevelCompleteTypeDef CompleteLevel, uint32_t Timeout);
  1058. void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
  1059. HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)(DMA_HandleTypeDef *_hdma));
  1060. HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID);
  1061. /**
  1062. * @}
  1063. */
  1064. /** @defgroup DMA_Exported_Functions_Group3 Peripheral State functions
  1065. * @brief Peripheral State functions
  1066. * @{
  1067. */
  1068. HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
  1069. uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
  1070. /**
  1071. * @}
  1072. */
  1073. /**
  1074. * @}
  1075. */
  1076. /* Private Constants -------------------------------------------------------------*/
  1077. /** @defgroup DMA_Private_Constants DMA Private Constants
  1078. * @brief DMA private defines and constants
  1079. * @{
  1080. */
  1081. /**
  1082. * @}
  1083. */
  1084. /* Private types -------------------------------------------------------------*/
  1085. /** @defgroup DMA_Private_Types DMA Private Types
  1086. * @{
  1087. */
  1088. /**
  1089. * @}
  1090. */
  1091. /* Private macros ------------------------------------------------------------*/
  1092. /** @defgroup DMA_Private_Macros DMA Private Macros
  1093. * @brief DMA private macros
  1094. * @{
  1095. */
  1096. #if defined(TIM24)
  1097. #define IS_DMA_REQUEST(REQUEST) (((REQUEST) <= DMA_REQUEST_TIM24_TRIG))
  1098. #elif defined(ADC3)
  1099. #define IS_DMA_REQUEST(REQUEST) (((REQUEST) <= DMA_REQUEST_ADC3))
  1100. #else
  1101. #define IS_DMA_REQUEST(REQUEST) (((REQUEST) <= DMA_REQUEST_USART10_TX))
  1102. #endif /* TIM24 */
  1103. #if defined(ADC3)
  1104. #define IS_BDMA_REQUEST(REQUEST) (((REQUEST) <= BDMA_REQUEST_ADC3))
  1105. #else
  1106. #define IS_BDMA_REQUEST(REQUEST) (((REQUEST) <= BDMA_REQUEST_DFSDM2_FLT0))
  1107. #endif /* ADC3 */
  1108. #define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
  1109. ((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
  1110. ((DIRECTION) == DMA_MEMORY_TO_MEMORY))
  1111. #define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x01U) && ((SIZE) < 0x10000U))
  1112. #define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
  1113. ((STATE) == DMA_PINC_DISABLE))
  1114. #define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
  1115. ((STATE) == DMA_MINC_DISABLE))
  1116. #define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
  1117. ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
  1118. ((SIZE) == DMA_PDATAALIGN_WORD))
  1119. #define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
  1120. ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
  1121. ((SIZE) == DMA_MDATAALIGN_WORD ))
  1122. #define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
  1123. ((MODE) == DMA_CIRCULAR) || \
  1124. ((MODE) == DMA_PFCTRL) || \
  1125. ((MODE) == DMA_DOUBLE_BUFFER_M0) || \
  1126. ((MODE) == DMA_DOUBLE_BUFFER_M1))
  1127. #define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
  1128. ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
  1129. ((PRIORITY) == DMA_PRIORITY_HIGH) || \
  1130. ((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
  1131. #define IS_DMA_FIFO_MODE_STATE(STATE) (((STATE) == DMA_FIFOMODE_DISABLE ) || \
  1132. ((STATE) == DMA_FIFOMODE_ENABLE))
  1133. #define IS_DMA_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == DMA_FIFO_THRESHOLD_1QUARTERFULL ) || \
  1134. ((THRESHOLD) == DMA_FIFO_THRESHOLD_HALFFULL) || \
  1135. ((THRESHOLD) == DMA_FIFO_THRESHOLD_3QUARTERSFULL) || \
  1136. ((THRESHOLD) == DMA_FIFO_THRESHOLD_FULL))
  1137. #define IS_DMA_MEMORY_BURST(BURST) (((BURST) == DMA_MBURST_SINGLE) || \
  1138. ((BURST) == DMA_MBURST_INC4) || \
  1139. ((BURST) == DMA_MBURST_INC8) || \
  1140. ((BURST) == DMA_MBURST_INC16))
  1141. #define IS_DMA_PERIPHERAL_BURST(BURST) (((BURST) == DMA_PBURST_SINGLE) || \
  1142. ((BURST) == DMA_PBURST_INC4) || \
  1143. ((BURST) == DMA_PBURST_INC8) || \
  1144. ((BURST) == DMA_PBURST_INC16))
  1145. /**
  1146. * @}
  1147. */
  1148. /* Private functions ---------------------------------------------------------*/
  1149. /** @defgroup DMA_Private_Functions DMA Private Functions
  1150. * @brief DMA private functions
  1151. * @{
  1152. */
  1153. /**
  1154. * @}
  1155. */
  1156. /**
  1157. * @}
  1158. */
  1159. /**
  1160. * @}
  1161. */
  1162. #ifdef __cplusplus
  1163. }
  1164. #endif
  1165. #endif /* STM32H7xx_HAL_DMA_H */