mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
106:ced8cbb51063
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 76:aeb1df146756 1 /**
mbed_official 76:aeb1df146756 2 ******************************************************************************
mbed_official 76:aeb1df146756 3 * @file stm32l1xx_gpio.h
mbed_official 76:aeb1df146756 4 * @author MCD Application Team
mbed_official 80:66393a7b209d 5 * @version V1.3.0
mbed_official 80:66393a7b209d 6 * @date 31-January-2014
mbed_official 76:aeb1df146756 7 * @brief This file contains all the functions prototypes for the GPIO
mbed_official 76:aeb1df146756 8 * firmware library.
mbed_official 76:aeb1df146756 9 ******************************************************************************
mbed_official 76:aeb1df146756 10 * @attention
mbed_official 76:aeb1df146756 11 *
mbed_official 106:ced8cbb51063 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 76:aeb1df146756 13 *
mbed_official 106:ced8cbb51063 14 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 106:ced8cbb51063 15 * are permitted provided that the following conditions are met:
mbed_official 106:ced8cbb51063 16 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 106:ced8cbb51063 17 * this list of conditions and the following disclaimer.
mbed_official 106:ced8cbb51063 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 106:ced8cbb51063 19 * this list of conditions and the following disclaimer in the documentation
mbed_official 106:ced8cbb51063 20 * and/or other materials provided with the distribution.
mbed_official 106:ced8cbb51063 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 106:ced8cbb51063 22 * may be used to endorse or promote products derived from this software
mbed_official 106:ced8cbb51063 23 * without specific prior written permission.
mbed_official 76:aeb1df146756 24 *
mbed_official 106:ced8cbb51063 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 106:ced8cbb51063 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 106:ced8cbb51063 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 106:ced8cbb51063 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 106:ced8cbb51063 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 106:ced8cbb51063 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 106:ced8cbb51063 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 106:ced8cbb51063 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 106:ced8cbb51063 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 106:ced8cbb51063 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 76:aeb1df146756 35 *
mbed_official 76:aeb1df146756 36 ******************************************************************************
mbed_official 76:aeb1df146756 37 */
mbed_official 76:aeb1df146756 38
mbed_official 76:aeb1df146756 39 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 76:aeb1df146756 40 #ifndef __STM32L1xx_GPIO_H
mbed_official 76:aeb1df146756 41 #define __STM32L1xx_GPIO_H
mbed_official 76:aeb1df146756 42
mbed_official 76:aeb1df146756 43 #ifdef __cplusplus
mbed_official 76:aeb1df146756 44 extern "C" {
mbed_official 76:aeb1df146756 45 #endif
mbed_official 76:aeb1df146756 46
mbed_official 76:aeb1df146756 47 /* Includes ------------------------------------------------------------------*/
mbed_official 76:aeb1df146756 48 #include "stm32l1xx.h"
mbed_official 76:aeb1df146756 49
mbed_official 76:aeb1df146756 50 /** @addtogroup STM32L1xx_StdPeriph_Driver
mbed_official 76:aeb1df146756 51 * @{
mbed_official 76:aeb1df146756 52 */
mbed_official 76:aeb1df146756 53
mbed_official 76:aeb1df146756 54 /** @addtogroup GPIO
mbed_official 76:aeb1df146756 55 * @{
mbed_official 76:aeb1df146756 56 */
mbed_official 76:aeb1df146756 57
mbed_official 76:aeb1df146756 58 /* Exported types ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 59
mbed_official 76:aeb1df146756 60 #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
mbed_official 76:aeb1df146756 61 ((PERIPH) == GPIOB) || \
mbed_official 76:aeb1df146756 62 ((PERIPH) == GPIOC) || \
mbed_official 76:aeb1df146756 63 ((PERIPH) == GPIOD) || \
mbed_official 76:aeb1df146756 64 ((PERIPH) == GPIOE) || \
mbed_official 76:aeb1df146756 65 ((PERIPH) == GPIOH) || \
mbed_official 76:aeb1df146756 66 ((PERIPH) == GPIOF) || \
mbed_official 76:aeb1df146756 67 ((PERIPH) == GPIOG))
mbed_official 76:aeb1df146756 68
mbed_official 76:aeb1df146756 69 /** @defgroup Configuration_Mode_enumeration
mbed_official 76:aeb1df146756 70 * @{
mbed_official 76:aeb1df146756 71 */
mbed_official 76:aeb1df146756 72 typedef enum
mbed_official 76:aeb1df146756 73 {
mbed_official 76:aeb1df146756 74 GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */
mbed_official 76:aeb1df146756 75 GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */
mbed_official 76:aeb1df146756 76 GPIO_Mode_AF = 0x02, /*!< GPIO Alternate function Mode */
mbed_official 76:aeb1df146756 77 GPIO_Mode_AN = 0x03 /*!< GPIO Analog Mode */
mbed_official 76:aeb1df146756 78 }GPIOMode_TypeDef;
mbed_official 76:aeb1df146756 79 #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) || \
mbed_official 76:aeb1df146756 80 ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN))
mbed_official 76:aeb1df146756 81 /**
mbed_official 76:aeb1df146756 82 * @}
mbed_official 76:aeb1df146756 83 */
mbed_official 76:aeb1df146756 84
mbed_official 76:aeb1df146756 85 /** @defgroup Output_type_enumeration
mbed_official 76:aeb1df146756 86 * @{
mbed_official 76:aeb1df146756 87 */
mbed_official 76:aeb1df146756 88 typedef enum
mbed_official 76:aeb1df146756 89 { GPIO_OType_PP = 0x00,
mbed_official 76:aeb1df146756 90 GPIO_OType_OD = 0x01
mbed_official 76:aeb1df146756 91 }GPIOOType_TypeDef;
mbed_official 76:aeb1df146756 92 #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
mbed_official 76:aeb1df146756 93
mbed_official 76:aeb1df146756 94 /**
mbed_official 76:aeb1df146756 95 * @}
mbed_official 76:aeb1df146756 96 */
mbed_official 76:aeb1df146756 97
mbed_official 76:aeb1df146756 98 /** @defgroup Output_Maximum_frequency_enumeration
mbed_official 76:aeb1df146756 99 * @{
mbed_official 76:aeb1df146756 100 */
mbed_official 76:aeb1df146756 101 typedef enum
mbed_official 76:aeb1df146756 102 {
mbed_official 76:aeb1df146756 103 GPIO_Speed_400KHz = 0x00, /*!< Very Low Speed */
mbed_official 76:aeb1df146756 104 GPIO_Speed_2MHz = 0x01, /*!< Low Speed */
mbed_official 76:aeb1df146756 105 GPIO_Speed_10MHz = 0x02, /*!< Medium Speed */
mbed_official 76:aeb1df146756 106 GPIO_Speed_40MHz = 0x03 /*!< High Speed */
mbed_official 76:aeb1df146756 107 }GPIOSpeed_TypeDef;
mbed_official 76:aeb1df146756 108 #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_400KHz) || ((SPEED) == GPIO_Speed_2MHz) || \
mbed_official 76:aeb1df146756 109 ((SPEED) == GPIO_Speed_10MHz)|| ((SPEED) == GPIO_Speed_40MHz))
mbed_official 76:aeb1df146756 110 /**
mbed_official 76:aeb1df146756 111 * @}
mbed_official 76:aeb1df146756 112 */
mbed_official 76:aeb1df146756 113
mbed_official 76:aeb1df146756 114 /** @defgroup Configuration_Pull-Up_Pull-Down_enumeration
mbed_official 76:aeb1df146756 115 * @{
mbed_official 76:aeb1df146756 116 */
mbed_official 76:aeb1df146756 117 typedef enum
mbed_official 76:aeb1df146756 118 { GPIO_PuPd_NOPULL = 0x00,
mbed_official 76:aeb1df146756 119 GPIO_PuPd_UP = 0x01,
mbed_official 76:aeb1df146756 120 GPIO_PuPd_DOWN = 0x02
mbed_official 76:aeb1df146756 121 }GPIOPuPd_TypeDef;
mbed_official 76:aeb1df146756 122 #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
mbed_official 76:aeb1df146756 123 ((PUPD) == GPIO_PuPd_DOWN))
mbed_official 76:aeb1df146756 124 /**
mbed_official 76:aeb1df146756 125 * @}
mbed_official 76:aeb1df146756 126 */
mbed_official 76:aeb1df146756 127
mbed_official 76:aeb1df146756 128 /** @defgroup Bit_SET_and_Bit_RESET_enumeration
mbed_official 76:aeb1df146756 129 * @{
mbed_official 76:aeb1df146756 130 */
mbed_official 76:aeb1df146756 131 typedef enum
mbed_official 76:aeb1df146756 132 { Bit_RESET = 0,
mbed_official 76:aeb1df146756 133 Bit_SET
mbed_official 76:aeb1df146756 134 }BitAction;
mbed_official 76:aeb1df146756 135 #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
mbed_official 76:aeb1df146756 136
mbed_official 76:aeb1df146756 137 /**
mbed_official 76:aeb1df146756 138 * @}
mbed_official 76:aeb1df146756 139 */
mbed_official 76:aeb1df146756 140
mbed_official 76:aeb1df146756 141 /**
mbed_official 76:aeb1df146756 142 * @brief GPIO Init structure definition
mbed_official 76:aeb1df146756 143 */
mbed_official 76:aeb1df146756 144 typedef struct
mbed_official 76:aeb1df146756 145 {
mbed_official 76:aeb1df146756 146 uint32_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured.
mbed_official 76:aeb1df146756 147 This parameter can be any value of @ref GPIO_pins_define */
mbed_official 76:aeb1df146756 148
mbed_official 76:aeb1df146756 149 GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins.
mbed_official 76:aeb1df146756 150 This parameter can be a value of @ref GPIOMode_TypeDef */
mbed_official 76:aeb1df146756 151
mbed_official 76:aeb1df146756 152 GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins.
mbed_official 76:aeb1df146756 153 This parameter can be a value of @ref GPIOSpeed_TypeDef */
mbed_official 76:aeb1df146756 154
mbed_official 76:aeb1df146756 155 GPIOOType_TypeDef GPIO_OType; /*!< Specifies the operating output type for the selected pins.
mbed_official 76:aeb1df146756 156 This parameter can be a value of @ref GPIOOType_TypeDef */
mbed_official 76:aeb1df146756 157
mbed_official 76:aeb1df146756 158 GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
mbed_official 76:aeb1df146756 159 This parameter can be a value of @ref GPIOPuPd_TypeDef */
mbed_official 76:aeb1df146756 160 }GPIO_InitTypeDef;
mbed_official 76:aeb1df146756 161
mbed_official 76:aeb1df146756 162 /* Exported constants --------------------------------------------------------*/
mbed_official 76:aeb1df146756 163
mbed_official 76:aeb1df146756 164 /** @defgroup GPIO_Exported_Constants
mbed_official 76:aeb1df146756 165 * @{
mbed_official 76:aeb1df146756 166 */
mbed_official 76:aeb1df146756 167
mbed_official 76:aeb1df146756 168 /** @defgroup GPIO_pins_define
mbed_official 76:aeb1df146756 169 * @{
mbed_official 76:aeb1df146756 170 */
mbed_official 76:aeb1df146756 171 #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */
mbed_official 76:aeb1df146756 172 #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
mbed_official 76:aeb1df146756 173 #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
mbed_official 76:aeb1df146756 174 #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
mbed_official 76:aeb1df146756 175 #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
mbed_official 76:aeb1df146756 176 #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
mbed_official 76:aeb1df146756 177 #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
mbed_official 76:aeb1df146756 178 #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
mbed_official 76:aeb1df146756 179 #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
mbed_official 76:aeb1df146756 180 #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
mbed_official 76:aeb1df146756 181 #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
mbed_official 76:aeb1df146756 182 #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
mbed_official 76:aeb1df146756 183 #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
mbed_official 76:aeb1df146756 184 #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
mbed_official 76:aeb1df146756 185 #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
mbed_official 76:aeb1df146756 186 #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
mbed_official 76:aeb1df146756 187 #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */
mbed_official 76:aeb1df146756 188
mbed_official 76:aeb1df146756 189 #define IS_GPIO_PIN(PIN) ((PIN) != (uint16_t)0x00)
mbed_official 76:aeb1df146756 190 #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
mbed_official 76:aeb1df146756 191 ((PIN) == GPIO_Pin_1) || \
mbed_official 76:aeb1df146756 192 ((PIN) == GPIO_Pin_2) || \
mbed_official 76:aeb1df146756 193 ((PIN) == GPIO_Pin_3) || \
mbed_official 76:aeb1df146756 194 ((PIN) == GPIO_Pin_4) || \
mbed_official 76:aeb1df146756 195 ((PIN) == GPIO_Pin_5) || \
mbed_official 76:aeb1df146756 196 ((PIN) == GPIO_Pin_6) || \
mbed_official 76:aeb1df146756 197 ((PIN) == GPIO_Pin_7) || \
mbed_official 76:aeb1df146756 198 ((PIN) == GPIO_Pin_8) || \
mbed_official 76:aeb1df146756 199 ((PIN) == GPIO_Pin_9) || \
mbed_official 76:aeb1df146756 200 ((PIN) == GPIO_Pin_10) || \
mbed_official 76:aeb1df146756 201 ((PIN) == GPIO_Pin_11) || \
mbed_official 76:aeb1df146756 202 ((PIN) == GPIO_Pin_12) || \
mbed_official 76:aeb1df146756 203 ((PIN) == GPIO_Pin_13) || \
mbed_official 76:aeb1df146756 204 ((PIN) == GPIO_Pin_14) || \
mbed_official 76:aeb1df146756 205 ((PIN) == GPIO_Pin_15))
mbed_official 76:aeb1df146756 206 /**
mbed_official 76:aeb1df146756 207 * @}
mbed_official 76:aeb1df146756 208 */
mbed_official 76:aeb1df146756 209
mbed_official 76:aeb1df146756 210 /** @defgroup GPIO_Pin_sources
mbed_official 76:aeb1df146756 211 * @{
mbed_official 76:aeb1df146756 212 */
mbed_official 76:aeb1df146756 213 #define GPIO_PinSource0 ((uint8_t)0x00)
mbed_official 76:aeb1df146756 214 #define GPIO_PinSource1 ((uint8_t)0x01)
mbed_official 76:aeb1df146756 215 #define GPIO_PinSource2 ((uint8_t)0x02)
mbed_official 76:aeb1df146756 216 #define GPIO_PinSource3 ((uint8_t)0x03)
mbed_official 76:aeb1df146756 217 #define GPIO_PinSource4 ((uint8_t)0x04)
mbed_official 76:aeb1df146756 218 #define GPIO_PinSource5 ((uint8_t)0x05)
mbed_official 76:aeb1df146756 219 #define GPIO_PinSource6 ((uint8_t)0x06)
mbed_official 76:aeb1df146756 220 #define GPIO_PinSource7 ((uint8_t)0x07)
mbed_official 76:aeb1df146756 221 #define GPIO_PinSource8 ((uint8_t)0x08)
mbed_official 76:aeb1df146756 222 #define GPIO_PinSource9 ((uint8_t)0x09)
mbed_official 76:aeb1df146756 223 #define GPIO_PinSource10 ((uint8_t)0x0A)
mbed_official 76:aeb1df146756 224 #define GPIO_PinSource11 ((uint8_t)0x0B)
mbed_official 76:aeb1df146756 225 #define GPIO_PinSource12 ((uint8_t)0x0C)
mbed_official 76:aeb1df146756 226 #define GPIO_PinSource13 ((uint8_t)0x0D)
mbed_official 76:aeb1df146756 227 #define GPIO_PinSource14 ((uint8_t)0x0E)
mbed_official 76:aeb1df146756 228 #define GPIO_PinSource15 ((uint8_t)0x0F)
mbed_official 76:aeb1df146756 229
mbed_official 76:aeb1df146756 230 #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
mbed_official 76:aeb1df146756 231 ((PINSOURCE) == GPIO_PinSource1) || \
mbed_official 76:aeb1df146756 232 ((PINSOURCE) == GPIO_PinSource2) || \
mbed_official 76:aeb1df146756 233 ((PINSOURCE) == GPIO_PinSource3) || \
mbed_official 76:aeb1df146756 234 ((PINSOURCE) == GPIO_PinSource4) || \
mbed_official 76:aeb1df146756 235 ((PINSOURCE) == GPIO_PinSource5) || \
mbed_official 76:aeb1df146756 236 ((PINSOURCE) == GPIO_PinSource6) || \
mbed_official 76:aeb1df146756 237 ((PINSOURCE) == GPIO_PinSource7) || \
mbed_official 76:aeb1df146756 238 ((PINSOURCE) == GPIO_PinSource8) || \
mbed_official 76:aeb1df146756 239 ((PINSOURCE) == GPIO_PinSource9) || \
mbed_official 76:aeb1df146756 240 ((PINSOURCE) == GPIO_PinSource10) || \
mbed_official 76:aeb1df146756 241 ((PINSOURCE) == GPIO_PinSource11) || \
mbed_official 76:aeb1df146756 242 ((PINSOURCE) == GPIO_PinSource12) || \
mbed_official 76:aeb1df146756 243 ((PINSOURCE) == GPIO_PinSource13) || \
mbed_official 76:aeb1df146756 244 ((PINSOURCE) == GPIO_PinSource14) || \
mbed_official 76:aeb1df146756 245 ((PINSOURCE) == GPIO_PinSource15))
mbed_official 76:aeb1df146756 246 /**
mbed_official 76:aeb1df146756 247 * @}
mbed_official 76:aeb1df146756 248 */
mbed_official 76:aeb1df146756 249
mbed_official 76:aeb1df146756 250 /** @defgroup GPIO_Alternat_function_selection_define
mbed_official 76:aeb1df146756 251 * @{
mbed_official 76:aeb1df146756 252 */
mbed_official 76:aeb1df146756 253
mbed_official 76:aeb1df146756 254 /**
mbed_official 76:aeb1df146756 255 * @brief AF 0 selection
mbed_official 76:aeb1df146756 256 */
mbed_official 76:aeb1df146756 257 #define GPIO_AF_RTC_50Hz ((uint8_t)0x00) /*!< RTC 50/60 Hz Alternate Function mapping */
mbed_official 76:aeb1df146756 258 #define GPIO_AF_MCO ((uint8_t)0x00) /*!< MCO Alternate Function mapping */
mbed_official 76:aeb1df146756 259 #define GPIO_AF_RTC_AF1 ((uint8_t)0x00) /*!< RTC_AF1 Alternate Function mapping */
mbed_official 76:aeb1df146756 260 #define GPIO_AF_WKUP ((uint8_t)0x00) /*!< Wakeup (WKUP1, WKUP2 and WKUP3) Alternate Function mapping */
mbed_official 76:aeb1df146756 261 #define GPIO_AF_SWJ ((uint8_t)0x00) /*!< SWJ (SW and JTAG) Alternate Function mapping */
mbed_official 76:aeb1df146756 262 #define GPIO_AF_TRACE ((uint8_t)0x00) /*!< TRACE Alternate Function mapping */
mbed_official 76:aeb1df146756 263
mbed_official 76:aeb1df146756 264 /**
mbed_official 76:aeb1df146756 265 * @brief AF 1 selection
mbed_official 76:aeb1df146756 266 */
mbed_official 76:aeb1df146756 267 #define GPIO_AF_TIM2 ((uint8_t)0x01) /*!< TIM2 Alternate Function mapping */
mbed_official 76:aeb1df146756 268 /**
mbed_official 76:aeb1df146756 269 * @brief AF 2 selection
mbed_official 76:aeb1df146756 270 */
mbed_official 76:aeb1df146756 271 #define GPIO_AF_TIM3 ((uint8_t)0x02) /*!< TIM3 Alternate Function mapping */
mbed_official 76:aeb1df146756 272 #define GPIO_AF_TIM4 ((uint8_t)0x02) /*!< TIM4 Alternate Function mapping */
mbed_official 76:aeb1df146756 273 #define GPIO_AF_TIM5 ((uint8_t)0x02) /*!< TIM5 Alternate Function mapping */
mbed_official 76:aeb1df146756 274 /**
mbed_official 76:aeb1df146756 275 * @brief AF 3 selection
mbed_official 76:aeb1df146756 276 */
mbed_official 76:aeb1df146756 277 #define GPIO_AF_TIM9 ((uint8_t)0x03) /*!< TIM9 Alternate Function mapping */
mbed_official 76:aeb1df146756 278 #define GPIO_AF_TIM10 ((uint8_t)0x03) /*!< TIM10 Alternate Function mapping */
mbed_official 76:aeb1df146756 279 #define GPIO_AF_TIM11 ((uint8_t)0x03) /*!< TIM11 Alternate Function mapping */
mbed_official 76:aeb1df146756 280 /**
mbed_official 76:aeb1df146756 281 * @brief AF 4 selection
mbed_official 76:aeb1df146756 282 */
mbed_official 76:aeb1df146756 283 #define GPIO_AF_I2C1 ((uint8_t)0x04) /*!< I2C1 Alternate Function mapping */
mbed_official 76:aeb1df146756 284 #define GPIO_AF_I2C2 ((uint8_t)0x04) /*!< I2C2 Alternate Function mapping */
mbed_official 76:aeb1df146756 285 /**
mbed_official 76:aeb1df146756 286 * @brief AF 5 selection
mbed_official 76:aeb1df146756 287 */
mbed_official 76:aeb1df146756 288 #define GPIO_AF_SPI1 ((uint8_t)0x05) /*!< SPI1 Alternate Function mapping */
mbed_official 76:aeb1df146756 289 #define GPIO_AF_SPI2 ((uint8_t)0x05) /*!< SPI2 Alternate Function mapping */
mbed_official 76:aeb1df146756 290 /**
mbed_official 76:aeb1df146756 291 * @brief AF 6 selection
mbed_official 76:aeb1df146756 292 */
mbed_official 76:aeb1df146756 293 #define GPIO_AF_SPI3 ((uint8_t)0x06) /*!< SPI3 Alternate Function mapping */
mbed_official 76:aeb1df146756 294 /**
mbed_official 76:aeb1df146756 295 * @brief AF 7 selection
mbed_official 76:aeb1df146756 296 */
mbed_official 76:aeb1df146756 297 #define GPIO_AF_USART1 ((uint8_t)0x07) /*!< USART1 Alternate Function mapping */
mbed_official 76:aeb1df146756 298 #define GPIO_AF_USART2 ((uint8_t)0x07) /*!< USART2 Alternate Function mapping */
mbed_official 76:aeb1df146756 299 #define GPIO_AF_USART3 ((uint8_t)0x07) /*!< USART3 Alternate Function mapping */
mbed_official 76:aeb1df146756 300 /**
mbed_official 76:aeb1df146756 301 * @brief AF 8 selection
mbed_official 76:aeb1df146756 302 */
mbed_official 76:aeb1df146756 303 #define GPIO_AF_UART4 ((uint8_t)0x08) /*!< UART4 Alternate Function mapping */
mbed_official 76:aeb1df146756 304 #define GPIO_AF_UART5 ((uint8_t)0x08) /*!< UART5 Alternate Function mapping */
mbed_official 76:aeb1df146756 305 /**
mbed_official 76:aeb1df146756 306 * @brief AF 10 selection
mbed_official 76:aeb1df146756 307 */
mbed_official 76:aeb1df146756 308 #define GPIO_AF_USB ((uint8_t)0xA) /*!< USB Full speed device Alternate Function mapping */
mbed_official 76:aeb1df146756 309 /**
mbed_official 76:aeb1df146756 310 * @brief AF 11 selection
mbed_official 76:aeb1df146756 311 */
mbed_official 76:aeb1df146756 312 #define GPIO_AF_LCD ((uint8_t)0x0B) /*!< LCD Alternate Function mapping */
mbed_official 76:aeb1df146756 313 /**
mbed_official 76:aeb1df146756 314 * @brief AF 12 selection
mbed_official 76:aeb1df146756 315 */
mbed_official 76:aeb1df146756 316 #define GPIO_AF_FSMC ((uint8_t)0x0C) /*!< FSMC Alternate Function mapping */
mbed_official 76:aeb1df146756 317 #define GPIO_AF_SDIO ((uint8_t)0x0C) /*!< SDIO Alternate Function mapping */
mbed_official 76:aeb1df146756 318 /**
mbed_official 76:aeb1df146756 319 * @brief AF 14 selection
mbed_official 76:aeb1df146756 320 */
mbed_official 76:aeb1df146756 321 #define GPIO_AF_RI ((uint8_t)0x0E) /*!< RI Alternate Function mapping */
mbed_official 76:aeb1df146756 322
mbed_official 76:aeb1df146756 323 /**
mbed_official 76:aeb1df146756 324 * @brief AF 15 selection
mbed_official 76:aeb1df146756 325 */
mbed_official 76:aeb1df146756 326 #define GPIO_AF_EVENTOUT ((uint8_t)0x0F) /*!< EVENTOUT Alternate Function mapping */
mbed_official 76:aeb1df146756 327
mbed_official 76:aeb1df146756 328 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_RTC_50Hz) || ((AF) == GPIO_AF_MCO) || \
mbed_official 76:aeb1df146756 329 ((AF) == GPIO_AF_RTC_AF1) || ((AF) == GPIO_AF_WKUP) || \
mbed_official 76:aeb1df146756 330 ((AF) == GPIO_AF_SWJ) || ((AF) == GPIO_AF_TRACE) || \
mbed_official 76:aeb1df146756 331 ((AF) == GPIO_AF_TIM2) || ((AF)== GPIO_AF_TIM3) || \
mbed_official 76:aeb1df146756 332 ((AF) == GPIO_AF_TIM4) || ((AF)== GPIO_AF_TIM9) || \
mbed_official 76:aeb1df146756 333 ((AF) == GPIO_AF_TIM10) || ((AF)== GPIO_AF_TIM11) || \
mbed_official 76:aeb1df146756 334 ((AF) == GPIO_AF_I2C1) || ((AF) == GPIO_AF_I2C2) || \
mbed_official 76:aeb1df146756 335 ((AF) == GPIO_AF_SPI1) || ((AF) == GPIO_AF_SPI2) || \
mbed_official 76:aeb1df146756 336 ((AF) == GPIO_AF_USART1) || ((AF) == GPIO_AF_USART2) || \
mbed_official 76:aeb1df146756 337 ((AF) == GPIO_AF_USART3) || ((AF) == GPIO_AF_USB) || \
mbed_official 76:aeb1df146756 338 ((AF) == GPIO_AF_LCD) || ((AF) == GPIO_AF_RI) || \
mbed_official 76:aeb1df146756 339 ((AF) == GPIO_AF_TIM5) || ((AF) == GPIO_AF_SPI3) || \
mbed_official 76:aeb1df146756 340 ((AF) == GPIO_AF_UART4) || ((AF) == GPIO_AF_UART5) || \
mbed_official 76:aeb1df146756 341 ((AF) == GPIO_AF_FSMC) || ((AF) == GPIO_AF_SDIO) || \
mbed_official 76:aeb1df146756 342 ((AF) == GPIO_AF_EVENTOUT))
mbed_official 76:aeb1df146756 343
mbed_official 76:aeb1df146756 344 /**
mbed_official 76:aeb1df146756 345 * @}
mbed_official 76:aeb1df146756 346 */
mbed_official 76:aeb1df146756 347
mbed_official 76:aeb1df146756 348 /** @defgroup GPIO_Legacy
mbed_official 76:aeb1df146756 349 * @{
mbed_official 76:aeb1df146756 350 */
mbed_official 76:aeb1df146756 351
mbed_official 76:aeb1df146756 352 #define GPIO_Mode_AIN GPIO_Mode_AN
mbed_official 76:aeb1df146756 353
mbed_official 76:aeb1df146756 354 /**
mbed_official 76:aeb1df146756 355 * @}
mbed_official 76:aeb1df146756 356 */
mbed_official 76:aeb1df146756 357
mbed_official 76:aeb1df146756 358 /**
mbed_official 76:aeb1df146756 359 * @}
mbed_official 76:aeb1df146756 360 */
mbed_official 76:aeb1df146756 361
mbed_official 76:aeb1df146756 362 /* Exported macro ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 363 /* Exported functions ------------------------------------------------------- */
mbed_official 76:aeb1df146756 364
mbed_official 76:aeb1df146756 365 /* Function used to set the GPIO configuration to the default reset state ****/
mbed_official 76:aeb1df146756 366 void GPIO_DeInit(GPIO_TypeDef* GPIOx);
mbed_official 76:aeb1df146756 367
mbed_official 76:aeb1df146756 368 /* Initialization and Configuration functions *********************************/
mbed_official 76:aeb1df146756 369 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
mbed_official 76:aeb1df146756 370 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
mbed_official 76:aeb1df146756 371 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
mbed_official 76:aeb1df146756 372
mbed_official 76:aeb1df146756 373 /* GPIO Read and Write functions **********************************************/
mbed_official 76:aeb1df146756 374 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
mbed_official 76:aeb1df146756 375 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
mbed_official 76:aeb1df146756 376 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
mbed_official 76:aeb1df146756 377 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
mbed_official 76:aeb1df146756 378 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
mbed_official 76:aeb1df146756 379 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
mbed_official 76:aeb1df146756 380 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
mbed_official 76:aeb1df146756 381 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
mbed_official 76:aeb1df146756 382 void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
mbed_official 76:aeb1df146756 383
mbed_official 76:aeb1df146756 384 /* GPIO Alternate functions configuration functions ***************************/
mbed_official 76:aeb1df146756 385 void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF);
mbed_official 76:aeb1df146756 386
mbed_official 76:aeb1df146756 387 #ifdef __cplusplus
mbed_official 76:aeb1df146756 388 }
mbed_official 76:aeb1df146756 389 #endif
mbed_official 76:aeb1df146756 390
mbed_official 76:aeb1df146756 391 #endif /*__STM32L1xx_GPIO_H */
mbed_official 76:aeb1df146756 392
mbed_official 76:aeb1df146756 393 /**
mbed_official 76:aeb1df146756 394 * @}
mbed_official 76:aeb1df146756 395 */
mbed_official 76:aeb1df146756 396
mbed_official 76:aeb1df146756 397 /**
mbed_official 76:aeb1df146756 398 * @}
mbed_official 76:aeb1df146756 399 */
mbed_official 76:aeb1df146756 400
mbed_official 76:aeb1df146756 401 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/