1 /** 2 ****************************************************************************** 3 * @file stm32l0xx_hal_gpio_ex.h 4 * @author MCD Application Team 5 * @brief Header file of GPIO HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2016 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 __STM32L0xx_HAL_GPIO_EX_H 21 #define __STM32L0xx_HAL_GPIO_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l0xx_hal_def.h" 29 30 /** @addtogroup STM32L0xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup GPIOEx GPIOEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 40 /* Exported constants --------------------------------------------------------*/ 41 42 /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants 43 * @{ 44 */ 45 46 47 /*----------------------------------------------------------------------------*/ 48 /*------------------------- STM32L083xx/STM32L073xx---------------------------*/ 49 /*----------------------------------------------------------------------------*/ 50 51 #if defined (STM32L083xx) || defined (STM32L073xx) 52 53 /* The table below gives an overview of the different alternate functions per port. 54 * For more details refer yourself to the product data sheet. 55 * 56 */ 57 58 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 59 *______________________________________________________________________________ 60 * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR |USART4 |COMP1 | 61 * PA1 |EVENTOUT|LCD |TIM2_C2 |TSC |USART2 |TIM21_TR|USART4 | | 62 * PA2 |TIM21_C1|LCD |TIM2_C3 |TSC |USART2 | |LPUART1 |COMP2 | 63 * PA3 |TIM21_C2|LCD |TIM2_C4 |TSC |USART2 | |LPUART1 | | 64 * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | | 65 * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | | 66 * PA6 |SPI1 |LCD |TIM3_C1 |TSC |LPUART1 |TIM22_C1|EVENTOUT|COMP1 | 67 * PA7 |SPI1 |LCD |TIM3_C2 |TSC | |TIM22_C2|EVENTOUT|COMP2 | 68 * PA8 |MCO |LCD |USB |EVENTOUT|USART1 | | |I2C3 | 69 * PA9 |MCO |LCD | |TSC |USART1 | |I2C1 |I2C3 | 70 * PA10| |LCD | |TSC |USART1 | |I2C1 | | 71 * PA11|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP1 | 72 * PA12|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP2 | 73 * PA13|SWDIO | |USB | | | |LPUART1 | | 74 * PA14|SWCLK | | | |USART2 | |LPUART1 | | 75 * PA15|SPI1 |LCD |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 |USART4 | | 76 *______________________________________________________________________________ 77 * PB0 |EVENTOUT|LCD |TIM3_C3 |TSC | | | | | 78 * PB1 | |LCD |TIM3_C4 |TSC |LPUART1 | | | | 79 * PB2 | | |LPTIM1_O|TSC | | | |I2C3 | 80 * PB3 |SPI1 |LCD |TIM2_C2 |TSC |EVENTOUT|USART1 |USART5 | | 81 * PB4 |SPI1 |LCD |TIM3_C1 |TSC |TIM22_C1|USART1 |USART5 |I2C3 | 82 * PB5 |SPI1 |LCD |LPTIM1_I|I2C1 |TIM3_C2 |USART1 |USART5 | | 83 * | | | | |TIM22_C2| | | | 84 * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | | 85 * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | |USART4 | | 86 * PB8 | |LCD | |TSC |I2C1 | | | | 87 * PB9 | |LCD |EVENTOUT| |I2C1 |SPI2 | | | 88 * PB10| |LCD |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 |LPUART1 | 89 * PB11|EVENTOUT|LCD |TIM2_C4 |TSC |LPUART1 | |I2C2 |LPUART1 | 90 * PB12|SPI2 |LCD |LPUART1 |TSC | |I2C2 |EVENTOUT| | 91 * PB13|SPI2 |LCD |MCO |TSC |LPUART1 |I2C2 |TIM21_C1| | 92 * PB14|SPI2 |LCD |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| | 93 * PB15|SPI2 |LCD |RTC | | | | | | 94 *______________________________________________________________________________ 95 * PC0 |LPTIM1_I|LCD |EVENTOUT|TSC | | |LPUART1 |I2C3 | 96 * PC1 |LPTIM1_O|LCD |EVENTOUT|TSC | | |LPUART1 |I2C3 | 97 * PC2 |LPTIM1_I|LCD |SPI2 |TSC | | | | | 98 * PC3 |LPTIM1_T|LCD |SPI2 |TSC | | | | | 99 * PC4 |EVENTOUT|LCD |LPUART1 | | | | | | 100 * PC5 | |LCD |LPUART1 |TSC | | | | | 101 * PC6 |TIM22_C1|LCD |TIM3_C1 |TSC | | | | | 102 * PC7 |TIM22_C2|LCD |TIM3_C2 |TSC | | | | | 103 * PC8 |TIM22_TR|LCD |TIM3_C3 |TSC | | | | | 104 * PC9 |TIM21_TR|LCD |USB |TSC | | | |I2C3 | 105 * | | |TIM3_C4 | | | | | | 106 * PC10|LPUART1 |LCD | | | | |USART4 | | 107 * PC11|LPUART1 |LCD | | | | |USART4 | | 108 * PC12| |LCD |USART5 | | | |USART4 | | 109 * PC13| | | | | | | | | 110 * PC14| | | | | | | | | 111 * PC15| | | | | | | | | 112 *______________________________________________________________________________ 113 * PD0 |TIM21_C1|SPI2 | | | | | | | 114 * PD1 | |SPI2 | | | | | | | 115 * PD2 |LPUART1 |LCD |TIM3_TR | | | |USART5 | | 116 * PD3 |USART2 |LCD |SPI2 | | | | | | 117 * PD4 |USART2 |SPI2 | | | | | | | 118 * PD5 |USART2 | | | | | | | | 119 * PD6 |USART2 | | | | | | | | 120 * PD7 |USART2 |TIM21_C2| | | | | | | 121 * PD8 |LPUART1 |LCD | | | | | | | 122 * PD9 |LPUART1 |LCD | | | | | | | 123 * PD10| |LCD | | | | | | | 124 * PD11|LPUART1 |LCD | | | | | | | 125 * PD12|LPUART1 |LCD | | | | | | | 126 * PD13| |LCD | | | | | | | 127 * PD14| |LCD | | | | | | | 128 * PD15|USB |LCD | | | | | | | 129 *______________________________________________________________________________ 130 * PE0 | |LCD |EVENTOUT| | | | | | 131 * PE1 | |LCD |EVENTOUT| | | | | | 132 * PE2 | |LCD |TIM3_TR | | | | | | 133 * PE3 |TIM22_C1|LCD |TIM3_C1 | | | | | | 134 * PE4 |TIM22_C2| |TIM3_C2 | | | | | | 135 * PE5 |TIM21_C1| |TIM3_C3 | | | | | | 136 * PE6 |TIM21_C2| |TIM3_C4 | | | | | | 137 * PE7 | |LCD | | | | |USART5 | | 138 * PE8 | |LCD | | | | |USART4 | | 139 * PE9 |TIM2_C1 |LCD |TIM2_TR | | | |USART4 | | 140 * PE10|TIM2_C2 |LCD | | | | |USART5 | | 141 * PE11|TIM2_C3 | | | | | |USART5 | | 142 * PE12|TIM2_C4 | |SPI1 | | | | | | 143 * PE13| |LCD |SPI1 | | | | | | 144 * PE14| |LCD |SPI1 | | | | | | 145 * PE15| |LCD |SPI1 | | | | | | 146 *______________________________________________________________________________ 147 * PH0 |USB | | | | | | | | 148 * PH1 | | | | | | | | | 149 * PH9 | | | | | | | | | 150 * PH10| | | | | | | | | 151 * 152 */ 153 154 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 155 * @{ 156 */ 157 158 /* 159 * Alternate function AF0 160 */ 161 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 162 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 163 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 164 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 165 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 166 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 167 #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */ 168 #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */ 169 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 170 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 171 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 172 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 173 #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */ 174 #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */ 175 /** 176 * 177 */ 178 179 /* 180 * Alternate function AF1 181 */ 182 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 183 #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */ 184 #define GPIO_AF1_TIM21 ((uint8_t)0x01U) /* TIM21 Alternate Function mapping */ 185 #define GPIO_AF1_LCD ((uint8_t)0x01U) /* LCD Alternate Function mapping */ 186 /** 187 * 188 */ 189 190 /* 191 * Alternate function AF2 192 */ 193 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 194 #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ 195 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 196 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 197 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 198 #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */ 199 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 200 #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */ 201 #define GPIO_AF2_USART5 ((uint8_t)0x02U) /* USART5 Alternate Function mapping */ 202 #define GPIO_AF2_SPI1 ((uint8_t)0x02U) /* SPI1 Alternate Function mapping */ 203 #define GPIO_AF2_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */ 204 /** 205 * 206 */ 207 208 /* 209 * Alternate function AF3 210 */ 211 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 212 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 213 #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */ 214 /** 215 * 216 */ 217 218 /* 219 * Alternate function AF4 220 */ 221 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 222 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 223 #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */ 224 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping*/ 225 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 226 #define GPIO_AF4_TIM3 ((uint8_t)0x04U) /* TIM3 Alternate Function mapping */ 227 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 228 /** 229 * 230 */ 231 232 /* 233 * Alternate function AF5 234 */ 235 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 236 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 237 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 238 #define GPIO_AF5_USART1 ((uint8_t)0x05U) /* USART1 Alternate Function mapping */ 239 #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */ 240 #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */ 241 /** 242 * 243 */ 244 245 /* 246 * Alternate function AF6 247 */ 248 249 #define GPIO_AF6_USART4 ((uint8_t)0x06U) /* USART4 Alternate Function mapping */ 250 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 251 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 252 #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */ 253 #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */ 254 #define GPIO_AF6_USART5 ((uint8_t)0x06U) /* USART5 Alternate Function mapping */ 255 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 256 /** 257 * 258 */ 259 260 /* 261 * Alternate function AF7 262 */ 263 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 264 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 265 #define GPIO_AF7_I2C3 ((uint8_t)0x07U) /* I2C3 Alternate Function mapping */ 266 #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */ 267 /** 268 * 269 */ 270 271 /** 272 * @} 273 */ 274 275 /** 276 * @} 277 */ 278 279 /** @defgroup GPIOEx_Private GPIOEx Private 280 * @{ 281 */ 282 /** 283 * IS_GPIO_AF macro definition 284 */ 285 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 286 287 /** 288 * @} 289 */ 290 #endif /* (STM32L083xx) || (STM32L073xx) */ 291 292 /*----------------------------------------------------------------------------*/ 293 /*------------------------- STM32L082xx and STM32L072xx-----------------------*/ 294 /*----------------------------------------------------------------------------*/ 295 #if defined (STM32L082xx) || defined (STM32L072xx) 296 297 /* The table below gives an overview of the different alternate functions per port. 298 * For more details refer yourself to the product data sheet. 299 */ 300 301 302 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 303 *______________________________________________________________________________ 304 * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR |USART4 |COMP1 | 305 * PA1 |EVENTOUT| |TIM2_C2 |TSC |USART2 |TIM21_TR|USART4 | | 306 * PA2 |TIM21_C1| |TIM2_C3 |TSC |USART2 | |LPUART1 |COMP2 | 307 * PA3 |TIM21_C2| |TIM2_C4 |TSC |USART2 | |LPUART1 | | 308 * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | | 309 * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | | 310 * PA6 |SPI1 | |TIM3_C1 |TSC |LPUART1 |TIM22_C1|EVENTOUT|COMP1 | 311 * PA7 |SPI1 | |TIM3_C2 |TSC | |TIM22_C2|EVENTOUT|COMP2 | 312 * PA8 |MCO | |USB |EVENTOUT|USART1 | | |I2C3 | 313 * PA9 |MCO | | |TSC |USART1 | |I2C1 |I2C3 | 314 * PA10| | | |TSC |USART1 | |I2C1 | | 315 * PA11|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP1 | 316 * PA12|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP2 | 317 * PA13|SWDIO | |USB | | | |LPUART1 | | 318 * PA14|SWCLK | | | |USART2 | |LPUART1 | | 319 * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 |USART4 | | 320 *______________________________________________________________________________ 321 * PB0 |EVENTOUT| |TIM3_C3 |TSC | | | | | 322 * PB1 | | |TIM3_C4 |TSC |LPUART1 | | | | 323 * PB2 | | |LPTIM1_O|TSC | | | |I2C3 | 324 * PB3 |SPI1 | |TIM2_C2 |TSC |EVENTOUT|USART1 |USART5 | | 325 * PB4 |SPI1 | |TIM3_C1 |TSC |TIM22_C1|USART1 |USART5 |I2C3 | 326 * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM3_C2 |USART1 |USART5 | | 327 * | | | | |TIM22_C2| | | | 328 * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | | 329 * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | |USART4 | | 330 * PB8 | | | |TSC |I2C1 | | | | 331 * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | | 332 * PB10| | |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 |LPUART1 | 333 * PB11|EVENTOUT| |TIM2_C4 |TSC |LPUART1 | |I2C2 |LPUART1 | 334 * PB12|SPI2 | |LPUART1 |TSC | |I2C2 |EVENTOUT| | 335 * PB13|SPI2 | |MCO |TSC |LPUART1 |I2C2 |TIM21_C1| | 336 * PB14|SPI2 | |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| | 337 * PB15|SPI2 | |RTC | | | | | | 338 *______________________________________________________________________________ 339 * PC0 |LPTIM1_I| |EVENTOUT|TSC | | |LPUART1 |I2C3 | 340 * PC1 |LPTIM1_O| |EVENTOUT|TSC | | |LPUART1 |I2C3 | 341 * PC2 |LPTIM1_I| |SPI2 |TSC | | | | | 342 * PC3 |LPTIM1_T| |SPI2 |TSC | | | | | 343 * PC4 |EVENTOUT| |LPUART1 | | | | | | 344 * PC5 | | |LPUART1 |TSC | | | | | 345 * PC6 |TIM22_C1| |TIM3_C1 |TSC | | | | | 346 * PC7 |TIM22_C2| |TIM3_C2 |TSC | | | | | 347 * PC8 |TIM22_TR| |TIM3_C3 |TSC | | | | | 348 * PC9 |TIM21_TR| |USB |TSC | | | |I2C3 | 349 * | | |TIM3_C4 | | | | | | 350 * PC10|LPUART1 | | | | | |USART4 | | 351 * PC11|LPUART1 | | | | | |USART4 | | 352 * PC12| | |USART5 | | | |USART4 | | 353 * PC13| | | | | | | | | 354 * PC14| | | | | | | | | 355 * PC15| | | | | | | | | 356 *______________________________________________________________________________ 357 * PD0 |TIM21_C1|SPI2 | | | | | | | 358 * PD1 | |SPI2 | | | | | | | 359 * PD2 |LPUART1 | |TIM3_TR | | | |USART5 | | 360 * PD3 |USART2 | |SPI2 | | | | | | 361 * PD4 |USART2 |SPI2 | | | | | | | 362 * PD5 |USART2 | | | | | | | | 363 * PD6 |USART2 | | | | | | | | 364 * PD7 |USART2 |TIM21_C2| | | | | | | 365 * PD8 |LPUART1 | | | | | | | | 366 * PD9 |LPUART1 | | | | | | | | 367 * PD10| | | | | | | | | 368 * PD11|LPUART1 | | | | | | | | 369 * PD12|LPUART1 | | | | | | | | 370 * PD13| | | | | | | | | 371 * PD14| | | | | | | | | 372 * PD15|USB | | | | | | | | 373 *______________________________________________________________________________ 374 * PE0 | | |EVENTOUT| | | | | | 375 * PE1 | | |EVENTOUT| | | | | | 376 * PE2 | | |TIM3_TR | | | | | | 377 * PE3 |TIM22_C1| |TIM3_C1 | | | | | | 378 * PE4 |TIM22_C2| |TIM3_C2 | | | | | | 379 * PE5 |TIM21_C1| |TIM3_C3 | | | | | | 380 * PE6 |TIM21_C2| |TIM3_C4 | | | | | | 381 * PE7 | | | | | | |USART5 | | 382 * PE8 | | | | | | |USART4 | | 383 * PE9 |TIM2_C1 | |TIM2_TR | | | |USART4 | | 384 * PE10|TIM2_C2 | | | | | |USART5 | | 385 * PE11|TIM2_C3 | | | | | |USART5 | | 386 * PE12|TIM2_C4 | |SPI1 | | | | | | 387 * PE13| | |SPI1 | | | | | | 388 * PE14| | |SPI1 | | | | | | 389 * PE15| | |SPI1 | | | | | | 390 *______________________________________________________________________________ 391 * PH0 |USB | | | | | | | | 392 * PH1 | | | | | | | | | 393 * PH9 | | | | | | | | | 394 * PH10| | | | | | | | | 395 * 396 */ 397 398 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 399 * @{ 400 */ 401 402 /* 403 * Alternate function AF0 404 */ 405 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 406 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 407 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 408 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 409 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 410 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 411 #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */ 412 #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */ 413 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 414 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 415 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 416 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 417 #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */ 418 #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */ 419 /** 420 * 421 */ 422 423 /* 424 * Alternate function AF1 425 */ 426 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 427 #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */ 428 #define GPIO_AF1_TIM21 ((uint8_t)0x01U) /* TIM21 Alternate Function mapping */ 429 /** 430 * 431 */ 432 433 /* 434 * Alternate function AF2 435 */ 436 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 437 #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ 438 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 439 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 440 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 441 #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */ 442 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 443 #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */ 444 #define GPIO_AF2_USART5 ((uint8_t)0x02U) /* USART5 Alternate Function mapping */ 445 #define GPIO_AF2_SPI1 ((uint8_t)0x02U) /* SPI1 Alternate Function mapping */ 446 #define GPIO_AF2_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */ 447 /** 448 * 449 */ 450 451 /* 452 * Alternate function AF3 453 */ 454 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 455 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 456 #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */ 457 /** 458 * 459 */ 460 461 /* 462 * Alternate function AF4 463 */ 464 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 465 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 466 #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */ 467 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 468 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 469 #define GPIO_AF4_TIM3 ((uint8_t)0x04U) /* TIM3 Alternate Function mapping */ 470 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 471 /** 472 * 473 */ 474 475 /* 476 * Alternate function AF5 477 */ 478 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 479 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 480 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 481 #define GPIO_AF5_USART1 ((uint8_t)0x05U) /* USART1 Alternate Function mapping */ 482 #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */ 483 #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */ 484 /** 485 * 486 */ 487 488 /* 489 * Alternate function AF6 490 */ 491 #define GPIO_AF6_USART4 ((uint8_t)0x06U) /* USART4 Alternate Function mapping */ 492 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 493 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 494 #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */ 495 #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */ 496 #define GPIO_AF6_USART5 ((uint8_t)0x06U) /* USART5 Alternate Function mapping */ 497 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 498 /** 499 * 500 */ 501 502 /* 503 * Alternate function AF7 504 */ 505 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 506 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 507 #define GPIO_AF7_I2C3 ((uint8_t)0x07U) /* I2C3 Alternate Function mapping */ 508 #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */ 509 /** 510 * 511 */ 512 513 /** 514 * @} 515 */ 516 517 /** 518 * @} 519 */ 520 521 /** @defgroup GPIOEx_Private GPIOEx Private 522 * @{ 523 */ 524 /** 525 * @brief IS_GPIO_AF macro definition 526 */ 527 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 528 529 /** 530 * @} 531 */ 532 #endif /* (STM32L082xx) || (STM32L072xx) */ 533 534 535 /*----------------------------------------------------------------------------*/ 536 /*------------------------- STM32L081xx and STM32L071xx-----------------------*/ 537 /*----------------------------------------------------------------------------*/ 538 #if defined (STM32L081xx) || defined (STM32L071xx) 539 540 /* The table below gives an overview of the different alternate functions per port. 541 * For more details refer yourself to the product data sheet. 542 * 543 */ 544 545 546 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 547 *______________________________________________________________________________ 548 * PA0 | | |TIM2_C1 | |USART2 |TIM2_TR |USART4 |COMP1 | 549 * PA1 |EVENTOUT| |TIM2_C2 | |USART2 |TIM21_TR|USART4 | | 550 * PA2 |TIM21_C1| |TIM2_C3 | |USART2 | |LPUART1 |COMP2 | 551 * PA3 |TIM21_C2| |TIM2_C4 | |USART2 | |LPUART1 | | 552 * PA4 |SPI1 | | | |USART2 |TIM22_TR| | | 553 * PA5 |SPI1 | |TIM2_TR | | |TIM2_C1 | | | 554 * PA6 |SPI1 | |TIM3_C1 | |LPUART1 |TIM22_C1|EVENTOUT|COMP1 | 555 * PA7 |SPI1 | |TIM3_C2 | | |TIM22_C2|EVENTOUT|COMP2 | 556 * PA8 |MCO | | |EVENTOUT|USART1 | | |I2C3 | 557 * PA9 |MCO | | | |USART1 | |I2C1 |I2C3 | 558 * PA10| | | | |USART1 | |I2C1 | | 559 * PA11|SPI1 | |EVENTOUT| |USART1 | |I2C2 |COMP1 | 560 * PA12|SPI1 | |EVENTOUT| |USART1 | |I2C2 |COMP2 | 561 * PA13|SWDIO | | | | | |LPUART1 | | 562 * PA14|SWCLK | | | |USART2 | |LPUART1 | | 563 * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 |USART4 | | 564 *______________________________________________________________________________ 565 * PB0 |EVENTOUT| |TIM3_C3 | | | | | | 566 * PB1 | | |TIM3_C4 | |LPUART1 | | | | 567 * PB2 | | |LPTIM1_O| | | | |I2C3 | 568 * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT|USART1 |USART5 | | 569 * PB4 |SPI1 | |TIM3_C1 | |TIM22_C1|USART1 |USART5 |I2C3 | 570 * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM3_C2 |USART1 |USART5 | | 571 * | | | | |TIM22_C2| | | | 572 * PB6 |USART1 |I2C1 |LPTIM1_T| | | | | | 573 * PB7 |USART1 |I2C1 |LPTIM1_I| | | |USART4 | | 574 * PB8 | | | | |I2C1 | | | | 575 * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | | 576 * PB10| | |TIM2_C3 | |LPUART1 |SPI2 |I2C2 |LPUART1 | 577 * PB11|EVENTOUT| |TIM2_C4 | |LPUART1 | |I2C2 |LPUART1 | 578 * PB12|SPI2 | |LPUART1 | | |I2C2 |EVENTOUT| | 579 * PB13|SPI2 | |MCO | |LPUART1 |I2C2 |TIM21_C1| | 580 * PB14|SPI2 | |RTC | |LPUART1 |I2C2 |TIM21_C2| | 581 * PB15|SPI2 | |RTC | | | | | | 582 *______________________________________________________________________________ 583 * PC0 |LPTIM1_I| |EVENTOUT| | | |LPUART1 |I2C3 | 584 * PC1 |LPTIM1_O| |EVENTOUT| | | |LPUART1 |I2C3 | 585 * PC2 |LPTIM1_I| |SPI2 | | | | | | 586 * PC3 |LPTIM1_T| |SPI2 | | | | | | 587 * PC4 |EVENTOUT| |LPUART1 | | | | | | 588 * PC5 | | |LPUART1 | | | | | | 589 * PC6 |TIM22_C1| |TIM3_C1 | | | | | | 590 * PC7 |TIM22_C2| |TIM3_C2 | | | | | | 591 * PC8 |TIM22_TR| |TIM3_C3 | | | | | | 592 * PC9 |TIM21_TR| | | | | | |I2C3 | 593 * | | |TIM3_C4 | | | | | | 594 * PC10|LPUART1 | | | | | |USART4 | | 595 * PC11|LPUART1 | | | | | |USART4 | | 596 * PC12| | |USART5 | | | |USART4 | | 597 * PC13| | | | | | | | | 598 * PC14| | | | | | | | | 599 * PC15| | | | | | | | | 600 *______________________________________________________________________________ 601 * PD0 |TIM21_C1|SPI2 | | | | | | | 602 * PD1 | |SPI2 | | | | | | | 603 * PD2 |LPUART1 | |TIM3_TR | | | |USART5 | | 604 * PD3 |USART2 | |SPI2 | | | | | | 605 * PD4 |USART2 |SPI2 | | | | | | | 606 * PD5 |USART2 | | | | | | | | 607 * PD6 |USART2 | | | | | | | | 608 * PD7 |USART2 |TIM21_C2| | | | | | | 609 * PD8 |LPUART1 | | | | | | | | 610 * PD9 |LPUART1 | | | | | | | | 611 * PD10| | | | | | | | | 612 * PD11|LPUART1 | | | | | | | | 613 * PD12|LPUART1 | | | | | | | | 614 * PD13| | | | | | | | | 615 * PD14| | | | | | | | | 616 * PD15| | | | | | | | | 617 *______________________________________________________________________________ 618 * PE0 | | |EVENTOUT| | | | | | 619 * PE1 | | |EVENTOUT| | | | | | 620 * PE2 | | |TIM3_TR | | | | | | 621 * PE3 |TIM22_C1| |TIM3_C1 | | | | | | 622 * PE4 |TIM22_C2| |TIM3_C2 | | | | | | 623 * PE5 |TIM21_C1| |TIM3_C3 | | | | | | 624 * PE6 |TIM21_C2| |TIM3_C4 | | | | | | 625 * PE7 | | | | | | |USART5 | | 626 * PE8 | | | | | | |USART4 | | 627 * PE9 |TIM2_C1 | |TIM2_TR | | | |USART4 | | 628 * PE10|TIM2_C2 | | | | | |USART5 | | 629 * PE11|TIM2_C3 | | | | | |USART5 | | 630 * PE12|TIM2_C4 | |SPI1 | | | | | | 631 * PE13| | |SPI1 | | | | | | 632 * PE14| | |SPI1 | | | | | | 633 * PE15| | |SPI1 | | | | | | 634 *______________________________________________________________________________ 635 * PH0 | | | | | | | | | 636 * PH1 | | | | | | | | | 637 * PH9 | | | | | | | | | 638 * PH10| | | | | | | | | 639 * 640 */ 641 642 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 643 * @{ 644 */ 645 646 /* 647 * Alternate function AF0 648 * 649 */ 650 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 651 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 652 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 653 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 654 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 655 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 656 #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */ 657 #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */ 658 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 659 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 660 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 661 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 662 #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */ 663 /** 664 * 665 */ 666 667 /* 668 * Alternate function AF1 669 * 670 */ 671 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 672 #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */ 673 #define GPIO_AF1_TIM21 ((uint8_t)0x01U) /* TIM21 Alternate Function mapping */ 674 /** 675 * 676 */ 677 678 /* 679 * Alternate function AF2 680 * 681 */ 682 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 683 #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ 684 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 685 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 686 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 687 #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */ 688 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 689 #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */ 690 #define GPIO_AF2_USART5 ((uint8_t)0x02U) /* USART5 Alternate Function mapping */ 691 #define GPIO_AF2_SPI1 ((uint8_t)0x02U) /* SPI1 Alternate Function mapping */ 692 /** 693 * 694 */ 695 696 /* 697 * Alternate function AF3 698 * @{ 699 */ 700 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 701 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 702 /** 703 * 704 */ 705 706 /* 707 * Alternate function AF4 708 * 709 */ 710 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 711 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 712 #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */ 713 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 714 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 715 #define GPIO_AF4_TIM3 ((uint8_t)0x04U) /* TIM3 Alternate Function mapping */ 716 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 717 /** 718 * 719 */ 720 721 /* 722 * Alternate function AF5 723 * 724 */ 725 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 726 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 727 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 728 #define GPIO_AF5_USART1 ((uint8_t)0x05U) /* USART1 Alternate Function mapping */ 729 #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */ 730 #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */ 731 /** 732 * 733 */ 734 735 /* 736 * Alternate function AF6 737 * 738 */ 739 #define GPIO_AF6_USART4 ((uint8_t)0x06U) /* USART4 Alternate Function mapping */ 740 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 741 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 742 #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */ 743 #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */ 744 #define GPIO_AF6_USART5 ((uint8_t)0x06U) /* USART5 Alternate Function mapping */ 745 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 746 /** 747 * 748 */ 749 750 /* 751 * Alternate function AF7 752 * 753 */ 754 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 755 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 756 #define GPIO_AF7_I2C3 ((uint8_t)0x07U) /* I2C3 Alternate Function mapping */ 757 #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */ 758 /** 759 * 760 */ 761 762 /** 763 * @} 764 */ 765 766 /** 767 * @} 768 */ 769 770 /** @defgroup GPIOEx_Private GPIOEx Private 771 * @{ 772 */ 773 774 /** 775 * IS_GPIO_AF macro definition 776 */ 777 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 778 779 /** 780 * @} 781 */ 782 #endif /* (STM32L081xx) || (STM32L071xx) */ 783 784 /*----------------------------------------------------------------------------*/ 785 /*------------------------- STM32L053xx/STM32L063xx---------------------------*/ 786 /*----------------------------------------------------------------------------*/ 787 #if defined (STM32L053xx) || defined (STM32L063xx) 788 789 /* The table below gives an overview of the different alternate functions per port. 790 * For more details refer yourself to the product data sheet. 791 * 792 */ 793 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 794 *______________________________________________________________________________ 795 * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR | |COMP1 | 796 * PA1 |EVENTOUT|LCD |TIM2_C2 |TSC |USART2 |TIM21_TR| | | 797 * PA2 |TIM21_C1|LCD |TIM2_C3 |TSC |USART2 | | |COMP2 | 798 * PA3 |TIM21_C2|LCD |TIM2_C4 |TSC |USART2 | | | | 799 * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | | 800 * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | | 801 * PA6 |SPI1 |LCD | |TSC |LPUART |TIM22_C1|EVENTOUT|COMP1 | 802 * PA7 |SPI1 |LCD | |TSC | |TIM22_C2|EVENTOUT|COMP2 | 803 * PA8 |MCO |LCD |USB |EVENTOUT|USART1 | | | | 804 * PA9 |MCO |LCD | |TSC |USART1 | | | | 805 * PA10| |LCD | |TSC |USART1 | | | | 806 * PA11|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP1 | 807 * PA12|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP2 | 808 * PA13|SWDIO | |USB | | | | | | 809 * PA14|SWCLK | | | |USART2 | | | | 810 * PA15|SPI1 |LCD |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | | 811 *______________________________________________________________________________ 812 * PB0 |EVENTOUT|LCD | |TSC | | | | | 813 * PB1 | |LCD | |TSC |LPUART1 | | | | 814 * PB2 | | |LPTIM1_O|TSC | | | | | 815 * PB3 |SPI1 |LCD |TIM2_C2 |TSC |EVENTOUT| | | | 816 * PB4 |SPI1 |LCD |EVENTOUT|TSC |TIM22_C1| | | | 817 * PB5 |SPI1 |LCD |LPTIM1_I|I2C1 |TIM22_C2| | | | 818 * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | | 819 * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | | | | 820 * PB8 | |LCD | |TSC |I2C1 | | | | 821 * PB9 | |LCD |EVENTOUT| |I2C1 |SPI2 | | | 822 * PB10| |LCD |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 | | 823 * PB11|EVENTOUT|LCD |TIM2_C4 |TSC |LPUART1 | |I2C2 | | 824 * PB12|SPI2 |LCD |LPUART1 |TSC | |I2C2 |EVENTOUT| | 825 * PB13|SPI2 |LCD | |TSC |LPUART1 |I2C2 |TIM21_C1| | 826 * PB14|SPI2 |LCD |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| | 827 * PB15|SPI2 |LCD |RTC | | | | | | 828 *______________________________________________________________________________ 829 * PC0 |LPTIM1_I|LCD |EVENTOUT|TSC | | | | | 830 * PC1 |LPTIM1_O|LCD |EVENTOUT|TSC | | | | | 831 * PC2 |LPTIM1_I|LCD |SPI2 |TSC | | | | | 832 * PC3 |LPTIM1_T|LCD |SPI2 |TSC | | | | | 833 * PC4 |EVENTOUT|LCD |LPUART | | | | | | 834 * PC5 | |LCD |LPUART |TSC | | | | | 835 * PC6 |TIM22_C1|LCD | |TSC | | | | | 836 * PC7 |TIM22_C2|LCD | |TSC | | | | | 837 * PC8 |TIM22_TR|LCD | |TSC | | | | | 838 * PC9 |TIM21_TR|LCD |USB |TSC | | | | | 839 * PC10|LPUART |LCD | | | | | | | 840 * PC11|LPUART |LCD | | | | | | | 841 * PC12| |LCD | | | | | | | 842 * PC13| | | | | | | | | 843 * PC14| | | | | | | | | 844 * PC15| | | | | | | | | 845 *______________________________________________________________________________ 846 * PD2 |LPUART |LCD | | | | | | | 847 *______________________________________________________________________________ 848 * PH0 |USB | | | | | | | | 849 * PH1 | | | | | | | | | 850 * * 851 */ 852 853 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 854 * @{ 855 */ 856 857 /* 858 * Alternate function AF0 859 */ 860 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 861 #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */ 862 #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */ 863 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 864 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 865 #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */ 866 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 867 #define GPIO_AF0_TSC ((uint8_t)0x00U) /* TSC Alternate Function mapping */ 868 #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */ 869 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 870 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 871 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 872 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 873 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 874 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 875 /** 876 * 877 */ 878 879 /* 880 * Alternate function AF1 881 */ 882 #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */ 883 #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */ 884 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 885 #define GPIO_AF1_LCD ((uint8_t)0x01U) /* LCD Alternate Function mapping */ 886 /** 887 * 888 */ 889 890 /* 891 * Alternate function AF2 892 */ 893 #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */ 894 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 895 #define GPIO_AF2_USB ((uint8_t)0x02U) /* USB Alternate Function mapping */ 896 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 897 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 898 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 899 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 900 /** 901 * 902 */ 903 904 /* 905 * Alternate function AF3 906 */ 907 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 908 #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */ 909 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 910 /** 911 * 912 */ 913 914 /* 915 * Alternate function AF4 916 */ 917 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 918 #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */ 919 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 920 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 921 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 922 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 923 /** 924 * 925 */ 926 927 /* 928 * Alternate function AF5 929 */ 930 #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */ 931 #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */ 932 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 933 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 934 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 935 /** 936 * 937 */ 938 939 /* 940 * Alternate function AF6 941 */ 942 #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */ 943 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 944 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 945 /** 946 * 947 */ 948 949 /* 950 * Alternate function AF7 951 */ 952 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 953 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 954 /** 955 * 956 */ 957 958 /** 959 * @} 960 */ 961 962 /** 963 * @} 964 */ 965 966 /** @defgroup GPIOEx_Private GPIOEx Private 967 * @{ 968 */ 969 /** 970 * @brief IS_GPIO_AF macro definition 971 */ 972 973 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 974 975 /** 976 * @} 977 */ 978 979 #endif /* STM32L053xx || STM32L063xx */ 980 /*------------------------------------------------------------------------------------------*/ 981 982 /*----------------------------------------------------------------------------*/ 983 /*------------------------- STM32L052xx/STM32L062xx---------------------------*/ 984 /*----------------------------------------------------------------------------*/ 985 #if defined (STM32L052xx) || defined (STM32L062xx) 986 987 /* The table below gives an overview of the different alternate functions per port. 988 * For more details refer yourself to the product data sheet. 989 * 990 */ 991 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 992 *______________________________________________________________________________ 993 * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR | |COMP1 | 994 * PA1 |EVENTOUT| |TIM2_C2 |TSC |USART2 |TIM21_TR| | | 995 * PA2 |TIM21_C1| |TIM2_C3 |TSC |USART2 | | |COMP2 | 996 * PA3 |TIM21_C2| |TIM2_C4 |TSC |USART2 | | | | 997 * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | | 998 * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | | 999 * PA6 |SPI1 | | |TSC |LPUART |TIM22_C1|EVENTOUT|COMP1 | 1000 * PA7 |SPI1 | | |TSC | |TIM22_C2|EVENTOUT|COMP2 | 1001 * PA8 |MCO | |USB |EVENTOUT|USART1 | | | | 1002 * PA9 |MCO | | |TSC |USART1 | | | | 1003 * PA10| | | |TSC |USART1 | | | | 1004 * PA11|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP1 | 1005 * PA12|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP2 | 1006 * PA13|SWDIO | |USB | | | | | | 1007 * PA14|SWCLK | | | |USART2 | | | | 1008 * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | | 1009 *______________________________________________________________________________ 1010 * PB0 |EVENTOUT| | |TSC | | | | | 1011 * PB1 | | | |TSC |LPUART1 | | | | 1012 * PB2 | | |LPTIM1_O|TSC | | | | | 1013 * PB3 |SPI1 | |TIM2_C2 |TSC |EVENTOUT| | | | 1014 * PB4 |SPI1 | |EVENTOUT|TSC |TIM22_C1| | | | 1015 * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM22_C2| | | | 1016 * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | | 1017 * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | | | | 1018 * PB8 | | | |TSC |I2C1 | | | | 1019 * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | | 1020 * PB10| | |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 | | 1021 * PB11|EVENTOUT| |TIM2_C4 |TSC |LPUART1 | |I2C2 | | 1022 * PB12|SPI2 | |LPUART1 |TSC | |I2C2 |EVENTOUT| | 1023 * PB13|SPI2 | | |TSC |LPUART1 |I2C2 |TIM21_C1| | 1024 * PB14|SPI2 | |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| | 1025 * PB15|SPI2 | |RTC | | | | | | 1026 *______________________________________________________________________________ 1027 * PC0 |LPTIM1_I| |EVENTOUT|TSC | | | | | 1028 * PC1 |LPTIM1_O| |EVENTOUT|TSC | | | | | 1029 * PC2 |LPTIM1_I| |SPI2 |TSC | | | | | 1030 * PC3 |LPTIM1_T| |SPI2 |TSC | | | | | 1031 * PC4 |EVENTOUT| |LPUART | | | | | | 1032 * PC5 | | |LPUART |TSC | | | | | 1033 * PC6 |TIM22_C1| | |TSC | | | | | 1034 * PC7 |TIM22_C2| | |TSC | | | | | 1035 * PC8 |TIM22_TR| | |TSC | | | | | 1036 * PC9 |TIM21_TR| |USB |TSC | | | | | 1037 * PC10|LPUART | | | | | | | | 1038 * PC11|LPUART | | | | | | | | 1039 * PC12| | | | | | | | | 1040 * PC13| | | | | | | | | 1041 * PC14| | | | | | | | | 1042 * PC15| | | | | | | | | 1043 *______________________________________________________________________________ 1044 * PD2 |LPUART | | | | | | | | 1045 *______________________________________________________________________________ 1046 * PH0 |USB | | | | | | | | 1047 * PH1 | | | | | | | | | 1048 * * 1049 */ 1050 1051 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 1052 * @{ 1053 */ 1054 1055 /* 1056 * Alternate function AF0 1057 */ 1058 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 1059 #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */ 1060 #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */ 1061 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 1062 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 1063 #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */ 1064 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 1065 #define GPIO_AF0_TSC ((uint8_t)0x00U) /* TSC Alternate Function mapping */ 1066 #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */ 1067 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 1068 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 1069 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 1070 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 1071 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 1072 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 1073 /** 1074 * 1075 */ 1076 1077 /* 1078 * Alternate function AF1 1079 */ 1080 #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */ 1081 #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */ 1082 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 1083 /** 1084 * 1085 */ 1086 1087 /** 1088 * Alternate function AF2 1089 */ 1090 #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */ 1091 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 1092 #define GPIO_AF2_USB ((uint8_t)0x02U) /* USB Alternate Function mapping */ 1093 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 1094 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 1095 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 1096 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 1097 /** 1098 * 1099 */ 1100 1101 /* 1102 * Alternate function AF3 1103 */ 1104 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 1105 #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */ 1106 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 1107 /** 1108 * 1109 */ 1110 1111 /* 1112 * Alternate function AF4 1113 */ 1114 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 1115 #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */ 1116 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 1117 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 1118 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 1119 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 1120 /** 1121 * 1122 */ 1123 1124 /* 1125 * Alternate function AF5 1126 */ 1127 #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */ 1128 #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */ 1129 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 1130 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 1131 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 1132 /** 1133 * 1134 */ 1135 1136 /* 1137 * Alternate function AF6 1138 */ 1139 #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */ 1140 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 1141 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 1142 /** 1143 * 1144 */ 1145 1146 /* 1147 * Alternate function AF7 1148 */ 1149 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 1150 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 1151 /** 1152 * 1153 */ 1154 1155 /** 1156 * @} 1157 */ 1158 1159 /** 1160 * @} 1161 */ 1162 1163 /** @defgroup GPIOEx_Private GPIOEx Private 1164 * @{ 1165 */ 1166 /** 1167 * @brief IS_GPIO_AF macro definition 1168 */ 1169 1170 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 1171 1172 /** 1173 * @} 1174 */ 1175 #endif /* STM32L052xx || STM32L062xx */ 1176 /*------------------------------------------------------------------------------------------*/ 1177 1178 /*----------------------------------------------------------------------------*/ 1179 /*------------------------------- STM32L051xx---------------------------------*/ 1180 /*----------------------------------------------------------------------------*/ 1181 #if defined (STM32L051xx) 1182 /* The table below gives an overview of the different alternate functions per port. 1183 * For more details refer yourself to the product data sheet. 1184 * 1185 */ 1186 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 1187 *______________________________________________________________________________ 1188 * PA0 | | |TIM2_C1 | |USART2 |TIM2_TR | |COMP1 | 1189 * PA1 |EVENTOUT| |TIM2_C2 | |USART2 |TIM21_TR| | | 1190 * PA2 |TIM21_C1| |TIM2_C3 | |USART2 | | |COMP2 | 1191 * PA3 |TIM21_C2| |TIM2_C4 | |USART2 | | | | 1192 * PA4 |SPI1 | | | |USART2 |TIM22_TR| | | 1193 * PA5 |SPI1 | |TIM2_TR | | |TIM2_C1 | | | 1194 * PA6 |SPI1 | | | |LPUART |TIM22_C1|EVENTOUT|COMP1 | 1195 * PA7 |SPI1 | | | | |TIM22_C2|EVENTOUT|COMP2 | 1196 * PA8 |MCO | | |EVENTOUT|USART1 | | | | 1197 * PA9 |MCO | | | |USART1 | | | | 1198 * PA10| | | | |USART1 | | | | 1199 * PA11|SPI1 | |EVENTOUT| |USART1 | | |COMP1 | 1200 * PA12|SPI1 | |EVENTOUT| |USART1 | | |COMP2 | 1201 * PA13|SWDIO | | | | | | | | 1202 * PA14|SWCLK | | | |USART2 | | | | 1203 * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | | 1204 *______________________________________________________________________________ 1205 * PB0 |EVENTOUT| | | | | | | | 1206 * PB1 | | | | |LPUART1 | | | | 1207 * PB2 | | |LPTIM1_O| | | | | | 1208 * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT| | | | 1209 * PB4 |SPI1 | |EVENTOUT| |TIM22_C1| | | | 1210 * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM22_C2| | | | 1211 * PB6 |USART1 |I2C1 |LPTIM1_T| | | | | | 1212 * PB7 |USART1 |I2C1 |LPTIM1_I| | | | | | 1213 * PB8 | | | | |I2C1 | | | | 1214 * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | | 1215 * PB10| | |TIM2_C3 | |LPUART1 |SPI2 |I2C2 | | 1216 * PB11|EVENTOUT| |TIM2_C4 | |LPUART1 | |I2C2 | | 1217 * PB12|SPI2 | |LPUART1 | | |I2C2 |EVENTOUT| | 1218 * PB13|SPI2 | | | |LPUART1 |I2C2 |TIM21_C1| | 1219 * PB14|SPI2 | |RTC | |LPUART1 |I2C2 |TIM21_C2| | 1220 * PB15|SPI2 | |RTC | | | | | | 1221 *______________________________________________________________________________ 1222 * PC0 |LPTIM1_I| |EVENTOUT| | | | | | 1223 * PC1 |LPTIM1_O| |EVENTOUT| | | | | | 1224 * PC2 |LPTIM1_I| |SPI2 | | | | | | 1225 * PC3 |LPTIM1_T| |SPI2 | | | | | | 1226 * PC4 |EVENTOUT| |LPUART | | | | | | 1227 * PC5 | | |LPUART | | | | | | 1228 * PC6 |TIM22_C1| | | | | | | | 1229 * PC7 |TIM22_C2| | | | | | | | 1230 * PC8 |TIM22_TR| | | | | | | | 1231 * PC9 |TIM21_TR| | | | | | | | 1232 * PC10|LPUART | | | | | | | | 1233 * PC11|LPUART | | | | | | | | 1234 * PC12| | | | | | | | | 1235 * PC13| | | | | | | | | 1236 * PC14| | | | | | | | | 1237 * PC15| | | | | | | | | 1238 *______________________________________________________________________________ 1239 * PD2 |LPUART | | | | | | | | 1240 *______________________________________________________________________________ 1241 * PH0 | | | | | | | | | 1242 * PH1 | | | | | | | | | 1243 * * 1244 */ 1245 1246 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 1247 * @{ 1248 */ 1249 1250 /* 1251 * Alternate function AF0 1252 */ 1253 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 1254 #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */ 1255 #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */ 1256 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 1257 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 1258 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 1259 #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */ 1260 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 1261 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 1262 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 1263 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 1264 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 1265 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 1266 /** 1267 * 1268 */ 1269 1270 /* 1271 * Alternate function AF1 1272 */ 1273 #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */ 1274 #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */ 1275 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 1276 /** 1277 * 1278 */ 1279 1280 /* 1281 * Alternate function AF2 1282 */ 1283 #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */ 1284 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 1285 #define GPIO_AF2_USB ((uint8_t)0x02U) /* USB Alternate Function mapping */ 1286 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 1287 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 1288 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 1289 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 1290 /** 1291 * 1292 */ 1293 1294 /* 1295 * Alternate function AF3 1296 */ 1297 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 1298 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 1299 /** 1300 * 1301 */ 1302 1303 /* 1304 * Alternate function AF4 1305 */ 1306 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 1307 #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */ 1308 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 1309 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 1310 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 1311 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 1312 /** 1313 * 1314 */ 1315 1316 /* 1317 * Alternate function AF5 1318 */ 1319 #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */ 1320 #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */ 1321 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 1322 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 1323 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 1324 /** 1325 * 1326 */ 1327 1328 /* 1329 * Alternate function AF6 1330 */ 1331 #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */ 1332 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 1333 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 1334 /** 1335 * 1336 */ 1337 1338 /* 1339 * Alternate function AF7 1340 */ 1341 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 1342 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 1343 /** 1344 * 1345 */ 1346 1347 /** 1348 * @} 1349 */ 1350 1351 /** 1352 * @} 1353 */ 1354 1355 /** @defgroup GPIOEx_Private GPIOEx Private 1356 * @{ 1357 */ 1358 1359 /** 1360 * @brief IS_GPIO_AF macro definition 1361 */ 1362 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 1363 1364 /** 1365 * @} 1366 */ 1367 #endif /* STM32L051xx */ 1368 /*------------------------------------------------------------------------------------------*/ 1369 1370 /*----------------------------------------------------------------------------*/ 1371 /*------------------------- STM32L031xx/STM32L041xx---------------------------*/ 1372 /*----------------------------------------------------------------------------*/ 1373 #if defined (STM32L031xx)|| defined (STM32L041xx) 1374 /* The table below gives an overview of the different alternate functions per port. 1375 * For more details refer yourself to the product data sheet. 1376 * 1377 */ 1378 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 1379 *______________________________________________________________________________ 1380 * PA0 | |LPTIM1 |TIM2_C1 | |USART2 |TIM2_TR | |COMP1 | 1381 * PA1 |EVENTOUT|LPTIM1 |TIM2_C2 |I2C1 |USART2 |TIM21_TR| | | 1382 * PA2 |TIM21_C1| |TIM2_C3 | |USART2 | |LPUART1 |COMP2 | 1383 * PA3 |TIM21_C2| |TIM2_C4 | |USART2 | |LPUART1 | | 1384 * PA4 |SPI1 |LPTIM1 | | |USART2 |TIM22_TR| | | 1385 * PA5 |SPI1 |LPTIM1 |TIM2_TR | | |TIM2_C1 | | | 1386 * PA6 |SPI1 |LPTIM1 | | |LPUART |TIM22_C1|EVENTOUT|COMP1 | 1387 * PA7 |SPI1 |LPTIM1 | | |USART2 |TIM22_C2|EVENTOUT|COMP2 | 1388 * PA8 |MCO | |LPTIM1 |EVENTOUT|USART2 |TIM2_C1 | | | 1389 * PA9 |MCO |I2C1 | | |USART2 |TIM22_C1| | | 1390 * PA10| |I2C1 | | |USART2 |TIM22_C2| | | 1391 * PA11|SPI1 | |EVENTOUT| |USART2 |TIM21_C2| |COMP1 | 1392 * PA12|SPI1 | |EVENTOUT| |USART2 | | |COMP2 | 1393 * PA13|SWDIO |LPTIM1 | | | | |LPUART1 | | 1394 * PA14|SWCLK |LPTIM1 | |I2C1 |USART2 | |LPUART1 | | 1395 * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | | 1396 *_____________________________________________________________________________| 1397 * PB0 |EVENTOUT|SPI1 | | |USART2 |TIM2_C3 | | | 1398 * PB1 |USART2 |SPI1 | | |LPUART1 |TIM2_C4 | | | 1399 * PB2 | | |LPTIM1_O| | | | | | 1400 * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT| | | | 1401 * PB4 |SPI1 | |EVENTOUT| |TIM22_C1| | | | 1402 * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM22_C2| | | | 1403 * PB6 |USART2 |I2C1 |LPTIM1_T| | |TIM21_C1| | | 1404 * PB7 |USART2 |I2C1 |LPTIM1_I| | | | | | 1405 * PB8 | | | | |I2C1 | | | | 1406 * PB9 | | |EVENTOUT| |I2C1 | | | | 1407 * PB10| | |TIM2_C3 | | | |LPUART1 | | 1408 * PB11|EVENTOUT| |TIM2_C4 | | | |LPUART1 | | 1409 * PB12|SPI2 | | | | | |EVENTOUT| | 1410 * PB13|SPI2 | |MCO | | |TIM21_C1|LPUART1 | | 1411 * PB14|SPI2 | |RTC | | |TIM21_C2|LPUART1 | | 1412 * PB15|SPI2 | |RTC | | | | | | 1413 *_____________________________________________________________________________| 1414 * PC0 |LPTIM1_I| |EVENTOUT| | | |LPUART1 | | 1415 * PC13| | | | | | | | | 1416 * PC14| | | | | | | | | 1417 * PC15| | | | | | | | | 1418 *_____________________________________________________________________________| 1419 * PH0 | | | | | | | | | 1420 * PH1 | | | | | | | | | 1421 *_____________________________________________________________________________| 1422 */ 1423 1424 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 1425 * @{ 1426 */ 1427 1428 /* 1429 * Alternate function AF0 1430 */ 1431 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 1432 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 1433 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 1434 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 1435 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 1436 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 1437 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 1438 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 1439 /** 1440 * 1441 */ 1442 1443 /* 1444 * Alternate function AF1 1445 */ 1446 #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */ 1447 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 1448 #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */ 1449 /** 1450 * 1451 */ 1452 1453 /* 1454 * Alternate function AF2 1455 */ 1456 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 1457 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 1458 #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */ 1459 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 1460 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 1461 /** 1462 * 1463 */ 1464 1465 /* 1466 * Alternate function AF3 1467 */ 1468 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 1469 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 1470 /** 1471 * 1472 */ 1473 1474 /* 1475 * Alternate function AF4 1476 */ 1477 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 1478 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 1479 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 1480 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 1481 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 1482 /** 1483 * 1484 */ 1485 1486 /* 1487 * Alternate function AF5 1488 */ 1489 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 1490 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 1491 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 1492 /** 1493 * 1494 */ 1495 1496 /* 1497 * Alternate function AF6 1498 */ 1499 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 1500 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 1501 /** 1502 * 1503 */ 1504 1505 /* 1506 * Alternate function AF7 1507 */ 1508 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 1509 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 1510 /** 1511 * 1512 */ 1513 1514 /** 1515 * @} 1516 */ 1517 1518 /** 1519 * @} 1520 */ 1521 1522 /** @defgroup GPIOEx_Private GPIOEx Private 1523 * @{ 1524 */ 1525 /** 1526 * @brief IS_GPIO_AF macro definition 1527 */ 1528 1529 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 1530 1531 /** 1532 * @} 1533 */ 1534 1535 #endif /* STM32L031xx/STM32L041xx*/ 1536 /*------------------------------------------------------------------------------------------*/ 1537 1538 /*----------------------------------------------------------------------------*/ 1539 /*------------------------- STM32L011xx/STM32L021xx---------------------------*/ 1540 /*----------------------------------------------------------------------------*/ 1541 #if defined (STM32L011xx)|| defined (STM32L021xx) 1542 /* The table below gives an overview of the different alternate functions per port. 1543 * For more details refer yourself to the product data sheet. 1544 * 1545 */ 1546 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 1547 *______________________________________________________________________________________ 1548 * PA0 |USART2_RX|LPTIM1_IN1|TIM2_C1 | |USART2_CTS|TIM2_ETR|LPUART1_RX |COMP1_OUT| 1549 * PA1 |EVENTOUT |LPTIM1_IN2|TIM2_C2 |I2C1 |USART2_RTS|TIM21_TR|LPUART1_TX | | 1550 * PA2 |TIM21_C1 | |TIM2_C3 | |USART2_TX | |LPUART1_TX |COMP2_OUT| 1551 * PA3 |TIM21_C2 | |TIM2_C4 | |USART2_RX | |LPUART1_RX | | 1552 * PA4 |SPI1 |LPTIM1_IN1|LPTIM1_TR|I2C1_SCL|USART2_CK |TIM2_TR |LPUART1_TX |COMP2_OUT| 1553 * PA5 |SPI1 |LPTIM1_IN2|TIM2_TR | | |TIM2_C1 | | | 1554 * PA6 |SPI1 |LPTIM1_ETR| | |LPUART1_CT| |EVENTOUT |COMP1_OUT| 1555 * PA7 |SPI1 |LPTIM1_OUT| | |USART2_CTS|TIM21_T |EVENTOUT |COMP2_OUT| 1556 * PA8 |MCO | |LPTIM1_I1|EVENTOUT|USART2_CK |TIM2_C1 | | | 1557 * PA9 |MCO |I2C1_SCL |LPTIM1_O | |USART2_TX |TIM21_C2| |COMP1_OUT| 1558 * PA10|TIM21_C1 |I2C1_SDA |RTC_REFIN| |USART2_RX |TIM2_C3 | |COMP1_OUT| 1559 * PA11|SPI1 |LPTIM1_OUT|EVENTOUT | |USART2_CTS|TIM21_C2| |COMP1_OUT| 1560 * PA12|SPI1 | |EVENTOUT | |USART2_RTS| | |COMP2_OUT| 1561 * PA13|SWDIO |LPTIM1_T | |I2C1_SDA| |SPI1 |LPUART1_RX |COMP1_OUT| 1562 * PA14|SWCLK |LPTIM1_O | |I2C1_SMB|USART2_TX |SPI1 |LPUART1_TX |COMP2_OUT| 1563 * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2_RX |TIM2_C1 | | | 1564 *______________________________________________________________________________________ | 1565 * PB0 |EVENTOUT |SPI1 |TIM2_C2 | |USART2_RTS|TIM2_C3 | | | 1566 * PB1 |USART2_CK|SPI1 |LPTIM1_I1| |LPUART1_RT|TIM2_C4 | | | 1567 * PB2 | | |LPTIM1_O | | | | | | 1568 * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT | | | | 1569 * PB4 |SPI1 | |EVENTOUT | | | | | | 1570 * PB5 |SPI1 | |LPTIM1_I1|I2C1 | |TIM21_C1| | | 1571 * PB6 |USART2_TX|I2C1_SCL |LPTIM1_T | | |TIM2_C3 |LPUART1_TX | | 1572 * PB7 |USART2_RX|I2C1 |LPTIM1_I2| | |TIM2_C4 |LPUART1_RX | | 1573 * PB8 |USART2_TX| |EVENTOUT | |I2C1 |SPI1 | | | 1574 * PB9 | | | | | | | | | 1575 *______________________________________________________________________________________ | 1576 * PC14| | | | | | | | | 1577 * PC15| | | | | | | | | 1578 *______________________________________________________________________________________ | 1579 */ 1580 1581 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 1582 * @{ 1583 */ 1584 1585 /* 1586 * Alternate function AF0 1587 */ 1588 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 1589 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 1590 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 1591 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 1592 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 1593 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 1594 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 1595 /** 1596 * 1597 */ 1598 1599 /* 1600 * Alternate function AF1 1601 */ 1602 #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */ 1603 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 1604 #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */ 1605 /** 1606 * 1607 */ 1608 1609 /* Alternate function AF2 1610 * 1611 */ 1612 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 1613 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 1614 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 1615 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 1616 /** 1617 * 1618 */ 1619 1620 /* 1621 * Alternate function AF3 1622 */ 1623 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 1624 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 1625 /** 1626 * 1627 */ 1628 1629 /* 1630 * Alternate function AF4 1631 */ 1632 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 1633 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 1634 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 1635 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 1636 /** 1637 * 1638 */ 1639 1640 /* 1641 * Alternate function AF5 1642 */ 1643 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 1644 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 1645 #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ 1646 /** 1647 * 1648 */ 1649 1650 /* 1651 * Alternate function AF6 1652 */ 1653 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 1654 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 1655 /** 1656 * 1657 */ 1658 1659 /* 1660 * Alternate function AF7 1661 */ 1662 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 1663 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 1664 /** 1665 * 1666 */ 1667 1668 /** 1669 * @} 1670 */ 1671 1672 /** 1673 * @} 1674 */ 1675 1676 /** @defgroup GPIOEx_Private GPIOEx Private 1677 * @{ 1678 */ 1679 /** 1680 * IS_GPIO_AF macro definition 1681 */ 1682 1683 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 1684 1685 /** 1686 * @} 1687 */ 1688 1689 #endif /* STM32L011xx/STM32L021xx*/ 1690 1691 /*----------------------------------------------------------------------------*/ 1692 /*----------------------------- STM32L010xB ----------------------------------*/ 1693 /*----------------------------------------------------------------------------*/ 1694 #if defined (STM32L010xB) 1695 /* The table below gives an overview of the different alternate functions per port. 1696 * For more details refer yourself to the product data sheet. 1697 * 1698 */ 1699 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 | 1700 *_______________________________________________________________________________________________| 1701 * PA0 | | |TIM2_CH1 | |USART2_CTS |TIM2_ETR | | | 1702 * PA1 |EVENTOUT | |TIM2_CH2 | |USART2_RTS |TIM21_ETR| | | 1703 * PA2 |TIM21_CH1 | |TIM2_CH3 | |USART2_TX | |LPUART1_TX | | 1704 * PA3 |TIM21_CH2 | |TIM2_CH4 | |USART2_RX | |LPUART1_RX | | 1705 * PA4 |SPI1_NSS | | | |USART2_CK |TIM22_ETR| | | 1706 * PA5 |SPI1_SCK | |TIM2_ETR | | |TIM2_CH1 | | | 1707 * PA6 |SPI1_MISO | | | |LPUART1_CTS|TIM22_CH1|EVENTOUT | | 1708 * PA7 |SPI1_MOSI | | | | |TIM22_CH2|EVENTOUT | | 1709 * PA8 |MCO | | |EVENTOUT | | | | | 1710 * PA9 |MCO | | | | | |I2C1_SCL | | 1711 * PA10| | | | | | |I2C1_SDA | | 1712 * PA11|SPI1_MISO | |EVENTOUT | | | | | | 1713 * PA12|SPI1_MOSI | |EVENTOUT | | | | | | 1714 * PA13|SWDIO | | | | | |LPUART1_RX | | 1715 * PA14|SWCLK | | | |USART2_TX | |LPUART1_TX | | 1716 * PA15|SPI1_NSS | |TIM2_ETR |EVENTOUT |USART2_RX |TIM2_CH1 | | | 1717 *_______________________________________________________________________________________________| 1718 * PB0 |EVENTOUT | | | | | | | | 1719 * PB1 | | | | |LPUART1_RTS| | | | 1720 * PB2 | | |LPTIM1_OUT | | | | | | 1721 * PB3 |SPI1_SCK | |TIM2_CH2 | |EVENTOUT | | | | 1722 * PB4 |SPI1_MISO | | | |TIM22_CH1 | | | | 1723 * PB5 |SPI1_MOSI | |LPTIM1_IN1 |I2C1_SMBA|TIM22_CH2 | | | | 1724 * PB6 | |I2C1_SCL |LPTIM1_ETR | | | | | | 1725 * PB7 | |I2C1_SDA |LPTIM1_IN2 | | | | | | 1726 * PB8 | | | | |I2C1_SCL | | | | 1727 * PB9 | | |EVENTOUT | |I2C1_SDA | | | | 1728 * PB10| | |TIM2_CH3 | |LPUART1_TX | | |LPUART1_RX| 1729 * PB11|EVENTOUT | |TIM2_CH4 | |LPUART1_RX | | |LPUART1_TX| 1730 * PB12| | |LPUART1_RTS| | | |EVENTOUT | | 1731 * PB13| | |MCO | |LPUART1_CTS| |TIM21_CH1 | | 1732 * PB14| | |RTC_OUT | |LPUART1_RTS| |TIM21_CH2 | | 1733 * PB15| | |RTC_REFIN | | | | | | 1734 *_______________________________________________________________________________________________| 1735 * PC0 |LPTIM1_IN1 | |EVENTOUT | | | |LPUART1_RX | | 1736 * PC1 |LPTIM1_OUT | |EVENTOUT | | | |LPUART1_TX | | 1737 * PC2 |LPTIM1_IN2 | | | | | | | | 1738 * PC3 |LPTIM1_ETR | | | | | | | | 1739 * PC4 |EVENTOUT | |LPUART1_TX | | | | | | 1740 * PC5 | | |LPUART1_RX | | | | | | 1741 * PC6 |TIM22_CH1 | | | | | | | | 1742 * PC7 |TIM22_CH2 | | | | | | | | 1743 * PC8 |TIM22_ETR | | | | | | | | 1744 * PC9 |TIM21_ETR | | | | | | | | 1745 * PC10|LPUART1_TX | | | | | | | | 1746 * PC11|LPUART1_RX | | | | | | | | 1747 *_______________________________________________________________________________________________| 1748 * PD2 |LPUART1_RTS| | | | | | | | 1749 *_______________________________________________________________________________________________| 1750 */ 1751 1752 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 1753 * @{ 1754 */ 1755 1756 /* 1757 * Alternate function AF0 1758 * 1759 */ 1760 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 1761 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 1762 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 1763 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 1764 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 1765 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 1766 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 1767 #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */ 1768 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 1769 /** 1770 * 1771 */ 1772 1773 /* 1774 * Alternate function AF1 1775 * 1776 */ 1777 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 1778 /** 1779 * 1780 */ 1781 1782 /* 1783 * Alternate function AF2 1784 * 1785 */ 1786 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 1787 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 1788 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 1789 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 1790 #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */ 1791 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 1792 /** 1793 * 1794 */ 1795 1796 /* 1797 * Alternate function AF3 1798 * @{ 1799 */ 1800 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 1801 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 1802 /** 1803 * 1804 */ 1805 1806 /* 1807 * Alternate function AF4 1808 * 1809 */ 1810 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 1811 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 1812 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 1813 #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */ 1814 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 1815 /** 1816 * 1817 */ 1818 1819 /* 1820 * Alternate function AF5 1821 * 1822 */ 1823 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 1824 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 1825 #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */ 1826 /** 1827 * 1828 */ 1829 1830 /* 1831 * Alternate function AF6 1832 * 1833 */ 1834 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 1835 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 1836 #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */ 1837 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 1838 /** 1839 * 1840 */ 1841 1842 /* 1843 * Alternate function AF7 1844 * 1845 */ 1846 #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */ 1847 /** 1848 * 1849 */ 1850 1851 /** 1852 * @} 1853 */ 1854 1855 /** 1856 * @} 1857 */ 1858 1859 /** @defgroup GPIOEx_Private GPIOEx Private 1860 * @{ 1861 */ 1862 1863 /** 1864 * IS_GPIO_AF macro definition 1865 */ 1866 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07) 1867 1868 /** 1869 * @} 1870 */ 1871 1872 #endif /* STM32L010xB */ 1873 1874 /*----------------------------------------------------------------------------*/ 1875 /*------------------------- STM32L010x8 --------------------------------------*/ 1876 /*----------------------------------------------------------------------------*/ 1877 #if defined (STM32L010x8) 1878 /* The table below gives an overview of the different alternate functions per port. 1879 * For more details refer yourself to the product data sheet. 1880 * 1881 */ 1882 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | 1883 *________________________________________________________________________________________________| 1884 * PA0 | | | TIM2_CH1 | | USART2_CTS | TIM2_ETR | | 1885 * PA1 | EVENTOUT | | TIM2_CH2 | | USART2_RTS | TIM21_ETR | | 1886 * PA2 | TIM21_CH1 | | TIM2_CH3 | | USART2_TX | | | 1887 * PA3 | TIM21_CH2 | | TIM2_CH4 | | USART2_RX | | | 1888 * PA4 | SPI1_NSS | | | | USART2_CK | | | 1889 * PA5 | SPI1_SCK | | TIM2_ETR | | | TIM2_CH1 | | 1890 * PA6 | SPI1_MISO | | | | LPUART1_CTS | | EVENTOUT | 1891 * PA7 | SPI1_MOSI | | | | | | EVENTOUT | 1892 * PA8 | MCO | | | EVENTOUT | | | | 1893 * PA9 | MCO | | | | | | | 1894 * PA10 | | | | | | | | 1895 * PA11 | SPI1_MISO | | EVENTOUT | | | | | 1896 * PA12 | SPI1_MOSI | | EVENTOUT | | | | | 1897 * PA13 | SWDIO | | | | | | | 1898 * PA14 | SWCLK | | | | USART2_TX | | | 1899 * PA15 | SPI1_NSS | | TIM2_ETR | EVENTOUT | USART2_RX | TIM2_CH1 | | 1900 *________________________________________________________________________________________________| 1901 * PB0 | EVENTOUT | | | | | | | 1902 * PB1 | | | | | LPUART1_RTS | | | 1903 * PB2 | | | LPTIM1_OUT | | | | | 1904 * PB3 | SPI1_SCK | | TIM2_CH2 | | EVENTOUT | | | 1905 * PB4 | SPI1_MISO | EVENTOUT | | | | | | 1906 * PB5 | SPI1_MOSI | LPTIM1_IN1 | I2C1_SMBA | | | | | 1907 * PB6 | | I2C1_SCL | LPTIM1_ETR | | | | | 1908 * PB7 | | I2C1_SDA | LPTIM1_IN2 | | | | | 1909 * PB8 | | | | | I2C1_SCL | | | 1910 * PB9 | | | EVENTOUT | | I2C1_SDA | | | 1911 * PB10 | | | TIM2_CH3 | | LPUART1_TX | | | 1912 * PB11 | EVENTOUT | | TIM2_CH4 | | LPUART1_RX | | | 1913 * PB12 | | | LPUART1_RTS | | | EVENTOUT | | 1914 * PB13 | | | | | LPUART1_CTS | | TIM21_CH1 | 1915 * PB14 | | | RTC_OUT | | LPUART1_RTS | | TIM21_CH2 | 1916 * PB15 | | | RTC_REFIN | | | | | 1917 *________________________________________________________________________________________________| 1918 * PC0 | LPTIM1_IN1 | | EVENTOUT | | | | | 1919 * PC1 | LPTIM1_OUT | | EVENTOUT | | | | | 1920 * PC2 | LPTIM1_IN2 | | | | | | | 1921 * PC3 | LPTIM1_ETR | | | | | | | 1922 * PC4 | EVENTOUT | | LPUART1_TX | | | | | 1923 * PC5 | | | LPUART1_RX | | | | | 1924 * PC9 | TIM21_ETR | | | | | | | 1925 * PC10 | LPUART1_TX | | | | | | | 1926 * PC11 | LPUART1_RX | | | | | | | 1927 * PD2 | LPUART1_RTS | | | | | | | 1928 *________________________________________________________________________________________________| 1929 */ 1930 1931 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 1932 * @{ 1933 */ 1934 1935 /* 1936 * Alternate function AF0 1937 */ 1938 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 1939 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 1940 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 1941 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 1942 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 1943 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 1944 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 1945 #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */ 1946 /** 1947 * 1948 */ 1949 1950 /* 1951 * Alternate function AF1 1952 */ 1953 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 1954 /** 1955 * 1956 */ 1957 1958 /* 1959 * Alternate function AF2 1960 */ 1961 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 1962 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 1963 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 1964 #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */ 1965 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 1966 /** 1967 * 1968 */ 1969 1970 /* 1971 * Alternate function AF3 1972 */ 1973 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 1974 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 1975 /** 1976 * 1977 */ 1978 1979 /* 1980 * Alternate function AF4 1981 */ 1982 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 1983 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 1984 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 1985 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 1986 /** 1987 * 1988 */ 1989 1990 /* 1991 * Alternate function AF5 1992 */ 1993 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 1994 /** 1995 * 1996 */ 1997 1998 /* 1999 * Alternate function AF6 2000 */ 2001 #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */ 2002 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 2003 /** 2004 * 2005 */ 2006 2007 2008 /** 2009 * @} 2010 */ 2011 2012 /** 2013 * @} 2014 */ 2015 2016 /** @defgroup GPIOEx_Private GPIOEx Private 2017 * @{ 2018 */ 2019 2020 /** 2021 * @brief IS_GPIO_AF macro definition 2022 */ 2023 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x06) 2024 2025 /** 2026 * @} 2027 */ 2028 #endif /* STM32L010x8 */ 2029 2030 2031 /*----------------------------------------------------------------------------*/ 2032 /*------------------------- STM32L010x6 --------------------------------------*/ 2033 /*----------------------------------------------------------------------------*/ 2034 #if defined (STM32L010x6) 2035 /* The table below gives an overview of the different alternate functions per port. 2036 * For more details refer yourself to the product data sheet. 2037 * 2038 */ 2039 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | 2040 *__________________________________________________________________________________________________| 2041 * PA1 | EVENTOUT | LPTIM1_IN2 | TIM2_CH2 | I2C1_SMBA | USART2_RTS | TIM21_ETR | | 2042 * PA2 | TIM21_CH1 | | TIM2_CH3 | | USART2_TX | | LPUART1_TX | 2043 * PA3 | TIM21_CH2 | | TIM2_CH4 | | USART2_RX | | LPUART1_RX | 2044 * PA4 | SPI1_NSS | LPTIM1_IN1 | | | USART2_CK | | | 2045 * PA5 | SPI1_SCK | LPTIM1_IN2 | TIM2_ETR | | | TIM2_CH1 | | 2046 * PA6 | SPI1_MISO | LPTIM1_ETR | | | LPUART1_CTS | | EVENTOUT | 2047 * PA7 | SPI1_MOSI | LPTIM1_OUT | | | USART2_CTS | | EVENTOUT | 2048 * PA8 | MCO | | LPTIM1_IN1 | EVENTOUT | USART2_CK | TIM2_CH1 | | 2049 * PA9 | MCO | I2C1_SCL | | | USART2_TX | | | 2050 * PA10 | | I2C1_SDA | | | USART2_RX | | | 2051 * PA11 | SPI1_MISO | | EVENTOUT | | USART2_CTS | TIM21_CH2 | | 2052 * PA12 | SPI1_MOSI | | EVENTOUT | | USART2_RTS | | | 2053 * PA13 | SWDIO | LPTIM1_ETR | | | | | LPUART1_RX | 2054 * PA14 | SWCLK | LPTIM1_OUT | | I2C1_SMBA | USART2_TX | | LPUART1_TX | 2055 * PA15 | SPI1_NSS | | TIM2_ETR | EVENTOUT | USART2_RX | TIM2_CH1 | | 2056 *__________________________________________________________________________________________________| 2057 * PB0 | EVENTOUT | SPI1_MISO | | | USART2_RTS | TIM2_CH3 | | 2058 * PB1 | USART2_CK | SPI1_MOSI | | | LPUART1_RTS | TIM2_CH4 | | 2059 * PB2 | | | LPTIM1_OUT | | | | | 2060 * PB3 | SPI1_SCK | | TIM2_CH2 | | EVENTOUT | | | 2061 * PB4 | SPI1_MISO | | EVENTOUT | | | | | 2062 * PB5 | SPI1_MOSI | LPTIM1_IN1 | I2C1_SMBA | | | | | 2063 * PB6 | USART2_TX | I2C1_SCL | LPTIM1_ETR | | | TIM21_CH1 | | 2064 * PB7 | USART2_RX | I2C1_SDA | LPTIM1_IN2 | | | | | 2065 * PB8 | | | | | I2C1_SCL | | | 2066 * PB9 | | | EVENTOUT | | I2C1_SDA | | | 2067 * PB10 | | | TIM2_CH3 | | | | LPUART1_TX | 2068 * PB11 | EVENTOUT | | TIM2_CH4 | | | | LPUART1_RX | 2069 * PB12 | SPI1_NSS | | | | | | EVENTOUT | 2070 * PB13 | SPI1_SCK | | MCO | | | TIM21_CH1 | LPUART1_CTS| 2071 * PB14 | SPI1_MISO | | RTC_OUT | | | TIM21_CH2 | LPUART1_RTS| 2072 * PB15 | SPI1_MOSI | | RTC_REFIN | | | | | 2073 *__________________________________________________________________________________________________| 2074 * PC0 | LPTIM1_IN1 | | EVENTOUT | | | | LPUART1_RX | 2075 *__________________________________________________________________________________________________| 2076 */ 2077 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 2078 * @{ 2079 */ 2080 2081 /* 2082 * Alternate function AF0 2083 */ 2084 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 2085 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 2086 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 2087 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 2088 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 2089 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 2090 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 2091 #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */ 2092 /** 2093 * 2094 */ 2095 2096 /* 2097 * Alternate function AF1 2098 */ 2099 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 2100 #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */ 2101 /** 2102 * 2103 */ 2104 2105 /* 2106 * Alternate function AF2 2107 */ 2108 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 2109 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 2110 #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */ 2111 #define GPIO_AF2_I2C1 ((uint8_t)0x02U) /* I2C1 Alternate Function mapping */ 2112 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 2113 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 2114 /** 2115 * 2116 */ 2117 2118 /* 2119 * Alternate function AF3 2120 */ 2121 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 2122 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 2123 /** 2124 * 2125 */ 2126 2127 /* 2128 * Alternate function AF4 2129 */ 2130 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 2131 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 2132 #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ 2133 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 2134 /** 2135 * 2136 */ 2137 2138 /* 2139 * Alternate function AF5 2140 */ 2141 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 2142 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 2143 /** 2144 * 2145 */ 2146 2147 /* 2148 * Alternate function AF6 2149 */ 2150 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 2151 #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */ 2152 /** 2153 * 2154 */ 2155 2156 /* 2157 * Alternate function AF7 2158 */ 2159 #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */ 2160 #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */ 2161 /** 2162 * 2163 */ 2164 2165 /** 2166 * @} 2167 */ 2168 2169 /** 2170 * @} 2171 */ 2172 2173 /** @defgroup GPIOEx_Private GPIOEx Private 2174 * @{ 2175 */ 2176 /** 2177 * @brief IS_GPIO_AF macro definition 2178 */ 2179 2180 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x06) 2181 2182 /** 2183 * @} 2184 */ 2185 2186 #endif /* STM32L010x6 */ 2187 2188 /*----------------------------------------------------------------------------*/ 2189 /*------------------------- STM32L010x4 --------------------------------------*/ 2190 /*----------------------------------------------------------------------------*/ 2191 #if defined (STM32L010x4) 2192 /* The table below gives an overview of the different alternate functions per port. 2193 * For more details refer yourself to the product data sheet. 2194 * 2195 */ 2196 /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | 2197 *_______________________________________________________________________ _________________________| 2198 * PA0 | USART2_RX | LPTIM1_IN1 | TIM2_CH1 | | USART2_CTS | TIM2_ETR | LPUART1_RX | 2199 * PA1 | EVENTOUT | LPTIM1_IN2 | TIM2_CH2 | I2C1_SMBA | USART2_RTS | TIM21_ETR | LPUART1_TX | 2200 * PA2 | TIM21_CH1 | | TIM2_CH3 | | USART2_TX | | LPUART1_TX | 2201 * PA3 | TIM21_CH2 | | TIM2_CH4 | | USART2_RX | | LPUART1_RX | 2202 * PA4 | SPI1_NSS | LPTIM1_IN1 | LPTIM1_ETR | I2C1_SCL | USART2_CK | TIM2_ETR | LPUART1_TX | 2203 * PA5 | SPI1_SCK | LPTIM1_IN2 | TIM2_ETR | | | TIM2_CH1 | | 2204 * PA6 | SPI1_MISO | LPTIM1_ETR | | LPUART1_CTS | | EVENTOUT | | 2205 * PA7 | SPI1_MOSI | LPTIM1_OUT | | USART2_CTS | TIM21_ETR | EVENTOUT | | 2206 * PA8 | MCO | | LPTIM1_IN1 | EVENTOUT | USART2_CK | TIM2_CH1 | | 2207 * PA9 | MCO | I2C1_SCL | LPTIM1_OUT | | USART2_TX | TIM21_CH2 | | 2208 * PA10 | TIM21_CH1 | I2C1_SDA | RTC_REFIN | | USART2_RX | TIM2_CH3 | | 2209 * PA11 | SPI1_MISO | LPTIM1_OUT | EVENTOUT | | USART2_CTS | TIM21_CH2 | | 2210 * PA12 | SPI1_MOSI | | EVENTOUT | | USART2_RTS | | | 2211 * PA13 | SWDIO | LPTIM1_ETR | | I2C1_SDA | | SPI1_SCK | LPUART1_RX | 2212 * PA14 | SWCLK | LPTIM1_OUT | | I2C1_SMBA | USART2_TX | SPI1_MISO | LPUART1_TX | 2213 * PA15 | SPI1_NSS | | TIM2_ETR | EVENTOUT | USART2_RX | TIM2_CH1 | | 2214 *_________________________________________________________________________________________________| 2215 * PB0 | EVENTOUT | SPI1_MISO | TIM2_CH2 | | USART2_RTS | TIM2_CH3 | | 2216 * PB1 | USART2_CK | SPI1_MOSI | LPTIM1_IN1 | | LPUART1_RTS | TIM2_CH4 | | 2217 * PB3 | SPI1_SCK | | TIM2_CH2 | | EVENTOUT | | | 2218 * PB4 | SPI1_MISO | | EVENTOUT | | | | | 2219 * PB5 | SPI1_MOSI | | LPTIM1_IN1 | I2C1_SMBA | | TIM21_CH1 | | 2220 * PB6 | USART2_TX | I2C1_SCL | LPTIM1_ETR | | | TIM2_CH3 | LPUART1_TX | 2221 * PB7 | USART2_RX | I2C1_SDA | LPTIM1_IN2 | | | TIM2_CH4 | LPUART1_RX | 2222 *_________________________________________________________________________________________________| 2223 */ 2224 2225 /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection 2226 * @{ 2227 */ 2228 2229 /* 2230 * Alternate function AF0 2231 */ 2232 #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */ 2233 #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */ 2234 #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */ 2235 #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */ 2236 #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */ 2237 #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */ 2238 #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */ 2239 /** 2240 * 2241 */ 2242 2243 /* 2244 * Alternate function AF1 2245 */ 2246 #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */ 2247 #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */ 2248 #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */ 2249 /** 2250 * 2251 */ 2252 2253 /* Alternate function AF2 2254 * 2255 */ 2256 #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */ 2257 #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */ 2258 #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */ 2259 #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */ 2260 /** 2261 * 2262 */ 2263 2264 /* 2265 * Alternate function AF3 2266 */ 2267 #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */ 2268 #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */ 2269 #define GPIO_AF3_LPUART1 ((uint8_t)0x03U) /* LPUART1 Alternate Function mapping */ 2270 #define GPIO_AF3_USART2 ((uint8_t)0x03U) /* USART2 Alternate Function mapping */ 2271 /** 2272 * 2273 */ 2274 2275 /* 2276 * Alternate function AF4 2277 */ 2278 #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */ 2279 #define GPIO_AF4_TIM21 ((uint8_t)0x04U) /* TIM21 Alternate Function mapping */ 2280 #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */ 2281 #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */ 2282 /** 2283 * 2284 */ 2285 2286 /* 2287 * Alternate function AF5 2288 */ 2289 #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */ 2290 #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */ 2291 #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ 2292 #define GPIO_AF5_EVENTOUT ((uint8_t)0x05U) /* EVENTOUT Alternate Function mapping */ 2293 /** 2294 * 2295 */ 2296 2297 /* 2298 * Alternate function AF6 2299 */ 2300 #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */ 2301 /** 2302 * 2303 */ 2304 2305 /** 2306 * @} 2307 */ 2308 2309 /** 2310 * @} 2311 */ 2312 2313 /** @defgroup GPIOEx_Private GPIOEx Private 2314 * @{ 2315 */ 2316 /** 2317 * IS_GPIO_AF macro definition 2318 */ 2319 2320 #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x06) 2321 2322 /** 2323 * @} 2324 */ 2325 2326 #endif /* STM32L010x4*/ 2327 2328 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \ 2329 defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx) || \ 2330 defined (STM32L010xB) 2331 2332 /** @addtogroup GPIOEx_Exported_Constants 2333 * @{ 2334 */ 2335 /** @defgroup GPIOEx_Pin_Available Pin available 2336 * @{ 2337 */ 2338 #define GPIOA_PIN_AVAILABLE GPIO_PIN_All 2339 #define GPIOB_PIN_AVAILABLE GPIO_PIN_All 2340 #define GPIOC_PIN_AVAILABLE GPIO_PIN_All 2341 #define GPIOD_PIN_AVAILABLE GPIO_PIN_All 2342 #define GPIOE_PIN_AVAILABLE GPIO_PIN_All 2343 #define GPIOH_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_9 | GPIO_PIN_10) 2344 /** 2345 * @} 2346 */ 2347 /** 2348 * @} 2349 */ 2350 2351 /** @addtogroup GPIOEx_Private 2352 * @{ 2353 */ 2354 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 2355 ((__GPIOx__) == (GPIOB))? 1U :\ 2356 ((__GPIOx__) == (GPIOC))? 2U :\ 2357 ((__GPIOx__) == (GPIOD))? 3U :\ 2358 ((__GPIOx__) == (GPIOE))? 4U :\ 2359 ((__GPIOx__) == (GPIOH))? 5U : 6U) 2360 2361 #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \ 2362 ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \ 2363 (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \ 2364 (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))) || \ 2365 (((__INSTANCE__) == GPIOD) && (((__PIN__) & (GPIOD_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOD_PIN_AVAILABLE)) == (GPIOD_PIN_AVAILABLE))) || \ 2366 (((__INSTANCE__) == GPIOE) && (((__PIN__) & (GPIOE_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOE_PIN_AVAILABLE)) == (GPIOE_PIN_AVAILABLE))) || \ 2367 (((__INSTANCE__) == GPIOH) && (((__PIN__) & (GPIOH_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOH_PIN_AVAILABLE)) == (GPIOH_PIN_AVAILABLE)))) 2368 /** 2369 * @} 2370 */ 2371 #elif defined (STM32L031xx) || defined (STM32L041xx) || defined (STM32L010x6) 2372 2373 /** @addtogroup GPIOEx_Exported_Constants 2374 * @{ 2375 */ 2376 /** @defgroup GPIOEx_Pin_Available Pin available 2377 * @{ 2378 */ 2379 2380 #define GPIOA_PIN_AVAILABLE GPIO_PIN_All 2381 #define GPIOB_PIN_AVAILABLE GPIO_PIN_All 2382 #define GPIOC_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15) 2383 #define GPIOH_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1) 2384 /** 2385 * @} 2386 */ 2387 /** 2388 * @} 2389 */ 2390 2391 /** @addtogroup GPIOEx_Private 2392 * @{ 2393 */ 2394 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 2395 ((__GPIOx__) == (GPIOB))? 1U :\ 2396 ((__GPIOx__) == (GPIOC))? 2U :\ 2397 ((__GPIOx__) == (GPIOH))? 5U : 6U) 2398 2399 2400 #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \ 2401 ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \ 2402 (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \ 2403 (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))) || \ 2404 (((__INSTANCE__) == GPIOH) && (((__PIN__) & (GPIOH_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOH_PIN_AVAILABLE)) == (GPIOH_PIN_AVAILABLE)))) 2405 2406 /** 2407 * @} 2408 */ 2409 2410 #elif defined (STM32L011xx) || defined (STM32L021xx) || defined (STM32L010x4) 2411 2412 /** @addtogroup GPIOEx_Exported_Constants 2413 * @{ 2414 */ 2415 /** @defgroup GPIOEx_Pin_Available Pin available 2416 * @{ 2417 */ 2418 2419 #define GPIOA_PIN_AVAILABLE GPIO_PIN_All 2420 #define GPIOB_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | \ 2421 GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 ) 2422 #define GPIOC_PIN_AVAILABLE (GPIO_PIN_14 | GPIO_PIN_15) 2423 2424 /** 2425 * @} 2426 */ 2427 /** 2428 * @} 2429 */ 2430 2431 /** @addtogroup GPIOEx_Private 2432 * @{ 2433 */ 2434 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 2435 ((__GPIOx__) == (GPIOB))? 1U :\ 2436 ((__GPIOx__) == (GPIOC))? 2U : 6U) 2437 2438 2439 #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \ 2440 ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \ 2441 (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \ 2442 (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE)))) 2443 /** 2444 * @} 2445 */ 2446 2447 #elif defined (STM32L063xx) || defined (STM32L062xx) || defined (STM32L053xx) || \ 2448 defined (STM32L052xx) || defined (STM32L051xx) || defined (STM32L010x8) 2449 2450 /** @addtogroup GPIOEx_Exported_Constants 2451 * @{ 2452 */ 2453 /** @defgroup GPIOEx_Pin_Available Pin available 2454 * @{ 2455 */ 2456 #define GPIOA_PIN_AVAILABLE GPIO_PIN_All 2457 #define GPIOB_PIN_AVAILABLE GPIO_PIN_All 2458 #define GPIOC_PIN_AVAILABLE GPIO_PIN_All 2459 #define GPIOD_PIN_AVAILABLE GPIO_PIN_2 2460 #define GPIOH_PIN_AVAILABLE GPIO_PIN_0 | GPIO_PIN_1 2461 /** 2462 * @} 2463 */ 2464 /** 2465 * @} 2466 */ 2467 2468 /** @addtogroup GPIOEx_Private 2469 * @{ 2470 */ 2471 #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\ 2472 ((__GPIOx__) == (GPIOB))? 1U :\ 2473 ((__GPIOx__) == (GPIOC))? 2U :\ 2474 ((__GPIOx__) == (GPIOD))? 3U :\ 2475 ((__GPIOx__) == (GPIOH))? 5U : 6U) 2476 2477 #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \ 2478 ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \ 2479 (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \ 2480 (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))) || \ 2481 (((__INSTANCE__) == GPIOD) && (((__PIN__) & (GPIOD_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOD_PIN_AVAILABLE)) == (GPIOD_PIN_AVAILABLE))) || \ 2482 (((__INSTANCE__) == GPIOH) && (((__PIN__) & (GPIOH_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOH_PIN_AVAILABLE)) == (GPIOH_PIN_AVAILABLE)))) 2483 /** 2484 * @} 2485 */ 2486 2487 #endif /* STM32L083xx || STM32L082xx || STM32L081xx || STM32L073xx || STM32L072xx || STM32L071xx*/ 2488 2489 2490 /** 2491 * @} 2492 */ 2493 2494 /** 2495 * @} 2496 */ 2497 #ifdef __cplusplus 2498 } 2499 #endif 2500 2501 #endif /* __STM32L0xx_HAL_GPIO_EX_H */ 2502 2503 2504