Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

278 lines
12 KiB

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