1 /** 2 ****************************************************************************** 3 * @file stm32l0xx_ll_exti.h 4 * @author MCD Application Team 5 * @brief Header file of EXTI LL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2020 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 /* Define to prevent recursive inclusion -------------------------------------*/ 19 #ifndef __STM32L0xx_HAL_EXTI_H 20 #define __STM32L0xx_HAL_EXTI_H 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 /* Includes ------------------------------------------------------------------*/ 26 #include "stm32l0xx.h" 27 28 /** @addtogroup STM32L0xx_HAL_Driver 29 * @{ 30 */ 31 32 /** @defgroup EXTI EXTI 33 * @brief EXTI HAL module driver 34 * @{ 35 */ 36 37 /* Exported types ------------------------------------------------------------*/ 38 /* Exported types ------------------------------------------------------------*/ 39 40 /** @defgroup EXTI_Exported_Types EXTI Exported Types 41 * @{ 42 */ 43 typedef enum 44 { 45 HAL_EXTI_COMMON_CB_ID = 0x00U, 46 HAL_EXTI_RISING_CB_ID = 0x01U, 47 HAL_EXTI_FALLING_CB_ID = 0x02U, 48 } EXTI_CallbackIDTypeDef; 49 50 51 /** 52 * @brief EXTI Handle structure definition 53 */ 54 typedef struct 55 { 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 { 65 uint32_t Line; /*!< The Exti line to be configured. This parameter 66 can be a value of @ref EXTI_Line */ 67 uint32_t Mode; /*!< The Exit Mode to be configured for a core. 68 This parameter can be a combination of @ref EXTI_Mode */ 69 uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter 70 can be a value of @ref EXTI_Trigger */ 71 uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured. 72 This parameter is only possible for line 0 to 15. It 73 can be a value of @ref EXTI_GPIOSel */ 74 } EXTI_ConfigTypeDef; 75 76 /** 77 * @} 78 */ 79 80 /* Exported constants --------------------------------------------------------*/ 81 /** @defgroup EXTI_Exported_Constants EXTI Exported Constants 82 * @{ 83 */ 84 85 /** @defgroup EXTI_Line EXTI Line 86 * @{ 87 */ 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 #if defined(EXTI_IMR_IM16) 107 #define EXTI_LINE_16 (EXTI_CONFIG | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */ 108 #else 109 #define EXTI_LINE_16 (EXTI_RESERVED | 0x10u) /*!< No interrupt supported in this line */ 110 #endif /* EXTI_IMR_IM16 */ 111 #define EXTI_LINE_17 (EXTI_CONFIG | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 112 #if defined(EXTI_IMR_IM18) 113 #define EXTI_LINE_18 (EXTI_DIRECT | 0x12u) /*!< External interrupt line 18 Connected to the USB Wakeup from suspend event */ 114 #else 115 #define EXTI_LINE_18 (EXTI_RESERVED | 0x12u) /*!< No interrupt supported in this line */ 116 #endif /* EXTI_IMR_IM18 */ 117 #define EXTI_LINE_19 (EXTI_CONFIG | 0x13u) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events or CSS_LSE */ 118 #define EXTI_LINE_20 (EXTI_CONFIG | 0x14u) /*!< External interrupt line 20 Connected to the RTC wakeup timer */ 119 #if defined(EXTI_IMR_IM21) 120 #define EXTI_LINE_21 (EXTI_CONFIG | 0x15u) /*!< External interrupt line 21 Connected to the Comparator 1 output */ 121 #else 122 #define EXTI_LINE_21 (EXTI_RESERVED | 0x15u) /*!< No interrupt supported in this line */ 123 #endif /* EXTI_IMR_IM21 */ 124 #if defined(EXTI_IMR_IM22) 125 #define EXTI_LINE_22 (EXTI_CONFIG | 0x16u) /*!< External interrupt line 22 Connected to the Comparator 2 output */ 126 #else 127 #define EXTI_LINE_22 (EXTI_RESERVED | 0x16u) /*!< No interrupt supported in this line */ 128 #endif /* EXTI_IMR_IM22 */ 129 #define EXTI_LINE_23 (EXTI_DIRECT | 0x17u) /*!< External interrupt line 23 Connected to the internal I2C1 wakeup event */ 130 #if defined(EXTI_IMR_IM24) 131 #define EXTI_LINE_24 (EXTI_DIRECT | 0x18u) /*!< External interrupt line 24 Connected to the internal I2C3 wakeup event */ 132 #else 133 #define EXTI_LINE_24 (EXTI_RESERVED | 0x18u) /*!< No interrupt supported in this line */ 134 #endif /* EXTI_IMR_IM24 */ 135 #if defined(EXTI_IMR_IM25) 136 #define EXTI_LINE_25 (EXTI_DIRECT | 0x19u) /*!< External interrupt line 25 Connected to the internal USART1 wakeup event */ 137 #else 138 #define EXTI_LINE_25 (EXTI_RESERVED | 0x19u) /*!< No interrupt supported in this line */ 139 #endif /* EXTI_IMR_IM25 */ 140 #define EXTI_LINE_26 (EXTI_DIRECT | 0x1Au) /*!< External interrupt line 26 Connected to the internal USART2 wakeup event */ 141 #define EXTI_LINE_27 (EXTI_RESERVED | 0x1Bu) /*!< No interrupt supported in this line */ 142 #define EXTI_LINE_28 (EXTI_DIRECT | 0x1Cu) /*!< External interrupt line 28 Connected to the LPUART1 Wakeup event */ 143 #define EXTI_LINE_29 (EXTI_DIRECT | 0x1Du) /*!< External interrupt line 29 Connected to the LPTIM1 Wakeup event */ 144 145 /** 146 * @} 147 */ 148 149 /** @defgroup EXTI_Mode EXTI Mode 150 * @{ 151 */ 152 #define EXTI_MODE_NONE 0x00000000u 153 #define EXTI_MODE_INTERRUPT 0x00000001u 154 #define EXTI_MODE_EVENT 0x00000002u 155 /** 156 * @} 157 */ 158 159 /** @defgroup EXTI_Trigger EXTI Trigger 160 * @{ 161 */ 162 #define EXTI_TRIGGER_NONE 0x00000000u 163 #define EXTI_TRIGGER_RISING 0x00000001u 164 #define EXTI_TRIGGER_FALLING 0x00000002u 165 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 166 /** 167 * @} 168 */ 169 170 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 171 * @brief 172 * @{ 173 */ 174 #define EXTI_GPIOA 0x00000000u 175 #define EXTI_GPIOB 0x00000001u 176 #define EXTI_GPIOC 0x00000002u 177 #if defined (GPIOD) 178 #define EXTI_GPIOD 0x00000003u 179 #endif /* GPIOD*/ 180 #if defined (GPIOE) 181 #define EXTI_GPIOE 0x00000004u 182 #endif /* GPIOE*/ 183 #if defined (GPIOH) 184 #define EXTI_GPIOH 0x00000007u 185 #endif /* GPIOH*/ 186 /** 187 * @} 188 */ 189 190 /** 191 * @} 192 */ 193 194 /* Exported macro ------------------------------------------------------------*/ 195 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 196 * @{ 197 */ 198 199 /** 200 * @} 201 */ 202 203 /* Private constants --------------------------------------------------------*/ 204 /** @defgroup EXTI_Private_Constants EXTI Private Constants 205 * @{ 206 */ 207 /** 208 * @brief EXTI Line property definition 209 */ 210 #define EXTI_PROPERTY_SHIFT 24u 211 #define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT) 212 #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) 213 #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 214 #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT) 215 #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO) 216 217 /** 218 * @brief EXTI bit usage 219 */ 220 #define EXTI_PIN_MASK 0x0000001Fu 221 222 /** 223 * @brief EXTI Mask for interrupt & event mode 224 */ 225 #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 226 227 /** 228 * @brief EXTI Mask for trigger possibilities 229 */ 230 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 231 232 /** 233 * @brief EXTI Line number 234 */ 235 #define EXTI_LINE_NB 30u 236 237 /** 238 * @} 239 */ 240 241 /* Private macros ------------------------------------------------------------*/ 242 /** @defgroup EXTI_Private_Macros EXTI Private Macros 243 * @{ 244 */ 245 #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \ 246 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 247 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 248 (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB)) 249 250 #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \ 251 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u)) 252 253 #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) 254 255 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING) 256 257 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u) 258 259 #if !defined (GPIOH) 260 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 261 ((__PORT__) == EXTI_GPIOB) || \ 262 ((__PORT__) == EXTI_GPIOC)) 263 #elif !defined (GPIOD) 264 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 265 ((__PORT__) == EXTI_GPIOB) || \ 266 ((__PORT__) == EXTI_GPIOC) || \ 267 ((__PORT__) == EXTI_GPIOH)) 268 #elif !defined (GPIOE) 269 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 270 ((__PORT__) == EXTI_GPIOB) || \ 271 ((__PORT__) == EXTI_GPIOC) || \ 272 ((__PORT__) == EXTI_GPIOD) || \ 273 ((__PORT__) == EXTI_GPIOH)) 274 #else 275 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 276 ((__PORT__) == EXTI_GPIOB) || \ 277 ((__PORT__) == EXTI_GPIOC) || \ 278 ((__PORT__) == EXTI_GPIOD) || \ 279 ((__PORT__) == EXTI_GPIOE) || \ 280 ((__PORT__) == EXTI_GPIOH)) 281 #endif /* GPIOH */ 282 283 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u) 284 /** 285 * @} 286 */ 287 288 289 /* Exported functions --------------------------------------------------------*/ 290 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 291 * @brief EXTI Exported Functions 292 * @{ 293 */ 294 295 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 296 * @brief Configuration functions 297 * @{ 298 */ 299 /* Configuration functions ****************************************************/ 300 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 301 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 302 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 303 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 304 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); 305 /** 306 * @} 307 */ 308 309 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 310 * @brief IO operation functions 311 * @{ 312 */ 313 /* IO operation functions *****************************************************/ 314 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 315 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 316 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 317 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 318 319 /** 320 * @} 321 */ 322 323 /** 324 * @} 325 */ 326 327 /** 328 * @} 329 */ 330 331 /** 332 * @} 333 */ 334 335 #ifdef __cplusplus 336 } 337 #endif 338 339 #endif /* STM32L0xx_HAL_EXTI_H */ 340 341