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.
Dependents: Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more
inc/stm32f30x_gpio.h@0:404f5a4f1385, 2016-05-09 (annotated)
- Committer:
- MartinJohnson
- Date:
- Mon May 09 04:00:25 2016 +0000
- Revision:
- 0:404f5a4f1385
Initial library for STM32F3 discovery board
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MartinJohnson | 0:404f5a4f1385 | 1 | /** |
| MartinJohnson | 0:404f5a4f1385 | 2 | ****************************************************************************** |
| MartinJohnson | 0:404f5a4f1385 | 3 | * @file stm32f30x_gpio.h |
| MartinJohnson | 0:404f5a4f1385 | 4 | * @author MCD Application Team |
| MartinJohnson | 0:404f5a4f1385 | 5 | * @version V1.2.3 |
| MartinJohnson | 0:404f5a4f1385 | 6 | * @date 10-July-2015 |
| MartinJohnson | 0:404f5a4f1385 | 7 | * @brief This file contains all the functions prototypes for the GPIO |
| MartinJohnson | 0:404f5a4f1385 | 8 | * firmware library. |
| MartinJohnson | 0:404f5a4f1385 | 9 | ****************************************************************************** |
| MartinJohnson | 0:404f5a4f1385 | 10 | * @attention |
| MartinJohnson | 0:404f5a4f1385 | 11 | * |
| MartinJohnson | 0:404f5a4f1385 | 12 | * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> |
| MartinJohnson | 0:404f5a4f1385 | 13 | * |
| MartinJohnson | 0:404f5a4f1385 | 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
| MartinJohnson | 0:404f5a4f1385 | 15 | * You may not use this file except in compliance with the License. |
| MartinJohnson | 0:404f5a4f1385 | 16 | * You may obtain a copy of the License at: |
| MartinJohnson | 0:404f5a4f1385 | 17 | * |
| MartinJohnson | 0:404f5a4f1385 | 18 | * http://www.st.com/software_license_agreement_liberty_v2 |
| MartinJohnson | 0:404f5a4f1385 | 19 | * |
| MartinJohnson | 0:404f5a4f1385 | 20 | * Unless required by applicable law or agreed to in writing, software |
| MartinJohnson | 0:404f5a4f1385 | 21 | * distributed under the License is distributed on an "AS IS" BASIS, |
| MartinJohnson | 0:404f5a4f1385 | 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| MartinJohnson | 0:404f5a4f1385 | 23 | * See the License for the specific language governing permissions and |
| MartinJohnson | 0:404f5a4f1385 | 24 | * limitations under the License. |
| MartinJohnson | 0:404f5a4f1385 | 25 | * |
| MartinJohnson | 0:404f5a4f1385 | 26 | ****************************************************************************** |
| MartinJohnson | 0:404f5a4f1385 | 27 | */ |
| MartinJohnson | 0:404f5a4f1385 | 28 | |
| MartinJohnson | 0:404f5a4f1385 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| MartinJohnson | 0:404f5a4f1385 | 30 | #ifndef __STM32F30x_GPIO_H |
| MartinJohnson | 0:404f5a4f1385 | 31 | #define __STM32F30x_GPIO_H |
| MartinJohnson | 0:404f5a4f1385 | 32 | |
| MartinJohnson | 0:404f5a4f1385 | 33 | #ifdef __cplusplus |
| MartinJohnson | 0:404f5a4f1385 | 34 | extern "C" { |
| MartinJohnson | 0:404f5a4f1385 | 35 | #endif |
| MartinJohnson | 0:404f5a4f1385 | 36 | |
| MartinJohnson | 0:404f5a4f1385 | 37 | /* Includes ------------------------------------------------------------------*/ |
| MartinJohnson | 0:404f5a4f1385 | 38 | #include "stm32f30x.h" |
| MartinJohnson | 0:404f5a4f1385 | 39 | |
| MartinJohnson | 0:404f5a4f1385 | 40 | /** @addtogroup STM32F30x_StdPeriph_Driver |
| MartinJohnson | 0:404f5a4f1385 | 41 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 42 | */ |
| MartinJohnson | 0:404f5a4f1385 | 43 | |
| MartinJohnson | 0:404f5a4f1385 | 44 | /** @addtogroup GPIO |
| MartinJohnson | 0:404f5a4f1385 | 45 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 46 | */ |
| MartinJohnson | 0:404f5a4f1385 | 47 | |
| MartinJohnson | 0:404f5a4f1385 | 48 | /* Exported types ------------------------------------------------------------*/ |
| MartinJohnson | 0:404f5a4f1385 | 49 | |
| MartinJohnson | 0:404f5a4f1385 | 50 | #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ |
| MartinJohnson | 0:404f5a4f1385 | 51 | ((PERIPH) == GPIOB) || \ |
| MartinJohnson | 0:404f5a4f1385 | 52 | ((PERIPH) == GPIOC) || \ |
| MartinJohnson | 0:404f5a4f1385 | 53 | ((PERIPH) == GPIOD) || \ |
| MartinJohnson | 0:404f5a4f1385 | 54 | ((PERIPH) == GPIOE) || \ |
| MartinJohnson | 0:404f5a4f1385 | 55 | ((PERIPH) == GPIOF) || \ |
| MartinJohnson | 0:404f5a4f1385 | 56 | ((PERIPH) == GPIOG) || \ |
| MartinJohnson | 0:404f5a4f1385 | 57 | ((PERIPH) == GPIOH)) |
| MartinJohnson | 0:404f5a4f1385 | 58 | |
| MartinJohnson | 0:404f5a4f1385 | 59 | #define IS_GPIO_LIST_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ |
| MartinJohnson | 0:404f5a4f1385 | 60 | ((PERIPH) == GPIOB) || \ |
| MartinJohnson | 0:404f5a4f1385 | 61 | ((PERIPH) == GPIOC)|| \ |
| MartinJohnson | 0:404f5a4f1385 | 62 | ((PERIPH) == GPIOD) || \ |
| MartinJohnson | 0:404f5a4f1385 | 63 | ((PERIPH) == GPIOF)) |
| MartinJohnson | 0:404f5a4f1385 | 64 | /** @defgroup Configuration_Mode_enumeration |
| MartinJohnson | 0:404f5a4f1385 | 65 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 66 | */ |
| MartinJohnson | 0:404f5a4f1385 | 67 | typedef enum |
| MartinJohnson | 0:404f5a4f1385 | 68 | { |
| MartinJohnson | 0:404f5a4f1385 | 69 | GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */ |
| MartinJohnson | 0:404f5a4f1385 | 70 | GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */ |
| MartinJohnson | 0:404f5a4f1385 | 71 | GPIO_Mode_AF = 0x02, /*!< GPIO Alternate function Mode */ |
| MartinJohnson | 0:404f5a4f1385 | 72 | GPIO_Mode_AN = 0x03 /*!< GPIO Analog In/Out Mode */ |
| MartinJohnson | 0:404f5a4f1385 | 73 | }GPIOMode_TypeDef; |
| MartinJohnson | 0:404f5a4f1385 | 74 | |
| MartinJohnson | 0:404f5a4f1385 | 75 | #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN)|| ((MODE) == GPIO_Mode_OUT) || \ |
| MartinJohnson | 0:404f5a4f1385 | 76 | ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN)) |
| MartinJohnson | 0:404f5a4f1385 | 77 | /** |
| MartinJohnson | 0:404f5a4f1385 | 78 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 79 | */ |
| MartinJohnson | 0:404f5a4f1385 | 80 | |
| MartinJohnson | 0:404f5a4f1385 | 81 | /** @defgroup Output_type_enumeration |
| MartinJohnson | 0:404f5a4f1385 | 82 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 83 | */ |
| MartinJohnson | 0:404f5a4f1385 | 84 | typedef enum |
| MartinJohnson | 0:404f5a4f1385 | 85 | { |
| MartinJohnson | 0:404f5a4f1385 | 86 | GPIO_OType_PP = 0x00, |
| MartinJohnson | 0:404f5a4f1385 | 87 | GPIO_OType_OD = 0x01 |
| MartinJohnson | 0:404f5a4f1385 | 88 | }GPIOOType_TypeDef; |
| MartinJohnson | 0:404f5a4f1385 | 89 | |
| MartinJohnson | 0:404f5a4f1385 | 90 | #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD)) |
| MartinJohnson | 0:404f5a4f1385 | 91 | |
| MartinJohnson | 0:404f5a4f1385 | 92 | /** |
| MartinJohnson | 0:404f5a4f1385 | 93 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 94 | */ |
| MartinJohnson | 0:404f5a4f1385 | 95 | |
| MartinJohnson | 0:404f5a4f1385 | 96 | /** @defgroup Output_Maximum_frequency_enumeration |
| MartinJohnson | 0:404f5a4f1385 | 97 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 98 | */ |
| MartinJohnson | 0:404f5a4f1385 | 99 | typedef enum |
| MartinJohnson | 0:404f5a4f1385 | 100 | { |
| MartinJohnson | 0:404f5a4f1385 | 101 | GPIO_Speed_Level_1 = 0x01, /*!< Fast Speed */ |
| MartinJohnson | 0:404f5a4f1385 | 102 | GPIO_Speed_Level_2 = 0x02, /*!< Meduim Speed */ |
| MartinJohnson | 0:404f5a4f1385 | 103 | GPIO_Speed_Level_3 = 0x03 /*!< High Speed */ |
| MartinJohnson | 0:404f5a4f1385 | 104 | }GPIOSpeed_TypeDef; |
| MartinJohnson | 0:404f5a4f1385 | 105 | |
| MartinJohnson | 0:404f5a4f1385 | 106 | #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_Level_1) || ((SPEED) == GPIO_Speed_Level_2) || \ |
| MartinJohnson | 0:404f5a4f1385 | 107 | ((SPEED) == GPIO_Speed_Level_3)) |
| MartinJohnson | 0:404f5a4f1385 | 108 | /** |
| MartinJohnson | 0:404f5a4f1385 | 109 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 110 | */ |
| MartinJohnson | 0:404f5a4f1385 | 111 | |
| MartinJohnson | 0:404f5a4f1385 | 112 | /** @defgroup Configuration_Pull-Up_Pull-Down_enumeration |
| MartinJohnson | 0:404f5a4f1385 | 113 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 114 | */ |
| MartinJohnson | 0:404f5a4f1385 | 115 | typedef enum |
| MartinJohnson | 0:404f5a4f1385 | 116 | { |
| MartinJohnson | 0:404f5a4f1385 | 117 | GPIO_PuPd_NOPULL = 0x00, |
| MartinJohnson | 0:404f5a4f1385 | 118 | GPIO_PuPd_UP = 0x01, |
| MartinJohnson | 0:404f5a4f1385 | 119 | GPIO_PuPd_DOWN = 0x02 |
| MartinJohnson | 0:404f5a4f1385 | 120 | }GPIOPuPd_TypeDef; |
| MartinJohnson | 0:404f5a4f1385 | 121 | |
| MartinJohnson | 0:404f5a4f1385 | 122 | #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \ |
| MartinJohnson | 0:404f5a4f1385 | 123 | ((PUPD) == GPIO_PuPd_DOWN)) |
| MartinJohnson | 0:404f5a4f1385 | 124 | /** |
| MartinJohnson | 0:404f5a4f1385 | 125 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 126 | */ |
| MartinJohnson | 0:404f5a4f1385 | 127 | |
| MartinJohnson | 0:404f5a4f1385 | 128 | /** @defgroup Bit_SET_and_Bit_RESET_enumeration |
| MartinJohnson | 0:404f5a4f1385 | 129 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 130 | */ |
| MartinJohnson | 0:404f5a4f1385 | 131 | typedef enum |
| MartinJohnson | 0:404f5a4f1385 | 132 | { |
| MartinJohnson | 0:404f5a4f1385 | 133 | Bit_RESET = 0, |
| MartinJohnson | 0:404f5a4f1385 | 134 | Bit_SET |
| MartinJohnson | 0:404f5a4f1385 | 135 | }BitAction; |
| MartinJohnson | 0:404f5a4f1385 | 136 | |
| MartinJohnson | 0:404f5a4f1385 | 137 | #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET)) |
| MartinJohnson | 0:404f5a4f1385 | 138 | /** |
| MartinJohnson | 0:404f5a4f1385 | 139 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 140 | */ |
| MartinJohnson | 0:404f5a4f1385 | 141 | |
| MartinJohnson | 0:404f5a4f1385 | 142 | /** |
| MartinJohnson | 0:404f5a4f1385 | 143 | * @brief GPIO Init structure definition |
| MartinJohnson | 0:404f5a4f1385 | 144 | */ |
| MartinJohnson | 0:404f5a4f1385 | 145 | typedef struct |
| MartinJohnson | 0:404f5a4f1385 | 146 | { |
| MartinJohnson | 0:404f5a4f1385 | 147 | uint32_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured. |
| MartinJohnson | 0:404f5a4f1385 | 148 | This parameter can be any value of @ref GPIO_pins_define */ |
| MartinJohnson | 0:404f5a4f1385 | 149 | |
| MartinJohnson | 0:404f5a4f1385 | 150 | GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. |
| MartinJohnson | 0:404f5a4f1385 | 151 | This parameter can be a value of @ref GPIOMode_TypeDef */ |
| MartinJohnson | 0:404f5a4f1385 | 152 | |
| MartinJohnson | 0:404f5a4f1385 | 153 | GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins. |
| MartinJohnson | 0:404f5a4f1385 | 154 | This parameter can be a value of @ref GPIOSpeed_TypeDef */ |
| MartinJohnson | 0:404f5a4f1385 | 155 | |
| MartinJohnson | 0:404f5a4f1385 | 156 | GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins. |
| MartinJohnson | 0:404f5a4f1385 | 157 | This parameter can be a value of @ref GPIOOType_TypeDef */ |
| MartinJohnson | 0:404f5a4f1385 | 158 | |
| MartinJohnson | 0:404f5a4f1385 | 159 | GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins. |
| MartinJohnson | 0:404f5a4f1385 | 160 | This parameter can be a value of @ref GPIOPuPd_TypeDef */ |
| MartinJohnson | 0:404f5a4f1385 | 161 | }GPIO_InitTypeDef; |
| MartinJohnson | 0:404f5a4f1385 | 162 | |
| MartinJohnson | 0:404f5a4f1385 | 163 | /* Exported constants --------------------------------------------------------*/ |
| MartinJohnson | 0:404f5a4f1385 | 164 | |
| MartinJohnson | 0:404f5a4f1385 | 165 | /** @defgroup GPIO_Exported_Constants |
| MartinJohnson | 0:404f5a4f1385 | 166 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 167 | */ |
| MartinJohnson | 0:404f5a4f1385 | 168 | |
| MartinJohnson | 0:404f5a4f1385 | 169 | /** @defgroup GPIO_pins_define |
| MartinJohnson | 0:404f5a4f1385 | 170 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 171 | */ |
| MartinJohnson | 0:404f5a4f1385 | 172 | #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 173 | #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 174 | #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 175 | #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 176 | #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 177 | #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 178 | #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 179 | #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 180 | #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 181 | #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 182 | #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 183 | #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 184 | #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 185 | #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 186 | #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 187 | #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */ |
| MartinJohnson | 0:404f5a4f1385 | 188 | #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */ |
| MartinJohnson | 0:404f5a4f1385 | 189 | |
| MartinJohnson | 0:404f5a4f1385 | 190 | #define IS_GPIO_PIN(PIN) ((PIN) != (uint16_t)0x00) |
| MartinJohnson | 0:404f5a4f1385 | 191 | |
| MartinJohnson | 0:404f5a4f1385 | 192 | #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \ |
| MartinJohnson | 0:404f5a4f1385 | 193 | ((PIN) == GPIO_Pin_1) || \ |
| MartinJohnson | 0:404f5a4f1385 | 194 | ((PIN) == GPIO_Pin_2) || \ |
| MartinJohnson | 0:404f5a4f1385 | 195 | ((PIN) == GPIO_Pin_3) || \ |
| MartinJohnson | 0:404f5a4f1385 | 196 | ((PIN) == GPIO_Pin_4) || \ |
| MartinJohnson | 0:404f5a4f1385 | 197 | ((PIN) == GPIO_Pin_5) || \ |
| MartinJohnson | 0:404f5a4f1385 | 198 | ((PIN) == GPIO_Pin_6) || \ |
| MartinJohnson | 0:404f5a4f1385 | 199 | ((PIN) == GPIO_Pin_7) || \ |
| MartinJohnson | 0:404f5a4f1385 | 200 | ((PIN) == GPIO_Pin_8) || \ |
| MartinJohnson | 0:404f5a4f1385 | 201 | ((PIN) == GPIO_Pin_9) || \ |
| MartinJohnson | 0:404f5a4f1385 | 202 | ((PIN) == GPIO_Pin_10) || \ |
| MartinJohnson | 0:404f5a4f1385 | 203 | ((PIN) == GPIO_Pin_11) || \ |
| MartinJohnson | 0:404f5a4f1385 | 204 | ((PIN) == GPIO_Pin_12) || \ |
| MartinJohnson | 0:404f5a4f1385 | 205 | ((PIN) == GPIO_Pin_13) || \ |
| MartinJohnson | 0:404f5a4f1385 | 206 | ((PIN) == GPIO_Pin_14) || \ |
| MartinJohnson | 0:404f5a4f1385 | 207 | ((PIN) == GPIO_Pin_15)) |
| MartinJohnson | 0:404f5a4f1385 | 208 | |
| MartinJohnson | 0:404f5a4f1385 | 209 | /** |
| MartinJohnson | 0:404f5a4f1385 | 210 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 211 | */ |
| MartinJohnson | 0:404f5a4f1385 | 212 | |
| MartinJohnson | 0:404f5a4f1385 | 213 | /** @defgroup GPIO_Pin_sources |
| MartinJohnson | 0:404f5a4f1385 | 214 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 215 | */ |
| MartinJohnson | 0:404f5a4f1385 | 216 | #define GPIO_PinSource0 ((uint8_t)0x00) |
| MartinJohnson | 0:404f5a4f1385 | 217 | #define GPIO_PinSource1 ((uint8_t)0x01) |
| MartinJohnson | 0:404f5a4f1385 | 218 | #define GPIO_PinSource2 ((uint8_t)0x02) |
| MartinJohnson | 0:404f5a4f1385 | 219 | #define GPIO_PinSource3 ((uint8_t)0x03) |
| MartinJohnson | 0:404f5a4f1385 | 220 | #define GPIO_PinSource4 ((uint8_t)0x04) |
| MartinJohnson | 0:404f5a4f1385 | 221 | #define GPIO_PinSource5 ((uint8_t)0x05) |
| MartinJohnson | 0:404f5a4f1385 | 222 | #define GPIO_PinSource6 ((uint8_t)0x06) |
| MartinJohnson | 0:404f5a4f1385 | 223 | #define GPIO_PinSource7 ((uint8_t)0x07) |
| MartinJohnson | 0:404f5a4f1385 | 224 | #define GPIO_PinSource8 ((uint8_t)0x08) |
| MartinJohnson | 0:404f5a4f1385 | 225 | #define GPIO_PinSource9 ((uint8_t)0x09) |
| MartinJohnson | 0:404f5a4f1385 | 226 | #define GPIO_PinSource10 ((uint8_t)0x0A) |
| MartinJohnson | 0:404f5a4f1385 | 227 | #define GPIO_PinSource11 ((uint8_t)0x0B) |
| MartinJohnson | 0:404f5a4f1385 | 228 | #define GPIO_PinSource12 ((uint8_t)0x0C) |
| MartinJohnson | 0:404f5a4f1385 | 229 | #define GPIO_PinSource13 ((uint8_t)0x0D) |
| MartinJohnson | 0:404f5a4f1385 | 230 | #define GPIO_PinSource14 ((uint8_t)0x0E) |
| MartinJohnson | 0:404f5a4f1385 | 231 | #define GPIO_PinSource15 ((uint8_t)0x0F) |
| MartinJohnson | 0:404f5a4f1385 | 232 | |
| MartinJohnson | 0:404f5a4f1385 | 233 | #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \ |
| MartinJohnson | 0:404f5a4f1385 | 234 | ((PINSOURCE) == GPIO_PinSource1) || \ |
| MartinJohnson | 0:404f5a4f1385 | 235 | ((PINSOURCE) == GPIO_PinSource2) || \ |
| MartinJohnson | 0:404f5a4f1385 | 236 | ((PINSOURCE) == GPIO_PinSource3) || \ |
| MartinJohnson | 0:404f5a4f1385 | 237 | ((PINSOURCE) == GPIO_PinSource4) || \ |
| MartinJohnson | 0:404f5a4f1385 | 238 | ((PINSOURCE) == GPIO_PinSource5) || \ |
| MartinJohnson | 0:404f5a4f1385 | 239 | ((PINSOURCE) == GPIO_PinSource6) || \ |
| MartinJohnson | 0:404f5a4f1385 | 240 | ((PINSOURCE) == GPIO_PinSource7) || \ |
| MartinJohnson | 0:404f5a4f1385 | 241 | ((PINSOURCE) == GPIO_PinSource8) || \ |
| MartinJohnson | 0:404f5a4f1385 | 242 | ((PINSOURCE) == GPIO_PinSource9) || \ |
| MartinJohnson | 0:404f5a4f1385 | 243 | ((PINSOURCE) == GPIO_PinSource10) || \ |
| MartinJohnson | 0:404f5a4f1385 | 244 | ((PINSOURCE) == GPIO_PinSource11) || \ |
| MartinJohnson | 0:404f5a4f1385 | 245 | ((PINSOURCE) == GPIO_PinSource12) || \ |
| MartinJohnson | 0:404f5a4f1385 | 246 | ((PINSOURCE) == GPIO_PinSource13) || \ |
| MartinJohnson | 0:404f5a4f1385 | 247 | ((PINSOURCE) == GPIO_PinSource14) || \ |
| MartinJohnson | 0:404f5a4f1385 | 248 | ((PINSOURCE) == GPIO_PinSource15)) |
| MartinJohnson | 0:404f5a4f1385 | 249 | /** |
| MartinJohnson | 0:404f5a4f1385 | 250 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 251 | */ |
| MartinJohnson | 0:404f5a4f1385 | 252 | |
| MartinJohnson | 0:404f5a4f1385 | 253 | /** @defgroup GPIO_Alternate_function_selection_define |
| MartinJohnson | 0:404f5a4f1385 | 254 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 255 | */ |
| MartinJohnson | 0:404f5a4f1385 | 256 | |
| MartinJohnson | 0:404f5a4f1385 | 257 | /** |
| MartinJohnson | 0:404f5a4f1385 | 258 | * @brief AF 0 selection |
| MartinJohnson | 0:404f5a4f1385 | 259 | */ |
| MartinJohnson | 0:404f5a4f1385 | 260 | #define GPIO_AF_0 ((uint8_t)0x00) /* JTCK-SWCLK, JTDI, JTDO/TRACESW0, JTMS-SWDAT, |
| MartinJohnson | 0:404f5a4f1385 | 261 | MCO, NJTRST, TRACED, TRACECK */ |
| MartinJohnson | 0:404f5a4f1385 | 262 | /** |
| MartinJohnson | 0:404f5a4f1385 | 263 | * @brief AF 1 selection |
| MartinJohnson | 0:404f5a4f1385 | 264 | */ |
| MartinJohnson | 0:404f5a4f1385 | 265 | #define GPIO_AF_1 ((uint8_t)0x01) /* OUT, TIM2, TIM15, TIM16, TIM17 */ |
| MartinJohnson | 0:404f5a4f1385 | 266 | |
| MartinJohnson | 0:404f5a4f1385 | 267 | /** |
| MartinJohnson | 0:404f5a4f1385 | 268 | * @brief AF 2 selection |
| MartinJohnson | 0:404f5a4f1385 | 269 | */ |
| MartinJohnson | 0:404f5a4f1385 | 270 | #define GPIO_AF_2 ((uint8_t)0x02) /* COMP1_OUT, TIM1, TIM2, TIM3, TIM4, TIM8, TIM15, TIM16 */ |
| MartinJohnson | 0:404f5a4f1385 | 271 | |
| MartinJohnson | 0:404f5a4f1385 | 272 | /** |
| MartinJohnson | 0:404f5a4f1385 | 273 | * @brief AF 3 selection |
| MartinJohnson | 0:404f5a4f1385 | 274 | */ |
| MartinJohnson | 0:404f5a4f1385 | 275 | #define GPIO_AF_3 ((uint8_t)0x03) /* COMP7_OUT, TIM8, TIM15, Touch, HRTIM1 */ |
| MartinJohnson | 0:404f5a4f1385 | 276 | |
| MartinJohnson | 0:404f5a4f1385 | 277 | /** |
| MartinJohnson | 0:404f5a4f1385 | 278 | * @brief AF 4 selection |
| MartinJohnson | 0:404f5a4f1385 | 279 | */ |
| MartinJohnson | 0:404f5a4f1385 | 280 | #define GPIO_AF_4 ((uint8_t)0x04) /* I2C1, I2C2, TIM1, TIM8, TIM16, TIM17 */ |
| MartinJohnson | 0:404f5a4f1385 | 281 | |
| MartinJohnson | 0:404f5a4f1385 | 282 | /** |
| MartinJohnson | 0:404f5a4f1385 | 283 | * @brief AF 5 selection |
| MartinJohnson | 0:404f5a4f1385 | 284 | */ |
| MartinJohnson | 0:404f5a4f1385 | 285 | #define GPIO_AF_5 ((uint8_t)0x05) /* IR_OUT, I2S2, I2S3, SPI1, SPI2, TIM8, USART4, USART5 */ |
| MartinJohnson | 0:404f5a4f1385 | 286 | |
| MartinJohnson | 0:404f5a4f1385 | 287 | /** |
| MartinJohnson | 0:404f5a4f1385 | 288 | * @brief AF 6 selection |
| MartinJohnson | 0:404f5a4f1385 | 289 | */ |
| MartinJohnson | 0:404f5a4f1385 | 290 | #define GPIO_AF_6 ((uint8_t)0x06) /* IR_OUT, I2S2, I2S3, SPI2, SPI3, TIM1, TIM8 */ |
| MartinJohnson | 0:404f5a4f1385 | 291 | |
| MartinJohnson | 0:404f5a4f1385 | 292 | /** |
| MartinJohnson | 0:404f5a4f1385 | 293 | * @brief AF 7 selection |
| MartinJohnson | 0:404f5a4f1385 | 294 | */ |
| MartinJohnson | 0:404f5a4f1385 | 295 | #define GPIO_AF_7 ((uint8_t)0x07) /* AOP2_OUT, CAN, COMP3_OUT, COMP5_OUT, COMP6_OUT, |
| MartinJohnson | 0:404f5a4f1385 | 296 | USART1, USART2, USART3 */ |
| MartinJohnson | 0:404f5a4f1385 | 297 | |
| MartinJohnson | 0:404f5a4f1385 | 298 | /** |
| MartinJohnson | 0:404f5a4f1385 | 299 | * @brief AF 8 selection |
| MartinJohnson | 0:404f5a4f1385 | 300 | */ |
| MartinJohnson | 0:404f5a4f1385 | 301 | #define GPIO_AF_8 ((uint8_t)0x08) /* COMP1_OUT, COMP2_OUT, COMP3_OUT, COMP4_OUT, |
| MartinJohnson | 0:404f5a4f1385 | 302 | COMP5_OUT, COMP6_OUT */ |
| MartinJohnson | 0:404f5a4f1385 | 303 | |
| MartinJohnson | 0:404f5a4f1385 | 304 | /** |
| MartinJohnson | 0:404f5a4f1385 | 305 | * @brief AF 9 selection |
| MartinJohnson | 0:404f5a4f1385 | 306 | */ |
| MartinJohnson | 0:404f5a4f1385 | 307 | #define GPIO_AF_9 ((uint8_t)0x09) /* AOP4_OUT, CAN, TIM1, TIM8, TIM15 */ |
| MartinJohnson | 0:404f5a4f1385 | 308 | |
| MartinJohnson | 0:404f5a4f1385 | 309 | /** |
| MartinJohnson | 0:404f5a4f1385 | 310 | * @brief AF 10 selection |
| MartinJohnson | 0:404f5a4f1385 | 311 | */ |
| MartinJohnson | 0:404f5a4f1385 | 312 | #define GPIO_AF_10 ((uint8_t)0x0A) /* AOP1_OUT, AOP3_OUT, TIM2, TIM3, TIM4, TIM8, TIM17 */ |
| MartinJohnson | 0:404f5a4f1385 | 313 | |
| MartinJohnson | 0:404f5a4f1385 | 314 | /** |
| MartinJohnson | 0:404f5a4f1385 | 315 | * @brief AF 11 selection |
| MartinJohnson | 0:404f5a4f1385 | 316 | */ |
| MartinJohnson | 0:404f5a4f1385 | 317 | #define GPIO_AF_11 ((uint8_t)0x0B) /* TIM1, TIM8 */ |
| MartinJohnson | 0:404f5a4f1385 | 318 | |
| MartinJohnson | 0:404f5a4f1385 | 319 | /** |
| MartinJohnson | 0:404f5a4f1385 | 320 | * @brief AF 12 selection |
| MartinJohnson | 0:404f5a4f1385 | 321 | */ |
| MartinJohnson | 0:404f5a4f1385 | 322 | #define GPIO_AF_12 ((uint8_t)0x0C) /* TIM1, HRTIM1 */ |
| MartinJohnson | 0:404f5a4f1385 | 323 | |
| MartinJohnson | 0:404f5a4f1385 | 324 | /** |
| MartinJohnson | 0:404f5a4f1385 | 325 | * @brief AF 13 selection |
| MartinJohnson | 0:404f5a4f1385 | 326 | */ |
| MartinJohnson | 0:404f5a4f1385 | 327 | #define GPIO_AF_13 ((uint8_t)0x0D) /* HRTIM1, AOP2_OUT */ |
| MartinJohnson | 0:404f5a4f1385 | 328 | |
| MartinJohnson | 0:404f5a4f1385 | 329 | /** |
| MartinJohnson | 0:404f5a4f1385 | 330 | * @brief AF 14 selection |
| MartinJohnson | 0:404f5a4f1385 | 331 | */ |
| MartinJohnson | 0:404f5a4f1385 | 332 | #define GPIO_AF_14 ((uint8_t)0x0E) /* USBDM, USBDP */ |
| MartinJohnson | 0:404f5a4f1385 | 333 | |
| MartinJohnson | 0:404f5a4f1385 | 334 | /** |
| MartinJohnson | 0:404f5a4f1385 | 335 | * @brief AF 15 selection |
| MartinJohnson | 0:404f5a4f1385 | 336 | */ |
| MartinJohnson | 0:404f5a4f1385 | 337 | #define GPIO_AF_15 ((uint8_t)0x0F) /* OUT */ |
| MartinJohnson | 0:404f5a4f1385 | 338 | |
| MartinJohnson | 0:404f5a4f1385 | 339 | #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_0)||((AF) == GPIO_AF_1)||\ |
| MartinJohnson | 0:404f5a4f1385 | 340 | ((AF) == GPIO_AF_2)||((AF) == GPIO_AF_3)||\ |
| MartinJohnson | 0:404f5a4f1385 | 341 | ((AF) == GPIO_AF_4)||((AF) == GPIO_AF_5)||\ |
| MartinJohnson | 0:404f5a4f1385 | 342 | ((AF) == GPIO_AF_6)||((AF) == GPIO_AF_7)||\ |
| MartinJohnson | 0:404f5a4f1385 | 343 | ((AF) == GPIO_AF_8)||((AF) == GPIO_AF_9)||\ |
| MartinJohnson | 0:404f5a4f1385 | 344 | ((AF) == GPIO_AF_10)||((AF) == GPIO_AF_11)||\ |
| MartinJohnson | 0:404f5a4f1385 | 345 | ((AF) == GPIO_AF_12)||((AF) == GPIO_AF_13)||\ |
| MartinJohnson | 0:404f5a4f1385 | 346 | ((AF) == GPIO_AF_14)||((AF) == GPIO_AF_15)) |
| MartinJohnson | 0:404f5a4f1385 | 347 | |
| MartinJohnson | 0:404f5a4f1385 | 348 | /** |
| MartinJohnson | 0:404f5a4f1385 | 349 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 350 | */ |
| MartinJohnson | 0:404f5a4f1385 | 351 | |
| MartinJohnson | 0:404f5a4f1385 | 352 | /** @defgroup GPIO_Speed_Legacy |
| MartinJohnson | 0:404f5a4f1385 | 353 | * @{ |
| MartinJohnson | 0:404f5a4f1385 | 354 | */ |
| MartinJohnson | 0:404f5a4f1385 | 355 | |
| MartinJohnson | 0:404f5a4f1385 | 356 | #define GPIO_Speed_10MHz GPIO_Speed_Level_1 /*!< Fast Speed:10MHz */ |
| MartinJohnson | 0:404f5a4f1385 | 357 | #define GPIO_Speed_2MHz GPIO_Speed_Level_2 /*!< Medium Speed:2MHz */ |
| MartinJohnson | 0:404f5a4f1385 | 358 | #define GPIO_Speed_50MHz GPIO_Speed_Level_3 /*!< High Speed:50MHz */ |
| MartinJohnson | 0:404f5a4f1385 | 359 | |
| MartinJohnson | 0:404f5a4f1385 | 360 | /** |
| MartinJohnson | 0:404f5a4f1385 | 361 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 362 | */ |
| MartinJohnson | 0:404f5a4f1385 | 363 | |
| MartinJohnson | 0:404f5a4f1385 | 364 | /** |
| MartinJohnson | 0:404f5a4f1385 | 365 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 366 | */ |
| MartinJohnson | 0:404f5a4f1385 | 367 | |
| MartinJohnson | 0:404f5a4f1385 | 368 | /* Exported macro ------------------------------------------------------------*/ |
| MartinJohnson | 0:404f5a4f1385 | 369 | /* Exported functions ------------------------------------------------------- */ |
| MartinJohnson | 0:404f5a4f1385 | 370 | /* Function used to set the GPIO configuration to the default reset state *****/ |
| MartinJohnson | 0:404f5a4f1385 | 371 | void GPIO_DeInit(GPIO_TypeDef* GPIOx); |
| MartinJohnson | 0:404f5a4f1385 | 372 | |
| MartinJohnson | 0:404f5a4f1385 | 373 | /* Initialization and Configuration functions *********************************/ |
| MartinJohnson | 0:404f5a4f1385 | 374 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); |
| MartinJohnson | 0:404f5a4f1385 | 375 | void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); |
| MartinJohnson | 0:404f5a4f1385 | 376 | void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); |
| MartinJohnson | 0:404f5a4f1385 | 377 | |
| MartinJohnson | 0:404f5a4f1385 | 378 | /* GPIO Read and Write functions **********************************************/ |
| MartinJohnson | 0:404f5a4f1385 | 379 | uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); |
| MartinJohnson | 0:404f5a4f1385 | 380 | uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); |
| MartinJohnson | 0:404f5a4f1385 | 381 | uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); |
| MartinJohnson | 0:404f5a4f1385 | 382 | uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); |
| MartinJohnson | 0:404f5a4f1385 | 383 | void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); |
| MartinJohnson | 0:404f5a4f1385 | 384 | void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); |
| MartinJohnson | 0:404f5a4f1385 | 385 | void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); |
| MartinJohnson | 0:404f5a4f1385 | 386 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); |
| MartinJohnson | 0:404f5a4f1385 | 387 | |
| MartinJohnson | 0:404f5a4f1385 | 388 | /* GPIO Alternate functions configuration functions ***************************/ |
| MartinJohnson | 0:404f5a4f1385 | 389 | void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF); |
| MartinJohnson | 0:404f5a4f1385 | 390 | |
| MartinJohnson | 0:404f5a4f1385 | 391 | #ifdef __cplusplus |
| MartinJohnson | 0:404f5a4f1385 | 392 | } |
| MartinJohnson | 0:404f5a4f1385 | 393 | #endif |
| MartinJohnson | 0:404f5a4f1385 | 394 | |
| MartinJohnson | 0:404f5a4f1385 | 395 | #endif /* __STM32F30x_GPIO_H */ |
| MartinJohnson | 0:404f5a4f1385 | 396 | /** |
| MartinJohnson | 0:404f5a4f1385 | 397 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 398 | */ |
| MartinJohnson | 0:404f5a4f1385 | 399 | |
| MartinJohnson | 0:404f5a4f1385 | 400 | /** |
| MartinJohnson | 0:404f5a4f1385 | 401 | * @} |
| MartinJohnson | 0:404f5a4f1385 | 402 | */ |
| MartinJohnson | 0:404f5a4f1385 | 403 | |
| MartinJohnson | 0:404f5a4f1385 | 404 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |