stm32f1xx_hal_dma_ex.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_dma_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of DMA HAL extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * 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 __STM32F1xx_HAL_DMA_EX_H
  20. #define __STM32F1xx_HAL_DMA_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f1xx_hal_def.h"
  26. /** @addtogroup STM32F1xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup DMAEx DMAEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /* Exported constants --------------------------------------------------------*/
  34. /* Exported macro ------------------------------------------------------------*/
  35. /** @defgroup DMAEx_Exported_Macros DMA Extended Exported Macros
  36. * @{
  37. */
  38. /* Interrupt & Flag management */
  39. #if defined (STM32F100xE) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || \
  40. defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
  41. /** @defgroup DMAEx_High_density_XL_density_Product_devices DMAEx High density and XL density product devices
  42. * @{
  43. */
  44. /**
  45. * @brief Returns the current DMA Channel transfer complete flag.
  46. * @param __HANDLE__: DMA handle
  47. * @retval The specified transfer complete flag index.
  48. */
  49. #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
  50. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
  51. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
  52. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
  53. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
  54. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
  55. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
  56. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_TC7 :\
  57. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TC1 :\
  58. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TC2 :\
  59. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TC3 :\
  60. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TC4 :\
  61. DMA_FLAG_TC5)
  62. /**
  63. * @brief Returns the current DMA Channel half transfer complete flag.
  64. * @param __HANDLE__: DMA handle
  65. * @retval The specified half transfer complete flag index.
  66. */
  67. #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
  68. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
  69. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
  70. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
  71. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
  72. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
  73. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
  74. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_HT7 :\
  75. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_HT1 :\
  76. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_HT2 :\
  77. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_HT3 :\
  78. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_HT4 :\
  79. DMA_FLAG_HT5)
  80. /**
  81. * @brief Returns the current DMA Channel transfer error flag.
  82. * @param __HANDLE__: DMA handle
  83. * @retval The specified transfer error flag index.
  84. */
  85. #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
  86. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
  87. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
  88. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
  89. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
  90. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
  91. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
  92. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_TE7 :\
  93. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TE1 :\
  94. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TE2 :\
  95. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TE3 :\
  96. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TE4 :\
  97. DMA_FLAG_TE5)
  98. /**
  99. * @brief Return the current DMA Channel Global interrupt flag.
  100. * @param __HANDLE__: DMA handle
  101. * @retval The specified transfer error flag index.
  102. */
  103. #define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
  104. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_GL1 :\
  105. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_GL2 :\
  106. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_GL3 :\
  107. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_GL4 :\
  108. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_GL5 :\
  109. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_GL6 :\
  110. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_GL7 :\
  111. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_GL1 :\
  112. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_GL2 :\
  113. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_GL3 :\
  114. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_GL4 :\
  115. DMA_FLAG_GL5)
  116. /**
  117. * @brief Get the DMA Channel pending flags.
  118. * @param __HANDLE__: DMA handle
  119. * @param __FLAG__: Get the specified flag.
  120. * This parameter can be any combination of the following values:
  121. * @arg DMA_FLAG_TCx: Transfer complete flag
  122. * @arg DMA_FLAG_HTx: Half transfer complete flag
  123. * @arg DMA_FLAG_TEx: Transfer error flag
  124. * Where x can be 1_7 or 1_5 (depending on DMA1 or DMA2) to select the DMA Channel flag.
  125. * @retval The state of FLAG (SET or RESET).
  126. */
  127. #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\
  128. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Channel7)? (DMA2->ISR & (__FLAG__)) :\
  129. (DMA1->ISR & (__FLAG__)))
  130. /**
  131. * @brief Clears the DMA Channel pending flags.
  132. * @param __HANDLE__: DMA handle
  133. * @param __FLAG__: specifies the flag to clear.
  134. * This parameter can be any combination of the following values:
  135. * @arg DMA_FLAG_TCx: Transfer complete flag
  136. * @arg DMA_FLAG_HTx: Half transfer complete flag
  137. * @arg DMA_FLAG_TEx: Transfer error flag
  138. * Where x can be 1_7 or 1_5 (depending on DMA1 or DMA2) to select the DMA Channel flag.
  139. * @retval None
  140. */
  141. #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \
  142. (((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Channel7)? (DMA2->IFCR = (__FLAG__)) :\
  143. (DMA1->IFCR = (__FLAG__)))
  144. /**
  145. * @}
  146. */
  147. #else
  148. /** @defgroup DMA_Low_density_Medium_density_Product_devices DMA Low density and Medium density product devices
  149. * @{
  150. */
  151. /**
  152. * @brief Returns the current DMA Channel transfer complete flag.
  153. * @param __HANDLE__: DMA handle
  154. * @retval The specified transfer complete flag index.
  155. */
  156. #define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
  157. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
  158. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
  159. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
  160. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
  161. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
  162. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
  163. DMA_FLAG_TC7)
  164. /**
  165. * @brief Return the current DMA Channel half transfer complete flag.
  166. * @param __HANDLE__: DMA handle
  167. * @retval The specified half transfer complete flag index.
  168. */
  169. #define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
  170. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
  171. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
  172. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
  173. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
  174. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
  175. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
  176. DMA_FLAG_HT7)
  177. /**
  178. * @brief Return the current DMA Channel transfer error flag.
  179. * @param __HANDLE__: DMA handle
  180. * @retval The specified transfer error flag index.
  181. */
  182. #define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
  183. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
  184. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
  185. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
  186. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
  187. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
  188. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
  189. DMA_FLAG_TE7)
  190. /**
  191. * @brief Return the current DMA Channel Global interrupt flag.
  192. * @param __HANDLE__: DMA handle
  193. * @retval The specified transfer error flag index.
  194. */
  195. #define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
  196. (((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_GL1 :\
  197. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_GL2 :\
  198. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_GL3 :\
  199. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_GL4 :\
  200. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_GL5 :\
  201. ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_GL6 :\
  202. DMA_FLAG_GL7)
  203. /**
  204. * @brief Get the DMA Channel pending flags.
  205. * @param __HANDLE__: DMA handle
  206. * @param __FLAG__: Get the specified flag.
  207. * This parameter can be any combination of the following values:
  208. * @arg DMA_FLAG_TCx: Transfer complete flag
  209. * @arg DMA_FLAG_HTx: Half transfer complete flag
  210. * @arg DMA_FLAG_TEx: Transfer error flag
  211. * @arg DMA_FLAG_GLx: Global interrupt flag
  212. * Where x can be 1_7 to select the DMA Channel flag.
  213. * @retval The state of FLAG (SET or RESET).
  214. */
  215. #define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__) (DMA1->ISR & (__FLAG__))
  216. /**
  217. * @brief Clear the DMA Channel pending flags.
  218. * @param __HANDLE__: DMA handle
  219. * @param __FLAG__: specifies the flag to clear.
  220. * This parameter can be any combination of the following values:
  221. * @arg DMA_FLAG_TCx: Transfer complete flag
  222. * @arg DMA_FLAG_HTx: Half transfer complete flag
  223. * @arg DMA_FLAG_TEx: Transfer error flag
  224. * @arg DMA_FLAG_GLx: Global interrupt flag
  225. * Where x can be 1_7 to select the DMA Channel flag.
  226. * @retval None
  227. */
  228. #define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (DMA1->IFCR = (__FLAG__))
  229. /**
  230. * @}
  231. */
  232. #endif
  233. /**
  234. * @}
  235. */
  236. /**
  237. * @}
  238. */
  239. /**
  240. * @}
  241. */
  242. #ifdef __cplusplus
  243. }
  244. #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || */
  245. /* STM32F103xG || STM32F105xC || STM32F107xC */
  246. #endif /* __STM32F1xx_HAL_DMA_H */