1 /** 2 ****************************************************************************** 3 * @file stm32f7xx_hal_exti.h 4 * @author MCD Application Team 5 * @brief Header file of EXTI HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2018 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 STM32F7xx_HAL_EXTI_H 21 #define STM32F7xx_HAL_EXTI_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f7xx_hal_def.h" 29 30 /** @addtogroup STM32F7xx_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 * @brief EXTI Handle structure definition 51 */ 52 typedef struct 53 { 54 uint32_t Line; /*!< Exti line number */ 55 void (* PendingCallback)(void); /*!< Exti pending callback */ 56 } EXTI_HandleTypeDef; 57 58 /** 59 * @brief EXTI Configuration structure definition 60 */ 61 typedef struct 62 { 63 uint32_t Line; /*!< The Exti line to be configured. This parameter 64 can be a value of @ref EXTI_Line */ 65 uint32_t Mode; /*!< The Exit Mode to be configured for a core. 66 This parameter can be a combination of @ref EXTI_Mode */ 67 uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter 68 can be a value of @ref EXTI_Trigger */ 69 uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured. 70 This parameter is only possible for line 0 to 15. It 71 can be a value of @ref EXTI_GPIOSel */ 72 } EXTI_ConfigTypeDef; 73 74 /** 75 * @} 76 */ 77 78 /* Exported constants --------------------------------------------------------*/ 79 /** @defgroup EXTI_Exported_Constants EXTI Exported Constants 80 * @{ 81 */ 82 83 /** @defgroup EXTI_Line EXTI Line 84 * @{ 85 */ 86 #define EXTI_LINE_0 (EXTI_GPIO | 0x00u) /*!< External interrupt line 0 */ 87 #define EXTI_LINE_1 (EXTI_GPIO | 0x01u) /*!< External interrupt line 1 */ 88 #define EXTI_LINE_2 (EXTI_GPIO | 0x02u) /*!< External interrupt line 2 */ 89 #define EXTI_LINE_3 (EXTI_GPIO | 0x03u) /*!< External interrupt line 3 */ 90 #define EXTI_LINE_4 (EXTI_GPIO | 0x04u) /*!< External interrupt line 4 */ 91 #define EXTI_LINE_5 (EXTI_GPIO | 0x05u) /*!< External interrupt line 5 */ 92 #define EXTI_LINE_6 (EXTI_GPIO | 0x06u) /*!< External interrupt line 6 */ 93 #define EXTI_LINE_7 (EXTI_GPIO | 0x07u) /*!< External interrupt line 7 */ 94 #define EXTI_LINE_8 (EXTI_GPIO | 0x08u) /*!< External interrupt line 8 */ 95 #define EXTI_LINE_9 (EXTI_GPIO | 0x09u) /*!< External interrupt line 9 */ 96 #define EXTI_LINE_10 (EXTI_GPIO | 0x0Au) /*!< External interrupt line 10 */ 97 #define EXTI_LINE_11 (EXTI_GPIO | 0x0Bu) /*!< External interrupt line 11 */ 98 #define EXTI_LINE_12 (EXTI_GPIO | 0x0Cu) /*!< External interrupt line 12 */ 99 #define EXTI_LINE_13 (EXTI_GPIO | 0x0Du) /*!< External interrupt line 13 */ 100 #define EXTI_LINE_14 (EXTI_GPIO | 0x0Eu) /*!< External interrupt line 14 */ 101 #define EXTI_LINE_15 (EXTI_GPIO | 0x0Fu) /*!< External interrupt line 15 */ 102 #define EXTI_LINE_16 (EXTI_CONFIG | 0x10u) /*!< External interrupt line 16 Connected to the PVD Output */ 103 #define EXTI_LINE_17 (EXTI_CONFIG | 0x11u) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 104 #define EXTI_LINE_18 (EXTI_CONFIG | 0x12u) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */ 105 #if defined(ETH) 106 #define EXTI_LINE_19 (EXTI_CONFIG | 0x13u) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 107 #else 108 #define EXTI_LINE_19 (EXTI_RESERVED | 0x13u) /*!< No interrupt supported in this line */ 109 #endif /* ETH */ 110 #define EXTI_LINE_20 (EXTI_CONFIG | 0x14u) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */ 111 #define EXTI_LINE_21 (EXTI_CONFIG | 0x15u) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */ 112 #define EXTI_LINE_22 (EXTI_CONFIG | 0x16u) /*!< External interrupt line 22 Connected to the RTC Wakeup event */ 113 #define EXTI_LINE_23 (EXTI_CONFIG | 0x17u) /*!< External interrupt line 23 Connected to the LPTIM Wakeup event */ 114 #if defined(EXTI_IMR_IM24) 115 #define EXTI_LINE_24 (EXTI_CONFIG | 0x18u) /*!< External interrupt line 24 Connected to the MDIO Slave global Interrupt Wakeup event */ 116 #endif /* EXTI_IMR_IM24 */ 117 /** 118 * @} 119 */ 120 121 /** @defgroup EXTI_Mode EXTI Mode 122 * @{ 123 */ 124 #define EXTI_MODE_NONE 0x00000000u 125 #define EXTI_MODE_INTERRUPT 0x00000001u 126 #define EXTI_MODE_EVENT 0x00000002u 127 /** 128 * @} 129 */ 130 131 /** @defgroup EXTI_Trigger EXTI Trigger 132 * @{ 133 */ 134 135 #define EXTI_TRIGGER_NONE 0x00000000u 136 #define EXTI_TRIGGER_RISING 0x00000001u 137 #define EXTI_TRIGGER_FALLING 0x00000002u 138 #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 139 /** 140 * @} 141 */ 142 143 /** @defgroup EXTI_GPIOSel EXTI GPIOSel 144 * @brief 145 * @{ 146 */ 147 #define EXTI_GPIOA 0x00000000u 148 #define EXTI_GPIOB 0x00000001u 149 #define EXTI_GPIOC 0x00000002u 150 #define EXTI_GPIOD 0x00000003u 151 #define EXTI_GPIOE 0x00000004u 152 #define EXTI_GPIOF 0x00000005u 153 #define EXTI_GPIOG 0x00000006u 154 #define EXTI_GPIOH 0x00000007u 155 #define EXTI_GPIOI 0x00000008u 156 #define EXTI_GPIOJ 0x00000009u 157 #if defined (GPIOK) 158 #define EXTI_GPIOK 0x0000000Au 159 #endif /* GPIOK */ 160 161 /** 162 * @} 163 */ 164 165 /* Exported macro ------------------------------------------------------------*/ 166 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros 167 * @{ 168 */ 169 170 /** 171 * @} 172 */ 173 174 /* Private constants --------------------------------------------------------*/ 175 /** @defgroup EXTI_Private_Constants EXTI Private Constants 176 * @{ 177 */ 178 /** 179 * @brief EXTI Line property definition 180 */ 181 #define EXTI_PROPERTY_SHIFT 24u 182 #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT) 183 #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG) 184 #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT) 185 #define EXTI_PROPERTY_MASK (EXTI_CONFIG | EXTI_GPIO) 186 187 /** 188 * @brief EXTI bit usage 189 */ 190 #define EXTI_PIN_MASK 0x0000001Fu 191 192 /** 193 * @brief EXTI Mask for interrupt & event mode 194 */ 195 #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT) 196 197 /** 198 * @brief EXTI Mask for trigger possibilities 199 */ 200 #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING) 201 202 /** 203 * @brief EXTI Line number 204 */ 205 #if defined(EXTI_IMR_IM24) 206 #define EXTI_LINE_NB 25u 207 #else 208 #define EXTI_LINE_NB 24u 209 #endif /* EXTI_IMR_IM24 */ 210 211 212 /** 213 * @} 214 */ 215 216 /* Private macros ------------------------------------------------------------*/ 217 /** @defgroup EXTI_Private_Macros EXTI Private Macros 218 * @{ 219 */ 220 #define IS_EXTI_LINE(__EXTI_LINE__) ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \ 221 ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \ 222 (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \ 223 (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB)) 224 225 #define IS_EXTI_MODE(__EXTI_LINE__) ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \ 226 (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u)) 227 228 #define IS_EXTI_TRIGGER(__EXTI_LINE__) (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u) 229 230 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__) (((__EXTI_LINE__) == EXTI_TRIGGER_FALLING) || \ 231 ((__EXTI_LINE__) == EXTI_TRIGGER_RISING) || \ 232 ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING)) 233 234 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__) (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u) 235 236 #if defined (GPIOK) 237 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 238 ((__PORT__) == EXTI_GPIOB) || \ 239 ((__PORT__) == EXTI_GPIOC) || \ 240 ((__PORT__) == EXTI_GPIOD) || \ 241 ((__PORT__) == EXTI_GPIOE) || \ 242 ((__PORT__) == EXTI_GPIOF) || \ 243 ((__PORT__) == EXTI_GPIOG) || \ 244 ((__PORT__) == EXTI_GPIOH) || \ 245 ((__PORT__) == EXTI_GPIOI) || \ 246 ((__PORT__) == EXTI_GPIOJ) || \ 247 ((__PORT__) == EXTI_GPIOK)) 248 #else 249 #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \ 250 ((__PORT__) == EXTI_GPIOB) || \ 251 ((__PORT__) == EXTI_GPIOC) || \ 252 ((__PORT__) == EXTI_GPIOD) || \ 253 ((__PORT__) == EXTI_GPIOE) || \ 254 ((__PORT__) == EXTI_GPIOF) || \ 255 ((__PORT__) == EXTI_GPIOG) || \ 256 ((__PORT__) == EXTI_GPIOH) || \ 257 ((__PORT__) == EXTI_GPIOI) || \ 258 ((__PORT__) == EXTI_GPIOJ)) 259 #endif /* GPIOK */ 260 261 #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16U) 262 /** 263 * @} 264 */ 265 266 /* Exported functions --------------------------------------------------------*/ 267 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions 268 * @brief EXTI Exported Functions 269 * @{ 270 */ 271 272 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions 273 * @brief Configuration functions 274 * @{ 275 */ 276 /* Configuration functions ****************************************************/ 277 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 278 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig); 279 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti); 280 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void)); 281 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine); 282 /** 283 * @} 284 */ 285 286 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions 287 * @brief IO operation functions 288 * @{ 289 */ 290 /* IO operation functions *****************************************************/ 291 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti); 292 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 293 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge); 294 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti); 295 296 /** 297 * @} 298 */ 299 300 /** 301 * @} 302 */ 303 304 /** 305 * @} 306 */ 307 308 /** 309 * @} 310 */ 311 312 #ifdef __cplusplus 313 } 314 #endif 315 316 #endif /* STM32F7xx_HAL_EXTI_H */ 317 318