1 /** 2 ****************************************************************************** 3 * @file stm32mp1xx_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 STM32MP1xx_HAL_EXTI_H 21 #define STM32MP1xx_HAL_EXTI_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32mp1xx_hal_def.h" 29 30 /** @addtogroup STM32MP1xx_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 HAL_EXTI_RISING_CB_ID = 0x01U, 48 HAL_EXTI_FALLING_CB_ID = 0x02U, 49 } EXTI_CallbackIDTypeDef; 50 51 52 /** 53 * @brief EXTI Handle structure definition 54 */ 55 typedef struct 56 { 57 uint32_t Line; /*!< Exti line number */ 58 void (* RisingCallback)(void); /*!< Exti rising callback */ 59 void (* FallingCallback)(void); /*!< Exti falling 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 | EXTI_EVENT | EXTI_REG1 | 0x00u) /* EXTI_GPIO */ 91 #define EXTI_LINE_1 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x01u) /* EXTI_GPIO */ 92 #define EXTI_LINE_2 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x02u) /* EXTI_GPIO */ 93 #define EXTI_LINE_3 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x03u) /* EXTI_GPIO */ 94 #define EXTI_LINE_4 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x04u) /* EXTI_GPIO */ 95 #define EXTI_LINE_5 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x05u) /* EXTI_GPIO */ 96 #define EXTI_LINE_6 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x06u) /* EXTI_GPIO */ 97 #define EXTI_LINE_7 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x07u) /* EXTI_GPIO */ 98 #define EXTI_LINE_8 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x08u) /* EXTI_GPIO */ 99 #define EXTI_LINE_9 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x09u) /* EXTI_GPIO */ 100 #define EXTI_LINE_10 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Au) /* EXTI_GPIO */ 101 #define EXTI_LINE_11 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Bu) /* EXTI_GPIO */ 102 #define EXTI_LINE_12 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Cu) /* EXTI_GPIO */ 103 #define EXTI_LINE_13 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Du) /* EXTI_GPIO */ 104 #define EXTI_LINE_14 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Eu) /* EXTI_GPIO */ 105 #define EXTI_LINE_15 (EXTI_GPIO | EXTI_EVENT | EXTI_REG1 | 0x0Fu) /* EXTI_GPIO */ 106 #define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10u) /* PVD and AVD */ 107 #define EXTI_LINE_17 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x11u) /* RTC timestamp and SecureError wakeup */ 108 #define EXTI_LINE_18 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x12u) /* TAMP tamper and SecureError wakeup */ 109 #define EXTI_LINE_19 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG1 | 0x13u) /* RTC Wakeup timer and Alarms (A and B) and SecureError wakeup */ 110 #define EXTI_LINE_20 (EXTI_RESERVED | EXTI_REG1 | 0x14u) /* RESERVED */ 111 #define EXTI_LINE_21 (EXTI_DIRECT | EXTI_REG1 | 0x15u) /* I2C1 wakeup */ 112 #define EXTI_LINE_22 (EXTI_DIRECT | EXTI_REG1 | 0x16u) /* I2C2 wakeup */ 113 #define EXTI_LINE_23 (EXTI_DIRECT | EXTI_REG1 | 0x17u) /* I2C3 wakeup */ 114 #define EXTI_LINE_24 (EXTI_DIRECT | EXTI_REG1 | 0x18u) /* I2C4 wakeup */ 115 #define EXTI_LINE_25 (EXTI_DIRECT | EXTI_REG1 | 0x19u) /* I2C5 wakeup */ 116 #define EXTI_LINE_26 (EXTI_DIRECT | EXTI_REG1 | 0x1Au) /* USART1 wakeup */ 117 #define EXTI_LINE_27 (EXTI_DIRECT | EXTI_REG1 | 0x1Bu) /* USART2 wakeup */ 118 #define EXTI_LINE_28 (EXTI_DIRECT | EXTI_REG1 | 0x1Cu) /* USART3 wakeup */ 119 #define EXTI_LINE_29 (EXTI_DIRECT | EXTI_REG1 | 0x1Du) /* USART6 wakeup */ 120 #define EXTI_LINE_30 (EXTI_DIRECT | EXTI_REG1 | 0x1Eu) /* UART4 wakeup */ 121 #define EXTI_LINE_31 (EXTI_DIRECT | EXTI_REG1 | 0x1Fu) /* UART5 wakeup */ 122 #define EXTI_LINE_32 (EXTI_DIRECT | EXTI_REG2 | 0x00u) /* UART7 wakeup */ 123 #define EXTI_LINE_33 (EXTI_DIRECT | EXTI_REG2 | 0x01u) /* UART8 wakeup */ 124 #define EXTI_LINE_34 (EXTI_RESERVED | EXTI_REG2 | 0x02u) /* RESERVED */ 125 #define EXTI_LINE_35 (EXTI_RESERVED | EXTI_REG2 | 0x03u) /* RESERVED */ 126 #define EXTI_LINE_36 (EXTI_DIRECT | EXTI_REG2 | 0x04u) /* SPI1 wakeup */ 127 #define EXTI_LINE_37 (EXTI_DIRECT | EXTI_REG2 | 0x05u) /* SPI2 wakeup */ 128 #define EXTI_LINE_38 (EXTI_DIRECT | EXTI_REG2 | 0x06u) /* SPI3 wakeup */ 129 #define EXTI_LINE_39 (EXTI_DIRECT | EXTI_REG2 | 0x07u) /* SPI4 wakeup */ 130 #define EXTI_LINE_40 (EXTI_DIRECT | EXTI_REG2 | 0x08u) /* SPI5 wakeup */ 131 #define EXTI_LINE_41 (EXTI_DIRECT | EXTI_REG2 | 0x09u) /* SPI6 wakeup */ 132 #define EXTI_LINE_42 (EXTI_DIRECT | EXTI_REG2 | 0x0Au) /* MDIOS wakeup */ 133 #define EXTI_LINE_43 (EXTI_DIRECT | EXTI_REG2 | 0x0Bu) /* USBH wakeup */ 134 #define EXTI_LINE_44 (EXTI_DIRECT | EXTI_REG2 | 0x0Cu) /* OTG wakeup */ 135 #define EXTI_LINE_45 (EXTI_DIRECT | EXTI_REG2 | 0x0Du) /* IWDG1 early wake */ 136 #define EXTI_LINE_46 (EXTI_DIRECT | EXTI_REG2 | 0x0Eu) /* IWDG1 early wake */ 137 #define EXTI_LINE_47 (EXTI_DIRECT | EXTI_REG2 | 0x0Fu) /* LPTIM1 wakeup */ 138 #define EXTI_LINE_48 (EXTI_DIRECT | EXTI_REG2 | 0x10u) /* LPTIM2 wakeup */ 139 #define EXTI_LINE_49 (EXTI_RESERVED | EXTI_REG2 | 0x11u) /* RESERVED */ 140 #define EXTI_LINE_50 (EXTI_DIRECT | EXTI_REG2 | 0x12u) /* LPTIM3 wakeup */ 141 #define EXTI_LINE_51 (EXTI_RESERVED | EXTI_REG2 | 0x13u) /* RESERVED */ 142 #define EXTI_LINE_52 (EXTI_DIRECT | EXTI_REG2 | 0x14u) /* LPTIM4 wakeup */ 143 #define EXTI_LINE_53 (EXTI_DIRECT | EXTI_REG2 | 0x15u) /* LPTIM5 wakeup */ 144 #define EXTI_LINE_54 (EXTI_DIRECT | EXTI_REG2 | 0x16u) /* I2C6 wakeup */ 145 #define EXTI_LINE_55 (EXTI_DIRECT | EXTI_REG2 | 0x17u) /* WKUP1 wakeup */ 146 #define EXTI_LINE_56 (EXTI_DIRECT | EXTI_REG2 | 0x18u) /* WKUP2 wakeup */ 147 #define EXTI_LINE_57 (EXTI_DIRECT | EXTI_REG2 | 0x19u) /* WKUP3 wakeup */ 148 #define EXTI_LINE_58 (EXTI_DIRECT | EXTI_REG2 | 0x1Au) /* WKUP4 wakeup */ 149 #define EXTI_LINE_59 (EXTI_DIRECT | EXTI_REG2 | 0x1Bu) /* WKUP5 wakeup */ 150 #define EXTI_LINE_60 (EXTI_DIRECT | EXTI_REG2 | 0x1Cu) /* WKUP6 wakeup */ 151 #define EXTI_LINE_61 (EXTI_DIRECT | EXTI_REG2 | 0x1Du) /* IPCC interrupt CPU1 */ 152 #define EXTI_LINE_62 (EXTI_DIRECT | EXTI_REG2 | 0x1Eu) /* IPCC interrupt CPU2 */ 153 #define EXTI_LINE_63 (EXTI_DIRECT | EXTI_REG2 | 0x1Fu) /* HSEM_IT1 interrupt */ 154 #define EXTI_LINE_64 (EXTI_DIRECT | EXTI_REG3 | 0x00u) /* HSEM_IT2 interrupt */ 155 #define EXTI_LINE_65 (EXTI_CONFIG | EXTI_REG3 | 0x01u) /* CPU2 SEV interrupt */ 156 #define EXTI_LINE_66 (EXTI_CONFIG | EXTI_EVENT | EXTI_REG3 | 0x02u) /* CPU1 SEV interrupt */ 157 #define EXTI_LINE_67 (EXTI_RESERVED | EXTI_REG3 | 0x03u) /* RESERVED */ 158 #define EXTI_LINE_68 (EXTI_CONFIG | EXTI_REG3 | 0x04u) /* WWDG1 reset */ 159 #define EXTI_LINE_69 (EXTI_DIRECT | EXTI_REG3 | 0x05u) /* HDMI CEC wakeup */ 160 #define EXTI_LINE_70 (EXTI_DIRECT | EXTI_REG3 | 0x06u) /* ETH1 pmt_intr_o wakeup */ 161 #define EXTI_LINE_71 (EXTI_DIRECT | EXTI_REG3 | 0x07u) /* ETH1 lpi_intr_o wakeup */ 162 #define EXTI_LINE_72 (EXTI_DIRECT | EXTI_REG3 | 0x08u) /* DTS wakeup */ 163 #define EXTI_LINE_73 (EXTI_CONFIG | EXTI_REG3 | 0x09u) /* CPU2 SYSRESETREQ local CPU2 reset */ 164 #define EXTI_LINE_74 (EXTI_RESERVED | EXTI_REG3 | 0x0Au) /* RESERVED */ 165 #define EXTI_LINE_75 (EXTI_DIRECT | EXTI_REG3 | 0x0Bu) /* CDBGPWRUPREQ event */ 166 167 168 /** 169 * @} 170 */ 171 172 /** @defgroup EXTI_Mode EXTI Mode 173 * @{ 174 */ 175 176 #define EXTI_MODE_C1_NONE 0x00000010u 177 #define EXTI_MODE_C1_INTERRUPT 0x00000011u 178 #define EXTI_MODE_C2_NONE 0x00000020u 179 #define EXTI_MODE_C2_INTERRUPT 0x00000021u 180 #define EXTI_MODE_C2_EVENT 0x00000022u 181 /** 182 * @} 183 */ 184 185 /** @defgroup EXTI_Trigger EXTI Trigger 186 * @{ 187 */ 188 #define EXTI_TRIGGER_NONE 0x00000000u 189 #define EXTI_TRIGGER_RISING 0x00000001u 190 #define EXTI_TRIGGER_FALLING 0x00000002u 191 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 192 /** 193 * @} 194 */ 195 196 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 197 * @brief 198 * @{ 199 */ 200 #define EXTI_GPIOA 0x00000000u 201 #define EXTI_GPIOB 0x00000001u 202 #define EXTI_GPIOC 0x00000002u 203 #define EXTI_GPIOD 0x00000003u 204 #define EXTI_GPIOE 0x00000004u 205 #define EXTI_GPIOF 0x00000005u 206 #define EXTI_GPIOG 0x00000006u 207 #define EXTI_GPIOH 0x00000007u 208 #define EXTI_GPIOI 0x00000008u 209 #define EXTI_GPIOJ 0x00000009u 210 #define EXTI_GPIOK 0x0000000Au 211 #define EXTI_GPIOZ 0x0000000Bu 212 /** 213 * @} 214 */ 215 216 /** 217 * @} 218 */ 219 220 /* Exported macro ------------------------------------------------------------*/ 221 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 222 * @{ 223 */ 224 225 /** 226 * @} 227 */ 228 229 /* Private constants --------------------------------------------------------*/ 230 /** @defgroup EXTI_Private_Constants EXTI Private Constants 231 * @{ 232 */ 233 /** 234 * @brief EXTI Line property definition 235 */ 236 #define EXTI_PROPERTY_SHIFT 24u 237 #define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT) 238 #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) 239 #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 240 #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT) 241 #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO) 242 243 /** 244 * @brief EXTI Event presence definition 245 */ 246 #define EXTI_EVENT_PRESENCE_SHIFT 28u 247 #define EXTI_EVENT (0x01uL << EXTI_EVENT_PRESENCE_SHIFT) 248 #define EXTI_EVENT_PRESENCE_MASK (EXTI_EVENT) 249 250 /** 251 * @brief EXTI Register and bit usage 252 */ 253 #define EXTI_REG_SHIFT 16u 254 #define EXTI_REG1 (0x00uL << EXTI_REG_SHIFT) 255 #define EXTI_REG2 (0x01uL << EXTI_REG_SHIFT) 256 #define EXTI_REG3 (0x02uL << EXTI_REG_SHIFT) 257 #define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2 | EXTI_REG3) 258 #define EXTI_PIN_MASK 0x0000001Fu 259 260 /** 261 * @brief EXTI Mask for interrupt & event mode 262 */ 263 #define EXTI_MODE_MASK (EXTI_MODE_C1 | EXTI_MODE_C2 | EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 264 265 /** 266 * @brief EXTI Mask for trigger possibilities 267 */ 268 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 269 270 /** 271 * @brief EXTI Line number 272 */ 273 #define EXTI_LINE_NB 76uL 274 275 /** 276 * @} 277 */ 278 279 /* Private macros ------------------------------------------------------------*/ 280 /** @defgroup EXTI_Private_Macros EXTI Private Macros 281 * @{ 282 */ 283 #define IS_EXTI_LINE(__LINE__) ((((__LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_EVENT_PRESENCE_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00u) && \ 284 ((((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \ 285 (((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 286 (((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 287 (((__LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \ 288 (((EXTI_LINE_NB / 32u) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32u)))) 289 290 #define IS_EXTI_MODE(__LINE__) ((((__LINE__) & EXTI_MODE_MASK) != 0x00u) && \ 291 (((__LINE__) & ~EXTI_MODE_MASK) == 0x00u)) 292 293 #define IS_EXTI_TRIGGER(__LINE__) (((__LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) 294 295 #define IS_EXTI_PENDING_EDGE(__LINE__) (((__LINE__) == EXTI_TRIGGER_RISING) || \ 296 ((__LINE__) == EXTI_TRIGGER_FALLING)) 297 298 #define IS_EXTI_CONFIG_LINE(__LINE__) (((__LINE__) & EXTI_CONFIG) != 0x00u) 299 300 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 301 ((__PORT__) == EXTI_GPIOB) || \ 302 ((__PORT__) == EXTI_GPIOC) || \ 303 ((__PORT__) == EXTI_GPIOD) || \ 304 ((__PORT__) == EXTI_GPIOE) || \ 305 ((__PORT__) == EXTI_GPIOF) || \ 306 ((__PORT__) == EXTI_GPIOG) || \ 307 ((__PORT__) == EXTI_GPIOH) || \ 308 ((__PORT__) == EXTI_GPIOI) || \ 309 ((__PORT__) == EXTI_GPIOK) || \ 310 ((__PORT__) == EXTI_GPIOZ)) 311 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u) 312 313 /** 314 * @} 315 */ 316 317 318 /* Exported functions --------------------------------------------------------*/ 319 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 320 * @brief EXTI Exported Functions 321 * @{ 322 */ 323 324 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 325 * @brief Configuration functions 326 * @{ 327 */ 328 /* Configuration functions ****************************************************/ 329 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 330 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 331 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 332 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 333 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); 334 /** 335 * @} 336 */ 337 338 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 339 * @brief IO operation functions 340 * @{ 341 */ 342 /* IO operation functions *****************************************************/ 343 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 344 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 345 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 346 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 347 348 /** 349 * @} 350 */ 351 352 /** 353 * @} 354 */ 355 356 /** 357 * @} 358 */ 359 360 /** 361 * @} 362 */ 363 364 #ifdef __cplusplus 365 } 366 #endif 367 368 #endif /* STM32MP1xx_HAL_EXTI_H */ 369