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