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:
130:1dec54e4aec3
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 130:1dec54e4aec3 1 /**
mbed_official 130:1dec54e4aec3 2 ******************************************************************************
mbed_official 130:1dec54e4aec3 3 * @file stm32f0xx_gpio.c
mbed_official 130:1dec54e4aec3 4 * @author MCD Application Team
mbed_official 130:1dec54e4aec3 5 * @version V1.3.0
mbed_official 130:1dec54e4aec3 6 * @date 16-January-2014
mbed_official 130:1dec54e4aec3 7 * @brief This file provides firmware functions to manage the following
mbed_official 130:1dec54e4aec3 8 * functionalities of the GPIO peripheral:
mbed_official 130:1dec54e4aec3 9 * + Initialization and Configuration functions
mbed_official 130:1dec54e4aec3 10 * + GPIO Read and Write functions
mbed_official 130:1dec54e4aec3 11 * + GPIO Alternate functions configuration functions
mbed_official 130:1dec54e4aec3 12 *
mbed_official 130:1dec54e4aec3 13 * @verbatim
mbed_official 130:1dec54e4aec3 14 *
mbed_official 130:1dec54e4aec3 15 *
mbed_official 130:1dec54e4aec3 16 ===========================================================================
mbed_official 130:1dec54e4aec3 17 ##### How to use this driver #####
mbed_official 130:1dec54e4aec3 18 ===========================================================================
mbed_official 130:1dec54e4aec3 19 [..]
mbed_official 130:1dec54e4aec3 20 (#) Enable the GPIO AHB clock using RCC_AHBPeriphClockCmd()
mbed_official 130:1dec54e4aec3 21 (#) Configure the GPIO pin(s) using GPIO_Init()
mbed_official 130:1dec54e4aec3 22 Four possible configuration are available for each pin:
mbed_official 130:1dec54e4aec3 23 (++) Input: Floating, Pull-up, Pull-down.
mbed_official 130:1dec54e4aec3 24 (++) Output: Push-Pull (Pull-up, Pull-down or no Pull)
mbed_official 130:1dec54e4aec3 25 Open Drain (Pull-up, Pull-down or no Pull).
mbed_official 130:1dec54e4aec3 26 In output mode, the speed is configurable: Low, Medium, Fast or High.
mbed_official 130:1dec54e4aec3 27 (++) Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull)
mbed_official 130:1dec54e4aec3 28 Open Drain (Pull-up, Pull-down or no Pull).
mbed_official 130:1dec54e4aec3 29 (++) Analog: required mode when a pin is to be used as ADC channel,
mbed_official 130:1dec54e4aec3 30 DAC output or comparator input.
mbed_official 130:1dec54e4aec3 31 (#) Peripherals alternate function:
mbed_official 130:1dec54e4aec3 32 (++) For ADC, DAC and comparators, configure the desired pin in analog
mbed_official 130:1dec54e4aec3 33 mode using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN
mbed_official 130:1dec54e4aec3 34 (++) For other peripherals (TIM, USART...):
mbed_official 130:1dec54e4aec3 35 (+++) Connect the pin to the desired peripherals' Alternate
mbed_official 130:1dec54e4aec3 36 Function (AF) using GPIO_PinAFConfig() function. For PortC,
mbed_official 130:1dec54e4aec3 37 PortD and PortF, no configuration is needed.
mbed_official 130:1dec54e4aec3 38 (+++) Configure the desired pin in alternate function mode using
mbed_official 130:1dec54e4aec3 39 GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
mbed_official 130:1dec54e4aec3 40 (+++) Select the type, pull-up/pull-down and output speed via
mbed_official 130:1dec54e4aec3 41 GPIO_PuPd, GPIO_OType and GPIO_Speed members
mbed_official 130:1dec54e4aec3 42 (+++) Call GPIO_Init() function
mbed_official 130:1dec54e4aec3 43 (#) To get the level of a pin configured in input mode use GPIO_ReadInputDataBit()
mbed_official 130:1dec54e4aec3 44 (#) To set/reset the level of a pin configured in output mode use
mbed_official 130:1dec54e4aec3 45 GPIO_SetBits()/GPIO_ResetBits()
mbed_official 130:1dec54e4aec3 46 (#) During and just after reset, the alternate functions are not active and
mbed_official 130:1dec54e4aec3 47 the GPIO pins are configured in input floating mode (except JTAG pins).
mbed_official 130:1dec54e4aec3 48 (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as
mbed_official 130:1dec54e4aec3 49 general-purpose (PC14 and PC15, respectively) when the LSE oscillator
mbed_official 130:1dec54e4aec3 50 is off. The LSE has priority over the GPIO function.
mbed_official 130:1dec54e4aec3 51 (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as general-purpose
mbed_official 130:1dec54e4aec3 52 PD0 and PD1, respectively, when the HSE oscillator is off. The HSE has
mbed_official 130:1dec54e4aec3 53 priority over the GPIO function.
mbed_official 130:1dec54e4aec3 54 @endverbatim
mbed_official 130:1dec54e4aec3 55 ******************************************************************************
mbed_official 130:1dec54e4aec3 56 * @attention
mbed_official 130:1dec54e4aec3 57 *
mbed_official 130:1dec54e4aec3 58 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 130:1dec54e4aec3 59 *
mbed_official 130:1dec54e4aec3 60 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 130:1dec54e4aec3 61 * are permitted provided that the following conditions are met:
mbed_official 130:1dec54e4aec3 62 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 130:1dec54e4aec3 63 * this list of conditions and the following disclaimer.
mbed_official 130:1dec54e4aec3 64 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 130:1dec54e4aec3 65 * this list of conditions and the following disclaimer in the documentation
mbed_official 130:1dec54e4aec3 66 * and/or other materials provided with the distribution.
mbed_official 130:1dec54e4aec3 67 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 130:1dec54e4aec3 68 * may be used to endorse or promote products derived from this software
mbed_official 130:1dec54e4aec3 69 * without specific prior written permission.
mbed_official 130:1dec54e4aec3 70 *
mbed_official 130:1dec54e4aec3 71 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 130:1dec54e4aec3 72 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 130:1dec54e4aec3 73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 130:1dec54e4aec3 74 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 130:1dec54e4aec3 75 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 130:1dec54e4aec3 76 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 130:1dec54e4aec3 77 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 130:1dec54e4aec3 78 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 130:1dec54e4aec3 79 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 130:1dec54e4aec3 80 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 130:1dec54e4aec3 81 *
mbed_official 130:1dec54e4aec3 82 ******************************************************************************
mbed_official 130:1dec54e4aec3 83 */
mbed_official 130:1dec54e4aec3 84
mbed_official 130:1dec54e4aec3 85 /* Includes ------------------------------------------------------------------*/
mbed_official 130:1dec54e4aec3 86 #include "stm32f0xx_gpio.h"
mbed_official 130:1dec54e4aec3 87 #include "stm32f0xx_rcc.h"
mbed_official 130:1dec54e4aec3 88
mbed_official 130:1dec54e4aec3 89 /** @addtogroup STM32F0xx_StdPeriph_Driver
mbed_official 130:1dec54e4aec3 90 * @{
mbed_official 130:1dec54e4aec3 91 */
mbed_official 130:1dec54e4aec3 92
mbed_official 130:1dec54e4aec3 93 /** @defgroup GPIO
mbed_official 130:1dec54e4aec3 94 * @brief GPIO driver modules
mbed_official 130:1dec54e4aec3 95 * @{
mbed_official 130:1dec54e4aec3 96 */
mbed_official 130:1dec54e4aec3 97
mbed_official 130:1dec54e4aec3 98 /* Private typedef -----------------------------------------------------------*/
mbed_official 130:1dec54e4aec3 99 /* Private define ------------------------------------------------------------*/
mbed_official 130:1dec54e4aec3 100 /* Private macro -------------------------------------------------------------*/
mbed_official 130:1dec54e4aec3 101 /* Private variables ---------------------------------------------------------*/
mbed_official 130:1dec54e4aec3 102 /* Private function prototypes -----------------------------------------------*/
mbed_official 130:1dec54e4aec3 103 /* Private functions ---------------------------------------------------------*/
mbed_official 130:1dec54e4aec3 104
mbed_official 130:1dec54e4aec3 105 /** @defgroup GPIO_Private_Functions
mbed_official 130:1dec54e4aec3 106 * @{
mbed_official 130:1dec54e4aec3 107 */
mbed_official 130:1dec54e4aec3 108
mbed_official 130:1dec54e4aec3 109 /** @defgroup GPIO_Group1 Initialization and Configuration
mbed_official 130:1dec54e4aec3 110 * @brief Initialization and Configuration
mbed_official 130:1dec54e4aec3 111 *
mbed_official 130:1dec54e4aec3 112 @verbatim
mbed_official 130:1dec54e4aec3 113 ===============================================================================
mbed_official 130:1dec54e4aec3 114 ##### Initialization and Configuration #####
mbed_official 130:1dec54e4aec3 115 ===============================================================================
mbed_official 130:1dec54e4aec3 116
mbed_official 130:1dec54e4aec3 117 @endverbatim
mbed_official 130:1dec54e4aec3 118 * @{
mbed_official 130:1dec54e4aec3 119 */
mbed_official 130:1dec54e4aec3 120
mbed_official 130:1dec54e4aec3 121 /**
mbed_official 130:1dec54e4aec3 122 * @brief Deinitializes the GPIOx peripheral registers to their default reset
mbed_official 130:1dec54e4aec3 123 * values.
mbed_official 130:1dec54e4aec3 124 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 125 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 126 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 127 * @retval None
mbed_official 130:1dec54e4aec3 128 */
mbed_official 130:1dec54e4aec3 129 void GPIO_DeInit(GPIO_TypeDef* GPIOx)
mbed_official 130:1dec54e4aec3 130 {
mbed_official 130:1dec54e4aec3 131 /* Check the parameters */
mbed_official 130:1dec54e4aec3 132 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 133
mbed_official 130:1dec54e4aec3 134 if(GPIOx == GPIOA)
mbed_official 130:1dec54e4aec3 135 {
mbed_official 130:1dec54e4aec3 136 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOA, ENABLE);
mbed_official 130:1dec54e4aec3 137 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOA, DISABLE);
mbed_official 130:1dec54e4aec3 138 }
mbed_official 130:1dec54e4aec3 139 else if(GPIOx == GPIOB)
mbed_official 130:1dec54e4aec3 140 {
mbed_official 130:1dec54e4aec3 141 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOB, ENABLE);
mbed_official 130:1dec54e4aec3 142 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOB, DISABLE);
mbed_official 130:1dec54e4aec3 143 }
mbed_official 130:1dec54e4aec3 144 else if(GPIOx == GPIOC)
mbed_official 130:1dec54e4aec3 145 {
mbed_official 130:1dec54e4aec3 146 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOC, ENABLE);
mbed_official 130:1dec54e4aec3 147 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOC, DISABLE);
mbed_official 130:1dec54e4aec3 148 }
mbed_official 130:1dec54e4aec3 149 else if(GPIOx == GPIOD)
mbed_official 130:1dec54e4aec3 150 {
mbed_official 130:1dec54e4aec3 151 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOD, ENABLE);
mbed_official 130:1dec54e4aec3 152 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOD, DISABLE);
mbed_official 130:1dec54e4aec3 153 }
mbed_official 130:1dec54e4aec3 154 else if(GPIOx == GPIOE)
mbed_official 130:1dec54e4aec3 155 {
mbed_official 130:1dec54e4aec3 156 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOE, ENABLE);
mbed_official 130:1dec54e4aec3 157 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOE, DISABLE);
mbed_official 130:1dec54e4aec3 158 }
mbed_official 130:1dec54e4aec3 159 else
mbed_official 130:1dec54e4aec3 160 {
mbed_official 130:1dec54e4aec3 161 if(GPIOx == GPIOF)
mbed_official 130:1dec54e4aec3 162 {
mbed_official 130:1dec54e4aec3 163 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOF, ENABLE);
mbed_official 130:1dec54e4aec3 164 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_GPIOF, DISABLE);
mbed_official 130:1dec54e4aec3 165 }
mbed_official 130:1dec54e4aec3 166 }
mbed_official 130:1dec54e4aec3 167 }
mbed_official 130:1dec54e4aec3 168
mbed_official 130:1dec54e4aec3 169 /**
mbed_official 130:1dec54e4aec3 170 * @brief Initializes the GPIOx peripheral according to the specified
mbed_official 130:1dec54e4aec3 171 * parameters in the GPIO_InitStruct.
mbed_official 130:1dec54e4aec3 172 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 173 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 174 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 175 * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that contains
mbed_official 130:1dec54e4aec3 176 * the configuration information for the specified GPIO peripheral.
mbed_official 130:1dec54e4aec3 177 * @retval None
mbed_official 130:1dec54e4aec3 178 */
mbed_official 130:1dec54e4aec3 179 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
mbed_official 130:1dec54e4aec3 180 {
mbed_official 130:1dec54e4aec3 181 uint32_t pinpos = 0x00, pos = 0x00 , currentpin = 0x00;
mbed_official 130:1dec54e4aec3 182
mbed_official 130:1dec54e4aec3 183 /* Check the parameters */
mbed_official 130:1dec54e4aec3 184 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 185 assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
mbed_official 130:1dec54e4aec3 186 assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
mbed_official 130:1dec54e4aec3 187 assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
mbed_official 130:1dec54e4aec3 188
mbed_official 130:1dec54e4aec3 189 /*-------------------------- Configure the port pins -----------------------*/
mbed_official 130:1dec54e4aec3 190 /*-- GPIO Mode Configuration --*/
mbed_official 130:1dec54e4aec3 191 for (pinpos = 0x00; pinpos < 0x10; pinpos++)
mbed_official 130:1dec54e4aec3 192 {
mbed_official 130:1dec54e4aec3 193 pos = ((uint32_t)0x01) << pinpos;
mbed_official 130:1dec54e4aec3 194
mbed_official 130:1dec54e4aec3 195 /* Get the port pins position */
mbed_official 130:1dec54e4aec3 196 currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
mbed_official 130:1dec54e4aec3 197
mbed_official 130:1dec54e4aec3 198 if (currentpin == pos)
mbed_official 130:1dec54e4aec3 199 {
mbed_official 130:1dec54e4aec3 200 if ((GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT) || (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_AF))
mbed_official 130:1dec54e4aec3 201 {
mbed_official 130:1dec54e4aec3 202 /* Check Speed mode parameters */
mbed_official 130:1dec54e4aec3 203 assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
mbed_official 130:1dec54e4aec3 204
mbed_official 130:1dec54e4aec3 205 /* Speed mode configuration */
mbed_official 130:1dec54e4aec3 206 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pinpos * 2));
mbed_official 130:1dec54e4aec3 207 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_InitStruct->GPIO_Speed) << (pinpos * 2));
mbed_official 130:1dec54e4aec3 208
mbed_official 130:1dec54e4aec3 209 /* Check Output mode parameters */
mbed_official 130:1dec54e4aec3 210 assert_param(IS_GPIO_OTYPE(GPIO_InitStruct->GPIO_OType));
mbed_official 130:1dec54e4aec3 211
mbed_official 130:1dec54e4aec3 212 /* Output mode configuration */
mbed_official 130:1dec54e4aec3 213 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pinpos));
mbed_official 130:1dec54e4aec3 214 GPIOx->OTYPER |= (uint16_t)(((uint16_t)GPIO_InitStruct->GPIO_OType) << ((uint16_t)pinpos));
mbed_official 130:1dec54e4aec3 215 }
mbed_official 130:1dec54e4aec3 216
mbed_official 130:1dec54e4aec3 217 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (pinpos * 2));
mbed_official 130:1dec54e4aec3 218
mbed_official 130:1dec54e4aec3 219 GPIOx->MODER |= (((uint32_t)GPIO_InitStruct->GPIO_Mode) << (pinpos * 2));
mbed_official 130:1dec54e4aec3 220
mbed_official 130:1dec54e4aec3 221 /* Pull-up Pull down resistor configuration */
mbed_official 130:1dec54e4aec3 222 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pinpos * 2));
mbed_official 130:1dec54e4aec3 223 GPIOx->PUPDR |= (((uint32_t)GPIO_InitStruct->GPIO_PuPd) << (pinpos * 2));
mbed_official 130:1dec54e4aec3 224 }
mbed_official 130:1dec54e4aec3 225 }
mbed_official 130:1dec54e4aec3 226 }
mbed_official 130:1dec54e4aec3 227
mbed_official 130:1dec54e4aec3 228 /**
mbed_official 130:1dec54e4aec3 229 * @brief Fills each GPIO_InitStruct member with its default value.
mbed_official 130:1dec54e4aec3 230 * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure which will
mbed_official 130:1dec54e4aec3 231 * be initialized.
mbed_official 130:1dec54e4aec3 232 * @retval None
mbed_official 130:1dec54e4aec3 233 */
mbed_official 130:1dec54e4aec3 234 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
mbed_official 130:1dec54e4aec3 235 {
mbed_official 130:1dec54e4aec3 236 /* Reset GPIO init structure parameters values */
mbed_official 130:1dec54e4aec3 237 GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
mbed_official 130:1dec54e4aec3 238 GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
mbed_official 130:1dec54e4aec3 239 GPIO_InitStruct->GPIO_Speed = GPIO_Speed_Level_2;
mbed_official 130:1dec54e4aec3 240 GPIO_InitStruct->GPIO_OType = GPIO_OType_PP;
mbed_official 130:1dec54e4aec3 241 GPIO_InitStruct->GPIO_PuPd = GPIO_PuPd_NOPULL;
mbed_official 130:1dec54e4aec3 242 }
mbed_official 130:1dec54e4aec3 243
mbed_official 130:1dec54e4aec3 244 /**
mbed_official 130:1dec54e4aec3 245 * @brief Locks GPIO Pins configuration registers.
mbed_official 130:1dec54e4aec3 246 * @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
mbed_official 130:1dec54e4aec3 247 * GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
mbed_official 130:1dec54e4aec3 248 * @note The configuration of the locked GPIO pins can no longer be modified
mbed_official 130:1dec54e4aec3 249 * until the next device reset.
mbed_official 130:1dec54e4aec3 250 * @param GPIOx: where x can be (A or B) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 251 * @param GPIO_Pin: specifies the port bit to be written.
mbed_official 130:1dec54e4aec3 252 * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
mbed_official 130:1dec54e4aec3 253 * @retval None
mbed_official 130:1dec54e4aec3 254 */
mbed_official 130:1dec54e4aec3 255 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 130:1dec54e4aec3 256 {
mbed_official 130:1dec54e4aec3 257 __IO uint32_t tmp = 0x00010000;
mbed_official 130:1dec54e4aec3 258
mbed_official 130:1dec54e4aec3 259 /* Check the parameters */
mbed_official 130:1dec54e4aec3 260 assert_param(IS_GPIO_LIST_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 261 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 130:1dec54e4aec3 262
mbed_official 130:1dec54e4aec3 263 tmp |= GPIO_Pin;
mbed_official 130:1dec54e4aec3 264 /* Set LCKK bit */
mbed_official 130:1dec54e4aec3 265 GPIOx->LCKR = tmp;
mbed_official 130:1dec54e4aec3 266 /* Reset LCKK bit */
mbed_official 130:1dec54e4aec3 267 GPIOx->LCKR = GPIO_Pin;
mbed_official 130:1dec54e4aec3 268 /* Set LCKK bit */
mbed_official 130:1dec54e4aec3 269 GPIOx->LCKR = tmp;
mbed_official 130:1dec54e4aec3 270 /* Read LCKK bit */
mbed_official 130:1dec54e4aec3 271 tmp = GPIOx->LCKR;
mbed_official 130:1dec54e4aec3 272 /* Read LCKK bit */
mbed_official 130:1dec54e4aec3 273 tmp = GPIOx->LCKR;
mbed_official 130:1dec54e4aec3 274 }
mbed_official 130:1dec54e4aec3 275
mbed_official 130:1dec54e4aec3 276 /**
mbed_official 130:1dec54e4aec3 277 * @}
mbed_official 130:1dec54e4aec3 278 */
mbed_official 130:1dec54e4aec3 279
mbed_official 130:1dec54e4aec3 280 /** @defgroup GPIO_Group2 GPIO Read and Write
mbed_official 130:1dec54e4aec3 281 * @brief GPIO Read and Write
mbed_official 130:1dec54e4aec3 282 *
mbed_official 130:1dec54e4aec3 283 @verbatim
mbed_official 130:1dec54e4aec3 284 ===============================================================================
mbed_official 130:1dec54e4aec3 285 ##### GPIO Read and Write #####
mbed_official 130:1dec54e4aec3 286 ===============================================================================
mbed_official 130:1dec54e4aec3 287
mbed_official 130:1dec54e4aec3 288 @endverbatim
mbed_official 130:1dec54e4aec3 289 * @{
mbed_official 130:1dec54e4aec3 290 */
mbed_official 130:1dec54e4aec3 291
mbed_official 130:1dec54e4aec3 292 /**
mbed_official 130:1dec54e4aec3 293 * @brief Reads the specified input port pin.
mbed_official 130:1dec54e4aec3 294 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 295 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 296 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 297 * @param GPIO_Pin: specifies the port bit to read.
mbed_official 130:1dec54e4aec3 298 * @note This parameter can be GPIO_Pin_x where x can be:
mbed_official 130:1dec54e4aec3 299 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GIIOF.
mbed_official 130:1dec54e4aec3 300 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 130:1dec54e4aec3 301 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 130:1dec54e4aec3 302 * @retval The input port pin value.
mbed_official 130:1dec54e4aec3 303 */
mbed_official 130:1dec54e4aec3 304 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 130:1dec54e4aec3 305 {
mbed_official 130:1dec54e4aec3 306 uint8_t bitstatus = 0x00;
mbed_official 130:1dec54e4aec3 307
mbed_official 130:1dec54e4aec3 308 /* Check the parameters */
mbed_official 130:1dec54e4aec3 309 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 310 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
mbed_official 130:1dec54e4aec3 311
mbed_official 130:1dec54e4aec3 312 if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
mbed_official 130:1dec54e4aec3 313 {
mbed_official 130:1dec54e4aec3 314 bitstatus = (uint8_t)Bit_SET;
mbed_official 130:1dec54e4aec3 315 }
mbed_official 130:1dec54e4aec3 316 else
mbed_official 130:1dec54e4aec3 317 {
mbed_official 130:1dec54e4aec3 318 bitstatus = (uint8_t)Bit_RESET;
mbed_official 130:1dec54e4aec3 319 }
mbed_official 130:1dec54e4aec3 320 return bitstatus;
mbed_official 130:1dec54e4aec3 321 }
mbed_official 130:1dec54e4aec3 322
mbed_official 130:1dec54e4aec3 323 /**
mbed_official 130:1dec54e4aec3 324 * @brief Reads the specified input port pin.
mbed_official 130:1dec54e4aec3 325 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 326 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 327 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 328 * @retval The input port pin value.
mbed_official 130:1dec54e4aec3 329 */
mbed_official 130:1dec54e4aec3 330 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
mbed_official 130:1dec54e4aec3 331 {
mbed_official 130:1dec54e4aec3 332 /* Check the parameters */
mbed_official 130:1dec54e4aec3 333 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 334
mbed_official 130:1dec54e4aec3 335 return ((uint16_t)GPIOx->IDR);
mbed_official 130:1dec54e4aec3 336 }
mbed_official 130:1dec54e4aec3 337
mbed_official 130:1dec54e4aec3 338 /**
mbed_official 130:1dec54e4aec3 339 * @brief Reads the specified output data port bit.
mbed_official 130:1dec54e4aec3 340 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 341 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 342 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 343 * @param GPIO_Pin: Specifies the port bit to read.
mbed_official 130:1dec54e4aec3 344 * @note This parameter can be GPIO_Pin_x where x can be:
mbed_official 130:1dec54e4aec3 345 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GIIOF.
mbed_official 130:1dec54e4aec3 346 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 130:1dec54e4aec3 347 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 130:1dec54e4aec3 348 * @retval The output port pin value.
mbed_official 130:1dec54e4aec3 349 */
mbed_official 130:1dec54e4aec3 350 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 130:1dec54e4aec3 351 {
mbed_official 130:1dec54e4aec3 352 uint8_t bitstatus = 0x00;
mbed_official 130:1dec54e4aec3 353
mbed_official 130:1dec54e4aec3 354 /* Check the parameters */
mbed_official 130:1dec54e4aec3 355 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 356 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
mbed_official 130:1dec54e4aec3 357
mbed_official 130:1dec54e4aec3 358 if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET)
mbed_official 130:1dec54e4aec3 359 {
mbed_official 130:1dec54e4aec3 360 bitstatus = (uint8_t)Bit_SET;
mbed_official 130:1dec54e4aec3 361 }
mbed_official 130:1dec54e4aec3 362 else
mbed_official 130:1dec54e4aec3 363 {
mbed_official 130:1dec54e4aec3 364 bitstatus = (uint8_t)Bit_RESET;
mbed_official 130:1dec54e4aec3 365 }
mbed_official 130:1dec54e4aec3 366 return bitstatus;
mbed_official 130:1dec54e4aec3 367 }
mbed_official 130:1dec54e4aec3 368
mbed_official 130:1dec54e4aec3 369 /**
mbed_official 130:1dec54e4aec3 370 * @brief Reads the specified GPIO output data port.
mbed_official 130:1dec54e4aec3 371 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 372 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 373 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 374 * @retval GPIO output data port value.
mbed_official 130:1dec54e4aec3 375 */
mbed_official 130:1dec54e4aec3 376 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
mbed_official 130:1dec54e4aec3 377 {
mbed_official 130:1dec54e4aec3 378 /* Check the parameters */
mbed_official 130:1dec54e4aec3 379 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 380
mbed_official 130:1dec54e4aec3 381 return ((uint16_t)GPIOx->ODR);
mbed_official 130:1dec54e4aec3 382 }
mbed_official 130:1dec54e4aec3 383
mbed_official 130:1dec54e4aec3 384 /**
mbed_official 130:1dec54e4aec3 385 * @brief Sets the selected data port bits.
mbed_official 130:1dec54e4aec3 386 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 387 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 388 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 389 * @param GPIO_Pin: specifies the port bits to be written.
mbed_official 130:1dec54e4aec3 390 * @note This parameter can be GPIO_Pin_x where x can be:
mbed_official 130:1dec54e4aec3 391 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GIIOF.
mbed_official 130:1dec54e4aec3 392 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 130:1dec54e4aec3 393 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 130:1dec54e4aec3 394 * @retval None
mbed_official 130:1dec54e4aec3 395 */
mbed_official 130:1dec54e4aec3 396 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 130:1dec54e4aec3 397 {
mbed_official 130:1dec54e4aec3 398 /* Check the parameters */
mbed_official 130:1dec54e4aec3 399 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 400 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 130:1dec54e4aec3 401
mbed_official 130:1dec54e4aec3 402 GPIOx->BSRR = GPIO_Pin;
mbed_official 130:1dec54e4aec3 403 }
mbed_official 130:1dec54e4aec3 404
mbed_official 130:1dec54e4aec3 405 /**
mbed_official 130:1dec54e4aec3 406 * @brief Clears the selected data port bits.
mbed_official 130:1dec54e4aec3 407 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 408 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 409 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 410 * @param GPIO_Pin: specifies the port bits to be written.
mbed_official 130:1dec54e4aec3 411 * @note This parameter can be GPIO_Pin_x where x can be:
mbed_official 130:1dec54e4aec3 412 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GIIOF.
mbed_official 130:1dec54e4aec3 413 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 130:1dec54e4aec3 414 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 130:1dec54e4aec3 415 * @retval None
mbed_official 130:1dec54e4aec3 416 */
mbed_official 130:1dec54e4aec3 417 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 130:1dec54e4aec3 418 {
mbed_official 130:1dec54e4aec3 419 /* Check the parameters */
mbed_official 130:1dec54e4aec3 420 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 421 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 130:1dec54e4aec3 422
mbed_official 130:1dec54e4aec3 423 GPIOx->BRR = GPIO_Pin;
mbed_official 130:1dec54e4aec3 424 }
mbed_official 130:1dec54e4aec3 425
mbed_official 130:1dec54e4aec3 426 /**
mbed_official 130:1dec54e4aec3 427 * @brief Sets or clears the selected data port bit.
mbed_official 130:1dec54e4aec3 428 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 429 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 430 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 431 * @param GPIO_Pin: specifies the port bit to be written.
mbed_official 130:1dec54e4aec3 432 * @param BitVal: specifies the value to be written to the selected bit.
mbed_official 130:1dec54e4aec3 433 * This parameter can be one of the BitAction enumeration values:
mbed_official 130:1dec54e4aec3 434 * @arg Bit_RESET: to clear the port pin
mbed_official 130:1dec54e4aec3 435 * @arg Bit_SET: to set the port pin
mbed_official 130:1dec54e4aec3 436 * @note This parameter can be GPIO_Pin_x where x can be:
mbed_official 130:1dec54e4aec3 437 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GIIOF.
mbed_official 130:1dec54e4aec3 438 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 130:1dec54e4aec3 439 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 130:1dec54e4aec3 440 * @retval None
mbed_official 130:1dec54e4aec3 441 */
mbed_official 130:1dec54e4aec3 442 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
mbed_official 130:1dec54e4aec3 443 {
mbed_official 130:1dec54e4aec3 444 /* Check the parameters */
mbed_official 130:1dec54e4aec3 445 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 446 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
mbed_official 130:1dec54e4aec3 447 assert_param(IS_GPIO_BIT_ACTION(BitVal));
mbed_official 130:1dec54e4aec3 448
mbed_official 130:1dec54e4aec3 449 if (BitVal != Bit_RESET)
mbed_official 130:1dec54e4aec3 450 {
mbed_official 130:1dec54e4aec3 451 GPIOx->BSRR = GPIO_Pin;
mbed_official 130:1dec54e4aec3 452 }
mbed_official 130:1dec54e4aec3 453 else
mbed_official 130:1dec54e4aec3 454 {
mbed_official 130:1dec54e4aec3 455 GPIOx->BRR = GPIO_Pin ;
mbed_official 130:1dec54e4aec3 456 }
mbed_official 130:1dec54e4aec3 457 }
mbed_official 130:1dec54e4aec3 458
mbed_official 130:1dec54e4aec3 459 /**
mbed_official 130:1dec54e4aec3 460 * @brief Writes data to the specified GPIO data port.
mbed_official 130:1dec54e4aec3 461 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 462 * @note GPIOE is available only for STM32F072.
mbed_official 130:1dec54e4aec3 463 * @note GPIOD is not available for STM32F031.
mbed_official 130:1dec54e4aec3 464 * @param PortVal: specifies the value to be written to the port output data register.
mbed_official 130:1dec54e4aec3 465 * @retval None
mbed_official 130:1dec54e4aec3 466 */
mbed_official 130:1dec54e4aec3 467 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
mbed_official 130:1dec54e4aec3 468 {
mbed_official 130:1dec54e4aec3 469 /* Check the parameters */
mbed_official 130:1dec54e4aec3 470 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 471
mbed_official 130:1dec54e4aec3 472 GPIOx->ODR = PortVal;
mbed_official 130:1dec54e4aec3 473 }
mbed_official 130:1dec54e4aec3 474
mbed_official 130:1dec54e4aec3 475 /**
mbed_official 130:1dec54e4aec3 476 * @}
mbed_official 130:1dec54e4aec3 477 */
mbed_official 130:1dec54e4aec3 478
mbed_official 130:1dec54e4aec3 479 /** @defgroup GPIO_Group3 GPIO Alternate functions configuration functions
mbed_official 130:1dec54e4aec3 480 * @brief GPIO Alternate functions configuration functions
mbed_official 130:1dec54e4aec3 481 *
mbed_official 130:1dec54e4aec3 482 @verbatim
mbed_official 130:1dec54e4aec3 483 ===============================================================================
mbed_official 130:1dec54e4aec3 484 ##### GPIO Alternate functions configuration functions #####
mbed_official 130:1dec54e4aec3 485 ===============================================================================
mbed_official 130:1dec54e4aec3 486
mbed_official 130:1dec54e4aec3 487 @endverbatim
mbed_official 130:1dec54e4aec3 488 * @{
mbed_official 130:1dec54e4aec3 489 */
mbed_official 130:1dec54e4aec3 490
mbed_official 130:1dec54e4aec3 491 /**
mbed_official 130:1dec54e4aec3 492 * @brief Writes data to the specified GPIO data port.
mbed_official 130:1dec54e4aec3 493 * @param GPIOx: where x can be (A, B, C, D, E or F) to select the GPIO peripheral.
mbed_official 130:1dec54e4aec3 494 * @note GPIOC, GPIOD, GPIOE and GPIOF are available only for STM32F072.
mbed_official 130:1dec54e4aec3 495 * @param GPIO_PinSource: specifies the pin for the Alternate function.
mbed_official 130:1dec54e4aec3 496 * This parameter can be GPIO_PinSourcex where x can be (0..15) for GPIOA, GPIOB, GPIOD, GPIOE
mbed_official 130:1dec54e4aec3 497 * and (0..12) for GPIOC and (0, 2..5, 9..10) for GPIOF.
mbed_official 130:1dec54e4aec3 498 * @param GPIO_AF: selects the pin to used as Alternate function.
mbed_official 130:1dec54e4aec3 499 * This parameter can be one of the following value:
mbed_official 130:1dec54e4aec3 500 * @arg GPIO_AF_0: WKUP, EVENTOUT, TIM15, SPI1, TIM17, MCO, SWDAT, SWCLK,
mbed_official 130:1dec54e4aec3 501 * TIM14, BOOT, USART1, CEC, IR_OUT, SPI2, TIM3, USART4,
mbed_official 130:1dec54e4aec3 502 * CAN, USART2, CRS, TIM16, TIM1, TS
mbed_official 130:1dec54e4aec3 503 * @arg GPIO_AF_1: USART2, CEC, TIM3, USART1, USART2, EVENTOUT, I2C1,
mbed_official 130:1dec54e4aec3 504 * I2C2, TIM15, SPI2, USART3, TS, SPI1
mbed_official 130:1dec54e4aec3 505 * @arg GPIO_AF_2: TIM2, TIM1, EVENTOUT, TIM16, TIM17, USB
mbed_official 130:1dec54e4aec3 506 * @arg GPIO_AF_3: TS, I2C1, TIM15, EVENTOUT
mbed_official 130:1dec54e4aec3 507 * @arg GPIO_AF_4: TIM14, USART4, USART3, CRS, CAN
mbed_official 130:1dec54e4aec3 508 * @arg GPIO_AF_5: TIM16, TIM17, TIM15, SPI2, I2C2
mbed_official 130:1dec54e4aec3 509 * @arg GPIO_AF_6: EVENTOUT
mbed_official 130:1dec54e4aec3 510 * @arg GPIO_AF_7: COMP1 OUT, COMP2 OUT
mbed_official 130:1dec54e4aec3 511 * @note The pin should already been configured in Alternate Function mode(AF)
mbed_official 130:1dec54e4aec3 512 * using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
mbed_official 130:1dec54e4aec3 513 * @note Refer to the Alternate function mapping table in the device datasheet
mbed_official 130:1dec54e4aec3 514 * for the detailed mapping of the system and peripherals'alternate
mbed_official 130:1dec54e4aec3 515 * function I/O pins.
mbed_official 130:1dec54e4aec3 516 * @retval None
mbed_official 130:1dec54e4aec3 517 */
mbed_official 130:1dec54e4aec3 518 void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
mbed_official 130:1dec54e4aec3 519 {
mbed_official 130:1dec54e4aec3 520 uint32_t temp = 0x00;
mbed_official 130:1dec54e4aec3 521 uint32_t temp_2 = 0x00;
mbed_official 130:1dec54e4aec3 522
mbed_official 130:1dec54e4aec3 523 /* Check the parameters */
mbed_official 130:1dec54e4aec3 524 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 130:1dec54e4aec3 525 assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
mbed_official 130:1dec54e4aec3 526 assert_param(IS_GPIO_AF(GPIO_AF));
mbed_official 130:1dec54e4aec3 527
mbed_official 130:1dec54e4aec3 528 temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
mbed_official 130:1dec54e4aec3 529 GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
mbed_official 130:1dec54e4aec3 530 temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
mbed_official 130:1dec54e4aec3 531 GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
mbed_official 130:1dec54e4aec3 532 }
mbed_official 130:1dec54e4aec3 533
mbed_official 130:1dec54e4aec3 534 /**
mbed_official 130:1dec54e4aec3 535 * @}
mbed_official 130:1dec54e4aec3 536 */
mbed_official 130:1dec54e4aec3 537
mbed_official 130:1dec54e4aec3 538 /**
mbed_official 130:1dec54e4aec3 539 * @}
mbed_official 130:1dec54e4aec3 540 */
mbed_official 130:1dec54e4aec3 541
mbed_official 130:1dec54e4aec3 542 /**
mbed_official 130:1dec54e4aec3 543 * @}
mbed_official 130:1dec54e4aec3 544 */
mbed_official 130:1dec54e4aec3 545
mbed_official 130:1dec54e4aec3 546 /**
mbed_official 130:1dec54e4aec3 547 * @}
mbed_official 130:1dec54e4aec3 548 */
mbed_official 130:1dec54e4aec3 549
mbed_official 130:1dec54e4aec3 550 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/