Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_exti.h (11528B)
1 /** 2 ****************************************************************************** 3 * @file stm32f1xx_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 STM32F1xx_HAL_EXTI_H 21 #define STM32F1xx_HAL_EXTI_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f1xx_hal_def.h" 29 30 /** @addtogroup STM32F1xx_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 HAL_EXTI_COMMON_CB_ID = 0x00U 50 } EXTI_CallbackIDTypeDef; 51 52 /** 53 * @brief EXTI Handle structure definition 54 */ 55 typedef struct { 56 uint32_t Line; /*!< Exti line number */ 57 void (*PendingCallback)(void); /*!< Exti pending callback */ 58 } EXTI_HandleTypeDef; 59 60 /** 61 * @brief EXTI Configuration structure definition 62 */ 63 typedef struct { 64 uint32_t Line; /*!< The Exti line to be configured. This parameter 65 can be a value of @ref EXTI_Line */ 66 uint32_t Mode; /*!< The Exit Mode to be configured for a core. 67 This parameter can be a combination of @ref EXTI_Mode */ 68 uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter 69 can be a value of @ref EXTI_Trigger */ 70 uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured. 71 This parameter is only possible for line 0 to 15. It 72 can be a value of @ref EXTI_GPIOSel */ 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_GPIO | 0x00u) /*!< External interrupt line 0 */ 88 #define EXTI_LINE_1 (EXTI_GPIO | 0x01u) /*!< External interrupt line 1 */ 89 #define EXTI_LINE_2 (EXTI_GPIO | 0x02u) /*!< External interrupt line 2 */ 90 #define EXTI_LINE_3 (EXTI_GPIO | 0x03u) /*!< External interrupt line 3 */ 91 #define EXTI_LINE_4 (EXTI_GPIO | 0x04u) /*!< External interrupt line 4 */ 92 #define EXTI_LINE_5 (EXTI_GPIO | 0x05u) /*!< External interrupt line 5 */ 93 #define EXTI_LINE_6 (EXTI_GPIO | 0x06u) /*!< External interrupt line 6 */ 94 #define EXTI_LINE_7 (EXTI_GPIO | 0x07u) /*!< External interrupt line 7 */ 95 #define EXTI_LINE_8 (EXTI_GPIO | 0x08u) /*!< External interrupt line 8 */ 96 #define EXTI_LINE_9 (EXTI_GPIO | 0x09u) /*!< External interrupt line 9 */ 97 #define EXTI_LINE_10 (EXTI_GPIO | 0x0Au) /*!< External interrupt line 10 */ 98 #define EXTI_LINE_11 (EXTI_GPIO | 0x0Bu) /*!< External interrupt line 11 */ 99 #define EXTI_LINE_12 (EXTI_GPIO | 0x0Cu) /*!< External interrupt line 12 */ 100 #define EXTI_LINE_13 (EXTI_GPIO | 0x0Du) /*!< External interrupt line 13 */ 101 #define EXTI_LINE_14 (EXTI_GPIO | 0x0Eu) /*!< External interrupt line 14 */ 102 #define EXTI_LINE_15 (EXTI_GPIO | 0x0Fu) /*!< External interrupt line 15 */ 103 #define EXTI_LINE_16 (EXTI_CONFIG | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */ 104 #define EXTI_LINE_17 (EXTI_CONFIG | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 105 #if defined(EXTI_IMR_IM18) 106 #define EXTI_LINE_18 (EXTI_CONFIG | 0x12u) /*!< External interrupt line 18 Connected to the USB Wakeup from suspend event */ 107 #endif /* EXTI_IMR_IM18 */ 108 #if defined(EXTI_IMR_IM19) 109 #define EXTI_LINE_19 (EXTI_CONFIG | 0x13u) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 110 #endif /* EXTI_IMR_IM19 */ 111 112 /** 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 126 /** @defgroup EXTI_Trigger EXTI Trigger 127 * @{ 128 */ 129 #define EXTI_TRIGGER_NONE 0x00000000u 130 #define EXTI_TRIGGER_RISING 0x00000001u 131 #define EXTI_TRIGGER_FALLING 0x00000002u 132 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 133 /** 134 * @} 135 */ 136 137 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 138 * @brief 139 * @{ 140 */ 141 #define EXTI_GPIOA 0x00000000u 142 #define EXTI_GPIOB 0x00000001u 143 #define EXTI_GPIOC 0x00000002u 144 #define EXTI_GPIOD 0x00000003u 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 /** 155 * @} 156 */ 157 158 /** 159 * @} 160 */ 161 162 /* Exported macro ------------------------------------------------------------*/ 163 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 164 * @{ 165 */ 166 167 /** 168 * @} 169 */ 170 171 /* Private constants --------------------------------------------------------*/ 172 /** @defgroup EXTI_Private_Constants EXTI Private Constants 173 * @{ 174 */ 175 /** 176 * @brief EXTI Line property definition 177 */ 178 #define EXTI_PROPERTY_SHIFT 24u 179 #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) 180 #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 181 #define EXTI_PROPERTY_MASK (EXTI_CONFIG | EXTI_GPIO) 182 183 /** 184 * @brief EXTI bit usage 185 */ 186 #define EXTI_PIN_MASK 0x0000001Fu 187 188 /** 189 * @brief EXTI Mask for interrupt & event mode 190 */ 191 #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 192 193 /** 194 * @brief EXTI Mask for trigger possibilities 195 */ 196 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 197 198 /** 199 * @brief EXTI Line number 200 */ 201 #if defined(EXTI_IMR_IM19) 202 #define EXTI_LINE_NB 20UL 203 #elif defined(EXTI_IMR_IM18) 204 #define EXTI_LINE_NB 19UL 205 #else /* EXTI_IMR_IM17 */ 206 #define EXTI_LINE_NB 18UL 207 #endif /* EXTI_IMR_IM19 */ 208 /** 209 * @} 210 */ 211 212 /* Private macros ------------------------------------------------------------*/ 213 /** @defgroup EXTI_Private_Macros EXTI Private Macros 214 * @{ 215 */ 216 #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \ 217 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 218 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 219 (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB)) 220 221 #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \ 222 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u)) 223 224 #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) 225 226 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING) 227 228 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u) 229 230 #if defined (GPIOG) 231 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 232 ((__PORT__) == EXTI_GPIOB) || \ 233 ((__PORT__) == EXTI_GPIOC) || \ 234 ((__PORT__) == EXTI_GPIOD) || \ 235 ((__PORT__) == EXTI_GPIOE) || \ 236 ((__PORT__) == EXTI_GPIOF) || \ 237 ((__PORT__) == EXTI_GPIOG)) 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_GPIOF)) 245 #elif defined (GPIOE) 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 #else 252 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 253 ((__PORT__) == EXTI_GPIOB) || \ 254 ((__PORT__) == EXTI_GPIOC) || \ 255 ((__PORT__) == EXTI_GPIOD)) 256 #endif /* GPIOG */ 257 258 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u) 259 260 /** 261 * @} 262 */ 263 264 /* Exported functions --------------------------------------------------------*/ 265 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 266 * @brief EXTI Exported Functions 267 * @{ 268 */ 269 270 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 271 * @brief Configuration functions 272 * @{ 273 */ 274 /* Configuration functions ****************************************************/ 275 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, 276 EXTI_ConfigTypeDef *pExtiConfig); 277 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, 278 EXTI_ConfigTypeDef *pExtiConfig); 279 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 280 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, 281 EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 282 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, 283 uint32_t ExtiLine); 284 /** 285 * @} 286 */ 287 288 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 289 * @brief IO operation functions 290 * @{ 291 */ 292 /* IO operation functions *****************************************************/ 293 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 294 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 295 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 296 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 297 298 /** 299 * @} 300 */ 301 302 /** 303 * @} 304 */ 305 306 /** 307 * @} 308 */ 309 310 /** 311 * @} 312 */ 313 314 #ifdef __cplusplus 315 } 316 #endif 317 318 #endif /* STM32F1xx_HAL_EXTI_H */ 319
