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