stm32f3xx_hal_exti.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_exti.h
  4. * @author MCD Application Team
  5. * @brief Header file of EXTI HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2019 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 STM32F3xx_HAL_EXTI_H
  20. #define STM32F3xx_HAL_EXTI_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx_hal_def.h"
  26. /** @addtogroup STM32F3xx_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. /**
  38. * @brief HAL EXTI common Callback ID enumeration definition
  39. */
  40. typedef enum
  41. {
  42. HAL_EXTI_COMMON_CB_ID = 0x00U
  43. } EXTI_CallbackIDTypeDef;
  44. /**
  45. * @brief EXTI Handle structure definition
  46. */
  47. typedef struct
  48. {
  49. uint32_t Line; /*!< Exti line number */
  50. void (* PendingCallback)(void); /*!< Exti pending callback */
  51. } EXTI_HandleTypeDef;
  52. /**
  53. * @brief EXTI Configuration structure definition
  54. */
  55. typedef struct
  56. {
  57. uint32_t Line; /*!< The Exti line to be configured. This parameter
  58. can be a value of @ref EXTI_Line */
  59. uint32_t Mode; /*!< The Exit Mode to be configured for a core.
  60. This parameter can be a combination of @ref EXTI_Mode */
  61. uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter
  62. can be a value of @ref EXTI_Trigger */
  63. uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured.
  64. This parameter is only possible for line 0 to 15. It
  65. can be a value of @ref EXTI_GPIOSel */
  66. } EXTI_ConfigTypeDef;
  67. /**
  68. * @}
  69. */
  70. /* Exported constants --------------------------------------------------------*/
  71. /** @defgroup EXTI_Exported_Constants EXTI Exported Constants
  72. * @{
  73. */
  74. /** @defgroup EXTI_Line EXTI Line
  75. * @{
  76. */
  77. #define EXTI_LINE_0 (EXTI_GPIO | EXTI_REG1 | 0x00u) /*!< External interrupt line 0 */
  78. #define EXTI_LINE_1 (EXTI_GPIO | EXTI_REG1 | 0x01u) /*!< External interrupt line 1 */
  79. #define EXTI_LINE_2 (EXTI_GPIO | EXTI_REG1 | 0x02u) /*!< External interrupt line 2 */
  80. #define EXTI_LINE_3 (EXTI_GPIO | EXTI_REG1 | 0x03u) /*!< External interrupt line 3 */
  81. #define EXTI_LINE_4 (EXTI_GPIO | EXTI_REG1 | 0x04u) /*!< External interrupt line 4 */
  82. #define EXTI_LINE_5 (EXTI_GPIO | EXTI_REG1 | 0x05u) /*!< External interrupt line 5 */
  83. #define EXTI_LINE_6 (EXTI_GPIO | EXTI_REG1 | 0x06u) /*!< External interrupt line 6 */
  84. #define EXTI_LINE_7 (EXTI_GPIO | EXTI_REG1 | 0x07u) /*!< External interrupt line 7 */
  85. #define EXTI_LINE_8 (EXTI_GPIO | EXTI_REG1 | 0x08u) /*!< External interrupt line 8 */
  86. #define EXTI_LINE_9 (EXTI_GPIO | EXTI_REG1 | 0x09u) /*!< External interrupt line 9 */
  87. #define EXTI_LINE_10 (EXTI_GPIO | EXTI_REG1 | 0x0Au) /*!< External interrupt line 10 */
  88. #define EXTI_LINE_11 (EXTI_GPIO | EXTI_REG1 | 0x0Bu) /*!< External interrupt line 11 */
  89. #define EXTI_LINE_12 (EXTI_GPIO | EXTI_REG1 | 0x0Cu) /*!< External interrupt line 12 */
  90. #define EXTI_LINE_13 (EXTI_GPIO | EXTI_REG1 | 0x0Du) /*!< External interrupt line 13 */
  91. #define EXTI_LINE_14 (EXTI_GPIO | EXTI_REG1 | 0x0Eu) /*!< External interrupt line 14 */
  92. #define EXTI_LINE_15 (EXTI_GPIO | EXTI_REG1 | 0x0Fu) /*!< External interrupt line 15 */
  93. #define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */
  94. #define EXTI_LINE_17 (EXTI_CONFIG | EXTI_REG1 | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */
  95. #if defined(EXTI_IMR_MR18)
  96. #define EXTI_LINE_18 (EXTI_CONFIG | EXTI_REG1 | 0x12u) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */
  97. #else
  98. #define EXTI_LINE_18 (EXTI_RESERVED | EXTI_REG1 | 0x12u)
  99. #endif /* EXTI_IMR_MR18 */
  100. #define EXTI_LINE_19 (EXTI_CONFIG | EXTI_REG1 | 0x13u) /*!< External interrupt line 19 Connected to the RTC tamper and Timestamps */
  101. #define EXTI_LINE_20 (EXTI_CONFIG | EXTI_REG1 | 0x14u) /*!< External interrupt line 20 Connected to the RTC wakeup timer */
  102. #if defined(EXTI_IMR_MR21)
  103. #define EXTI_LINE_21 (EXTI_CONFIG | EXTI_REG1 | 0x15u) /*!< External interrupt line 21 Connected to the Comparator 1 output */
  104. #else
  105. #define EXTI_LINE_21 (EXTI_RESERVED | EXTI_REG1 | 0x15u)
  106. #endif /* EXTI_IMR_MR21 */
  107. #define EXTI_LINE_22 (EXTI_CONFIG | EXTI_REG1 | 0x16u) /*!< External interrupt line 22 Connected to the Comparator 2 output */
  108. #define EXTI_LINE_23 (EXTI_DIRECT | EXTI_REG1 | 0x17u) /*!< External interrupt line 23 Connected to the internal I2C1 wakeup event */
  109. #if defined(EXTI_IMR_MR24)
  110. #define EXTI_LINE_24 (EXTI_DIRECT | EXTI_REG1 | 0x18u) /*!< External interrupt line 24 Connected to the internal I2C2 wakeup event */
  111. #else
  112. #define EXTI_LINE_24 (EXTI_RESERVED | EXTI_REG1 | 0x18u)
  113. #endif /* EXTI_IMR_MR24 */
  114. #define EXTI_LINE_25 (EXTI_DIRECT | EXTI_REG1 | 0x19u) /*!< External interrupt line 25 Connected to the internal USART1 wakeup event */
  115. #if defined(EXTI_IMR_MR26)
  116. #define EXTI_LINE_26 (EXTI_DIRECT | EXTI_REG1 | 0x1Au) /*!< External interrupt line 26 Connected to the internal USART2 wakeup event */
  117. #else
  118. #define EXTI_LINE_26 (EXTI_RESERVED | EXTI_REG1 | 0x1Au)
  119. #endif /* EXTI_IMR_MR26 */
  120. #if defined(EXTI_IMR_MR27)
  121. #define EXTI_LINE_27 (EXTI_DIRECT | EXTI_REG1 | 0x1Bu) /*!< External interrupt line 27 Connected to the internal I2C3 wakeup event */
  122. #else
  123. #define EXTI_LINE_27 (EXTI_RESERVED | EXTI_REG1 | 0x1Bu)
  124. #endif /* EXTI_IMR_MR27 */
  125. #if defined(EXTI_IMR_MR28)
  126. #define EXTI_LINE_28 (EXTI_DIRECT | EXTI_REG1 | 0x1Cu) /*!< External interrupt line 28 Connected to the internal USART3 wakeup event */
  127. #else
  128. #define EXTI_LINE_28 (EXTI_RESERVED | EXTI_REG1 | 0x1Cu)
  129. #endif /* EXTI_IMR_MR28 */
  130. #if defined(EXTI_32_63_SUPPORT)
  131. #if defined(EXTI_IMR_MR29)
  132. #define EXTI_LINE_29 (EXTI_CONFIG | EXTI_REG1 | 0x1Du) /*!< External interrupt line 29 Connected to the Comparator 3 output */
  133. #else
  134. #define EXTI_LINE_29 (EXTI_RESERVED | EXTI_REG1 | 0x1Cu)
  135. #endif /* EXTI_IMR_MR29 */
  136. #if defined(EXTI_IMR_MR30)
  137. #define EXTI_LINE_30 (EXTI_CONFIG | EXTI_REG1 | 0x1Eu) /*!< External interrupt line 30 Connected to the Comparator 4 output */
  138. #else
  139. #define EXTI_LINE_30 (EXTI_RESERVED | EXTI_REG1 | 0x1Eu)
  140. #endif /* EXTI_IMR_MR30 */
  141. #if defined(EXTI_IMR_MR31)
  142. #define EXTI_LINE_31 (EXTI_CONFIG | EXTI_REG1 | 0x1Fu) /*!< External interrupt line 31 Connected to the Comparator 5 output */
  143. #else
  144. #define EXTI_LINE_31 (EXTI_RESERVED | EXTI_REG1 | 0x1Fu)
  145. #endif /* EXTI_IMR_MR31 */
  146. #define EXTI_LINE_32 (EXTI_CONFIG | EXTI_REG2 | 0x00u) /*!< External interrupt line 32 Connected to the Comparator 6 output */
  147. #if defined(EXTI_IMR2_MR33)
  148. #define EXTI_LINE_33 (EXTI_CONFIG | EXTI_REG2 | 0x01u) /*!< External interrupt line 33 Connected to the Comparator 7 output */
  149. #else
  150. #define EXTI_LINE_33 (EXTI_RESERVED | EXTI_REG2 | 0x01u)
  151. #endif /* EXTI_IMR2_MR33 */
  152. #if defined(EXTI_IMR2_MR34)
  153. #define EXTI_LINE_34 (EXTI_DIRECT | EXTI_REG2 | 0x02u) /*!< External interrupt line 34 Connected to the USART4 output */
  154. #else
  155. #define EXTI_LINE_34 (EXTI_RESERVED | EXTI_REG2 | 0x02u)
  156. #endif /* EXTI_IMR2_MR34 */
  157. #if defined(EXTI_IMR2_MR35)
  158. #define EXTI_LINE_35 (EXTI_DIRECT | EXTI_REG2 | 0x03u) /*!< External interrupt line 35 Connected to the USART5 output */
  159. #else
  160. #define EXTI_LINE_35 (EXTI_RESERVED | EXTI_REG2 | 0x03u)
  161. #endif /* EXTI_IMR2_MR35 */
  162. #endif /* EXTI_32_63_SUPPORT */
  163. /**
  164. * @}
  165. */
  166. /** @defgroup EXTI_Mode EXTI Mode
  167. * @{
  168. */
  169. #define EXTI_MODE_NONE 0x00000000u
  170. #define EXTI_MODE_INTERRUPT 0x00000001u
  171. #define EXTI_MODE_EVENT 0x00000002u
  172. /**
  173. * @}
  174. */
  175. /** @defgroup EXTI_Trigger EXTI Trigger
  176. * @{
  177. */
  178. #define EXTI_TRIGGER_NONE 0x00000000u
  179. #define EXTI_TRIGGER_RISING 0x00000001u
  180. #define EXTI_TRIGGER_FALLING 0x00000002u
  181. #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
  182. /**
  183. * @}
  184. */
  185. /** @defgroup EXTI_GPIOSel EXTI GPIOSel
  186. * @brief
  187. * @{
  188. */
  189. #define EXTI_GPIOA 0x00000000u
  190. #define EXTI_GPIOB 0x00000001u
  191. #define EXTI_GPIOC 0x00000002u
  192. #define EXTI_GPIOD 0x00000003u
  193. #if defined(GPIOE)
  194. #define EXTI_GPIOE 0x00000004u
  195. #endif /* GPIOE */
  196. #define EXTI_GPIOF 0x00000005u
  197. #if defined(GPIOG)
  198. #define EXTI_GPIOG 0x00000006u
  199. #endif /* GPIOG */
  200. #if defined(GPIOH)
  201. #define EXTI_GPIOH 0x00000007u
  202. #endif /* GPIOH */
  203. /**
  204. * @}
  205. */
  206. /**
  207. * @}
  208. */
  209. /* Exported macro ------------------------------------------------------------*/
  210. /** @defgroup EXTI_Exported_Macros EXTI Exported Macros
  211. * @{
  212. */
  213. /**
  214. * @}
  215. */
  216. /* Private constants --------------------------------------------------------*/
  217. /** @defgroup EXTI_Private_Constants EXTI Private Constants
  218. * @{
  219. */
  220. /**
  221. * @brief EXTI Line property definition
  222. */
  223. #define EXTI_PROPERTY_SHIFT 24u
  224. #define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT)
  225. #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT)
  226. #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
  227. #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT)
  228. #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO)
  229. /**
  230. * @brief EXTI Register and bit usage
  231. */
  232. #define EXTI_REG_SHIFT 16u
  233. #define EXTI_REG1 (0x00uL << EXTI_REG_SHIFT)
  234. #define EXTI_REG2 (0x01uL << EXTI_REG_SHIFT)
  235. #define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2)
  236. #define EXTI_PIN_MASK 0x0000001Fu
  237. /**
  238. * @brief EXTI Mask for interrupt & event mode
  239. */
  240. #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
  241. /**
  242. * @brief EXTI Mask for trigger possibilities
  243. */
  244. #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
  245. /**
  246. * @brief EXTI Line number
  247. */
  248. #if defined(EXTI_32_63_SUPPORT)
  249. #define EXTI_LINE_NB 36uL
  250. #else
  251. #define EXTI_LINE_NB 29uL
  252. #endif /* EXTI_32_63_SUPPORT */
  253. /**
  254. * @}
  255. */
  256. /* Private macros ------------------------------------------------------------*/
  257. /** @defgroup EXTI_Private_Macros EXTI Private Macros
  258. * @{
  259. */
  260. #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00u) && \
  261. ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \
  262. (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \
  263. (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \
  264. (((__EXTI_LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \
  265. (((EXTI_LINE_NB / 32u) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32u))))
  266. #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \
  267. (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u))
  268. #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
  269. #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING)
  270. #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u)
  271. #if defined(GPIOH)
  272. #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
  273. ((__PORT__) == EXTI_GPIOB) || \
  274. ((__PORT__) == EXTI_GPIOC) || \
  275. ((__PORT__) == EXTI_GPIOD) || \
  276. ((__PORT__) == EXTI_GPIOE) || \
  277. ((__PORT__) == EXTI_GPIOF) || \
  278. ((__PORT__) == EXTI_GPIOG) || \
  279. ((__PORT__) == EXTI_GPIOH))
  280. #elif defined(GPIOE)
  281. #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
  282. ((__PORT__) == EXTI_GPIOB) || \
  283. ((__PORT__) == EXTI_GPIOC) || \
  284. ((__PORT__) == EXTI_GPIOD) || \
  285. ((__PORT__) == EXTI_GPIOE) || \
  286. ((__PORT__) == EXTI_GPIOF))
  287. #else
  288. #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
  289. ((__PORT__) == EXTI_GPIOB) || \
  290. ((__PORT__) == EXTI_GPIOC) || \
  291. ((__PORT__) == EXTI_GPIOD) || \
  292. ((__PORT__) == EXTI_GPIOF))
  293. #endif /* GPIOE */
  294. #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u)
  295. /**
  296. * @}
  297. */
  298. /* Exported functions --------------------------------------------------------*/
  299. /** @defgroup EXTI_Exported_Functions EXTI Exported Functions
  300. * @brief EXTI Exported Functions
  301. * @{
  302. */
  303. /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
  304. * @brief Configuration functions
  305. * @{
  306. */
  307. /* Configuration functions ****************************************************/
  308. HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  309. HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  310. HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
  311. HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
  312. HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
  313. /**
  314. * @}
  315. */
  316. /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
  317. * @brief IO operation functions
  318. * @{
  319. */
  320. /* IO operation functions *****************************************************/
  321. void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
  322. uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  323. void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  324. void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
  325. /**
  326. * @}
  327. */
  328. /**
  329. * @}
  330. */
  331. /**
  332. * @}
  333. */
  334. /**
  335. * @}
  336. */
  337. #ifdef __cplusplus
  338. }
  339. #endif
  340. #endif /* STM32F3xx_HAL_EXTI_H */