1 /** 2 ****************************************************************************** 3 * @file stm32f0xx_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 STM32F0xx_HAL_EXTI_H 21 #define STM32F0xx_HAL_EXTI_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f0xx_hal_def.h" 29 30 /** @addtogroup STM32F0xx_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 | 0x00u) /*!< External interrupt line 0 */ 91 #define EXTI_LINE_1 (EXTI_GPIO | 0x01u) /*!< External interrupt line 1 */ 92 #define EXTI_LINE_2 (EXTI_GPIO | 0x02u) /*!< External interrupt line 2 */ 93 #define EXTI_LINE_3 (EXTI_GPIO | 0x03u) /*!< External interrupt line 3 */ 94 #define EXTI_LINE_4 (EXTI_GPIO | 0x04u) /*!< External interrupt line 4 */ 95 #define EXTI_LINE_5 (EXTI_GPIO | 0x05u) /*!< External interrupt line 5 */ 96 #define EXTI_LINE_6 (EXTI_GPIO | 0x06u) /*!< External interrupt line 6 */ 97 #define EXTI_LINE_7 (EXTI_GPIO | 0x07u) /*!< External interrupt line 7 */ 98 #define EXTI_LINE_8 (EXTI_GPIO | 0x08u) /*!< External interrupt line 8 */ 99 #define EXTI_LINE_9 (EXTI_GPIO | 0x09u) /*!< External interrupt line 9 */ 100 #define EXTI_LINE_10 (EXTI_GPIO | 0x0Au) /*!< External interrupt line 10 */ 101 #define EXTI_LINE_11 (EXTI_GPIO | 0x0Bu) /*!< External interrupt line 11 */ 102 #define EXTI_LINE_12 (EXTI_GPIO | 0x0Cu) /*!< External interrupt line 12 */ 103 #define EXTI_LINE_13 (EXTI_GPIO | 0x0Du) /*!< External interrupt line 13 */ 104 #define EXTI_LINE_14 (EXTI_GPIO | 0x0Eu) /*!< External interrupt line 14 */ 105 #define EXTI_LINE_15 (EXTI_GPIO | 0x0Fu) /*!< External interrupt line 15 */ 106 107 #if defined (EXTI_IMR_MR16) 108 #define EXTI_LINE_16 (EXTI_CONFIG | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */ 109 #else 110 #define EXTI_LINE_16 (EXTI_RESERVED | 0x10u) 111 #endif /* EXTI_IMR_MR16 */ 112 113 #define EXTI_LINE_17 (EXTI_CONFIG | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 114 115 #if defined (EXTI_IMR_MR18) 116 #define EXTI_LINE_18 (EXTI_CONFIG | 0x12u) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */ 117 #else 118 #define EXTI_LINE_18 (EXTI_RESERVED | 0x12u) 119 #endif /* EXTI_IMR_MR18 */ 120 121 #define EXTI_LINE_19 (EXTI_CONFIG | 0x13u) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 122 123 #if defined (EXTI_IMR_MR20) 124 #define EXTI_LINE_20 (EXTI_CONFIG | 0x14u) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */ 125 #else 126 #define EXTI_LINE_20 (EXTI_RESERVED | 0x14u) 127 #endif /* EXTI_IMR_MR20 */ 128 129 #if defined (EXTI_IMR_MR21) 130 #define EXTI_LINE_21 (EXTI_CONFIG | 0x15u) /*!< External interrupt line 21 Connected to the Comparator 1 output */ 131 #else 132 #define EXTI_LINE_21 (EXTI_RESERVED | 0x15u) 133 #endif /* EXTI_IMR_MR21 */ 134 135 #if defined (EXTI_IMR_MR22) 136 #define EXTI_LINE_22 (EXTI_CONFIG | 0x16u) /*!< External interrupt line 22 Connected to the Comparator 2 output */ 137 #else 138 #define EXTI_LINE_22 (EXTI_RESERVED | 0x16u) 139 #endif /* EXTI_IMR_MR22 */ 140 141 #if defined (EXTI_IMR_MR23) 142 #define EXTI_LINE_23 (EXTI_DIRECT | 0x17u) /*!< External interrupt line 23 Connected to the internal I2C1 wakeup event */ 143 #else 144 #define EXTI_LINE_23 (EXTI_RESERVED | 0x17u) 145 #endif /* EXTI_IMR_MR23 */ 146 147 #define EXTI_LINE_24 (EXTI_RESERVED | 0x18u) 148 149 #if defined (EXTI_IMR_MR25) 150 #define EXTI_LINE_25 (EXTI_CONFIG | 0x19u) /*!< External interrupt line 25 Connected to the internal USART1 wakeup event */ 151 #else 152 #define EXTI_LINE_25 (EXTI_RESERVED | 0x19u) 153 #endif /* EXTI_IMR_MR25 */ 154 155 #if defined (EXTI_IMR_MR26) 156 #define EXTI_LINE_26 (EXTI_CONFIG | 0x1Au) /*!< External interrupt line 26 Connected to the internal USART2 wakeup event */ 157 #else 158 #define EXTI_LINE_26 (EXTI_RESERVED | 0x1Au) 159 #endif /* EXTI_IMR_MR26 */ 160 161 #if defined (EXTI_IMR_MR27) 162 #define EXTI_LINE_27 (EXTI_CONFIG | 0x1Bu) /*!< External interrupt line 27 Connected to the internal CEC wakeup event */ 163 #else 164 #define EXTI_LINE_27 (EXTI_RESERVED | 0x1Bu) 165 #endif /* EXTI_IMR_MR27 */ 166 167 #if defined (EXTI_IMR_MR28) 168 #define EXTI_LINE_28 (EXTI_CONFIG | 0x1Cu) /*!< External interrupt line 28 Connected to the internal USART3 wakeup event */ 169 #else 170 #define EXTI_LINE_28 (EXTI_RESERVED | 0x1Cu) 171 #endif /* EXTI_IMR_MR28 */ 172 173 #define EXTI_LINE_29 (EXTI_RESERVED | 0x1Du) 174 #define EXTI_LINE_30 (EXTI_RESERVED | 0x1Eu) 175 176 #if defined (EXTI_IMR_MR31) 177 #define EXTI_LINE_31 (EXTI_CONFIG | 0x1Fu) /*!< External interrupt line 31 Connected to the VDDIO2 supply comparator output */ 178 #else 179 #define EXTI_LINE_31 (EXTI_RESERVED | 0x1Fu) 180 #endif /* EXTI_IMR_MR31 */ 181 182 /** 183 * @} 184 */ 185 186 /** @defgroup EXTI_Mode EXTI Mode 187 * @{ 188 */ 189 #define EXTI_MODE_NONE 0x00000000u 190 #define EXTI_MODE_INTERRUPT 0x00000001u 191 #define EXTI_MODE_EVENT 0x00000002u 192 /** 193 * @} 194 */ 195 196 /** @defgroup EXTI_Trigger EXTI Trigger 197 * @{ 198 */ 199 #define EXTI_TRIGGER_NONE 0x00000000u 200 #define EXTI_TRIGGER_RISING 0x00000001u 201 #define EXTI_TRIGGER_FALLING 0x00000002u 202 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 203 /** 204 * @} 205 */ 206 207 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 208 * @brief 209 * @{ 210 */ 211 #define EXTI_GPIOA 0x00000000u 212 #define EXTI_GPIOB 0x00000001u 213 #define EXTI_GPIOC 0x00000002u 214 #if defined (GPIOD) 215 #define EXTI_GPIOD 0x00000003u 216 #endif /* GPIOD */ 217 #if defined (GPIOE) 218 #define EXTI_GPIOE 0x00000004u 219 #endif /* GPIOE */ 220 #define EXTI_GPIOF 0x00000005u 221 /** 222 * @} 223 */ 224 225 /** 226 * @} 227 */ 228 229 /* Exported macro ------------------------------------------------------------*/ 230 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 231 * @{ 232 */ 233 234 /** 235 * @} 236 */ 237 238 /* Private constants --------------------------------------------------------*/ 239 /** @defgroup EXTI_Private_Constants EXTI Private Constants 240 * @{ 241 */ 242 /** 243 * @brief EXTI Line property definition 244 */ 245 #define EXTI_PROPERTY_SHIFT 24u 246 #define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT) 247 #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) 248 #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 249 #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT) 250 #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO) 251 252 /** 253 * @brief EXTI bit usage 254 */ 255 #define EXTI_PIN_MASK 0x0000001Fu 256 257 /** 258 * @brief EXTI Mask for interrupt & event mode 259 */ 260 #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 261 262 /** 263 * @brief EXTI Mask for trigger possibilities 264 */ 265 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 266 267 /** 268 * @brief EXTI Line number 269 */ 270 #define EXTI_LINE_NB 32uL 271 272 /** 273 * @} 274 */ 275 276 /* Private macros ------------------------------------------------------------*/ 277 /** @defgroup EXTI_Private_Macros EXTI Private Macros 278 * @{ 279 */ 280 #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \ 281 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \ 282 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 283 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 284 (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB)) 285 286 #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \ 287 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u)) 288 289 #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) 290 291 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING) 292 293 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u) 294 295 #if defined (GPIOE) 296 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 297 ((__PORT__) == EXTI_GPIOB) || \ 298 ((__PORT__) == EXTI_GPIOC) || \ 299 ((__PORT__) == EXTI_GPIOD) || \ 300 ((__PORT__) == EXTI_GPIOE) || \ 301 ((__PORT__) == EXTI_GPIOF)) 302 #elif defined (GPIOD) 303 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 304 ((__PORT__) == EXTI_GPIOB) || \ 305 ((__PORT__) == EXTI_GPIOC) || \ 306 ((__PORT__) == EXTI_GPIOD) || \ 307 ((__PORT__) == EXTI_GPIOF)) 308 #else 309 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 310 ((__PORT__) == EXTI_GPIOB) || \ 311 ((__PORT__) == EXTI_GPIOC) || \ 312 ((__PORT__) == EXTI_GPIOF)) 313 #endif /* GPIOE */ 314 315 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u) 316 317 /** 318 * @} 319 */ 320 321 322 /* Exported functions --------------------------------------------------------*/ 323 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 324 * @brief EXTI Exported Functions 325 * @{ 326 */ 327 328 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 329 * @brief Configuration functions 330 * @{ 331 */ 332 /* Configuration functions ****************************************************/ 333 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 334 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 335 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 336 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 337 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); 338 /** 339 * @} 340 */ 341 342 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 343 * @brief IO operation functions 344 * @{ 345 */ 346 /* IO operation functions *****************************************************/ 347 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 348 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 349 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 350 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 351 352 /** 353 * @} 354 */ 355 356 /** 357 * @} 358 */ 359 360 /** 361 * @} 362 */ 363 364 /** 365 * @} 366 */ 367 368 #ifdef __cplusplus 369 } 370 #endif 371 372 #endif /* STM32F0xx_HAL_EXTI_H */ 373 374