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.

stm32f4xx_hal_exti.h 15KB

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