stm32f7xx_hal_exti.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_exti.h
  4. * @author MCD Application Team
  5. * @brief Header file of EXTI HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2018 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 STM32F7xx_HAL_EXTI_H
  20. #define STM32F7xx_HAL_EXTI_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f7xx_hal_def.h"
  26. /** @addtogroup STM32F7xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup EXTI EXTI
  30. * @brief EXTI HAL module driver
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup EXTI_Exported_Types EXTI Exported Types
  35. * @{
  36. */
  37. typedef enum
  38. {
  39. HAL_EXTI_COMMON_CB_ID = 0x00U
  40. } EXTI_CallbackIDTypeDef;
  41. /**
  42. * @brief EXTI Handle structure definition
  43. */
  44. typedef struct
  45. {
  46. uint32_t Line; /*!< Exti line number */
  47. void (* PendingCallback)(void); /*!< Exti pending callback */
  48. } EXTI_HandleTypeDef;
  49. /**
  50. * @brief EXTI Configuration structure definition
  51. */
  52. typedef struct
  53. {
  54. uint32_t Line; /*!< The Exti line to be configured. This parameter
  55. can be a value of @ref EXTI_Line */
  56. uint32_t Mode; /*!< The Exit Mode to be configured for a core.
  57. This parameter can be a combination of @ref EXTI_Mode */
  58. uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter
  59. can be a value of @ref EXTI_Trigger */
  60. uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured.
  61. This parameter is only possible for line 0 to 15. It
  62. can be a value of @ref EXTI_GPIOSel */
  63. } EXTI_ConfigTypeDef;
  64. /**
  65. * @}
  66. */
  67. /* Exported constants --------------------------------------------------------*/
  68. /** @defgroup EXTI_Exported_Constants EXTI Exported Constants
  69. * @{
  70. */
  71. /** @defgroup EXTI_Line EXTI Line
  72. * @{
  73. */
  74. #define EXTI_LINE_0 (EXTI_GPIO | 0x00u) /*!< External interrupt line 0 */
  75. #define EXTI_LINE_1 (EXTI_GPIO | 0x01u) /*!< External interrupt line 1 */
  76. #define EXTI_LINE_2 (EXTI_GPIO | 0x02u) /*!< External interrupt line 2 */
  77. #define EXTI_LINE_3 (EXTI_GPIO | 0x03u) /*!< External interrupt line 3 */
  78. #define EXTI_LINE_4 (EXTI_GPIO | 0x04u) /*!< External interrupt line 4 */
  79. #define EXTI_LINE_5 (EXTI_GPIO | 0x05u) /*!< External interrupt line 5 */
  80. #define EXTI_LINE_6 (EXTI_GPIO | 0x06u) /*!< External interrupt line 6 */
  81. #define EXTI_LINE_7 (EXTI_GPIO | 0x07u) /*!< External interrupt line 7 */
  82. #define EXTI_LINE_8 (EXTI_GPIO | 0x08u) /*!< External interrupt line 8 */
  83. #define EXTI_LINE_9 (EXTI_GPIO | 0x09u) /*!< External interrupt line 9 */
  84. #define EXTI_LINE_10 (EXTI_GPIO | 0x0Au) /*!< External interrupt line 10 */
  85. #define EXTI_LINE_11 (EXTI_GPIO | 0x0Bu) /*!< External interrupt line 11 */
  86. #define EXTI_LINE_12 (EXTI_GPIO | 0x0Cu) /*!< External interrupt line 12 */
  87. #define EXTI_LINE_13 (EXTI_GPIO | 0x0Du) /*!< External interrupt line 13 */
  88. #define EXTI_LINE_14 (EXTI_GPIO | 0x0Eu) /*!< External interrupt line 14 */
  89. #define EXTI_LINE_15 (EXTI_GPIO | 0x0Fu) /*!< External interrupt line 15 */
  90. #define EXTI_LINE_16 (EXTI_CONFIG | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */
  91. #define EXTI_LINE_17 (EXTI_CONFIG | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */
  92. #define EXTI_LINE_18 (EXTI_CONFIG | 0x12u) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */
  93. #if defined(ETH)
  94. #define EXTI_LINE_19 (EXTI_CONFIG | 0x13u) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */
  95. #else
  96. #define EXTI_LINE_19 (EXTI_RESERVED | 0x13u) /*!< No interrupt supported in this line */
  97. #endif /* ETH */
  98. #define EXTI_LINE_20 (EXTI_CONFIG | 0x14u) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */
  99. #define EXTI_LINE_21 (EXTI_CONFIG | 0x15u) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */
  100. #define EXTI_LINE_22 (EXTI_CONFIG | 0x16u) /*!< External interrupt line 22 Connected to the RTC Wakeup event */
  101. #define EXTI_LINE_23 (EXTI_CONFIG | 0x17u) /*!< External interrupt line 23 Connected to the LPTIM Wakeup event */
  102. #if defined(EXTI_IMR_IM24)
  103. #define EXTI_LINE_24 (EXTI_CONFIG | 0x18u) /*!< External interrupt line 24 Connected to the MDIO Slave global Interrupt Wakeup event */
  104. #endif /* EXTI_IMR_IM24 */
  105. /**
  106. * @}
  107. */
  108. /** @defgroup EXTI_Mode EXTI Mode
  109. * @{
  110. */
  111. #define EXTI_MODE_NONE 0x00000000u
  112. #define EXTI_MODE_INTERRUPT 0x00000001u
  113. #define EXTI_MODE_EVENT 0x00000002u
  114. /**
  115. * @}
  116. */
  117. /** @defgroup EXTI_Trigger EXTI Trigger
  118. * @{
  119. */
  120. #define EXTI_TRIGGER_NONE 0x00000000u
  121. #define EXTI_TRIGGER_RISING 0x00000001u
  122. #define EXTI_TRIGGER_FALLING 0x00000002u
  123. #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
  124. /**
  125. * @}
  126. */
  127. /** @defgroup EXTI_GPIOSel EXTI GPIOSel
  128. * @brief
  129. * @{
  130. */
  131. #define EXTI_GPIOA 0x00000000u
  132. #define EXTI_GPIOB 0x00000001u
  133. #define EXTI_GPIOC 0x00000002u
  134. #define EXTI_GPIOD 0x00000003u
  135. #define EXTI_GPIOE 0x00000004u
  136. #define EXTI_GPIOF 0x00000005u
  137. #define EXTI_GPIOG 0x00000006u
  138. #define EXTI_GPIOH 0x00000007u
  139. #define EXTI_GPIOI 0x00000008u
  140. #define EXTI_GPIOJ 0x00000009u
  141. #if defined (GPIOK)
  142. #define EXTI_GPIOK 0x0000000Au
  143. #endif /* GPIOK */
  144. /**
  145. * @}
  146. */
  147. /* Exported macro ------------------------------------------------------------*/
  148. /** @defgroup EXTI_Exported_Macros EXTI Exported Macros
  149. * @{
  150. */
  151. /**
  152. * @}
  153. */
  154. /* Private constants --------------------------------------------------------*/
  155. /** @defgroup EXTI_Private_Constants EXTI Private Constants
  156. * @{
  157. */
  158. /**
  159. * @brief EXTI Line property definition
  160. */
  161. #define EXTI_PROPERTY_SHIFT 24u
  162. #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT)
  163. #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
  164. #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT)
  165. #define EXTI_PROPERTY_MASK (EXTI_CONFIG | EXTI_GPIO)
  166. /**
  167. * @brief EXTI bit usage
  168. */
  169. #define EXTI_PIN_MASK 0x0000001Fu
  170. /**
  171. * @brief EXTI Mask for interrupt & event mode
  172. */
  173. #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
  174. /**
  175. * @brief EXTI Mask for trigger possibilities
  176. */
  177. #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
  178. /**
  179. * @brief EXTI Line number
  180. */
  181. #if defined(EXTI_IMR_IM24)
  182. #define EXTI_LINE_NB 25u
  183. #else
  184. #define EXTI_LINE_NB 24u
  185. #endif /* EXTI_IMR_IM24 */
  186. /**
  187. * @}
  188. */
  189. /* Private macros ------------------------------------------------------------*/
  190. /** @defgroup EXTI_Private_Macros EXTI Private Macros
  191. * @{
  192. */
  193. #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \
  194. ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \
  195. (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \
  196. (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB))
  197. #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \
  198. (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u))
  199. #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
  200. #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) (((__EXTI_LINE__) == EXTI_TRIGGER_FALLING) || \
  201. ((__EXTI_LINE__) == EXTI_TRIGGER_RISING) || \
  202. ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING))
  203. #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u)
  204. #if defined (GPIOK)
  205. #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
  206. ((__PORT__) == EXTI_GPIOB) || \
  207. ((__PORT__) == EXTI_GPIOC) || \
  208. ((__PORT__) == EXTI_GPIOD) || \
  209. ((__PORT__) == EXTI_GPIOE) || \
  210. ((__PORT__) == EXTI_GPIOF) || \
  211. ((__PORT__) == EXTI_GPIOG) || \
  212. ((__PORT__) == EXTI_GPIOH) || \
  213. ((__PORT__) == EXTI_GPIOI) || \
  214. ((__PORT__) == EXTI_GPIOJ) || \
  215. ((__PORT__) == EXTI_GPIOK))
  216. #else
  217. #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
  218. ((__PORT__) == EXTI_GPIOB) || \
  219. ((__PORT__) == EXTI_GPIOC) || \
  220. ((__PORT__) == EXTI_GPIOD) || \
  221. ((__PORT__) == EXTI_GPIOE) || \
  222. ((__PORT__) == EXTI_GPIOF) || \
  223. ((__PORT__) == EXTI_GPIOG) || \
  224. ((__PORT__) == EXTI_GPIOH) || \
  225. ((__PORT__) == EXTI_GPIOI) || \
  226. ((__PORT__) == EXTI_GPIOJ))
  227. #endif /* GPIOK */
  228. #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16U)
  229. /**
  230. * @}
  231. */
  232. /* Exported functions --------------------------------------------------------*/
  233. /** @defgroup EXTI_Exported_Functions EXTI Exported Functions
  234. * @brief EXTI Exported Functions
  235. * @{
  236. */
  237. /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
  238. * @brief Configuration functions
  239. * @{
  240. */
  241. /* Configuration functions ****************************************************/
  242. HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  243. HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  244. HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
  245. HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
  246. HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
  247. /**
  248. * @}
  249. */
  250. /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
  251. * @brief IO operation functions
  252. * @{
  253. */
  254. /* IO operation functions *****************************************************/
  255. void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
  256. uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  257. void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  258. void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
  259. /**
  260. * @}
  261. */
  262. /**
  263. * @}
  264. */
  265. /**
  266. * @}
  267. */
  268. /**
  269. * @}
  270. */
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274. #endif /* STM32F7xx_HAL_EXTI_H */