1 /** 2 ****************************************************************************** 3 * @file stm32wbxx_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 STM32WBxx_HAL_EXTI_H 21 #define STM32WBxx_HAL_EXTI_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32wbxx_hal_def.h" 29 30 /** @addtogroup STM32WBxx_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 typedef enum 45 { 46 HAL_EXTI_COMMON_CB_ID = 0x00U, 47 } EXTI_CallbackIDTypeDef; 48 49 50 /** 51 * @brief EXTI Handle structure definition 52 */ 53 typedef struct 54 { 55 uint32_t Line; /*!< Exti line number */ 56 void (* PendingCallback)(void); /*!< Exti pending callback */ 57 } EXTI_HandleTypeDef; 58 59 /** 60 * @brief EXTI Configuration structure definition 61 */ 62 typedef struct 63 { 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 | EXTI_EVENT | EXTI_REG1 | 0x00u) 88 #define EXTI_LINE_1 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x01u) 89 #define EXTI_LINE_2 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x02u) 90 #define EXTI_LINE_3 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x03u) 91 #define EXTI_LINE_4 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x04u) 92 #define EXTI_LINE_5 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x05u) 93 #define EXTI_LINE_6 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x06u) 94 #define EXTI_LINE_7 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x07u) 95 #define EXTI_LINE_8 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x08u) 96 #define EXTI_LINE_9 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x09u) 97 #define EXTI_LINE_10 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Au) 98 #define EXTI_LINE_11 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Bu) 99 #define EXTI_LINE_12 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Cu) 100 #define EXTI_LINE_13 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Du) 101 #define EXTI_LINE_14 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Eu) 102 #define EXTI_LINE_15 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Fu) 103 #define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10u) 104 #define EXTI_LINE_17 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x11u) 105 #define EXTI_LINE_18 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x12u) 106 #define EXTI_LINE_19 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x13u) 107 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB35xx) || defined (STM32WB15xx) || defined(STM32WB1Mxx) 108 #define EXTI_LINE_20 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x14u) 109 #else 110 #define EXTI_LINE_20 (EXTI_RESERVED | EXTI_REG1 | 0x14u) 111 #endif /* STM32WB55xx || STM32WB5Mxx || ... */ 112 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB35xx) 113 #define EXTI_LINE_21 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x15u) 114 #else 115 #define EXTI_LINE_21 (EXTI_RESERVED | EXTI_REG1 | 0x15u) 116 #endif /* STM32WB55xx || STM32WB5Mxx || STM32WB35xx */ 117 #define EXTI_LINE_22 (EXTI_DIRECT | EXTI_REG1 | 0x16u) 118 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB35xx) 119 #define EXTI_LINE_23 (EXTI_DIRECT | EXTI_REG1 | 0x17u) 120 #else 121 #define EXTI_LINE_23 (EXTI_RESERVED | EXTI_REG1 | 0x17u) 122 #endif /* STM32WB55xx || STM32WB5Mxx || STM32WB35xx */ 123 #define EXTI_LINE_24 (EXTI_DIRECT | EXTI_REG1 | 0x18u) 124 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB35xx) || defined (STM32WB15xx) || defined(STM32WB1Mxx) 125 #define EXTI_LINE_25 (EXTI_DIRECT | EXTI_REG1 | 0x19u) 126 #else 127 #define EXTI_LINE_25 (EXTI_RESERVED | EXTI_REG1 | 0x19u) 128 #endif /* STM32WB55xx || STM32WB5Mxx || ... */ 129 #define EXTI_LINE_26 (EXTI_RESERVED | EXTI_REG1 | 0x1Au) 130 #define EXTI_LINE_27 (EXTI_RESERVED | EXTI_REG1 | 0x1Bu) 131 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB35xx) 132 #define EXTI_LINE_28 (EXTI_DIRECT | EXTI_REG1 | 0x1Cu) 133 #else 134 #define EXTI_LINE_28 (EXTI_RESERVED | EXTI_REG1 | 0x1Cu) 135 #endif /* STM32WB55xx || STM32WB5Mxx || STM32WB35xx */ 136 #define EXTI_LINE_29 (EXTI_DIRECT | EXTI_REG1 | 0x1Du) 137 #define EXTI_LINE_30 (EXTI_DIRECT | EXTI_REG1 | 0x1Eu) 138 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB35xx) || defined (STM32WB15xx) || defined(STM32WB1Mxx) 139 #define EXTI_LINE_31 (EXTI_CONFIG | EXTI_REG1 | 0x1Fu) 140 #else 141 #define EXTI_LINE_31 (EXTI_RESERVED | EXTI_REG1 | 0x1Fu) 142 #endif /* STM32WB55xx || STM32WB5Mxx || ... */ 143 #define EXTI_LINE_32 (EXTI_RESERVED | EXTI_REG2 | 0x00u) 144 #define EXTI_LINE_33 (EXTI_CONFIG | EXTI_REG2 | 0x01u) 145 #define EXTI_LINE_34 (EXTI_RESERVED | EXTI_REG2 | 0x02u) 146 #define EXTI_LINE_35 (EXTI_RESERVED | EXTI_REG2 | 0x03u) 147 #define EXTI_LINE_36 (EXTI_DIRECT | EXTI_REG2 | 0x04u) 148 #define EXTI_LINE_37 (EXTI_DIRECT | EXTI_REG2 | 0x05u) 149 #define EXTI_LINE_38 (EXTI_DIRECT | EXTI_REG2 | 0x06u) 150 #define EXTI_LINE_39 (EXTI_DIRECT | EXTI_REG2 | 0x07u) 151 #define EXTI_LINE_40 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG2 | 0x08u) 152 #define EXTI_LINE_41 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG2 | 0x09u) 153 #define EXTI_LINE_42 (EXTI_DIRECT | EXTI_REG2 | 0x0Au) 154 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) 155 #define EXTI_LINE_43 (EXTI_DIRECT | EXTI_REG2 | 0x0Bu) 156 #else 157 #define EXTI_LINE_43 (EXTI_RESERVED | EXTI_REG2 | 0x0Bu) 158 #endif /* STM32WB55xx || STM32WB5Mxx */ 159 #define EXTI_LINE_44 (EXTI_DIRECT | EXTI_REG2 | 0x0Cu) 160 #define EXTI_LINE_45 (EXTI_DIRECT | EXTI_REG2 | 0x0Du) 161 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) || defined (STM32WB50xx) || defined (STM32WB35xx) || defined (STM32WB30xx) 162 #define EXTI_LINE_46 (EXTI_DIRECT | EXTI_REG2 | 0x0Eu) 163 #else 164 #define EXTI_LINE_46 (EXTI_RESERVED | EXTI_REG2 | 0x0Eu) 165 #endif /* STM32WB55xx || STM32WB5Mxx || ... */ 166 #define EXTI_LINE_47 (EXTI_RESERVED | EXTI_REG2 | 0x0Fu) 167 #define EXTI_LINE_48 (EXTI_DIRECT | EXTI_REG2 | 0x10u) 168 /** 169 * @} 170 */ 171 172 /** @defgroup EXTI_Mode EXTI Mode 173 * @{ 174 */ 175 #define EXTI_MODE_NONE 0x00000000u 176 #define EXTI_MODE_INTERRUPT 0x00000001u 177 #define EXTI_MODE_EVENT 0x00000002u 178 /** 179 * @} 180 */ 181 182 /** @defgroup EXTI_Trigger EXTI Trigger 183 * @{ 184 */ 185 #define EXTI_TRIGGER_NONE 0x00000000u 186 #define EXTI_TRIGGER_RISING 0x00000001u 187 #define EXTI_TRIGGER_FALLING 0x00000002u 188 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 189 /** 190 * @} 191 */ 192 193 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 194 * @brief 195 * @{ 196 */ 197 #define EXTI_GPIOA 0x00000000u 198 #define EXTI_GPIOB 0x00000001u 199 #define EXTI_GPIOC 0x00000002u 200 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) 201 #define EXTI_GPIOD 0x00000003u 202 #endif /* STM32WB55xx || STM32WB5Mxx */ 203 #define EXTI_GPIOE 0x00000004u 204 #define EXTI_GPIOH 0x00000007u 205 /** 206 * @} 207 */ 208 209 /** 210 * @} 211 */ 212 213 /* Exported macro ------------------------------------------------------------*/ 214 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 215 * @{ 216 */ 217 218 /** 219 * @} 220 */ 221 222 /* Private constants --------------------------------------------------------*/ 223 /** @defgroup EXTI_Private_Constants EXTI Private Constants 224 * @{ 225 */ 226 /** 227 * @brief EXTI Line property definition 228 */ 229 #define EXTI_PROPERTY_SHIFT 24u 230 #define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT) 231 #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) 232 #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 233 #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT) 234 #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO) 235 236 /** 237 * @brief EXTI Event presence definition 238 */ 239 #define EXTI_EVENT_PRESENCE_SHIFT 28u 240 #define EXTI_EVENT (0x01uL << EXTI_EVENT_PRESENCE_SHIFT) 241 #define EXTI_EVENT_PRESENCE_MASK (EXTI_EVENT) 242 243 /** 244 * @brief EXTI Register and bit usage 245 */ 246 #define EXTI_REG_SHIFT 16u 247 #define EXTI_REG1 (0x00uL << EXTI_REG_SHIFT) 248 #define EXTI_REG2 (0x01uL << EXTI_REG_SHIFT) 249 #define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2) 250 #define EXTI_PIN_MASK 0x0000001Fu 251 252 /** 253 * @brief EXTI Mask for interrupt & event mode 254 */ 255 #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 256 257 /** 258 * @brief EXTI Mask for trigger possibilities 259 */ 260 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 261 262 /** 263 * @brief EXTI Line number 264 */ 265 #define EXTI_LINE_NB 49uL 266 267 /** 268 * @} 269 */ 270 271 /* Private macros ------------------------------------------------------------*/ 272 /** @defgroup EXTI_Private_Macros EXTI Private Macros 273 * @{ 274 */ 275 #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_EVENT_PRESENCE_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00u) && \ 276 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \ 277 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 278 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 279 (((__EXTI_LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \ 280 (((EXTI_LINE_NB / 32u) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32u)))) 281 282 #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \ 283 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u)) 284 285 #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) 286 287 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING) 288 289 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u) 290 291 #if defined (STM32WB55xx) || defined (STM32WB5Mxx) 292 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 293 ((__PORT__) == EXTI_GPIOB) || \ 294 ((__PORT__) == EXTI_GPIOC) || \ 295 ((__PORT__) == EXTI_GPIOD) || \ 296 ((__PORT__) == EXTI_GPIOE) || \ 297 ((__PORT__) == EXTI_GPIOH)) 298 #else 299 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 300 ((__PORT__) == EXTI_GPIOB) || \ 301 ((__PORT__) == EXTI_GPIOC) || \ 302 ((__PORT__) == EXTI_GPIOE) || \ 303 ((__PORT__) == EXTI_GPIOH)) 304 #endif /* STM32WB55xx || STM32WB5Mxx */ 305 306 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u) 307 308 /** 309 * @} 310 */ 311 312 313 /* Exported functions --------------------------------------------------------*/ 314 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 315 * @brief EXTI Exported Functions 316 * @{ 317 */ 318 319 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 320 * @brief Configuration functions 321 * @{ 322 */ 323 /* Configuration functions ****************************************************/ 324 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 325 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 326 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 327 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 328 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); 329 /** 330 * @} 331 */ 332 333 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 334 * @brief IO operation functions 335 * @{ 336 */ 337 /* IO operation functions *****************************************************/ 338 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 339 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 340 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 341 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 342 343 /** 344 * @} 345 */ 346 347 /** 348 * @} 349 */ 350 351 /** 352 * @} 353 */ 354 355 /** 356 * @} 357 */ 358 359 #ifdef __cplusplus 360 } 361 #endif 362 363 #endif /* STM32WBxx_HAL_EXTI_H */ 364