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