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