1 /** 2 ****************************************************************************** 3 * @file stm32l5xx_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) 2019 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 STM32L5xx_HAL_EXTI_H 22 #define STM32L5xx_HAL_EXTI_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* Includes ------------------------------------------------------------------*/ 29 #include "stm32l5xx_hal_def.h" 30 31 /** @addtogroup STM32L5xx_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 /** 54 * @brief EXTI Handle structure definition 55 */ 56 typedef struct 57 { 58 uint32_t Line; /*!< Exti line number */ 59 void (* RisingCallback) (void); /*!< Exti rising callback */ 60 void (* FallingCallback) (void); /*!< Exti falling callback */ 61 }EXTI_HandleTypeDef; 62 63 /** 64 * @brief EXTI Configuration structure definition 65 */ 66 typedef struct 67 { 68 uint32_t Line; /*!< The Exti line to be configured. This parameter 69 can be a value of @ref EXTI_Line */ 70 uint32_t Mode; /*!< The Exit Mode to be configured for a core. 71 This parameter can be a combination of @ref EXTI_Mode */ 72 uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter 73 can be a value of @ref EXTI_Trigger */ 74 uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured. 75 This parameter is only possible for line 0 to 15. It 76 can be a value of @ref EXTI_GPIOSel */ 77 }EXTI_ConfigTypeDef; 78 79 /** 80 * @} 81 */ 82 83 /* Exported constants --------------------------------------------------------*/ 84 /** @defgroup EXTI_Exported_Constants EXTI Exported Constants 85 * @{ 86 */ 87 88 /** @defgroup EXTI_Line EXTI Line 89 * @{ 90 */ 91 #define EXTI_LINE_0 (EXTI_GPIO | EXTI_REG1 | 0x00U) 92 #define EXTI_LINE_1 (EXTI_GPIO | EXTI_REG1 | 0x01U) 93 #define EXTI_LINE_2 (EXTI_GPIO | EXTI_REG1 | 0x02U) 94 #define EXTI_LINE_3 (EXTI_GPIO | EXTI_REG1 | 0x03U) 95 #define EXTI_LINE_4 (EXTI_GPIO | EXTI_REG1 | 0x04U) 96 #define EXTI_LINE_5 (EXTI_GPIO | EXTI_REG1 | 0x05U) 97 #define EXTI_LINE_6 (EXTI_GPIO | EXTI_REG1 | 0x06U) 98 #define EXTI_LINE_7 (EXTI_GPIO | EXTI_REG1 | 0x07U) 99 #define EXTI_LINE_8 (EXTI_GPIO | EXTI_REG1 | 0x08U) 100 #define EXTI_LINE_9 (EXTI_GPIO | EXTI_REG1 | 0x09U) 101 #define EXTI_LINE_10 (EXTI_GPIO | EXTI_REG1 | 0x0AU) 102 #define EXTI_LINE_11 (EXTI_GPIO | EXTI_REG1 | 0x0BU) 103 #define EXTI_LINE_12 (EXTI_GPIO | EXTI_REG1 | 0x0CU) 104 #define EXTI_LINE_13 (EXTI_GPIO | EXTI_REG1 | 0x0DU) 105 #define EXTI_LINE_14 (EXTI_GPIO | EXTI_REG1 | 0x0EU) 106 #define EXTI_LINE_15 (EXTI_GPIO | EXTI_REG1 | 0x0FU) 107 #define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10U) 108 #define EXTI_LINE_17 (EXTI_DIRECT | EXTI_REG1 | 0x11U) 109 #define EXTI_LINE_18 (EXTI_DIRECT | EXTI_REG1 | 0x12U) 110 #define EXTI_LINE_19 (EXTI_DIRECT | EXTI_REG1 | 0x13U) 111 #define EXTI_LINE_20 (EXTI_DIRECT | EXTI_REG1 | 0x14U) 112 #define EXTI_LINE_21 (EXTI_CONFIG | EXTI_REG1 | 0x15U) 113 #define EXTI_LINE_22 (EXTI_CONFIG | EXTI_REG1 | 0x16U) 114 #define EXTI_LINE_23 (EXTI_DIRECT | EXTI_REG1 | 0x17U) 115 #define EXTI_LINE_24 (EXTI_DIRECT | EXTI_REG1 | 0x18U) 116 #define EXTI_LINE_25 (EXTI_DIRECT | EXTI_REG1 | 0x19U) 117 #define EXTI_LINE_26 (EXTI_DIRECT | EXTI_REG1 | 0x1AU) 118 #define EXTI_LINE_27 (EXTI_DIRECT | EXTI_REG1 | 0x1BU) 119 #define EXTI_LINE_28 (EXTI_DIRECT | EXTI_REG1 | 0x1CU) 120 #define EXTI_LINE_29 (EXTI_DIRECT | EXTI_REG1 | 0x1DU) 121 #define EXTI_LINE_30 (EXTI_DIRECT | EXTI_REG1 | 0x1EU) 122 #define EXTI_LINE_31 (EXTI_DIRECT | EXTI_REG1 | 0x1FU) 123 #define EXTI_LINE_32 (EXTI_DIRECT | EXTI_REG2 | 0x00U) 124 #define EXTI_LINE_33 (EXTI_DIRECT | EXTI_REG2 | 0x01U) 125 #define EXTI_LINE_34 (EXTI_DIRECT | EXTI_REG2 | 0x02U) 126 #define EXTI_LINE_35 (EXTI_CONFIG | EXTI_REG2 | 0x03U) 127 #define EXTI_LINE_36 (EXTI_CONFIG | EXTI_REG2 | 0x04U) 128 #define EXTI_LINE_37 (EXTI_CONFIG | EXTI_REG2 | 0x05U) 129 #define EXTI_LINE_38 (EXTI_CONFIG | EXTI_REG2 | 0x06U) 130 #define EXTI_LINE_39 (EXTI_RESERVED | EXTI_REG2 | 0x07U) 131 #define EXTI_LINE_40 (EXTI_DIRECT | EXTI_REG2 | 0x08U) 132 #define EXTI_LINE_41 (EXTI_DIRECT | EXTI_REG2 | 0x09U) 133 #define EXTI_LINE_42 (EXTI_DIRECT | EXTI_REG2 | 0x0AU) 134 /** 135 * @} 136 */ 137 138 /** @defgroup EXTI_Mode EXTI Mode 139 * @{ 140 */ 141 #define EXTI_MODE_NONE 0x00000000U 142 #define EXTI_MODE_INTERRUPT 0x00000001U 143 #define EXTI_MODE_EVENT 0x00000002U 144 /** 145 * @} 146 */ 147 148 /** @defgroup EXTI_Trigger EXTI Trigger 149 * @{ 150 */ 151 #define EXTI_TRIGGER_NONE 0x00000000U 152 #define EXTI_TRIGGER_RISING 0x00000001U 153 #define EXTI_TRIGGER_FALLING 0x00000002U 154 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 155 /** 156 * @} 157 */ 158 159 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 160 * @brief 161 * @{ 162 */ 163 #define EXTI_GPIOA 0x00000000U 164 #define EXTI_GPIOB 0x00000001U 165 #define EXTI_GPIOC 0x00000002U 166 #define EXTI_GPIOD 0x00000003U 167 #define EXTI_GPIOE 0x00000004U 168 #define EXTI_GPIOF 0x00000005U 169 #define EXTI_GPIOG 0x00000006U 170 #define EXTI_GPIOH 0x00000007U 171 /** 172 * @} 173 */ 174 175 /** @defgroup EXTI_Line_attributes EXTI line attributes 176 * @brief EXTI line secure or non-secure and privileged or non-privileged attributes 177 * @note secure and non-secure attributes are only available from secure state when the system 178 * implement the security (TZEN=1) 179 * @{ 180 */ 181 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 182 #define EXTI_LINE_SEC (EXTI_LINE_ATTR_SEC_MASK | 0x00000001U) /*!< Secure line attribute */ 183 #define EXTI_LINE_NSEC (EXTI_LINE_ATTR_SEC_MASK | 0x00000000U) /*!< Non-secure line attribute */ 184 #endif /* __ARM_FEATURE_CMSE */ 185 #define EXTI_LINE_PRIV (EXTI_LINE_ATTR_PRIV_MASK | 0x00000002U) /*!< Privileged line attribute */ 186 #define EXTI_LINE_NPRIV (EXTI_LINE_ATTR_PRIV_MASK | 0x00000000U) /*!< Non-privileged line attribute */ 187 /** 188 * @} 189 */ 190 191 /** 192 * @} 193 */ 194 195 /* Exported macro ------------------------------------------------------------*/ 196 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 197 * @{ 198 */ 199 200 /** 201 * @} 202 */ 203 204 /* Private constants --------------------------------------------------------*/ 205 /** @defgroup EXTI_Private_Constants EXTI Private Constants 206 * @{ 207 */ 208 /** 209 * @brief EXTI Line property definition 210 */ 211 #define EXTI_PROPERTY_SHIFT 24U 212 #define EXTI_DIRECT (0x01UL << EXTI_PROPERTY_SHIFT) 213 #define EXTI_CONFIG (0x02UL << EXTI_PROPERTY_SHIFT) 214 #define EXTI_GPIO ((0x04UL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 215 #define EXTI_RESERVED (0x08UL << EXTI_PROPERTY_SHIFT) 216 #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO) 217 218 /** 219 * @brief EXTI Register and bit usage 220 */ 221 #define EXTI_REG_SHIFT 16U 222 #define EXTI_REG1 (0x00UL << EXTI_REG_SHIFT) 223 #define EXTI_REG2 (0x01UL << EXTI_REG_SHIFT) 224 #define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2) 225 #define EXTI_PIN_MASK 0x0000001FU 226 227 /** 228 * @brief EXTI Mask for interrupt & event mode 229 */ 230 #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 231 232 /** 233 * @brief EXTI Mask for trigger possibilities 234 */ 235 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 236 237 /** 238 * @brief EXTI Line number 239 */ 240 #define EXTI_LINE_NB 43UL 241 242 /** 243 * @brief EXTI Mask for secure & privilege attributes 244 */ 245 #define EXTI_LINE_ATTR_SEC_MASK 0x100U 246 #define EXTI_LINE_ATTR_PRIV_MASK 0x200U 247 /** 248 * @} 249 */ 250 251 /* Private macros ------------------------------------------------------------*/ 252 /** @defgroup EXTI_Private_Macros EXTI Private Macros 253 * @{ 254 */ 255 #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00U) && \ 256 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \ 257 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 258 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 259 (((__EXTI_LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \ 260 (((EXTI_LINE_NB / 32U) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32U)))) 261 262 #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00U) && \ 263 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00U)) 264 265 #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00U) 266 267 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) (((__EXTI_LINE__) == EXTI_TRIGGER_RISING) || \ 268 ((__EXTI_LINE__) == EXTI_TRIGGER_FALLING)) 269 270 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00U) 271 272 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 273 ((__PORT__) == EXTI_GPIOB) || \ 274 ((__PORT__) == EXTI_GPIOC) || \ 275 ((__PORT__) == EXTI_GPIOD) || \ 276 ((__PORT__) == EXTI_GPIOE) || \ 277 ((__PORT__) == EXTI_GPIOF) || \ 278 ((__PORT__) == EXTI_GPIOG) || \ 279 ((__PORT__) == EXTI_GPIOH)) 280 281 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16U) 282 283 284 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 285 286 #define IS_EXTI_LINE_ATTRIBUTES(__ATTRIBUTES__) (((((__ATTRIBUTES__) & EXTI_LINE_SEC) == EXTI_LINE_SEC) || \ 287 (((__ATTRIBUTES__) & EXTI_LINE_NSEC) == EXTI_LINE_NSEC) || \ 288 (((__ATTRIBUTES__) & EXTI_LINE_PRIV) == EXTI_LINE_PRIV) || \ 289 (((__ATTRIBUTES__) & EXTI_LINE_NPRIV) == EXTI_LINE_NPRIV)) && \ 290 (((__ATTRIBUTES__) & ~(EXTI_LINE_SEC|EXTI_LINE_NSEC|EXTI_LINE_PRIV|EXTI_LINE_NPRIV)) == 0U)) 291 292 #else 293 294 #define IS_EXTI_LINE_ATTRIBUTES(__ATTRIBUTES__) (((((__ATTRIBUTES__) & EXTI_LINE_PRIV) == EXTI_LINE_PRIV) || \ 295 (((__ATTRIBUTES__) & EXTI_LINE_NPRIV) == EXTI_LINE_NPRIV)) && \ 296 (((__ATTRIBUTES__) & ~(EXTI_LINE_PRIV|EXTI_LINE_NPRIV)) == 0U)) 297 298 #endif /* __ARM_FEATURE_CMSE */ 299 300 /** 301 * @} 302 */ 303 304 305 /* Exported functions --------------------------------------------------------*/ 306 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 307 * @brief EXTI Exported Functions 308 * @{ 309 */ 310 311 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 312 * @brief Configuration functions 313 * @{ 314 */ 315 /* Configuration functions ****************************************************/ 316 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 317 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 318 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 319 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 320 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); 321 /** 322 * @} 323 */ 324 325 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 326 * @brief IO operation functions 327 * @{ 328 */ 329 /* IO operation functions *****************************************************/ 330 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 331 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 332 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 333 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 334 335 /** 336 * @} 337 */ 338 339 /** @addtogroup EXTI_Exported_Functions_Group3 EXTI line attributes management functions 340 * @{ 341 */ 342 343 /* EXTI line attributes management functions **********************************/ 344 void HAL_EXTI_ConfigLineAttributes(uint32_t ExtiLine, uint32_t LineAttributes); 345 HAL_StatusTypeDef HAL_EXTI_GetConfigLineAttributes(uint32_t ExtiLine, uint32_t *pLineAttributes); 346 347 /** 348 * @} 349 */ 350 351 /** 352 * @} 353 */ 354 355 /** 356 * @} 357 */ 358 359 /** 360 * @} 361 */ 362 363 #ifdef __cplusplus 364 } 365 #endif 366 367 #endif /* STM32L5xx_HAL_EXTI_H */ 368 369 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 370