mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri May 30 15:30:09 2014 +0100
Revision:
218:44081b78fdc2
Parent:
205:c41fc65bcfb4
Synchronized with git revision d854859072d318241476ccc5f335965444d4c1d8

Full URL: https://github.com/mbedmicro/mbed/commit/d854859072d318241476ccc5f335965444d4c1d8/

[NUCLEO_F072RB] Update CubeF0 HAL driver

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 205:c41fc65bcfb4 1 /**
mbed_official 205:c41fc65bcfb4 2 ******************************************************************************
mbed_official 205:c41fc65bcfb4 3 * @file stm32f0xx_hal_gpio.c
mbed_official 205:c41fc65bcfb4 4 * @author MCD Application Team
mbed_official 205:c41fc65bcfb4 5 * @version V1.0.0
mbed_official 218:44081b78fdc2 6 * @date 28-May-2014
mbed_official 205:c41fc65bcfb4 7 * @brief GPIO HAL module driver.
mbed_official 205:c41fc65bcfb4 8 *
mbed_official 205:c41fc65bcfb4 9 * This file provides firmware functions to manage the following
mbed_official 205:c41fc65bcfb4 10 * functionalities of the General Purpose Input/Output (GPIO) peripheral:
mbed_official 205:c41fc65bcfb4 11 * + Initialization/de-initialization function
mbed_official 205:c41fc65bcfb4 12 * + IO operation function
mbed_official 205:c41fc65bcfb4 13 *
mbed_official 205:c41fc65bcfb4 14 @verbatim
mbed_official 205:c41fc65bcfb4 15 ==============================================================================
mbed_official 205:c41fc65bcfb4 16 ##### GPIO specific features #####
mbed_official 205:c41fc65bcfb4 17 ==============================================================================
mbed_official 205:c41fc65bcfb4 18 [..]
mbed_official 205:c41fc65bcfb4 19 Each port bit of the general-purpose I/O (GPIO) ports can be individually
mbed_official 205:c41fc65bcfb4 20 configured by software in several modes:
mbed_official 205:c41fc65bcfb4 21 (+) Input mode
mbed_official 205:c41fc65bcfb4 22 (+) Analog mode
mbed_official 205:c41fc65bcfb4 23 (+) Output mode
mbed_official 205:c41fc65bcfb4 24 (+) Alternate function mode
mbed_official 205:c41fc65bcfb4 25 (+) External interrupt/event lines
mbed_official 205:c41fc65bcfb4 26
mbed_official 205:c41fc65bcfb4 27 [..]
mbed_official 205:c41fc65bcfb4 28 During and just after reset, the alternate functions and external interrupt
mbed_official 205:c41fc65bcfb4 29 lines are not active and the I/O ports are configured in input floating mode.
mbed_official 205:c41fc65bcfb4 30
mbed_official 205:c41fc65bcfb4 31 [..]
mbed_official 205:c41fc65bcfb4 32 All GPIO pins have weak internal pull-up and pull-down resistors, which can be
mbed_official 205:c41fc65bcfb4 33 activated or not.
mbed_official 205:c41fc65bcfb4 34
mbed_official 205:c41fc65bcfb4 35 [..]
mbed_official 205:c41fc65bcfb4 36 In Output or Alternate mode, each IO can be configured on open-drain or push-pull
mbed_official 205:c41fc65bcfb4 37 type and the IO speed can be selected depending on the VDD value.
mbed_official 205:c41fc65bcfb4 38
mbed_official 205:c41fc65bcfb4 39 [..]
mbed_official 205:c41fc65bcfb4 40 The microcontroller IO pins are connected to onboard peripherals/modules through a
mbed_official 205:c41fc65bcfb4 41 multiplexer that allows only one peripheral’s alternate function (AF) connected
mbed_official 205:c41fc65bcfb4 42 to an IO pin at a time. In this way, there can be no conflict between peripherals
mbed_official 205:c41fc65bcfb4 43 sharing the same IO pin.
mbed_official 205:c41fc65bcfb4 44
mbed_official 205:c41fc65bcfb4 45 [..]
mbed_official 205:c41fc65bcfb4 46 All ports have external interrupt/event capability. To use external interrupt
mbed_official 205:c41fc65bcfb4 47 lines, the port must be configured in input mode. All available GPIO pins are
mbed_official 205:c41fc65bcfb4 48 connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
mbed_official 205:c41fc65bcfb4 49
mbed_official 205:c41fc65bcfb4 50 [..]
mbed_official 205:c41fc65bcfb4 51 The external interrupt/event controller consists of up to 23 edge detectors
mbed_official 205:c41fc65bcfb4 52 (16 lines are connected to GPIO) for generating event/interrupt requests (each
mbed_official 205:c41fc65bcfb4 53 input line can be independently configured to select the type (interrupt or event)
mbed_official 205:c41fc65bcfb4 54 and the corresponding trigger event (rising or falling or both). Each line can
mbed_official 205:c41fc65bcfb4 55 also be masked independently.
mbed_official 205:c41fc65bcfb4 56
mbed_official 205:c41fc65bcfb4 57 ##### How to use this driver #####
mbed_official 205:c41fc65bcfb4 58 ==============================================================================
mbed_official 205:c41fc65bcfb4 59 [..]
mbed_official 205:c41fc65bcfb4 60 (#) Enable the GPIO AHB clock using the following function : __GPIOx_CLK_ENABLE().
mbed_official 205:c41fc65bcfb4 61
mbed_official 205:c41fc65bcfb4 62 (#) In case of external interrupt/event mode selection, enable the SYSCFG clock
mbed_official 205:c41fc65bcfb4 63 using the following function __SYSCFG_CLK_ENABLE().
mbed_official 205:c41fc65bcfb4 64
mbed_official 205:c41fc65bcfb4 65 (#) Configure the GPIO pin(s) using HAL_GPIO_Init().
mbed_official 205:c41fc65bcfb4 66 (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
mbed_official 205:c41fc65bcfb4 67 (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef
mbed_official 205:c41fc65bcfb4 68 structure.
mbed_official 205:c41fc65bcfb4 69 (++) In case of Output or alternate function mode selection: the speed is
mbed_official 205:c41fc65bcfb4 70 configured through "Speed" member from GPIO_InitTypeDef structure,
mbed_official 205:c41fc65bcfb4 71 the speed is configurable: 2 MHz, 10 MHz and 50 MHz.
mbed_official 205:c41fc65bcfb4 72 (++) If alternate mode is selected, the alternate function connected to the IO
mbed_official 205:c41fc65bcfb4 73 is configured through "Alternate" member from GPIO_InitTypeDef structure
mbed_official 205:c41fc65bcfb4 74 (++) Analog mode is required when a pin is to be used as ADC channel
mbed_official 205:c41fc65bcfb4 75 or DAC output.
mbed_official 205:c41fc65bcfb4 76 (++) In case of external interrupt/event selection the "Mode" member from
mbed_official 205:c41fc65bcfb4 77 GPIO_InitTypeDef structure select the type (interrupt or event) and
mbed_official 205:c41fc65bcfb4 78 the corresponding trigger event (rising or falling or both).
mbed_official 205:c41fc65bcfb4 79
mbed_official 205:c41fc65bcfb4 80 (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
mbed_official 205:c41fc65bcfb4 81 mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
mbed_official 205:c41fc65bcfb4 82 HAL_NVIC_EnableIRQ().
mbed_official 205:c41fc65bcfb4 83
mbed_official 205:c41fc65bcfb4 84 (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
mbed_official 205:c41fc65bcfb4 85
mbed_official 205:c41fc65bcfb4 86 (#) To set/reset the level of a pin configured in output mode use
mbed_official 205:c41fc65bcfb4 87 HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
mbed_official 205:c41fc65bcfb4 88
mbed_official 205:c41fc65bcfb4 89 (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
mbed_official 205:c41fc65bcfb4 90
mbed_official 205:c41fc65bcfb4 91 (#) During and just after reset, the alternate functions are not
mbed_official 205:c41fc65bcfb4 92 active and the GPIO pins are configured in input floating mode (except JTAG
mbed_official 205:c41fc65bcfb4 93 pins).
mbed_official 205:c41fc65bcfb4 94
mbed_official 205:c41fc65bcfb4 95 (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose
mbed_official 205:c41fc65bcfb4 96 (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
mbed_official 205:c41fc65bcfb4 97 priority over the GPIO function.
mbed_official 205:c41fc65bcfb4 98
mbed_official 205:c41fc65bcfb4 99 (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as
mbed_official 205:c41fc65bcfb4 100 general purpose PD0 and PD1, respectively, when the HSE oscillator is off.
mbed_official 205:c41fc65bcfb4 101 The HSE has priority over the GPIO function.
mbed_official 205:c41fc65bcfb4 102
mbed_official 205:c41fc65bcfb4 103 @endverbatim
mbed_official 205:c41fc65bcfb4 104 ******************************************************************************
mbed_official 205:c41fc65bcfb4 105 * @attention
mbed_official 205:c41fc65bcfb4 106 *
mbed_official 205:c41fc65bcfb4 107 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 205:c41fc65bcfb4 108 *
mbed_official 205:c41fc65bcfb4 109 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 205:c41fc65bcfb4 110 * are permitted provided that the following conditions are met:
mbed_official 205:c41fc65bcfb4 111 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 205:c41fc65bcfb4 112 * this list of conditions and the following disclaimer.
mbed_official 205:c41fc65bcfb4 113 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 205:c41fc65bcfb4 114 * this list of conditions and the following disclaimer in the documentation
mbed_official 205:c41fc65bcfb4 115 * and/or other materials provided with the distribution.
mbed_official 205:c41fc65bcfb4 116 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 205:c41fc65bcfb4 117 * may be used to endorse or promote products derived from this software
mbed_official 205:c41fc65bcfb4 118 * without specific prior written permission.
mbed_official 205:c41fc65bcfb4 119 *
mbed_official 205:c41fc65bcfb4 120 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 205:c41fc65bcfb4 121 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 205:c41fc65bcfb4 122 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 205:c41fc65bcfb4 123 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 205:c41fc65bcfb4 124 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 205:c41fc65bcfb4 125 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 205:c41fc65bcfb4 126 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 205:c41fc65bcfb4 127 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 205:c41fc65bcfb4 128 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 205:c41fc65bcfb4 129 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 205:c41fc65bcfb4 130 *
mbed_official 205:c41fc65bcfb4 131 ******************************************************************************
mbed_official 205:c41fc65bcfb4 132 */
mbed_official 205:c41fc65bcfb4 133
mbed_official 205:c41fc65bcfb4 134 /* Includes ------------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 135 #include "stm32f0xx_hal.h"
mbed_official 205:c41fc65bcfb4 136
mbed_official 205:c41fc65bcfb4 137 /** @addtogroup STM32F0xx_HAL_Driver
mbed_official 205:c41fc65bcfb4 138 * @{
mbed_official 205:c41fc65bcfb4 139 */
mbed_official 205:c41fc65bcfb4 140
mbed_official 205:c41fc65bcfb4 141 /** @defgroup GPIO GPIO
mbed_official 205:c41fc65bcfb4 142 * @brief GPIO HAL module driver
mbed_official 205:c41fc65bcfb4 143 * @{
mbed_official 205:c41fc65bcfb4 144 */
mbed_official 205:c41fc65bcfb4 145
mbed_official 205:c41fc65bcfb4 146 #ifdef HAL_GPIO_MODULE_ENABLED
mbed_official 205:c41fc65bcfb4 147
mbed_official 205:c41fc65bcfb4 148 /* Private typedef -----------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 149 /* Private define ------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 150 /* Private macro -------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 151 #define __HAL_GET_GPIO_SOURCE(__GPIOx__) \
mbed_official 205:c41fc65bcfb4 152 (((uint32_t)(__GPIOx__) == ((uint32_t)GPIOA_BASE))? 0 :\
mbed_official 205:c41fc65bcfb4 153 ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0400)))? 1 :\
mbed_official 205:c41fc65bcfb4 154 ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0800)))? 2 :\
mbed_official 205:c41fc65bcfb4 155 ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x0C00)))? 3 :\
mbed_official 205:c41fc65bcfb4 156 ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1000)))? 4 :\
mbed_official 205:c41fc65bcfb4 157 ((uint32_t)(__GPIOx__) == ((uint32_t)(GPIOA_BASE + 0x1400)))? 5 : 6)
mbed_official 205:c41fc65bcfb4 158
mbed_official 205:c41fc65bcfb4 159 #define GPIO_MODE ((uint32_t)0x00000003)
mbed_official 205:c41fc65bcfb4 160 #define EXTI_MODE ((uint32_t)0x10000000)
mbed_official 205:c41fc65bcfb4 161 #define GPIO_MODE_IT ((uint32_t)0x00010000)
mbed_official 205:c41fc65bcfb4 162 #define GPIO_MODE_EVT ((uint32_t)0x00020000)
mbed_official 205:c41fc65bcfb4 163 #define RISING_EDGE ((uint32_t)0x00100000)
mbed_official 205:c41fc65bcfb4 164 #define FALLING_EDGE ((uint32_t)0x00200000)
mbed_official 205:c41fc65bcfb4 165 #define GPIO_OUTPUT_TYPE ((uint32_t)0x00000010)
mbed_official 205:c41fc65bcfb4 166
mbed_official 205:c41fc65bcfb4 167 #define GPIO_NUMBER ((uint32_t)16)
mbed_official 205:c41fc65bcfb4 168 /* Private variables ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 169 /* Private function prototypes -----------------------------------------------*/
mbed_official 205:c41fc65bcfb4 170 /* Private functions ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 171
mbed_official 205:c41fc65bcfb4 172 /** @defgroup GPIO_Private_Functions
mbed_official 205:c41fc65bcfb4 173 * @{
mbed_official 205:c41fc65bcfb4 174 */
mbed_official 205:c41fc65bcfb4 175
mbed_official 205:c41fc65bcfb4 176 /** @defgroup HAL_GPIO_Group1 Initialization/de-initialization functions
mbed_official 205:c41fc65bcfb4 177 * @brief Initialization and Configuration functions
mbed_official 205:c41fc65bcfb4 178 *
mbed_official 205:c41fc65bcfb4 179 @verbatim
mbed_official 205:c41fc65bcfb4 180 ===============================================================================
mbed_official 205:c41fc65bcfb4 181 ##### Initialization and de-initialization functions #####
mbed_official 205:c41fc65bcfb4 182 ===============================================================================
mbed_official 205:c41fc65bcfb4 183
mbed_official 205:c41fc65bcfb4 184 @endverbatim
mbed_official 205:c41fc65bcfb4 185 * @{
mbed_official 205:c41fc65bcfb4 186 */
mbed_official 205:c41fc65bcfb4 187
mbed_official 205:c41fc65bcfb4 188 /**
mbed_official 205:c41fc65bcfb4 189 * @brief Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init.
mbed_official 205:c41fc65bcfb4 190 * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F0 family
mbed_official 205:c41fc65bcfb4 191 * @param GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains
mbed_official 205:c41fc65bcfb4 192 * the configuration information for the specified GPIO peripheral.
mbed_official 205:c41fc65bcfb4 193 * @note GPIOE is available only for STM32F072.
mbed_official 205:c41fc65bcfb4 194 * @note GPIOD is not available for STM32F031.
mbed_official 205:c41fc65bcfb4 195 * @retval None
mbed_official 205:c41fc65bcfb4 196 */
mbed_official 205:c41fc65bcfb4 197 void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
mbed_official 205:c41fc65bcfb4 198 {
mbed_official 205:c41fc65bcfb4 199 uint32_t position;
mbed_official 205:c41fc65bcfb4 200 uint32_t ioposition = 0x00;
mbed_official 205:c41fc65bcfb4 201 uint32_t iocurrent = 0x00;
mbed_official 205:c41fc65bcfb4 202 uint32_t temp = 0x00;
mbed_official 205:c41fc65bcfb4 203
mbed_official 205:c41fc65bcfb4 204 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 205 assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
mbed_official 205:c41fc65bcfb4 206 assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
mbed_official 205:c41fc65bcfb4 207 assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
mbed_official 205:c41fc65bcfb4 208 assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
mbed_official 205:c41fc65bcfb4 209
mbed_official 205:c41fc65bcfb4 210 /* Configure the port pins */
mbed_official 205:c41fc65bcfb4 211 for (position = 0; position < GPIO_NUMBER; position++)
mbed_official 205:c41fc65bcfb4 212 {
mbed_official 205:c41fc65bcfb4 213 /* Get the IO position */
mbed_official 205:c41fc65bcfb4 214 ioposition = ((uint32_t)0x01) << position;
mbed_official 205:c41fc65bcfb4 215 /* Get the current IO position */
mbed_official 205:c41fc65bcfb4 216 iocurrent = (uint32_t)(GPIO_Init->Pin) & ioposition;
mbed_official 205:c41fc65bcfb4 217
mbed_official 205:c41fc65bcfb4 218 if (iocurrent == ioposition)
mbed_official 205:c41fc65bcfb4 219 {
mbed_official 205:c41fc65bcfb4 220 /*--------------------- GPIO Mode Configuration ------------------------*/
mbed_official 205:c41fc65bcfb4 221 /* In case of Alternate function mode selection */
mbed_official 205:c41fc65bcfb4 222 if((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
mbed_official 205:c41fc65bcfb4 223 {
mbed_official 205:c41fc65bcfb4 224 /* Check the Alternate function parameter */
mbed_official 205:c41fc65bcfb4 225 assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
mbed_official 205:c41fc65bcfb4 226 /* Configure Alternate function mapped with the current IO */
mbed_official 205:c41fc65bcfb4 227 temp = GPIOx->AFR[position >> 3];
mbed_official 205:c41fc65bcfb4 228 temp &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
mbed_official 205:c41fc65bcfb4 229 temp |= ((uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & (uint32_t)0x07) * 4));
mbed_official 205:c41fc65bcfb4 230 GPIOx->AFR[position >> 3] = temp;
mbed_official 205:c41fc65bcfb4 231 }
mbed_official 205:c41fc65bcfb4 232
mbed_official 205:c41fc65bcfb4 233 /* Configure IO Direction mode (Input, Output, Alternate or Analog) */
mbed_official 205:c41fc65bcfb4 234 temp = GPIOx->MODER;
mbed_official 205:c41fc65bcfb4 235 temp &= ~(GPIO_MODER_MODER0 << (position * 2));
mbed_official 205:c41fc65bcfb4 236 temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2));
mbed_official 205:c41fc65bcfb4 237 GPIOx->MODER = temp;
mbed_official 205:c41fc65bcfb4 238
mbed_official 205:c41fc65bcfb4 239 /* In case of Output or Alternate function mode selection */
mbed_official 205:c41fc65bcfb4 240 if ((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||
mbed_official 205:c41fc65bcfb4 241 (GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
mbed_official 205:c41fc65bcfb4 242 {
mbed_official 205:c41fc65bcfb4 243 /* Check the Speed parameter */
mbed_official 205:c41fc65bcfb4 244 assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
mbed_official 205:c41fc65bcfb4 245 /* Configure the IO Speed */
mbed_official 205:c41fc65bcfb4 246 temp = GPIOx->OSPEEDR;
mbed_official 205:c41fc65bcfb4 247 temp &= ~(GPIO_OSPEEDER_OSPEEDR0 << (position * 2));
mbed_official 205:c41fc65bcfb4 248 temp |= (GPIO_Init->Speed << (position * 2));
mbed_official 205:c41fc65bcfb4 249 GPIOx->OSPEEDR = temp;
mbed_official 205:c41fc65bcfb4 250
mbed_official 205:c41fc65bcfb4 251 /* Configure the IO Output Type */
mbed_official 205:c41fc65bcfb4 252 temp = GPIOx->OTYPER;
mbed_official 205:c41fc65bcfb4 253 temp &= ~(GPIO_OTYPER_OT_0 << position) ;
mbed_official 205:c41fc65bcfb4 254 temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4) << position);
mbed_official 205:c41fc65bcfb4 255 GPIOx->OTYPER = temp;
mbed_official 205:c41fc65bcfb4 256 }
mbed_official 205:c41fc65bcfb4 257
mbed_official 205:c41fc65bcfb4 258 /* Activate the Pull-up or Pull down resistor for the current IO */
mbed_official 205:c41fc65bcfb4 259 temp = GPIOx->PUPDR;
mbed_official 205:c41fc65bcfb4 260 temp &= ~(GPIO_PUPDR_PUPDR0 << (position * 2));
mbed_official 205:c41fc65bcfb4 261 temp |= ((GPIO_Init->Pull) << (position * 2));
mbed_official 205:c41fc65bcfb4 262 GPIOx->PUPDR = temp;
mbed_official 205:c41fc65bcfb4 263
mbed_official 205:c41fc65bcfb4 264 /*--------------------- EXTI Mode Configuration ------------------------*/
mbed_official 205:c41fc65bcfb4 265 /* Configure the External Interrupt or event for the current IO */
mbed_official 205:c41fc65bcfb4 266 if((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
mbed_official 205:c41fc65bcfb4 267 {
mbed_official 205:c41fc65bcfb4 268 /* Enable SYSCFG Clock */
mbed_official 205:c41fc65bcfb4 269 __SYSCFG_CLK_ENABLE();
mbed_official 205:c41fc65bcfb4 270
mbed_official 205:c41fc65bcfb4 271 temp = SYSCFG->EXTICR[position >> 2];
mbed_official 205:c41fc65bcfb4 272 temp &= ~(((uint32_t)0x0F) << (4 * (position & 0x03)));
mbed_official 205:c41fc65bcfb4 273 temp |= ((uint32_t)(__HAL_GET_GPIO_SOURCE(GPIOx)) << (4 * (position & 0x03)));
mbed_official 205:c41fc65bcfb4 274 SYSCFG->EXTICR[position >> 2] = temp;
mbed_official 205:c41fc65bcfb4 275
mbed_official 205:c41fc65bcfb4 276 /* Clear EXTI line configuration */
mbed_official 205:c41fc65bcfb4 277 temp = EXTI->IMR;
mbed_official 205:c41fc65bcfb4 278 temp &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 279 if((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
mbed_official 205:c41fc65bcfb4 280 {
mbed_official 205:c41fc65bcfb4 281 temp |= iocurrent;
mbed_official 205:c41fc65bcfb4 282 }
mbed_official 205:c41fc65bcfb4 283 EXTI->IMR = temp;
mbed_official 205:c41fc65bcfb4 284
mbed_official 205:c41fc65bcfb4 285 temp = EXTI->EMR;
mbed_official 205:c41fc65bcfb4 286 temp &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 287 if((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
mbed_official 205:c41fc65bcfb4 288 {
mbed_official 205:c41fc65bcfb4 289 temp |= iocurrent;
mbed_official 205:c41fc65bcfb4 290 }
mbed_official 205:c41fc65bcfb4 291 EXTI->EMR = temp;
mbed_official 205:c41fc65bcfb4 292
mbed_official 205:c41fc65bcfb4 293 /* Clear Rising Falling edge configuration */
mbed_official 205:c41fc65bcfb4 294 temp = EXTI->RTSR;
mbed_official 205:c41fc65bcfb4 295 temp &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 296 if((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
mbed_official 205:c41fc65bcfb4 297 {
mbed_official 205:c41fc65bcfb4 298 temp |= iocurrent;
mbed_official 205:c41fc65bcfb4 299 }
mbed_official 205:c41fc65bcfb4 300 EXTI->RTSR = temp;
mbed_official 205:c41fc65bcfb4 301
mbed_official 205:c41fc65bcfb4 302 temp = EXTI->FTSR;
mbed_official 205:c41fc65bcfb4 303 temp &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 304 if((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
mbed_official 205:c41fc65bcfb4 305 {
mbed_official 205:c41fc65bcfb4 306 temp |= iocurrent;
mbed_official 205:c41fc65bcfb4 307 }
mbed_official 205:c41fc65bcfb4 308 EXTI->FTSR = temp;
mbed_official 205:c41fc65bcfb4 309 }
mbed_official 205:c41fc65bcfb4 310 }
mbed_official 205:c41fc65bcfb4 311 }
mbed_official 205:c41fc65bcfb4 312 }
mbed_official 205:c41fc65bcfb4 313
mbed_official 205:c41fc65bcfb4 314 /**
mbed_official 205:c41fc65bcfb4 315 * @brief De-initializes the GPIOx peripheral registers to their default reset values.
mbed_official 205:c41fc65bcfb4 316 * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F0 family
mbed_official 205:c41fc65bcfb4 317 * @param GPIO_Pin: specifies the port bit to be written.
mbed_official 205:c41fc65bcfb4 318 * This parameter can be one of GPIO_PIN_x where x can be (0..15).
mbed_official 205:c41fc65bcfb4 319 * @note GPIOE is available only for STM32F072.
mbed_official 205:c41fc65bcfb4 320 * @note GPIOD is not available for STM32F031.
mbed_official 205:c41fc65bcfb4 321 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 322 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 205:c41fc65bcfb4 323 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 324 * @retval None
mbed_official 205:c41fc65bcfb4 325 */
mbed_official 205:c41fc65bcfb4 326 void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
mbed_official 205:c41fc65bcfb4 327 {
mbed_official 205:c41fc65bcfb4 328 uint32_t position;
mbed_official 205:c41fc65bcfb4 329 uint32_t ioposition = 0x00;
mbed_official 205:c41fc65bcfb4 330 uint32_t iocurrent = 0x00;
mbed_official 205:c41fc65bcfb4 331 uint32_t tmp = 0x00;
mbed_official 205:c41fc65bcfb4 332
mbed_official 205:c41fc65bcfb4 333 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 334 assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
mbed_official 205:c41fc65bcfb4 335
mbed_official 205:c41fc65bcfb4 336 /* Configure the port pins */
mbed_official 205:c41fc65bcfb4 337 for (position = 0; position < GPIO_NUMBER; position++)
mbed_official 205:c41fc65bcfb4 338 {
mbed_official 205:c41fc65bcfb4 339 /* Get the IO position */
mbed_official 205:c41fc65bcfb4 340 ioposition = ((uint32_t)0x01) << position;
mbed_official 205:c41fc65bcfb4 341 /* Get the current IO position */
mbed_official 205:c41fc65bcfb4 342 iocurrent = (GPIO_Pin) & ioposition;
mbed_official 205:c41fc65bcfb4 343
mbed_official 205:c41fc65bcfb4 344 if (iocurrent == ioposition)
mbed_official 205:c41fc65bcfb4 345 {
mbed_official 205:c41fc65bcfb4 346 /*------------------------- GPIO Mode Configuration --------------------*/
mbed_official 205:c41fc65bcfb4 347 /* Configure IO Direction in Input Floting Mode */
mbed_official 205:c41fc65bcfb4 348 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (position * 2));
mbed_official 205:c41fc65bcfb4 349
mbed_official 205:c41fc65bcfb4 350 /* Configure the default Alternate Function in current IO */
mbed_official 205:c41fc65bcfb4 351 GPIOx->AFR[position >> 3] &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
mbed_official 205:c41fc65bcfb4 352
mbed_official 205:c41fc65bcfb4 353 /* Configure the default value for IO Speed */
mbed_official 205:c41fc65bcfb4 354 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (position * 2));
mbed_official 205:c41fc65bcfb4 355
mbed_official 205:c41fc65bcfb4 356 /* Configure the default value IO Output Type */
mbed_official 205:c41fc65bcfb4 357 GPIOx->OTYPER &= ~(GPIO_OTYPER_OT_0 << position) ;
mbed_official 205:c41fc65bcfb4 358
mbed_official 205:c41fc65bcfb4 359 /* Deactivate the Pull-up oand Pull-down resistor for the current IO */
mbed_official 205:c41fc65bcfb4 360 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << (position * 2));
mbed_official 205:c41fc65bcfb4 361
mbed_official 205:c41fc65bcfb4 362
mbed_official 205:c41fc65bcfb4 363 /*------------------------- EXTI Mode Configuration --------------------*/
mbed_official 205:c41fc65bcfb4 364 /* Configure the External Interrupt or event for the current IO */
mbed_official 205:c41fc65bcfb4 365 tmp = ((uint32_t)0x0F) << (4 * (position & 0x03));
mbed_official 205:c41fc65bcfb4 366 SYSCFG->EXTICR[position >> 2] &= ~tmp;
mbed_official 205:c41fc65bcfb4 367
mbed_official 205:c41fc65bcfb4 368 /* Clear EXTI line configuration */
mbed_official 205:c41fc65bcfb4 369 EXTI->IMR &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 370 EXTI->EMR &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 371
mbed_official 205:c41fc65bcfb4 372 /* Clear Rising Falling edge configuration */
mbed_official 205:c41fc65bcfb4 373 EXTI->RTSR &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 374 EXTI->FTSR &= ~((uint32_t)iocurrent);
mbed_official 205:c41fc65bcfb4 375 }
mbed_official 205:c41fc65bcfb4 376 }
mbed_official 205:c41fc65bcfb4 377 }
mbed_official 205:c41fc65bcfb4 378
mbed_official 205:c41fc65bcfb4 379 /**
mbed_official 205:c41fc65bcfb4 380 * @}
mbed_official 205:c41fc65bcfb4 381 */
mbed_official 205:c41fc65bcfb4 382
mbed_official 205:c41fc65bcfb4 383 /** @defgroup HAL_GPIO_Group2 IO operation functions
mbed_official 205:c41fc65bcfb4 384 * @brief GPIO Read and Write
mbed_official 205:c41fc65bcfb4 385 *
mbed_official 205:c41fc65bcfb4 386 @verbatim
mbed_official 205:c41fc65bcfb4 387 ===============================================================================
mbed_official 205:c41fc65bcfb4 388 ##### IO operation functions #####
mbed_official 205:c41fc65bcfb4 389 ===============================================================================
mbed_official 205:c41fc65bcfb4 390
mbed_official 205:c41fc65bcfb4 391 @endverbatim
mbed_official 205:c41fc65bcfb4 392 * @{
mbed_official 205:c41fc65bcfb4 393 */
mbed_official 205:c41fc65bcfb4 394
mbed_official 205:c41fc65bcfb4 395 /**
mbed_official 205:c41fc65bcfb4 396 * @brief Reads the specified input port pin.
mbed_official 205:c41fc65bcfb4 397 * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F0 family
mbed_official 205:c41fc65bcfb4 398 * @param GPIO_Pin: specifies the port bit to read.
mbed_official 205:c41fc65bcfb4 399 * This parameter can be GPIO_PIN_x where x can be (0..15).
mbed_official 205:c41fc65bcfb4 400 * @note GPIOE is available only for STM32F072.
mbed_official 205:c41fc65bcfb4 401 * @note GPIOD is not available for STM32F031.
mbed_official 205:c41fc65bcfb4 402 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 403 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 205:c41fc65bcfb4 404 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 405 * @retval The input port pin value.
mbed_official 205:c41fc65bcfb4 406 */
mbed_official 205:c41fc65bcfb4 407 GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 205:c41fc65bcfb4 408 {
mbed_official 205:c41fc65bcfb4 409 GPIO_PinState bitstatus;
mbed_official 205:c41fc65bcfb4 410
mbed_official 205:c41fc65bcfb4 411 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 412 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 205:c41fc65bcfb4 413
mbed_official 205:c41fc65bcfb4 414 if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
mbed_official 205:c41fc65bcfb4 415 {
mbed_official 205:c41fc65bcfb4 416 bitstatus = GPIO_PIN_SET;
mbed_official 205:c41fc65bcfb4 417 }
mbed_official 205:c41fc65bcfb4 418 else
mbed_official 205:c41fc65bcfb4 419 {
mbed_official 205:c41fc65bcfb4 420 bitstatus = GPIO_PIN_RESET;
mbed_official 205:c41fc65bcfb4 421 }
mbed_official 205:c41fc65bcfb4 422 return bitstatus;
mbed_official 205:c41fc65bcfb4 423 }
mbed_official 205:c41fc65bcfb4 424
mbed_official 205:c41fc65bcfb4 425 /**
mbed_official 205:c41fc65bcfb4 426 * @brief Sets or clears the selected data port bit.
mbed_official 205:c41fc65bcfb4 427 *
mbed_official 205:c41fc65bcfb4 428 * @note This function uses GPIOx_BSRR register to allow atomic read/modify
mbed_official 205:c41fc65bcfb4 429 * accesses. In this way, there is no risk of an IRQ occurring between
mbed_official 205:c41fc65bcfb4 430 * the read and the modify access.
mbed_official 205:c41fc65bcfb4 431 *
mbed_official 205:c41fc65bcfb4 432 * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F0 family
mbed_official 205:c41fc65bcfb4 433 * @note GPIOE is available only for STM32F072.
mbed_official 205:c41fc65bcfb4 434 * @note GPIOD is not available for STM32F031.
mbed_official 205:c41fc65bcfb4 435 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 436 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 205:c41fc65bcfb4 437 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 438 * @param GPIO_Pin: specifies the port bit to be written.
mbed_official 205:c41fc65bcfb4 439 * This parameter can be one of GPIO_PIN_x where x can be (0..15).
mbed_official 205:c41fc65bcfb4 440 * @param PinState: specifies the value to be written to the selected bit.
mbed_official 205:c41fc65bcfb4 441 * This parameter can be one of the GPIO_PinState enum values:
mbed_official 205:c41fc65bcfb4 442 * @arg GPIO_BIT_RESET: to clear the port pin
mbed_official 205:c41fc65bcfb4 443 * @arg GPIO_BIT_SET: to set the port pin
mbed_official 205:c41fc65bcfb4 444 * @retval None
mbed_official 205:c41fc65bcfb4 445 */
mbed_official 205:c41fc65bcfb4 446 void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
mbed_official 205:c41fc65bcfb4 447 {
mbed_official 205:c41fc65bcfb4 448 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 449 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 205:c41fc65bcfb4 450 assert_param(IS_GPIO_PIN_ACTION(PinState));
mbed_official 205:c41fc65bcfb4 451
mbed_official 205:c41fc65bcfb4 452 if (PinState != GPIO_PIN_RESET)
mbed_official 205:c41fc65bcfb4 453 {
mbed_official 205:c41fc65bcfb4 454 GPIOx->BSRRL = GPIO_Pin;
mbed_official 205:c41fc65bcfb4 455 }
mbed_official 205:c41fc65bcfb4 456 else
mbed_official 205:c41fc65bcfb4 457 {
mbed_official 205:c41fc65bcfb4 458 GPIOx->BSRRH = GPIO_Pin ;
mbed_official 205:c41fc65bcfb4 459 }
mbed_official 205:c41fc65bcfb4 460 }
mbed_official 205:c41fc65bcfb4 461
mbed_official 205:c41fc65bcfb4 462 /**
mbed_official 205:c41fc65bcfb4 463 * @brief Toggles the specified GPIO pin
mbed_official 205:c41fc65bcfb4 464 * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F0 family
mbed_official 205:c41fc65bcfb4 465 * @param GPIO_Pin: specifies the pins to be toggled.
mbed_official 205:c41fc65bcfb4 466 * @note GPIOE is available only for STM32F072.
mbed_official 205:c41fc65bcfb4 467 * @note GPIOD is not available for STM32F031.
mbed_official 205:c41fc65bcfb4 468 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 469 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 205:c41fc65bcfb4 470 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 471 * @retval None
mbed_official 205:c41fc65bcfb4 472 */
mbed_official 205:c41fc65bcfb4 473 void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 205:c41fc65bcfb4 474 {
mbed_official 205:c41fc65bcfb4 475 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 476 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 205:c41fc65bcfb4 477
mbed_official 205:c41fc65bcfb4 478 GPIOx->ODR ^= GPIO_Pin;
mbed_official 205:c41fc65bcfb4 479 }
mbed_official 205:c41fc65bcfb4 480
mbed_official 205:c41fc65bcfb4 481 /**
mbed_official 205:c41fc65bcfb4 482 * @brief Locks GPIO Pins configuration registers.
mbed_official 205:c41fc65bcfb4 483 * @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
mbed_official 205:c41fc65bcfb4 484 * GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
mbed_official 205:c41fc65bcfb4 485 * @note The configuration of the locked GPIO pins can no longer be modified
mbed_official 205:c41fc65bcfb4 486 * until the next reset.
mbed_official 205:c41fc65bcfb4 487 * @param GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F0 family
mbed_official 205:c41fc65bcfb4 488 * @param GPIO_Pin: specifies the port bit to be locked.
mbed_official 205:c41fc65bcfb4 489 * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
mbed_official 205:c41fc65bcfb4 490 * @note GPIOE is available only for STM32F072.
mbed_official 205:c41fc65bcfb4 491 * @note GPIOD is not available for STM32F031.
mbed_official 205:c41fc65bcfb4 492 * For STM32F051 and STM32F030: (0..15) for GPIOA, GPIOB, GPIOC, (2) for GPIOD and (0..1, 4..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 493 * For STM32F072: (0..15) for GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, (0..10) for GPIOF.
mbed_official 205:c41fc65bcfb4 494 * For STM32F031: (0..15) for GPIOA, GPIOB, (13..15) for GPIOC and (0..1, 6..7) for GPIOF.
mbed_official 205:c41fc65bcfb4 495 * @retval None
mbed_official 205:c41fc65bcfb4 496 */
mbed_official 205:c41fc65bcfb4 497 HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 205:c41fc65bcfb4 498 {
mbed_official 205:c41fc65bcfb4 499 __IO uint32_t tmp = GPIO_LCKR_LCKK;
mbed_official 205:c41fc65bcfb4 500
mbed_official 205:c41fc65bcfb4 501 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 502 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 205:c41fc65bcfb4 503
mbed_official 205:c41fc65bcfb4 504 /* Apply lock key write sequence */
mbed_official 205:c41fc65bcfb4 505 tmp |= GPIO_Pin;
mbed_official 205:c41fc65bcfb4 506 /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
mbed_official 205:c41fc65bcfb4 507 GPIOx->LCKR = tmp;
mbed_official 205:c41fc65bcfb4 508 /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
mbed_official 205:c41fc65bcfb4 509 GPIOx->LCKR = GPIO_Pin;
mbed_official 205:c41fc65bcfb4 510 /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
mbed_official 205:c41fc65bcfb4 511 GPIOx->LCKR = tmp;
mbed_official 205:c41fc65bcfb4 512 /* Read LCKK bit*/
mbed_official 205:c41fc65bcfb4 513 tmp = GPIOx->LCKR;
mbed_official 205:c41fc65bcfb4 514
mbed_official 205:c41fc65bcfb4 515 if(GPIOx->LCKR & GPIO_LCKR_LCKK)
mbed_official 205:c41fc65bcfb4 516 {
mbed_official 205:c41fc65bcfb4 517 return HAL_OK;
mbed_official 205:c41fc65bcfb4 518 }
mbed_official 205:c41fc65bcfb4 519 else
mbed_official 205:c41fc65bcfb4 520 {
mbed_official 205:c41fc65bcfb4 521 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 522 }
mbed_official 205:c41fc65bcfb4 523 }
mbed_official 205:c41fc65bcfb4 524
mbed_official 205:c41fc65bcfb4 525 /**
mbed_official 205:c41fc65bcfb4 526 * @brief This function handles EXTI interrupt request.
mbed_official 205:c41fc65bcfb4 527 * @param GPIO_Pin: Specifies the pins connected EXTI line
mbed_official 205:c41fc65bcfb4 528 * @retval None
mbed_official 205:c41fc65bcfb4 529 */
mbed_official 205:c41fc65bcfb4 530 void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
mbed_official 205:c41fc65bcfb4 531 {
mbed_official 205:c41fc65bcfb4 532 /* EXTI line interrupt detected */
mbed_official 205:c41fc65bcfb4 533 if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
mbed_official 205:c41fc65bcfb4 534 {
mbed_official 205:c41fc65bcfb4 535 __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
mbed_official 205:c41fc65bcfb4 536 HAL_GPIO_EXTI_Callback(GPIO_Pin);
mbed_official 205:c41fc65bcfb4 537 }
mbed_official 205:c41fc65bcfb4 538 }
mbed_official 205:c41fc65bcfb4 539
mbed_official 205:c41fc65bcfb4 540 /**
mbed_official 205:c41fc65bcfb4 541 * @brief EXTI line detection callbacks.
mbed_official 205:c41fc65bcfb4 542 * @param GPIO_Pin: Specifies the pins connected EXTI line
mbed_official 205:c41fc65bcfb4 543 * @retval None
mbed_official 205:c41fc65bcfb4 544 */
mbed_official 205:c41fc65bcfb4 545 __weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
mbed_official 205:c41fc65bcfb4 546 {
mbed_official 205:c41fc65bcfb4 547 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 548 the HAL_GPIO_EXTI_Callback could be implemented in the user file
mbed_official 205:c41fc65bcfb4 549 */
mbed_official 205:c41fc65bcfb4 550 }
mbed_official 205:c41fc65bcfb4 551
mbed_official 205:c41fc65bcfb4 552 /**
mbed_official 205:c41fc65bcfb4 553 * @}
mbed_official 205:c41fc65bcfb4 554 */
mbed_official 205:c41fc65bcfb4 555
mbed_official 205:c41fc65bcfb4 556
mbed_official 205:c41fc65bcfb4 557 /**
mbed_official 205:c41fc65bcfb4 558 * @}
mbed_official 205:c41fc65bcfb4 559 */
mbed_official 205:c41fc65bcfb4 560
mbed_official 205:c41fc65bcfb4 561 #endif /* HAL_GPIO_MODULE_ENABLED */
mbed_official 205:c41fc65bcfb4 562 /**
mbed_official 205:c41fc65bcfb4 563 * @}
mbed_official 205:c41fc65bcfb4 564 */
mbed_official 205:c41fc65bcfb4 565
mbed_official 205:c41fc65bcfb4 566 /**
mbed_official 205:c41fc65bcfb4 567 * @}
mbed_official 205:c41fc65bcfb4 568 */
mbed_official 205:c41fc65bcfb4 569
mbed_official 205:c41fc65bcfb4 570 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/