Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 X_NUCLEO_IKS01A1 mbed
Fork of HelloWorld_IKS01A1 by
stm32f4xx_gpio.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_gpio.h 00004 * @author MCD Application Team 00005 * @version V1.0.0 00006 * @date 30-September-2011 00007 * @brief This file contains all the functions prototypes for the GPIO firmware 00008 * library. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00013 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00014 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00015 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00016 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00017 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00018 * 00019 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> 00020 ****************************************************************************** 00021 */ 00022 00023 /* Define to prevent recursive inclusion -------------------------------------*/ 00024 #ifndef __STM32F4xx_GPIO_H 00025 #define __STM32F4xx_GPIO_H 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 /* Includes ------------------------------------------------------------------*/ 00032 #include "stm32f4xx.h" 00033 00034 /** @addtogroup STM32F4xx_StdPeriph_Driver 00035 * @{ 00036 */ 00037 00038 /** @addtogroup GPIO 00039 * @{ 00040 */ 00041 00042 /* Exported types ------------------------------------------------------------*/ 00043 00044 #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ 00045 ((PERIPH) == GPIOB) || \ 00046 ((PERIPH) == GPIOC) || \ 00047 ((PERIPH) == GPIOD) || \ 00048 ((PERIPH) == GPIOE) || \ 00049 ((PERIPH) == GPIOF) || \ 00050 ((PERIPH) == GPIOG) || \ 00051 ((PERIPH) == GPIOH) || \ 00052 ((PERIPH) == GPIOI)) 00053 00054 /** 00055 * @brief GPIO Configuration Mode enumeration 00056 */ 00057 typedef enum 00058 { 00059 GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */ 00060 GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */ 00061 GPIO_Mode_AF = 0x02, /*!< GPIO Alternate function Mode */ 00062 GPIO_Mode_AN = 0x03 /*!< GPIO Analog Mode */ 00063 }GPIOMode_TypeDef; 00064 #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) || \ 00065 ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN)) 00066 00067 /** 00068 * @brief GPIO Output type enumeration 00069 */ 00070 typedef enum 00071 { 00072 GPIO_OType_PP = 0x00, 00073 GPIO_OType_OD = 0x01 00074 }GPIOOType_TypeDef; 00075 #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD)) 00076 00077 00078 /** 00079 * @brief GPIO Output Maximum frequency enumeration 00080 */ 00081 typedef enum 00082 { 00083 GPIO_Speed_2MHz = 0x00, /*!< Low speed */ 00084 GPIO_Speed_25MHz = 0x01, /*!< Medium speed */ 00085 GPIO_Speed_50MHz = 0x02, /*!< Fast speed */ 00086 GPIO_Speed_100MHz = 0x03 /*!< High speed on 30 pF (80 MHz Output max speed on 15 pF) */ 00087 }GPIOSpeed_TypeDef; 00088 #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_2MHz) || ((SPEED) == GPIO_Speed_25MHz) || \ 00089 ((SPEED) == GPIO_Speed_50MHz)|| ((SPEED) == GPIO_Speed_100MHz)) 00090 00091 /** 00092 * @brief GPIO Configuration PullUp PullDown enumeration 00093 */ 00094 typedef enum 00095 { 00096 GPIO_PuPd_NOPULL = 0x00, 00097 GPIO_PuPd_UP = 0x01, 00098 GPIO_PuPd_DOWN = 0x02 00099 }GPIOPuPd_TypeDef; 00100 #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \ 00101 ((PUPD) == GPIO_PuPd_DOWN)) 00102 00103 /** 00104 * @brief GPIO Bit SET and Bit RESET enumeration 00105 */ 00106 typedef enum 00107 { 00108 Bit_RESET = 0, 00109 Bit_SET 00110 }BitAction; 00111 #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET)) 00112 00113 00114 /** 00115 * @brief GPIO Init structure definition 00116 */ 00117 typedef struct 00118 { 00119 uint32_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured. 00120 This parameter can be any value of @ref GPIO_pins_define */ 00121 00122 GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. 00123 This parameter can be a value of @ref GPIOMode_TypeDef */ 00124 00125 GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins. 00126 This parameter can be a value of @ref GPIOSpeed_TypeDef */ 00127 00128 GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins. 00129 This parameter can be a value of @ref GPIOOType_TypeDef */ 00130 00131 GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins. 00132 This parameter can be a value of @ref GPIOPuPd_TypeDef */ 00133 }GPIO_InitTypeDef; 00134 00135 /* Exported constants --------------------------------------------------------*/ 00136 00137 /** @defgroup GPIO_Exported_Constants 00138 * @{ 00139 */ 00140 00141 /** @defgroup GPIO_pins_define 00142 * @{ 00143 */ 00144 #define GPIO_Pin_0 ((uint16_t)0x0001) /* Pin 0 selected */ 00145 #define GPIO_Pin_1 ((uint16_t)0x0002) /* Pin 1 selected */ 00146 #define GPIO_Pin_2 ((uint16_t)0x0004) /* Pin 2 selected */ 00147 #define GPIO_Pin_3 ((uint16_t)0x0008) /* Pin 3 selected */ 00148 #define GPIO_Pin_4 ((uint16_t)0x0010) /* Pin 4 selected */ 00149 #define GPIO_Pin_5 ((uint16_t)0x0020) /* Pin 5 selected */ 00150 #define GPIO_Pin_6 ((uint16_t)0x0040) /* Pin 6 selected */ 00151 #define GPIO_Pin_7 ((uint16_t)0x0080) /* Pin 7 selected */ 00152 #define GPIO_Pin_8 ((uint16_t)0x0100) /* Pin 8 selected */ 00153 #define GPIO_Pin_9 ((uint16_t)0x0200) /* Pin 9 selected */ 00154 #define GPIO_Pin_10 ((uint16_t)0x0400) /* Pin 10 selected */ 00155 #define GPIO_Pin_11 ((uint16_t)0x0800) /* Pin 11 selected */ 00156 #define GPIO_Pin_12 ((uint16_t)0x1000) /* Pin 12 selected */ 00157 #define GPIO_Pin_13 ((uint16_t)0x2000) /* Pin 13 selected */ 00158 #define GPIO_Pin_14 ((uint16_t)0x4000) /* Pin 14 selected */ 00159 #define GPIO_Pin_15 ((uint16_t)0x8000) /* Pin 15 selected */ 00160 #define GPIO_Pin_All ((uint16_t)0xFFFF) /* All pins selected */ 00161 00162 #define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00)) 00163 #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \ 00164 ((PIN) == GPIO_Pin_1) || \ 00165 ((PIN) == GPIO_Pin_2) || \ 00166 ((PIN) == GPIO_Pin_3) || \ 00167 ((PIN) == GPIO_Pin_4) || \ 00168 ((PIN) == GPIO_Pin_5) || \ 00169 ((PIN) == GPIO_Pin_6) || \ 00170 ((PIN) == GPIO_Pin_7) || \ 00171 ((PIN) == GPIO_Pin_8) || \ 00172 ((PIN) == GPIO_Pin_9) || \ 00173 ((PIN) == GPIO_Pin_10) || \ 00174 ((PIN) == GPIO_Pin_11) || \ 00175 ((PIN) == GPIO_Pin_12) || \ 00176 ((PIN) == GPIO_Pin_13) || \ 00177 ((PIN) == GPIO_Pin_14) || \ 00178 ((PIN) == GPIO_Pin_15)) 00179 /** 00180 * @} 00181 */ 00182 00183 00184 /** @defgroup GPIO_Pin_sources 00185 * @{ 00186 */ 00187 #define GPIO_PinSource0 ((uint8_t)0x00) 00188 #define GPIO_PinSource1 ((uint8_t)0x01) 00189 #define GPIO_PinSource2 ((uint8_t)0x02) 00190 #define GPIO_PinSource3 ((uint8_t)0x03) 00191 #define GPIO_PinSource4 ((uint8_t)0x04) 00192 #define GPIO_PinSource5 ((uint8_t)0x05) 00193 #define GPIO_PinSource6 ((uint8_t)0x06) 00194 #define GPIO_PinSource7 ((uint8_t)0x07) 00195 #define GPIO_PinSource8 ((uint8_t)0x08) 00196 #define GPIO_PinSource9 ((uint8_t)0x09) 00197 #define GPIO_PinSource10 ((uint8_t)0x0A) 00198 #define GPIO_PinSource11 ((uint8_t)0x0B) 00199 #define GPIO_PinSource12 ((uint8_t)0x0C) 00200 #define GPIO_PinSource13 ((uint8_t)0x0D) 00201 #define GPIO_PinSource14 ((uint8_t)0x0E) 00202 #define GPIO_PinSource15 ((uint8_t)0x0F) 00203 00204 #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \ 00205 ((PINSOURCE) == GPIO_PinSource1) || \ 00206 ((PINSOURCE) == GPIO_PinSource2) || \ 00207 ((PINSOURCE) == GPIO_PinSource3) || \ 00208 ((PINSOURCE) == GPIO_PinSource4) || \ 00209 ((PINSOURCE) == GPIO_PinSource5) || \ 00210 ((PINSOURCE) == GPIO_PinSource6) || \ 00211 ((PINSOURCE) == GPIO_PinSource7) || \ 00212 ((PINSOURCE) == GPIO_PinSource8) || \ 00213 ((PINSOURCE) == GPIO_PinSource9) || \ 00214 ((PINSOURCE) == GPIO_PinSource10) || \ 00215 ((PINSOURCE) == GPIO_PinSource11) || \ 00216 ((PINSOURCE) == GPIO_PinSource12) || \ 00217 ((PINSOURCE) == GPIO_PinSource13) || \ 00218 ((PINSOURCE) == GPIO_PinSource14) || \ 00219 ((PINSOURCE) == GPIO_PinSource15)) 00220 /** 00221 * @} 00222 */ 00223 00224 /** @defgroup GPIO_Alternat_function_selection_define 00225 * @{ 00226 */ 00227 /** 00228 * @brief AF 0 selection 00229 */ 00230 #define GPIO_AF_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ 00231 #define GPIO_AF_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ 00232 #define GPIO_AF_TAMPER ((uint8_t)0x00) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ 00233 #define GPIO_AF_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ 00234 #define GPIO_AF_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ 00235 00236 /** 00237 * @brief AF 1 selection 00238 */ 00239 #define GPIO_AF_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ 00240 #define GPIO_AF_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ 00241 00242 /** 00243 * @brief AF 2 selection 00244 */ 00245 #define GPIO_AF_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ 00246 #define GPIO_AF_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ 00247 #define GPIO_AF_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ 00248 00249 /** 00250 * @brief AF 3 selection 00251 */ 00252 #define GPIO_AF_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ 00253 #define GPIO_AF_TIM9 ((uint8_t)0x03) /* TIM9 Alternate Function mapping */ 00254 #define GPIO_AF_TIM10 ((uint8_t)0x03) /* TIM10 Alternate Function mapping */ 00255 #define GPIO_AF_TIM11 ((uint8_t)0x03) /* TIM11 Alternate Function mapping */ 00256 00257 /** 00258 * @brief AF 4 selection 00259 */ 00260 #define GPIO_AF_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ 00261 #define GPIO_AF_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ 00262 #define GPIO_AF_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ 00263 00264 /** 00265 * @brief AF 5 selection 00266 */ 00267 #define GPIO_AF_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ 00268 #define GPIO_AF_SPI2 ((uint8_t)0x05) /* SPI2/I2S2 Alternate Function mapping */ 00269 00270 /** 00271 * @brief AF 6 selection 00272 */ 00273 #define GPIO_AF_SPI3 ((uint8_t)0x06) /* SPI3/I2S3 Alternate Function mapping */ 00274 00275 /** 00276 * @brief AF 7 selection 00277 */ 00278 #define GPIO_AF_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ 00279 #define GPIO_AF_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ 00280 #define GPIO_AF_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ 00281 #define GPIO_AF_I2S3ext ((uint8_t)0x07) /* I2S3ext Alternate Function mapping */ 00282 00283 /** 00284 * @brief AF 8 selection 00285 */ 00286 #define GPIO_AF_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ 00287 #define GPIO_AF_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ 00288 #define GPIO_AF_USART6 ((uint8_t)0x08) /* USART6 Alternate Function mapping */ 00289 00290 /** 00291 * @brief AF 9 selection 00292 */ 00293 #define GPIO_AF_CAN1 ((uint8_t)0x09) /* CAN1 Alternate Function mapping */ 00294 #define GPIO_AF_CAN2 ((uint8_t)0x09) /* CAN2 Alternate Function mapping */ 00295 #define GPIO_AF_TIM12 ((uint8_t)0x09) /* TIM12 Alternate Function mapping */ 00296 #define GPIO_AF_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ 00297 #define GPIO_AF_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ 00298 00299 /** 00300 * @brief AF 10 selection 00301 */ 00302 #define GPIO_AF_OTG_FS ((uint8_t)0xA) /* OTG_FS Alternate Function mapping */ 00303 #define GPIO_AF_OTG_HS ((uint8_t)0xA) /* OTG_HS Alternate Function mapping */ 00304 00305 /** 00306 * @brief AF 11 selection 00307 */ 00308 #define GPIO_AF_ETH ((uint8_t)0x0B) /* ETHERNET Alternate Function mapping */ 00309 00310 /** 00311 * @brief AF 12 selection 00312 */ 00313 #define GPIO_AF_FSMC ((uint8_t)0xC) /* FSMC Alternate Function mapping */ 00314 #define GPIO_AF_OTG_HS_FS ((uint8_t)0xC) /* OTG HS configured in FS, Alternate Function mapping */ 00315 #define GPIO_AF_SDIO ((uint8_t)0xC) /* SDIO Alternate Function mapping */ 00316 00317 /** 00318 * @brief AF 13 selection 00319 */ 00320 #define GPIO_AF_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ 00321 00322 /** 00323 * @brief AF 15 selection 00324 */ 00325 #define GPIO_AF_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ 00326 00327 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_RTC_50Hz) || ((AF) == GPIO_AF_TIM14) || \ 00328 ((AF) == GPIO_AF_MCO) || ((AF) == GPIO_AF_TAMPER) || \ 00329 ((AF) == GPIO_AF_SWJ) || ((AF) == GPIO_AF_TRACE) || \ 00330 ((AF) == GPIO_AF_TIM1) || ((AF) == GPIO_AF_TIM2) || \ 00331 ((AF) == GPIO_AF_TIM3) || ((AF) == GPIO_AF_TIM4) || \ 00332 ((AF) == GPIO_AF_TIM5) || ((AF) == GPIO_AF_TIM8) || \ 00333 ((AF) == GPIO_AF_I2C1) || ((AF) == GPIO_AF_I2C2) || \ 00334 ((AF) == GPIO_AF_I2C3) || ((AF) == GPIO_AF_SPI1) || \ 00335 ((AF) == GPIO_AF_SPI2) || ((AF) == GPIO_AF_TIM13) || \ 00336 ((AF) == GPIO_AF_SPI3) || ((AF) == GPIO_AF_TIM14) || \ 00337 ((AF) == GPIO_AF_USART1) || ((AF) == GPIO_AF_USART2) || \ 00338 ((AF) == GPIO_AF_USART3) || ((AF) == GPIO_AF_UART4) || \ 00339 ((AF) == GPIO_AF_UART5) || ((AF) == GPIO_AF_USART6) || \ 00340 ((AF) == GPIO_AF_CAN1) || ((AF) == GPIO_AF_CAN2) || \ 00341 ((AF) == GPIO_AF_OTG_FS) || ((AF) == GPIO_AF_OTG_HS) || \ 00342 ((AF) == GPIO_AF_ETH) || ((AF) == GPIO_AF_FSMC) || \ 00343 ((AF) == GPIO_AF_OTG_HS_FS) || ((AF) == GPIO_AF_SDIO) || \ 00344 ((AF) == GPIO_AF_DCMI) || ((AF) == GPIO_AF_EVENTOUT)) 00345 /** 00346 * @} 00347 */ 00348 00349 /** @defgroup GPIO_Legacy 00350 * @{ 00351 */ 00352 00353 #define GPIO_Mode_AIN GPIO_Mode_AN 00354 00355 #define GPIO_AF_OTG1_FS GPIO_AF_OTG_FS 00356 #define GPIO_AF_OTG2_HS GPIO_AF_OTG_HS 00357 #define GPIO_AF_OTG2_FS GPIO_AF_OTG_HS_FS 00358 00359 /** 00360 * @} 00361 */ 00362 00363 /** 00364 * @} 00365 */ 00366 00367 /* Exported macro ------------------------------------------------------------*/ 00368 /* Exported functions --------------------------------------------------------*/ 00369 00370 /* Function used to set the GPIO configuration to the default reset state ****/ 00371 void GPIO_DeInit(GPIO_TypeDef* GPIOx); 00372 00373 /* Initialization and Configuration functions *********************************/ 00374 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); 00375 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); 00376 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 00377 00378 /* GPIO Read and Write functions **********************************************/ 00379 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 00380 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); 00381 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 00382 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); 00383 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 00384 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 00385 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); 00386 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); 00387 void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); 00388 00389 /* GPIO Alternate functions configuration function ****************************/ 00390 void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF); 00391 00392 #ifdef __cplusplus 00393 } 00394 #endif 00395 00396 #endif /*__STM32F4xx_GPIO_H */ 00397 00398 /** 00399 * @} 00400 */ 00401 00402 /** 00403 * @} 00404 */ 00405 00406 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 00407
Generated on Tue Jul 12 2022 19:53:13 by
