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