1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_gpio.h 4 * @author MCD Application Team 5 * @version V1.4.0 6 * @date 04-August-2014 7 * @brief This file contains all the functions prototypes for the GPIO firmware 8 * library. 9 ****************************************************************************** 10 * @attention 11 * 12 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> 13 * 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 * You may not use this file except in compliance with the License. 16 * You may obtain a copy of the License at: 17 * 18 * http://www.st.com/software_license_agreement_liberty_v2 19 * 20 * Unless required by applicable law or agreed to in writing, software 21 * distributed under the License is distributed on an "AS IS" BASIS, 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the License for the specific language governing permissions and 24 * limitations under the License. 25 * 26 ****************************************************************************** 27 */ 28 29 /* Define to prevent recursive inclusion -------------------------------------*/ 30 #ifndef __STM32F4xx_GPIO_H 31 #define __STM32F4xx_GPIO_H 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* Includes ------------------------------------------------------------------*/ 38 #include "stm32f4xx.h" 39 40 /** @addtogroup STM32F4xx_StdPeriph_Driver 41 * @{ 42 */ 43 44 /** @addtogroup GPIO 45 * @{ 46 */ 47 48 /* Exported types ------------------------------------------------------------*/ 49 50 #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ 51 ((PERIPH) == GPIOB) || \ 52 ((PERIPH) == GPIOC) || \ 53 ((PERIPH) == GPIOD) || \ 54 ((PERIPH) == GPIOE) || \ 55 ((PERIPH) == GPIOF) || \ 56 ((PERIPH) == GPIOG) || \ 57 ((PERIPH) == GPIOH) || \ 58 ((PERIPH) == GPIOI) || \ 59 ((PERIPH) == GPIOJ) || \ 60 ((PERIPH) == GPIOK)) 61 62 /** 63 * @brief GPIO Configuration Mode enumeration 64 */ 65 typedef enum 66 { 67 GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */ 68 GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */ 69 GPIO_Mode_AF = 0x02, /*!< GPIO Alternate function Mode */ 70 GPIO_Mode_AN = 0x03 /*!< GPIO Analog Mode */ 71 }GPIOMode_TypeDef; 72 #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) || \ 73 ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN)) 74 75 /** 76 * @brief GPIO Output type enumeration 77 */ 78 typedef enum 79 { 80 GPIO_OType_PP = 0x00, 81 GPIO_OType_OD = 0x01 82 }GPIOOType_TypeDef; 83 #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD)) 84 85 86 /** 87 * @brief GPIO Output Maximum frequency enumeration 88 */ 89 typedef enum 90 { 91 GPIO_Low_Speed = 0x00, /*!< Low speed */ 92 GPIO_Medium_Speed = 0x01, /*!< Medium speed */ 93 GPIO_Fast_Speed = 0x02, /*!< Fast speed */ 94 GPIO_High_Speed = 0x03 /*!< High speed */ 95 }GPIOSpeed_TypeDef; 96 97 /* Add legacy definition */ 98 #define GPIO_Speed_2MHz GPIO_Low_Speed 99 #define GPIO_Speed_25MHz GPIO_Medium_Speed 100 #define GPIO_Speed_50MHz GPIO_Fast_Speed 101 #define GPIO_Speed_100MHz GPIO_High_Speed 102 103 #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Low_Speed) || ((SPEED) == GPIO_Medium_Speed) || \ 104 ((SPEED) == GPIO_Fast_Speed)|| ((SPEED) == GPIO_High_Speed)) 105 106 /** 107 * @brief GPIO Configuration PullUp PullDown enumeration 108 */ 109 typedef enum 110 { 111 GPIO_PuPd_NOPULL = 0x00, 112 GPIO_PuPd_UP = 0x01, 113 GPIO_PuPd_DOWN = 0x02 114 }GPIOPuPd_TypeDef; 115 #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \ 116 ((PUPD) == GPIO_PuPd_DOWN)) 117 118 /** 119 * @brief GPIO Bit SET and Bit RESET enumeration 120 */ 121 typedef enum 122 { 123 Bit_RESET = 0, 124 Bit_SET 125 }BitAction; 126 #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET)) 127 128 129 /** 130 * @brief GPIO Init structure definition 131 */ 132 typedef struct 133 { 134 uint32_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured. 135 This parameter can be any value of @ref GPIO_pins_define */ 136 137 GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. 138 This parameter can be a value of @ref GPIOMode_TypeDef */ 139 140 GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins. 141 This parameter can be a value of @ref GPIOSpeed_TypeDef */ 142 143 GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins. 144 This parameter can be a value of @ref GPIOOType_TypeDef */ 145 146 GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins. 147 This parameter can be a value of @ref GPIOPuPd_TypeDef */ 148 }GPIO_InitTypeDef; 149 150 /* Exported constants --------------------------------------------------------*/ 151 152 /** @defgroup GPIO_Exported_Constants 153 * @{ 154 */ 155 156 /** @defgroup GPIO_pins_define 157 * @{ 158 */ 159 #define GPIO_Pin_0 ((uint16_t)0x0001) /* Pin 0 selected */ 160 #define GPIO_Pin_1 ((uint16_t)0x0002) /* Pin 1 selected */ 161 #define GPIO_Pin_2 ((uint16_t)0x0004) /* Pin 2 selected */ 162 #define GPIO_Pin_3 ((uint16_t)0x0008) /* Pin 3 selected */ 163 #define GPIO_Pin_4 ((uint16_t)0x0010) /* Pin 4 selected */ 164 #define GPIO_Pin_5 ((uint16_t)0x0020) /* Pin 5 selected */ 165 #define GPIO_Pin_6 ((uint16_t)0x0040) /* Pin 6 selected */ 166 #define GPIO_Pin_7 ((uint16_t)0x0080) /* Pin 7 selected */ 167 #define GPIO_Pin_8 ((uint16_t)0x0100) /* Pin 8 selected */ 168 #define GPIO_Pin_9 ((uint16_t)0x0200) /* Pin 9 selected */ 169 #define GPIO_Pin_10 ((uint16_t)0x0400) /* Pin 10 selected */ 170 #define GPIO_Pin_11 ((uint16_t)0x0800) /* Pin 11 selected */ 171 #define GPIO_Pin_12 ((uint16_t)0x1000) /* Pin 12 selected */ 172 #define GPIO_Pin_13 ((uint16_t)0x2000) /* Pin 13 selected */ 173 #define GPIO_Pin_14 ((uint16_t)0x4000) /* Pin 14 selected */ 174 #define GPIO_Pin_15 ((uint16_t)0x8000) /* Pin 15 selected */ 175 #define GPIO_Pin_All ((uint16_t)0xFFFF) /* All pins selected */ 176 177 #define GPIO_PIN_MASK ((uint32_t)0x0000FFFF) /* PIN mask for assert test */ 178 #define IS_GPIO_PIN(PIN) (((PIN) & GPIO_PIN_MASK ) != (uint32_t)0x00) 179 #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \ 180 ((PIN) == GPIO_Pin_1) || \ 181 ((PIN) == GPIO_Pin_2) || \ 182 ((PIN) == GPIO_Pin_3) || \ 183 ((PIN) == GPIO_Pin_4) || \ 184 ((PIN) == GPIO_Pin_5) || \ 185 ((PIN) == GPIO_Pin_6) || \ 186 ((PIN) == GPIO_Pin_7) || \ 187 ((PIN) == GPIO_Pin_8) || \ 188 ((PIN) == GPIO_Pin_9) || \ 189 ((PIN) == GPIO_Pin_10) || \ 190 ((PIN) == GPIO_Pin_11) || \ 191 ((PIN) == GPIO_Pin_12) || \ 192 ((PIN) == GPIO_Pin_13) || \ 193 ((PIN) == GPIO_Pin_14) || \ 194 ((PIN) == GPIO_Pin_15)) 195 /** 196 * @} 197 */ 198 199 200 /** @defgroup GPIO_Pin_sources 201 * @{ 202 */ 203 #define GPIO_PinSource0 ((uint8_t)0x00) 204 #define GPIO_PinSource1 ((uint8_t)0x01) 205 #define GPIO_PinSource2 ((uint8_t)0x02) 206 #define GPIO_PinSource3 ((uint8_t)0x03) 207 #define GPIO_PinSource4 ((uint8_t)0x04) 208 #define GPIO_PinSource5 ((uint8_t)0x05) 209 #define GPIO_PinSource6 ((uint8_t)0x06) 210 #define GPIO_PinSource7 ((uint8_t)0x07) 211 #define GPIO_PinSource8 ((uint8_t)0x08) 212 #define GPIO_PinSource9 ((uint8_t)0x09) 213 #define GPIO_PinSource10 ((uint8_t)0x0A) 214 #define GPIO_PinSource11 ((uint8_t)0x0B) 215 #define GPIO_PinSource12 ((uint8_t)0x0C) 216 #define GPIO_PinSource13 ((uint8_t)0x0D) 217 #define GPIO_PinSource14 ((uint8_t)0x0E) 218 #define GPIO_PinSource15 ((uint8_t)0x0F) 219 220 #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \ 221 ((PINSOURCE) == GPIO_PinSource1) || \ 222 ((PINSOURCE) == GPIO_PinSource2) || \ 223 ((PINSOURCE) == GPIO_PinSource3) || \ 224 ((PINSOURCE) == GPIO_PinSource4) || \ 225 ((PINSOURCE) == GPIO_PinSource5) || \ 226 ((PINSOURCE) == GPIO_PinSource6) || \ 227 ((PINSOURCE) == GPIO_PinSource7) || \ 228 ((PINSOURCE) == GPIO_PinSource8) || \ 229 ((PINSOURCE) == GPIO_PinSource9) || \ 230 ((PINSOURCE) == GPIO_PinSource10) || \ 231 ((PINSOURCE) == GPIO_PinSource11) || \ 232 ((PINSOURCE) == GPIO_PinSource12) || \ 233 ((PINSOURCE) == GPIO_PinSource13) || \ 234 ((PINSOURCE) == GPIO_PinSource14) || \ 235 ((PINSOURCE) == GPIO_PinSource15)) 236 /** 237 * @} 238 */ 239 240 /** @defgroup GPIO_Alternat_function_selection_define 241 * @{ 242 */ 243 /** 244 * @brief AF 0 selection 245 */ 246 #define GPIO_AF_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ 247 #define GPIO_AF_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ 248 #define GPIO_AF_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ 249 #define GPIO_AF_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ 250 #define GPIO_AF_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ 251 252 /** 253 * @brief AF 1 selection 254 */ 255 #define GPIO_AF_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ 256 #define GPIO_AF_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ 257 258 /** 259 * @brief AF 2 selection 260 */ 261 #define GPIO_AF_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ 262 #define GPIO_AF_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ 263 #define GPIO_AF_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ 264 265 /** 266 * @brief AF 3 selection 267 */ 268 #define GPIO_AF_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ 269 #define GPIO_AF_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ 270 #define GPIO_AF_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ 271 #define GPIO_AF_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ 272 273 /** 274 * @brief AF 4 selection 275 */ 276 #define GPIO_AF_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ 277 #define GPIO_AF_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ 278 #define GPIO_AF_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ 279 280 /** 281 * @brief AF 5 selection 282 */ 283 #define GPIO_AF_SPI1 ((uint8_t)0x05) /* SPI1/I2S1 Alternate Function mapping */ 284 #define GPIO_AF_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ 285 #define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI3/I2S3 Alternate Function mapping (Only for STM32F411xE Devices) */ 286 #define GPIO_AF_SPI4 ((uint8_t)0x05) /* SPI4/I2S4 Alternate Function mapping */ 287 #define GPIO_AF_SPI5 ((uint8_t)0x05) /* SPI5 Alternate Function mapping */ 288 #define GPIO_AF_SPI6 ((uint8_t)0x05) /* SPI6 Alternate Function mapping */ 289 290 /** 291 * @brief AF 6 selection 292 */ 293 #define GPIO_AF_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ 294 #define GPIO_AF6_SPI2 ((uint8_t)0x06) /* SPI2 Alternate Function mapping (Only for STM32F411xE Devices) */ 295 #define GPIO_AF6_SPI4 ((uint8_t)0x06) /* SPI4 Alternate Function mapping (Only for STM32F411xE Devices) */ 296 #define GPIO_AF6_SPI5 ((uint8_t)0x06) /* SPI5 Alternate Function mapping (Only for STM32F411xE Devices) */ 297 #define GPIO_AF_SAI1 ((uint8_t)0x06) /* SAI1 Alternate Function mapping */ 298 299 /** 300 * @brief AF 7 selection 301 */ 302 #define GPIO_AF_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ 303 #define GPIO_AF_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ 304 #define GPIO_AF_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ 305 #define GPIO_AF7_SPI3 ((uint8_t)0x07) /* SPI3/I2S3ext Alternate Function mapping */ 306 307 /** 308 * @brief AF 7 selection Legacy 309 */ 310 #define GPIO_AF_I2S3ext GPIO_AF7_SPI3 311 312 /** 313 * @brief AF 8 selection 314 */ 315 #define GPIO_AF_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ 316 #define GPIO_AF_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ 317 #define GPIO_AF_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ 318 #define GPIO_AF_UART7 ((uint8_t)0x08) /* UART7 Alternate Function mapping */ 319 #define GPIO_AF_UART8 ((uint8_t)0x08) /* UART8 Alternate Function mapping */ 320 321 /** 322 * @brief AF 9 selection 323 */ 324 #define GPIO_AF_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ 325 #define GPIO_AF_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ 326 #define GPIO_AF_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ 327 #define GPIO_AF_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ 328 #define GPIO_AF_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ 329 330 #define GPIO_AF9_I2C2 ((uint8_t)0x09) /* I2C2 Alternate Function mapping (Only for STM32F401xx/STM32F411xE Devices) */ 331 #define GPIO_AF9_I2C3 ((uint8_t)0x09) /* I2C3 Alternate Function mapping (Only for STM32F401xx/STM32F411xE Devices) */ 332 333 /** 334 * @brief AF 10 selection 335 */ 336 #define GPIO_AF_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ 337 #define GPIO_AF_OTG_HS ((uint8_t)0xA) /* OTG_HS Alternate Function mapping */ 338 339 /** 340 * @brief AF 11 selection 341 */ 342 #define GPIO_AF_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */ 343 344 /** 345 * @brief AF 12 selection 346 */ 347 #if defined (STM32F40_41xxx) 348 #define GPIO_AF_FSMC ((uint8_t)0xC) /* FSMC Alternate Function mapping */ 349 #endif /* STM32F40_41xxx */ 350 351 #if defined (STM32F427_437xx) || defined (STM32F429_439xx) 352 #define GPIO_AF_FMC ((uint8_t)0xC) /* FMC Alternate Function mapping */ 353 #endif /* STM32F427_437xx || STM32F429_439xx */ 354 355 #define GPIO_AF_OTG_HS_FS ((uint8_t)0xC) /* OTG HS configured in FS, Alternate Function mapping */ 356 #define GPIO_AF_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ 357 358 /** 359 * @brief AF 13 selection 360 */ 361 #define GPIO_AF_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ 362 363 /** 364 * @brief AF 14 selection 365 */ 366 367 #define GPIO_AF_LTDC ((uint8_t)0x0E) /* LCD-TFT Alternate Function mapping */ 368 369 /** 370 * @brief AF 15 selection 371 */ 372 #define GPIO_AF_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ 373 374 #if defined (STM32F40_41xxx) 375 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_RTC_50Hz) || ((AF) == GPIO_AF_TIM14) || \ 376 ((AF) == GPIO_AF_MCO) || ((AF) == GPIO_AF_TAMPER) || \ 377 ((AF) == GPIO_AF_SWJ) || ((AF) == GPIO_AF_TRACE) || \ 378 ((AF) == GPIO_AF_TIM1) || ((AF) == GPIO_AF_TIM2) || \ 379 ((AF) == GPIO_AF_TIM3) || ((AF) == GPIO_AF_TIM4) || \ 380 ((AF) == GPIO_AF_TIM5) || ((AF) == GPIO_AF_TIM8) || \ 381 ((AF) == GPIO_AF_I2C1) || ((AF) == GPIO_AF_I2C2) || \ 382 ((AF) == GPIO_AF_I2C3) || ((AF) == GPIO_AF_SPI1) || \ 383 ((AF) == GPIO_AF_SPI2) || ((AF) == GPIO_AF_TIM13) || \ 384 ((AF) == GPIO_AF_SPI3) || ((AF) == GPIO_AF_TIM14) || \ 385 ((AF) == GPIO_AF_USART1) || ((AF) == GPIO_AF_USART2) || \ 386 ((AF) == GPIO_AF_USART3) || ((AF) == GPIO_AF_UART4) || \ 387 ((AF) == GPIO_AF_UART5) || ((AF) == GPIO_AF_USART6) || \ 388 ((AF) == GPIO_AF_CAN1) || ((AF) == GPIO_AF_CAN2) || \ 389 ((AF) == GPIO_AF_OTG_FS) || ((AF) == GPIO_AF_OTG_HS) || \ 390 ((AF) == GPIO_AF_ETH) || ((AF) == GPIO_AF_OTG_HS_FS) || \ 391 ((AF) == GPIO_AF_SDIO) || ((AF) == GPIO_AF_DCMI) || \ 392 ((AF) == GPIO_AF_EVENTOUT) || ((AF) == GPIO_AF_FSMC)) 393 #endif /* STM32F40_41xxx */ 394 395 #if defined (STM32F401xx) 396 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_RTC_50Hz) || ((AF) == GPIO_AF_TIM14) || \ 397 ((AF) == GPIO_AF_MCO) || ((AF) == GPIO_AF_TAMPER) || \ 398 ((AF) == GPIO_AF_SWJ) || ((AF) == GPIO_AF_TRACE) || \ 399 ((AF) == GPIO_AF_TIM1) || ((AF) == GPIO_AF_TIM2) || \ 400 ((AF) == GPIO_AF_TIM3) || ((AF) == GPIO_AF_TIM4) || \ 401 ((AF) == GPIO_AF_TIM5) || ((AF) == GPIO_AF_TIM8) || \ 402 ((AF) == GPIO_AF_I2C1) || ((AF) == GPIO_AF_I2C2) || \ 403 ((AF) == GPIO_AF_I2C3) || ((AF) == GPIO_AF_SPI1) || \ 404 ((AF) == GPIO_AF_SPI2) || ((AF) == GPIO_AF_TIM13) || \ 405 ((AF) == GPIO_AF_SPI3) || ((AF) == GPIO_AF_TIM14) || \ 406 ((AF) == GPIO_AF_USART1) || ((AF) == GPIO_AF_USART2) || \ 407 ((AF) == GPIO_AF_SDIO) || ((AF) == GPIO_AF_USART6) || \ 408 ((AF) == GPIO_AF_OTG_FS) || ((AF) == GPIO_AF_OTG_HS) || \ 409 ((AF) == GPIO_AF_EVENTOUT) || ((AF) == GPIO_AF_SPI4)) 410 #endif /* STM32F401xx */ 411 412 #if defined (STM32F411xE) 413 #define IS_GPIO_AF(AF) (((AF) < 16) && ((AF) != 11) && ((AF) != 13) && ((AF) != 14)) 414 #endif /* STM32F411xE */ 415 416 #if defined (STM32F427_437xx) || defined (STM32F429_439xx) 417 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_RTC_50Hz) || ((AF) == GPIO_AF_TIM14) || \ 418 ((AF) == GPIO_AF_MCO) || ((AF) == GPIO_AF_TAMPER) || \ 419 ((AF) == GPIO_AF_SWJ) || ((AF) == GPIO_AF_TRACE) || \ 420 ((AF) == GPIO_AF_TIM1) || ((AF) == GPIO_AF_TIM2) || \ 421 ((AF) == GPIO_AF_TIM3) || ((AF) == GPIO_AF_TIM4) || \ 422 ((AF) == GPIO_AF_TIM5) || ((AF) == GPIO_AF_TIM8) || \ 423 ((AF) == GPIO_AF_I2C1) || ((AF) == GPIO_AF_I2C2) || \ 424 ((AF) == GPIO_AF_I2C3) || ((AF) == GPIO_AF_SPI1) || \ 425 ((AF) == GPIO_AF_SPI2) || ((AF) == GPIO_AF_TIM13) || \ 426 ((AF) == GPIO_AF_SPI3) || ((AF) == GPIO_AF_TIM14) || \ 427 ((AF) == GPIO_AF_USART1) || ((AF) == GPIO_AF_USART2) || \ 428 ((AF) == GPIO_AF_USART3) || ((AF) == GPIO_AF_UART4) || \ 429 ((AF) == GPIO_AF_UART5) || ((AF) == GPIO_AF_USART6) || \ 430 ((AF) == GPIO_AF_CAN1) || ((AF) == GPIO_AF_CAN2) || \ 431 ((AF) == GPIO_AF_OTG_FS) || ((AF) == GPIO_AF_OTG_HS) || \ 432 ((AF) == GPIO_AF_ETH) || ((AF) == GPIO_AF_OTG_HS_FS) || \ 433 ((AF) == GPIO_AF_SDIO) || ((AF) == GPIO_AF_DCMI) || \ 434 ((AF) == GPIO_AF_EVENTOUT) || ((AF) == GPIO_AF_SPI4) || \ 435 ((AF) == GPIO_AF_SPI5) || ((AF) == GPIO_AF_SPI6) || \ 436 ((AF) == GPIO_AF_UART7) || ((AF) == GPIO_AF_UART8) || \ 437 ((AF) == GPIO_AF_FMC) || ((AF) == GPIO_AF_SAI1) || \ 438 ((AF) == GPIO_AF_LTDC)) 439 #endif /* STM32F427_437xx || STM32F429_439xx */ 440 441 /** 442 * @} 443 */ 444 445 /** @defgroup GPIO_Legacy 446 * @{ 447 */ 448 449 #define GPIO_Mode_AIN GPIO_Mode_AN 450 451 #define GPIO_AF_OTG1_FS GPIO_AF_OTG_FS 452 #define GPIO_AF_OTG2_HS GPIO_AF_OTG_HS 453 #define GPIO_AF_OTG2_FS GPIO_AF_OTG_HS_FS 454 455 /** 456 * @} 457 */ 458 459 /** 460 * @} 461 */ 462 463 /* Exported macro ------------------------------------------------------------*/ 464 /* Exported functions --------------------------------------------------------*/ 465 466 /* Function used to set the GPIO configuration to the default reset state ****/ 467 void GPIO_DeInit(GPIO_TypeDef* GPIOx); 468 469 /* Initialization and Configuration functions *********************************/ 470 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); 471 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); 472 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 473 474 /* GPIO Read and Write functions **********************************************/ 475 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 476 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); 477 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 478 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); 479 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 480 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 481 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); 482 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); 483 void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 484 485 /* GPIO Alternate functions configuration function ****************************/ 486 void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF); 487 488 #ifdef __cplusplus 489 } 490 #endif 491 492 #endif /*__STM32F4xx_GPIO_H */ 493 494 /** 495 * @} 496 */ 497 498 /** 499 * @} 500 */ 501 502 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 503