TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32l4xx_hal_gpio.c Source File

stm32l4xx_hal_gpio.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_gpio.c
00004   * @author  MCD Application Team
00005   * @version V1.5.1
00006   * @date    31-May-2016
00007   * @brief   GPIO HAL module driver.
00008   *          This file provides firmware functions to manage the following
00009   *          functionalities of the General Purpose Input/Output (GPIO) peripheral:
00010   *           + Initialization and de-initialization functions
00011   *           + IO operation functions
00012   *
00013   @verbatim
00014   ==============================================================================
00015                     ##### GPIO Peripheral features #####
00016   ==============================================================================
00017   [..]
00018     (+) Each port bit of the general-purpose I/O (GPIO) ports can be individually
00019         configured by software in several modes:
00020         (++) Input mode
00021         (++) Analog mode
00022         (++) Output mode
00023         (++) Alternate function mode
00024         (++) External interrupt/event lines
00025 
00026     (+) During and just after reset, the alternate functions and external interrupt
00027         lines are not active and the I/O ports are configured in input floating mode.
00028 
00029     (+) All GPIO pins have weak internal pull-up and pull-down resistors, which can be
00030         activated or not.
00031 
00032     (+) In Output or Alternate mode, each IO can be configured on open-drain or push-pull
00033         type and the IO speed can be selected depending on the VDD value.
00034 
00035     (+) The microcontroller IO pins are connected to onboard peripherals/modules through a
00036         multiplexer that allows only one peripheral alternate function (AF) connected
00037        to an IO pin at a time. In this way, there can be no conflict between peripherals
00038        sharing the same IO pin.
00039 
00040     (+) All ports have external interrupt/event capability. To use external interrupt
00041         lines, the port must be configured in input mode. All available GPIO pins are
00042         connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
00043 
00044     (+) The external interrupt/event controller consists of up to 39 edge detectors
00045         (16 lines are connected to GPIO) for generating event/interrupt requests (each
00046         input line can be independently configured to select the type (interrupt or event)
00047         and the corresponding trigger event (rising or falling or both). Each line can
00048         also be masked independently.
00049 
00050                      ##### How to use this driver #####
00051   ==============================================================================
00052   [..]
00053     (#) Enable the GPIO AHB clock using the following function: __HAL_RCC_GPIOx_CLK_ENABLE().
00054 
00055     (#) Configure the GPIO pin(s) using HAL_GPIO_Init().
00056         (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
00057         (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef
00058              structure.
00059         (++) In case of Output or alternate function mode selection: the speed is
00060              configured through "Speed" member from GPIO_InitTypeDef structure.
00061         (++) In alternate mode is selection, the alternate function connected to the IO
00062              is configured through "Alternate" member from GPIO_InitTypeDef structure.
00063         (++) Analog mode is required when a pin is to be used as ADC channel
00064              or DAC output.
00065         (++) In case of external interrupt/event selection the "Mode" member from
00066              GPIO_InitTypeDef structure select the type (interrupt or event) and
00067              the corresponding trigger event (rising or falling or both).
00068 
00069     (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
00070         mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
00071         HAL_NVIC_EnableIRQ().
00072 
00073     (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
00074 
00075     (#) To set/reset the level of a pin configured in output mode use
00076         HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
00077 
00078    (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
00079   
00080     (#) During and just after reset, the alternate functions are not
00081         active and the GPIO pins are configured in input floating mode (except JTAG
00082         pins).
00083 
00084     (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose
00085         (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
00086         priority over the GPIO function.
00087 
00088     (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as
00089         general purpose PH0 and PH1, respectively, when the HSE oscillator is off.
00090         The HSE has priority over the GPIO function.
00091 
00092   @endverbatim
00093   ******************************************************************************
00094   * @attention
00095   *
00096   * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
00097   *
00098   * Redistribution and use in source and binary forms, with or without modification,
00099   * are permitted provided that the following conditions are met:
00100   *   1. Redistributions of source code must retain the above copyright notice,
00101   *      this list of conditions and the following disclaimer.
00102   *   2. Redistributions in binary form must reproduce the above copyright notice,
00103   *      this list of conditions and the following disclaimer in the documentation
00104   *      and/or other materials provided with the distribution.
00105   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00106   *      may be used to endorse or promote products derived from this software
00107   *      without specific prior written permission.
00108   *
00109   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00110   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00111   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00112   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00113   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00114   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00115   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00116   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00117   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00118   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00119   *
00120   ******************************************************************************
00121   */
00122 
00123 /* Includes ------------------------------------------------------------------*/
00124 #include "stm32l4xx_hal.h"
00125 
00126 /** @addtogroup STM32L4xx_HAL_Driver
00127   * @{
00128   */
00129 
00130 /** @defgroup GPIO GPIO
00131   * @brief GPIO HAL module driver
00132   * @{
00133   */
00134 
00135 #ifdef HAL_GPIO_MODULE_ENABLED
00136 
00137 /* Private typedef -----------------------------------------------------------*/
00138 /* Private defines -----------------------------------------------------------*/
00139 /** @defgroup GPIO_Private_Defines GPIO Private Defines
00140   * @{
00141   */
00142 #define GPIO_MODE             ((uint32_t)0x00000003)
00143 #define ANALOG_MODE           ((uint32_t)0x00000008)
00144 #define EXTI_MODE             ((uint32_t)0x10000000)
00145 #define GPIO_MODE_IT          ((uint32_t)0x00010000)
00146 #define GPIO_MODE_EVT         ((uint32_t)0x00020000)
00147 #define RISING_EDGE           ((uint32_t)0x00100000)
00148 #define FALLING_EDGE          ((uint32_t)0x00200000)
00149 #define GPIO_OUTPUT_TYPE      ((uint32_t)0x00000010)
00150 
00151 #define GPIO_NUMBER           ((uint32_t)16)
00152 /**
00153   * @}
00154   */
00155   
00156 /* Private macros ------------------------------------------------------------*/
00157 /* Private macros ------------------------------------------------------------*/
00158 /** @defgroup GPIO_Private_Macros GPIO Private Macros
00159   * @{
00160   */
00161 /**
00162   * @}
00163   */
00164 /* Private variables ---------------------------------------------------------*/
00165 /* Private function prototypes -----------------------------------------------*/
00166 /* Exported functions --------------------------------------------------------*/
00167 
00168 /** @defgroup GPIO_Exported_Functions GPIO Exported Functions
00169   * @{
00170   */
00171 
00172 /** @defgroup GPIO_Exported_Functions_Group1 Initialization/de-initialization functions 
00173  *  @brief    Initialization and Configuration functions
00174  *
00175 @verbatim
00176  ===============================================================================
00177               ##### Initialization and de-initialization functions #####
00178  ===============================================================================
00179 
00180 @endverbatim
00181   * @{
00182   */
00183 
00184 /**
00185   * @brief  Initialize the GPIOx peripheral according to the specified parameters in the GPIO_Init.
00186   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family
00187   * @param  GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains
00188   *         the configuration information for the specified GPIO peripheral.
00189   * @retval None
00190   */
00191 void HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init)
00192 {
00193   uint32_t position = 0x00;
00194   uint32_t iocurrent = 0x00;
00195   uint32_t temp = 0x00;
00196 
00197   /* Check the parameters */
00198   assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
00199   assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
00200   assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
00201   assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
00202 
00203   /* Configure the port pins */
00204   while (((GPIO_Init->Pin) >> position) != RESET)
00205   {
00206     /* Get current io position */
00207     iocurrent = (GPIO_Init->Pin) & (1U << position);
00208 
00209     if(iocurrent)
00210     {
00211       /*--------------------- GPIO Mode Configuration ------------------------*/
00212       /* In case of Alternate function mode selection */
00213       if((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
00214       {
00215         /* Check the Alternate function parameters */
00216         assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
00217         assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
00218         
00219         /* Configure Alternate function mapped with the current IO */
00220         temp = GPIOx->AFR[position >> 3];
00221         temp &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
00222         temp |= ((uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & (uint32_t)0x07) * 4));
00223         GPIOx->AFR[position >> 3] = temp;
00224       }
00225 
00226       /* Configure IO Direction mode (Input, Output, Alternate or Analog) */
00227       temp = GPIOx->MODER;
00228       temp &= ~(GPIO_MODER_MODE0 << (position * 2));
00229       temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2));
00230       GPIOx->MODER = temp;
00231 
00232       /* In case of Output or Alternate function mode selection */
00233       if((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||
00234          (GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
00235       {
00236         /* Check the Speed parameter */
00237         assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
00238         /* Configure the IO Speed */
00239         temp = GPIOx->OSPEEDR;
00240         temp &= ~(GPIO_OSPEEDR_OSPEED0 << (position * 2));
00241         temp |= (GPIO_Init->Speed << (position * 2));
00242         GPIOx->OSPEEDR = temp;
00243 
00244         /* Configure the IO Output Type */
00245         temp = GPIOx->OTYPER;
00246         temp &= ~(GPIO_OTYPER_OT0 << position) ;
00247         temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4) << position);
00248         GPIOx->OTYPER = temp;
00249       }
00250 
00251 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
00252 
00253       /* In case of Analog mode, check if ADC control mode is selected */
00254       if((GPIO_Init->Mode & GPIO_MODE_ANALOG) == GPIO_MODE_ANALOG)
00255       {
00256         /* Configure the IO Output Type */
00257         temp = GPIOx->ASCR;
00258         temp &= ~(GPIO_ASCR_ASC0 << position) ;
00259         temp |= (((GPIO_Init->Mode & ANALOG_MODE) >> 3) << position);
00260         GPIOx->ASCR = temp;
00261       }
00262 
00263 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
00264 
00265       /* Activate the Pull-up or Pull down resistor for the current IO */
00266       temp = GPIOx->PUPDR;
00267       temp &= ~(GPIO_PUPDR_PUPD0 << (position * 2));
00268       temp |= ((GPIO_Init->Pull) << (position * 2));
00269       GPIOx->PUPDR = temp;
00270 
00271       /*--------------------- EXTI Mode Configuration ------------------------*/
00272       /* Configure the External Interrupt or event for the current IO */
00273       if((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
00274       {
00275         /* Enable SYSCFG Clock */
00276         __HAL_RCC_SYSCFG_CLK_ENABLE();
00277 
00278         temp = SYSCFG->EXTICR[position >> 2];
00279         temp &= ~(((uint32_t)0x0F) << (4 * (position & 0x03)));
00280         temp |= (GPIO_GET_INDEX(GPIOx) << (4 * (position & 0x03)));
00281         SYSCFG->EXTICR[position >> 2] = temp;
00282 
00283         /* Clear EXTI line configuration */
00284         temp = EXTI->IMR1;
00285         temp &= ~((uint32_t)iocurrent);
00286         if((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
00287         {
00288           temp |= iocurrent;
00289         }
00290         EXTI->IMR1 = temp;
00291 
00292         temp = EXTI->EMR1;
00293         temp &= ~((uint32_t)iocurrent);
00294         if((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
00295         {
00296           temp |= iocurrent;
00297         }
00298         EXTI->EMR1 = temp;
00299 
00300         /* Clear Rising Falling edge configuration */
00301         temp = EXTI->RTSR1;
00302         temp &= ~((uint32_t)iocurrent);
00303         if((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
00304         {
00305           temp |= iocurrent;
00306         }
00307         EXTI->RTSR1 = temp;
00308 
00309         temp = EXTI->FTSR1;
00310         temp &= ~((uint32_t)iocurrent);
00311         if((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
00312         {
00313           temp |= iocurrent;
00314         }
00315         EXTI->FTSR1 = temp;
00316       }
00317     }
00318     
00319     position++;
00320   }
00321 }
00322 
00323 /**
00324   * @brief  De-initialize the GPIOx peripheral registers to their default reset values.
00325   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family
00326   * @param  GPIO_Pin: specifies the port bit to be written.
00327   *         This parameter can be one of GPIO_PIN_x where x can be (0..15).
00328   * @retval None
00329   */
00330 void HAL_GPIO_DeInit(GPIO_TypeDef  *GPIOx, uint32_t GPIO_Pin)
00331 {
00332   uint32_t position = 0x00;
00333   uint32_t iocurrent = 0x00;
00334   uint32_t tmp = 0x00;
00335 
00336   /* Check the parameters */
00337   assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
00338   assert_param(IS_GPIO_PIN(GPIO_Pin));
00339 
00340   /* Configure the port pins */
00341   while ((GPIO_Pin >> position) != RESET)
00342   {
00343     /* Get current io position */
00344     iocurrent = (GPIO_Pin) & (1U << position);
00345 
00346     if (iocurrent)
00347     {
00348       /*------------------------- GPIO Mode Configuration --------------------*/
00349       /* Configure IO in Analog Mode */
00350       GPIOx->MODER |= (GPIO_MODER_MODE0 << (position * 2));
00351 
00352       /* Configure the default Alternate Function in current IO */
00353       GPIOx->AFR[position >> 3] &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
00354 
00355       /* Configure the default value for IO Speed */
00356       GPIOx->OSPEEDR &= ~(GPIO_OSPEEDR_OSPEED0 << (position * 2));
00357 
00358       /* Configure the default value IO Output Type */
00359       GPIOx->OTYPER  &= ~(GPIO_OTYPER_OT0 << position) ;
00360 
00361       /* Deactivate the Pull-up and Pull-down resistor for the current IO */
00362       GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPD0 << (position * 2));
00363 
00364 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
00365 
00366       /* Deactivate the Control bit of Analog mode for the current IO */
00367       GPIOx->ASCR &= ~(GPIO_ASCR_ASC0<< position);
00368 
00369 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
00370 
00371       /*------------------------- EXTI Mode Configuration --------------------*/
00372       /* Clear the External Interrupt or Event for the current IO */
00373       
00374       tmp = SYSCFG->EXTICR[position >> 2];
00375       tmp &= (((uint32_t)0x0F) << (4 * (position & 0x03)));
00376       if(tmp == (GPIO_GET_INDEX(GPIOx) << (4 * (position & 0x03))))
00377       {
00378         tmp = ((uint32_t)0x0F) << (4 * (position & 0x03));
00379         SYSCFG->EXTICR[position >> 2] &= ~tmp;
00380 
00381         /* Clear EXTI line configuration */
00382         EXTI->IMR1 &= ~((uint32_t)iocurrent);
00383         EXTI->EMR1 &= ~((uint32_t)iocurrent);
00384 
00385         /* Clear Rising Falling edge configuration */
00386         EXTI->RTSR1 &= ~((uint32_t)iocurrent);
00387         EXTI->FTSR1 &= ~((uint32_t)iocurrent);
00388       }
00389     }
00390     
00391     position++;
00392   }
00393 }
00394 
00395 /**
00396   * @}
00397   */
00398 
00399 /** @defgroup GPIO_Exported_Functions_Group2 IO operation functions 
00400  *  @brief GPIO Read, Write, Toggle, Lock and EXTI management functions.
00401  *
00402 @verbatim
00403  ===============================================================================
00404                        ##### IO operation functions #####
00405  ===============================================================================
00406 
00407 @endverbatim
00408   * @{
00409   */
00410 
00411 /**
00412   * @brief  Read the specified input port pin.
00413   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family
00414   * @param  GPIO_Pin: specifies the port bit to read.
00415   *         This parameter can be GPIO_PIN_x where x can be (0..15).
00416   * @retval The input port pin value.
00417   */
00418 GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
00419 {
00420   GPIO_PinState bitstatus;
00421 
00422   /* Check the parameters */
00423   assert_param(IS_GPIO_PIN(GPIO_Pin));
00424 
00425   if((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
00426   {
00427     bitstatus = GPIO_PIN_SET;
00428   }
00429   else
00430   {
00431     bitstatus = GPIO_PIN_RESET;
00432   }
00433   return bitstatus;
00434 }
00435 
00436 /**
00437   * @brief  Set or clear the selected data port bit.
00438   *
00439   * @note   This function uses GPIOx_BSRR and GPIOx_BRR registers to allow atomic read/modify
00440   *         accesses. In this way, there is no risk of an IRQ occurring between
00441   *         the read and the modify access.
00442   *
00443   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family
00444   * @param  GPIO_Pin: specifies the port bit to be written.
00445   *         This parameter can be one of GPIO_PIN_x where x can be (0..15).
00446   * @param  PinState: specifies the value to be written to the selected bit.
00447   *         This parameter can be one of the GPIO_PinState enum values:
00448   *            @arg GPIO_PIN_RESET: to clear the port pin
00449   *            @arg GPIO_PIN_SET: to set the port pin
00450   * @retval None
00451   */
00452 void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
00453 {
00454   /* Check the parameters */
00455   assert_param(IS_GPIO_PIN(GPIO_Pin));
00456   assert_param(IS_GPIO_PIN_ACTION(PinState));
00457 
00458   if(PinState != GPIO_PIN_RESET)
00459   {
00460     GPIOx->BSRR = (uint32_t)GPIO_Pin;
00461   }
00462   else
00463   {
00464     GPIOx->BRR = (uint32_t)GPIO_Pin;
00465   }
00466 }
00467 
00468 /**
00469   * @brief  Toggle the specified GPIO pin.
00470   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family
00471   * @param  GPIO_Pin: specifies the pin to be toggled.
00472   * @retval None
00473   */
00474 void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
00475 {
00476   /* Check the parameters */
00477   assert_param(IS_GPIO_PIN(GPIO_Pin));
00478 
00479   GPIOx->ODR ^= GPIO_Pin;
00480 }
00481 
00482 /**
00483 * @brief  Lock GPIO Pins configuration registers.
00484   * @note   The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
00485   *         GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
00486   * @note   The configuration of the locked GPIO pins can no longer be modified
00487   *         until the next reset.
00488   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family
00489   * @param  GPIO_Pin: specifies the port bits to be locked.
00490   *         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
00491   * @retval None
00492   */
00493 HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
00494 {
00495   __IO uint32_t tmp = GPIO_LCKR_LCKK;
00496 
00497   /* Check the parameters */
00498   assert_param(IS_GPIO_LOCK_INSTANCE(GPIOx));
00499   assert_param(IS_GPIO_PIN(GPIO_Pin));
00500 
00501   /* Apply lock key write sequence */
00502   tmp |= GPIO_Pin;
00503   /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
00504   GPIOx->LCKR = tmp;
00505   /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
00506   GPIOx->LCKR = GPIO_Pin;
00507   /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
00508   GPIOx->LCKR = tmp;
00509   /* Read LCKK bit*/
00510   tmp = GPIOx->LCKR;
00511 
00512   if((GPIOx->LCKR & GPIO_LCKR_LCKK) != RESET)
00513   {
00514     return HAL_OK;
00515   }
00516   else
00517   {
00518     return HAL_ERROR;
00519   }
00520 }
00521 
00522 /**
00523   * @brief  Handle EXTI interrupt request.
00524   * @param  GPIO_Pin: Specifies the port pin connected to corresponding EXTI line.
00525   * @retval None
00526   */
00527 void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
00528 {
00529   /* EXTI line interrupt detected */
00530   if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
00531   {
00532     __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
00533     HAL_GPIO_EXTI_Callback(GPIO_Pin);
00534   }
00535 }
00536 
00537 /**
00538   * @brief  EXTI line detection callback.
00539   * @param  GPIO_Pin: Specifies the port pin connected to corresponding EXTI line.
00540   * @retval None
00541   */
00542 __weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
00543 {
00544   /* Prevent unused argument(s) compilation warning */
00545   UNUSED(GPIO_Pin);
00546 
00547   /* NOTE: This function should not be modified, when the callback is needed,
00548            the HAL_GPIO_EXTI_Callback could be implemented in the user file
00549    */
00550 }
00551 
00552 /**
00553   * @}
00554   */
00555 
00556 
00557 /**
00558   * @}
00559   */
00560 
00561 #endif /* HAL_GPIO_MODULE_ENABLED */
00562 /**
00563   * @}
00564   */
00565 
00566 /**
00567   * @}
00568   */
00569 
00570 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/