1 /** 2 ****************************************************************************** 3 * @file stm32u5xx_hal_gpio_ex.h 4 * @author MCD Application Team 5 * @brief Header file of GPIO HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2021 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 STM32U5xx_HAL_GPIO_EX_H 21 #define STM32U5xx_HAL_GPIO_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32u5xx_hal_def.h" 29 30 /** @addtogroup STM32U5xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup GPIOEx GPIOEx 35 * @brief GPIO Extended HAL module driver 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 /** @defgroup LPGPIO_MapTypeDef GPIO/Ex Exported Types 41 * @{ 42 */ 43 typedef struct 44 { 45 GPIO_TypeDef *GPIO_PORT; 46 uint32_t Pin_Pos; 47 } LPGPIO_MapTypeDef; 48 /** 49 * @} 50 */ 51 52 /* Exported constants --------------------------------------------------------*/ 53 /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants 54 * @{ 55 */ 56 57 /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection 58 * @{ 59 */ 60 61 /** 62 * @brief AF 0 selection 63 */ 64 #define GPIO_AF0_RTC_50HZ ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ 65 #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ 66 #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ 67 #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ 68 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00) /* LPTIM1 Alternate Function mapping */ 69 #define GPIO_AF0_CSLEEP ((uint8_t)0x00) /* CSLEEP Alternate Function mapping */ 70 #define GPIO_AF0_CSTOP ((uint8_t)0x00) /* CSTOP Alternate Function mapping */ 71 #define GPIO_AF0_CRS ((uint8_t)0x00) /* CRS Alternate Function mapping */ 72 #define GPIO_AF0_SRDSTOP ((uint8_t)0x00) /* SRDSTOP Alternate Function mapping */ 73 74 /** 75 * @brief AF 1 selection 76 */ 77 #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ 78 #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ 79 #define GPIO_AF1_TIM5 ((uint8_t)0x01) /* TIM5 Alternate Function mapping */ 80 #define GPIO_AF1_TIM8 ((uint8_t)0x01) /* TIM8 Alternate Function mapping */ 81 #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */ 82 #define GPIO_AF1_IR ((uint8_t)0x01) /* IR Alternate Function mapping */ 83 84 /** 85 * @brief AF 2 selection 86 */ 87 #define GPIO_AF2_TIM1 ((uint8_t)0x02) /* TIM1 Alternate Function mapping */ 88 #define GPIO_AF2_TIM2 ((uint8_t)0x02) /* TIM2 Alternate Function mapping */ 89 #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ 90 #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ 91 #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ 92 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02) /* LPTIM1 Alternate Function mapping */ 93 #define GPIO_AF2_LPTIM2 ((uint8_t)0x02) /* LPTIM2 Alternate Function mapping */ 94 #define GPIO_AF2_LPTIM3 ((uint8_t)0x02) /* LPTIM3 Alternate Function mapping */ 95 #if defined(I2C5) 96 #define GPIO_AF2_I2C5 ((uint8_t)0x02) /* I2C5 Alternate Function mapping */ 97 #endif /* I2C5 */ 98 #if defined(I2C6) 99 #define GPIO_AF2_I2C6 ((uint8_t)0x02) /* I2C6 Alternate Function mapping */ 100 #endif /* I2C6 */ 101 #if defined(GFXTIM) 102 #define GPIO_AF2_GFXTIM ((uint8_t)0x02) /* GFXTIM Alternate Function mapping */ 103 #endif /* GFXTIM */ 104 105 /** 106 * @brief AF 3 selection 107 */ 108 #define GPIO_AF3_I2C4 ((uint8_t)0x03) /* I2C4 Alternate Function mapping */ 109 #define GPIO_AF3_OCTOSPI1 ((uint8_t)0x03) /* OCTOSPI1 Alternate Function mapping */ 110 #define GPIO_AF3_SAI1 ((uint8_t)0x03) /* SAI1 Alternate Function mapping */ 111 #define GPIO_AF3_SPI2 ((uint8_t)0x03) /* SPI2 Alternate Function mapping */ 112 #define GPIO_AF3_TIM1 ((uint8_t)0x03) /* TIM1 Alternate Function mapping */ 113 #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ 114 #define GPIO_AF3_TIM8_COMP1 ((uint8_t)0x03) /* TIM8/COMP1 Break in Alternate Function mapping */ 115 #define GPIO_AF3_TIM8_COMP2 ((uint8_t)0x03) /* TIM8/COMP2 Break in Alternate Function mapping */ 116 #define GPIO_AF3_TIM1_COMP1 ((uint8_t)0x03) /* TIM1/COMP1 Break in Alternate Function mapping */ 117 #define GPIO_AF3_TIM1_COMP2 ((uint8_t)0x03) /* TIM1/COMP2 Break in Alternate Function mapping */ 118 #if defined(USART2) 119 #define GPIO_AF3_USART2 ((uint8_t)0x03) /* USART2 Alternate Function mapping */ 120 #endif /* USART2 */ 121 #define GPIO_AF3_ADF1 ((uint8_t)0x03) /* ADF1 Alternate Function mapping */ 122 #if defined(USB_OTG_HS) 123 #define GPIO_AF3_USB_HS ((uint8_t)0x03) /* USB_HS Alternate Function mapping */ 124 #endif /* USB_OTG_HS */ 125 126 /** 127 * @brief AF 4 selection 128 */ 129 #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ 130 #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ 131 #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ 132 #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */ 133 #define GPIO_AF4_PSSI ((uint8_t)0x04) /* PSSI Alternate Function mapping */ 134 #define GPIO_AF4_DCMI ((uint8_t)0x04) /* DCMI Alternate Function mapping */ 135 #define GPIO_AF4_LPTIM3 ((uint8_t)0x04) /* LPTIM3 Alternate Function mapping */ 136 #if defined (I2C5) 137 #define GPIO_AF4_I2C5 ((uint8_t)0x04) /* I2C5 Alternate Function mapping */ 138 #endif /* I2C5 */ 139 140 /** 141 * @brief AF 5 selection 142 */ 143 #define GPIO_AF5_I2C4 ((uint8_t)0x05) /* I2C4 Alternate Function mapping */ 144 #define GPIO_AF5_OCTOSPI1 ((uint8_t)0x05) /* OCTOSPI1 Alternate Function mapping */ 145 #if defined(OCTOSPI2) 146 #define GPIO_AF5_OCTOSPI2 ((uint8_t)0x05) /* OCTOSPI2 Alternate Function mapping */ 147 #endif /* OCTOSPI2 */ 148 #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ 149 #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */ 150 #define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI3 Alternate Function mapping */ 151 #define GPIO_AF5_DCMI ((uint8_t)0x05) /* DCMI Alternate Function mapping */ 152 #define GPIO_AF5_MDF1 ((uint8_t)0x05) /* MDF1 Alternate Function mapping */ 153 #define GPIO_AF5_PSSI ((uint8_t)0x05) /* PSSI Alternate Function mapping */ 154 #if defined(GFXTIM) 155 #define GPIO_AF5_GFXTIM ((uint8_t)0x05) /* GFXTIM Alternate Function mapping */ 156 #endif /* GFXTIM */ 157 158 /** 159 * @brief AF 6 selection 160 */ 161 #define GPIO_AF6_OCTOSPI1 ((uint8_t)0x06) /* OCTOSPI1 Alternate Function mapping */ 162 #if defined(OCTOSPI2) 163 #define GPIO_AF6_OCTOSPI2 ((uint8_t)0x06) /* OCTOSPI2 Alternate Function mapping */ 164 #endif /* OCTOPSI2 */ 165 #define GPIO_AF6_MDF1 ((uint8_t)0x06) /* MDF1 Alternate Function mapping */ 166 #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */ 167 #define GPIO_AF6_I2C3 ((uint8_t)0x06) /* I2C3 Alternate Function mapping */ 168 169 /** 170 * @brief AF 7 selection 171 */ 172 #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ 173 #if defined(USART2) 174 #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ 175 #endif /* USART2 */ 176 #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ 177 #if defined(USART6) 178 #define GPIO_AF7_USART6 ((uint8_t)0x07) /* USART6 Alternate Function mapping */ 179 #endif /* USART6 */ 180 #if defined(LTDC) 181 #define GPIO_AF7_LTDC ((uint8_t)0x07) /* LTDC Alternate Function mapping */ 182 #endif /* LTDC */ 183 184 /** 185 * @brief AF 8 selection 186 */ 187 #define GPIO_AF8_LPUART1 ((uint8_t)0x08) /* LPUART1 Alternate Function mapping */ 188 #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ 189 #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ 190 #define GPIO_AF8_SDMMC1 ((uint8_t)0x08) /* SDMMC1 Alternate Function mapping */ 191 #if defined(SDMMC2) 192 #define GPIO_AF8_SDMMC2 ((uint8_t)0x08) /* SDMMC2 Alternate Function mapping */ 193 #endif /* SDMMC2 */ 194 #if defined(LTDC) 195 #define GPIO_AF8_LTDC ((uint8_t)0x08) /* LTDC Alternate Function mapping */ 196 #endif /* LTDC */ 197 #if defined(HSPI1) 198 #define GPIO_AF8_HSPI1 ((uint8_t)0x08) /* HSPI1 Alternate Function mapping */ 199 #endif /* HSPI1 */ 200 201 /** 202 * @brief AF 9 selection 203 */ 204 #define GPIO_AF9_FDCAN1 ((uint8_t)0x09) /* FDCAN1 Alternate Function mapping */ 205 #define GPIO_AF9_TSC ((uint8_t)0x09) /* TSC Alternate Function mapping */ 206 207 /** 208 * @brief AF 10 selection 209 */ 210 #define GPIO_AF10_DCMI ((uint8_t)0x0A) /* DCMI Alternate Function mapping */ 211 #define GPIO_AF10_PSSI ((uint8_t)0x0A) /* PSSI Alternate Function mapping */ 212 #define GPIO_AF10_USB ((uint8_t)0x0A) /* USB Alternate Function mapping */ 213 #define GPIO_AF10_OCTOSPI1 ((uint8_t)0x0A) /* OCTOSPI1 Alternate Function mapping */ 214 #if defined(OCTOSPI2) 215 #define GPIO_AF10_OCTOSPI2 ((uint8_t)0x0A) /* OCTOSPI2 Alternate Function mapping */ 216 #endif /* OCTOSPI2 */ 217 #define GPIO_AF10_CRS ((uint8_t)0x0A) /* CRS Alternate Function mapping */ 218 #if defined(USB_OTG_HS) 219 #define GPIO_AF10_USB_HS ((uint8_t)0x0A) /* USB_HS Alternate Function mapping */ 220 #endif /* USB_OTG_HS */ 221 #if defined(DSI) 222 #define GPIO_AF10_DSI ((uint8_t)0x0A) /* DSI Alternate Function mapping */ 223 #endif /* DSI */ 224 #if defined(GFXTIM) 225 #define GPIO_AF10_GFXTIM ((uint8_t)0x0A) /* GFXTIM Alternate Function mapping */ 226 #endif /* GFXTIM */ 227 228 /** 229 * @brief AF 11 selection 230 */ 231 #if defined(UCPD1) 232 #define GPIO_AF11_UCPD1 ((uint8_t)0x0B) /* UCPD1 Alternate Function mapping */ 233 #endif /* UCPD1 */ 234 #if defined(SDMMC2) 235 #define GPIO_AF11_SDMMC2 ((uint8_t)0x0B) /* SDMMC2 Alternate Function mapping */ 236 #endif /* SDMMC2 */ 237 #define GPIO_AF11_LPGPIO1 ((uint8_t)0x0B) /* LPGPIO1 Alternate Function mapping */ 238 #if defined(FMC_BASE) 239 #define GPIO_AF11_FMC ((uint8_t)0x0B) /* FMC Alternate Function mapping */ 240 #endif /* FMC_BASE */ 241 #if defined(DSI) 242 #define GPIO_AF11_DSI ((uint8_t)0x0B) /* DSI Alternate Function mapping */ 243 #endif /* DSI */ 244 #if defined(GFXTIM) 245 #define GPIO_AF11_GFXTIM ((uint8_t)0x0B) /* GFXTIM Alternate Function mapping */ 246 #endif /* GFXTIM */ 247 248 /** 249 * @brief AF 12 selection 250 */ 251 #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */ 252 #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */ 253 #if defined(FMC_BASE) 254 #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */ 255 #endif /* FMC_BASE */ 256 #define GPIO_AF12_TIM1_COMP1 ((uint8_t)0x0C) /* TIM1/COMP1 Break in Alternate Function mapping */ 257 #define GPIO_AF12_TIM1_COMP2 ((uint8_t)0x0C) /* TIM1/COMP2 Break in Alternate Function mapping */ 258 #define GPIO_AF12_TIM8_COMP2 ((uint8_t)0x0C) /* TIM8/COMP2 Break in Alternate Function mapping */ 259 #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */ 260 #if defined(SDMMC2) 261 #define GPIO_AF12_SDMMC2 ((uint8_t)0x0C) /* SDMMC2 Alternate Function mapping */ 262 #endif /* SDMMC2 */ 263 264 /** 265 * @brief AF 13 selection 266 */ 267 #define GPIO_AF13_SAI1 ((uint8_t)0x0D) /* SAI1 Alternate Function mapping */ 268 #if defined(SAI2) 269 #define GPIO_AF13_SAI2 ((uint8_t)0x0D) /* SAI2 Alternate Function mapping */ 270 #endif /* SAI2 */ 271 #define GPIO_AF13_LPTIM4 ((uint8_t)0x0D) /* LPTIM4 Alternate Function mapping */ 272 #define GPIO_AF13_LPTIM2 ((uint8_t)0x0D) /* LPTIM2 Alternate Function mapping */ 273 #if defined(GFXTIM) 274 #define GPIO_AF13_GFXTIM ((uint8_t)0x0D) /* GFXTIM Alternate Function mapping */ 275 #endif /* GFXTIM */ 276 277 /** 278 * @brief AF 14 selection 279 */ 280 #define GPIO_AF14_LPTIM2 ((uint8_t)0x0E) /* LPTIM2 Alternate Function mapping */ 281 #define GPIO_AF14_LPTIM3 ((uint8_t)0x0E) /* LPTIM3 Alternate Function mapping */ 282 #define GPIO_AF14_TIM2 ((uint8_t)0x0E) /* TIM2 Alternate Function mapping */ 283 #define GPIO_AF14_TIM15 ((uint8_t)0x0E) /* TIM15 Alternate Function mapping */ 284 #define GPIO_AF14_TIM15_COMP1 ((uint8_t)0x0E) /* TIM15/COMP1 Alternate Function mapping */ 285 #define GPIO_AF14_TIM16 ((uint8_t)0x0E) /* TIM16 Alternate Function mapping */ 286 #define GPIO_AF14_TIM16_COMP1 ((uint8_t)0x0E) /* TIM16/COMP1 Alternate Function mapping */ 287 #define GPIO_AF14_TIM17 ((uint8_t)0x0E) /* TIM17 Alternate Function mapping */ 288 #define GPIO_AF14_TIM17_COMP1 ((uint8_t)0x0E) /* TIM17/COMP1 Alternate Function mapping */ 289 #if defined(FMC_BASE) 290 #define GPIO_AF14_FMC ((uint8_t)0x0E) /* FMC Alternate Function mapping */ 291 #endif /* FMC_BASE */ 292 293 /** 294 * @brief AF 15 selection 295 */ 296 #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ 297 298 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) 299 300 /** 301 * @} 302 */ 303 304 /** 305 * @} 306 */ 307 308 /* Exported macro ------------------------------------------------------------*/ 309 /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros 310 * @{ 311 */ 312 313 /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index 314 * @{ 315 */ 316 317 /* GPIO_Peripheral_Memory_Mapping Peripheral Memory Mapping */ 318 #define GPIO_GET_INDEX(__GPIOx__) (((uint32_t )(__GPIOx__) & (~GPIOA_BASE)) >> 10) 319 320 /** 321 * @} 322 */ 323 324 /** 325 * @} 326 */ 327 328 /* Exported functions --------------------------------------------------------*/ 329 330 /** 331 * @} 332 */ 333 334 /** 335 * @} 336 */ 337 338 #ifdef __cplusplus 339 } 340 #endif 341 342 #endif /* STM32U5xx_HAL_GPIO_EX_H */ 343