25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

265 lines
9.8 KiB

  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. HAL_EXTI_RISING_CB_ID = 0x01U,
  42. HAL_EXTI_FALLING_CB_ID = 0x02U,
  43. } EXTI_CallbackIDTypeDef;
  44. /**
  45. * @brief EXTI Handle structure definition
  46. */
  47. typedef struct
  48. {
  49. uint32_t Line; /*!< Exti line number */
  50. void (* RisingCallback)(void); /*!< Exti rising callback */
  51. void (* FallingCallback)(void); /*!< Exti falling callback */
  52. } EXTI_HandleTypeDef;
  53. /**
  54. * @brief EXTI Configuration structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t Line; /*!< The Exti line to be configured. This parameter
  59. can be a value of @ref EXTI_Line */
  60. uint32_t Mode; /*!< The Exit Mode to be configured for a core.
  61. This parameter can be a combination of @ref EXTI_Mode */
  62. uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter
  63. can be a value of @ref EXTI_Trigger */
  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_IMR_IM0 /*!< External interrupt line 0 */
  76. #define EXTI_LINE_1 EXTI_IMR_IM1 /*!< External interrupt line 1 */
  77. #define EXTI_LINE_2 EXTI_IMR_IM2 /*!< External interrupt line 2 */
  78. #define EXTI_LINE_3 EXTI_IMR_IM3 /*!< External interrupt line 3 */
  79. #define EXTI_LINE_4 EXTI_IMR_IM4 /*!< External interrupt line 4 */
  80. #define EXTI_LINE_5 EXTI_IMR_IM5 /*!< External interrupt line 5 */
  81. #define EXTI_LINE_6 EXTI_IMR_IM6 /*!< External interrupt line 6 */
  82. #define EXTI_LINE_7 EXTI_IMR_IM7 /*!< External interrupt line 7 */
  83. #define EXTI_LINE_8 EXTI_IMR_IM8 /*!< External interrupt line 8 */
  84. #define EXTI_LINE_9 EXTI_IMR_IM9 /*!< External interrupt line 9 */
  85. #define EXTI_LINE_10 EXTI_IMR_IM10 /*!< External interrupt line 10 */
  86. #define EXTI_LINE_11 EXTI_IMR_IM11 /*!< External interrupt line 11 */
  87. #define EXTI_LINE_12 EXTI_IMR_IM12 /*!< External interrupt line 12 */
  88. #define EXTI_LINE_13 EXTI_IMR_IM13 /*!< External interrupt line 13 */
  89. #define EXTI_LINE_14 EXTI_IMR_IM14 /*!< External interrupt line 14 */
  90. #define EXTI_LINE_15 EXTI_IMR_IM15 /*!< External interrupt line 15 */
  91. #define EXTI_LINE_16 EXTI_IMR_IM16 /*!< External interrupt line 16 Connected to the PVD Output */
  92. #define EXTI_LINE_17 EXTI_IMR_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
  93. #define EXTI_LINE_18 EXTI_IMR_IM18 /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */
  94. #define EXTI_LINE_19 EXTI_IMR_IM19 /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */
  95. #define EXTI_LINE_20 EXTI_IMR_IM20 /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */
  96. #define EXTI_LINE_21 EXTI_IMR_IM21 /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */
  97. #define EXTI_LINE_22 EXTI_IMR_IM22 /*!< External interrupt line 22 Connected to the RTC Wakeup event */
  98. /**
  99. * @}
  100. */
  101. /** @defgroup EXTI_Mode EXTI Mode
  102. * @{
  103. */
  104. #define EXTI_MODE_INTERRUPT 0x00000000U
  105. #define EXTI_MODE_EVENT 0x00000004U
  106. /**
  107. * @}
  108. */
  109. /** @defgroup EXTI_Trigger EXTI Trigger
  110. * @{
  111. */
  112. #define EXTI_TRIGGER_RISING 0x00000008U
  113. #define EXTI_TRIGGER_FALLING 0x0000000CU
  114. #define EXTI_TRIGGER_RISING_FALLING 0x00000010U
  115. /**
  116. * @}
  117. */
  118. /**
  119. * @}
  120. */
  121. /* Exported macro ------------------------------------------------------------*/
  122. /** @defgroup EXTI_Exported_Macros EXTI Exported Macros
  123. * @{
  124. */
  125. /**
  126. * @}
  127. */
  128. /* Private constants --------------------------------------------------------*/
  129. /** @defgroup EXTI_Private_Constants EXTI Private Constants
  130. * @{
  131. */
  132. /**
  133. * @brief EXTI Mask for interrupt & event mode
  134. */
  135. #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
  136. /**
  137. * @brief EXTI Mask for trigger possibilities
  138. */
  139. #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING | EXTI_TRIGGER_RISING_FALLING)
  140. /**
  141. * @brief EXTI Line number
  142. */
  143. #define EXTI_LINE_NB 23UL
  144. /**
  145. * @}
  146. */
  147. /* Private macros ------------------------------------------------------------*/
  148. /** @defgroup EXTI_Private_Macros EXTI Private Macros
  149. * @{
  150. */
  151. #define IS_EXTI_LINE(__LINE__) (((__LINE__) == EXTI_LINE_0) || \
  152. ((__LINE__) == EXTI_LINE_1) || \
  153. ((__LINE__) == EXTI_LINE_2) || \
  154. ((__LINE__) == EXTI_LINE_3) || \
  155. ((__LINE__) == EXTI_LINE_4) || \
  156. ((__LINE__) == EXTI_LINE_5) || \
  157. ((__LINE__) == EXTI_LINE_6) || \
  158. ((__LINE__) == EXTI_LINE_7) || \
  159. ((__LINE__) == EXTI_LINE_8) || \
  160. ((__LINE__) == EXTI_LINE_9) || \
  161. ((__LINE__) == EXTI_LINE_10) || \
  162. ((__LINE__) == EXTI_LINE_11) || \
  163. ((__LINE__) == EXTI_LINE_12) || \
  164. ((__LINE__) == EXTI_LINE_13) || \
  165. ((__LINE__) == EXTI_LINE_14) || \
  166. ((__LINE__) == EXTI_LINE_15) || \
  167. ((__LINE__) == EXTI_LINE_16) || \
  168. ((__LINE__) == EXTI_LINE_17) || \
  169. ((__LINE__) == EXTI_LINE_18) || \
  170. ((__LINE__) == EXTI_LINE_19) || \
  171. ((__LINE__) == EXTI_LINE_20) || \
  172. ((__LINE__) == EXTI_LINE_21) || \
  173. ((__LINE__) == EXTI_LINE_22))
  174. #define IS_EXTI_MODE(__LINE__) ((((__LINE__) & ~EXTI_MODE_MASK) == 0x00U))
  175. #define IS_EXTI_TRIGGER(__LINE__) (((__LINE__) & ~EXTI_TRIGGER_MASK) == 0x00U)
  176. #define IS_EXTI_PENDING_EDGE(__LINE__) (((__LINE__) == EXTI_TRIGGER_FALLING) || \
  177. ((__LINE__) == EXTI_TRIGGER_RISING) || \
  178. ((__LINE__) == EXTI_TRIGGER_RISING_FALLING))
  179. #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16U)
  180. /**
  181. * @}
  182. */
  183. /* Exported functions --------------------------------------------------------*/
  184. /** @defgroup EXTI_Exported_Functions EXTI Exported Functions
  185. * @brief EXTI Exported Functions
  186. * @{
  187. */
  188. /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
  189. * @brief Configuration functions
  190. * @{
  191. */
  192. /* Configuration functions ****************************************************/
  193. HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  194. HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  195. HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
  196. HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
  197. HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
  198. /**
  199. * @}
  200. */
  201. /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
  202. * @brief IO operation functions
  203. * @{
  204. */
  205. /* IO operation functions *****************************************************/
  206. void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
  207. uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  208. void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  209. void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
  210. /**
  211. * @}
  212. */
  213. /**
  214. * @}
  215. */
  216. /**
  217. * @}
  218. */
  219. /**
  220. * @}
  221. */
  222. #ifdef __cplusplus
  223. }
  224. #endif
  225. #endif /* STM32f4xx_HAL_EXTI_H */
  226. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/