]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube/ST_Code/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c
Make vSetupTimerInterrupt weak in the RVDS M4 MPU port to give the
[freertos] / FreeRTOS / Demo / CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube / ST_Code / Drivers / STM32L4xx_HAL_Driver / Src / stm32l4xx_hal_gpio.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l4xx_hal_gpio.c\r
4   * @author  MCD Application Team\r
5   * @brief   GPIO HAL module driver.\r
6   *          This file provides firmware functions to manage the following\r
7   *          functionalities of the General Purpose Input/Output (GPIO) peripheral:\r
8   *           + Initialization and de-initialization functions\r
9   *           + IO operation functions\r
10   *\r
11   @verbatim\r
12   ==============================================================================\r
13                     ##### GPIO Peripheral features #####\r
14   ==============================================================================\r
15   [..]\r
16     (+) Each port bit of the general-purpose I/O (GPIO) ports can be individually\r
17         configured by software in several modes:\r
18         (++) Input mode\r
19         (++) Analog mode\r
20         (++) Output mode\r
21         (++) Alternate function mode\r
22         (++) External interrupt/event lines\r
23 \r
24     (+) During and just after reset, the alternate functions and external interrupt\r
25         lines are not active and the I/O ports are configured in input floating mode.\r
26 \r
27     (+) All GPIO pins have weak internal pull-up and pull-down resistors, which can be\r
28         activated or not.\r
29 \r
30     (+) In Output or Alternate mode, each IO can be configured on open-drain or push-pull\r
31         type and the IO speed can be selected depending on the VDD value.\r
32 \r
33     (+) The microcontroller IO pins are connected to onboard peripherals/modules through a\r
34         multiplexer that allows only one peripheral alternate function (AF) connected\r
35        to an IO pin at a time. In this way, there can be no conflict between peripherals\r
36        sharing the same IO pin.\r
37 \r
38     (+) All ports have external interrupt/event capability. To use external interrupt\r
39         lines, the port must be configured in input mode. All available GPIO pins are\r
40         connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.\r
41 \r
42     (+) The external interrupt/event controller consists of up to 39 edge detectors\r
43         (16 lines are connected to GPIO) for generating event/interrupt requests (each\r
44         input line can be independently configured to select the type (interrupt or event)\r
45         and the corresponding trigger event (rising or falling or both). Each line can\r
46         also be masked independently.\r
47 \r
48                      ##### How to use this driver #####\r
49   ==============================================================================\r
50   [..]\r
51     (#) Enable the GPIO AHB clock using the following function: __HAL_RCC_GPIOx_CLK_ENABLE().\r
52 \r
53     (#) Configure the GPIO pin(s) using HAL_GPIO_Init().\r
54         (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure\r
55         (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef\r
56              structure.\r
57         (++) In case of Output or alternate function mode selection: the speed is\r
58              configured through "Speed" member from GPIO_InitTypeDef structure.\r
59         (++) In alternate mode is selection, the alternate function connected to the IO\r
60              is configured through "Alternate" member from GPIO_InitTypeDef structure.\r
61         (++) Analog mode is required when a pin is to be used as ADC channel\r
62              or DAC output.\r
63         (++) In case of external interrupt/event selection the "Mode" member from\r
64              GPIO_InitTypeDef structure select the type (interrupt or event) and\r
65              the corresponding trigger event (rising or falling or both).\r
66 \r
67     (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority\r
68         mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using\r
69         HAL_NVIC_EnableIRQ().\r
70 \r
71     (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().\r
72 \r
73     (#) To set/reset the level of a pin configured in output mode use\r
74         HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().\r
75 \r
76    (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().\r
77 \r
78     (#) During and just after reset, the alternate functions are not\r
79         active and the GPIO pins are configured in input floating mode (except JTAG\r
80         pins).\r
81 \r
82     (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose\r
83         (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has\r
84         priority over the GPIO function.\r
85 \r
86     (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as\r
87         general purpose PH0 and PH1, respectively, when the HSE oscillator is off.\r
88         The HSE has priority over the GPIO function.\r
89 \r
90   @endverbatim\r
91   ******************************************************************************\r
92   * @attention\r
93   *\r
94   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.\r
95   * All rights reserved.</center></h2>\r
96   *\r
97   * This software component is licensed by ST under BSD 3-Clause license,\r
98   * the "License"; You may not use this file except in compliance with the\r
99   * License. You may obtain a copy of the License at:\r
100   *                        opensource.org/licenses/BSD-3-Clause\r
101   *\r
102   ******************************************************************************\r
103   */\r
104 \r
105 /* Includes ------------------------------------------------------------------*/\r
106 #include "stm32l4xx_hal.h"\r
107 \r
108 /** @addtogroup STM32L4xx_HAL_Driver\r
109   * @{\r
110   */\r
111 \r
112 /** @defgroup GPIO GPIO\r
113   * @brief GPIO HAL module driver\r
114   * @{\r
115   */\r
116 /** MISRA C:2012 deviation rule has been granted for following rules:\r
117   * Rule-12.2 - Medium: RHS argument is in interval [0,INF] which is out of\r
118   * range of the shift operator in following API :\r
119   * HAL_GPIO_Init\r
120   * HAL_GPIO_DeInit\r
121   */\r
122 \r
123 #ifdef HAL_GPIO_MODULE_ENABLED\r
124 \r
125 /* Private typedef -----------------------------------------------------------*/\r
126 /* Private defines -----------------------------------------------------------*/\r
127 /** @defgroup GPIO_Private_Defines GPIO Private Defines\r
128   * @{\r
129   */\r
130 #define GPIO_MODE             (0x00000003u)\r
131 #define ANALOG_MODE           (0x00000008u)\r
132 #define EXTI_MODE             (0x10000000u)\r
133 #define GPIO_MODE_IT          (0x00010000u)\r
134 #define GPIO_MODE_EVT         (0x00020000u)\r
135 #define RISING_EDGE           (0x00100000u)\r
136 #define FALLING_EDGE          (0x00200000u)\r
137 #define GPIO_OUTPUT_TYPE      (0x00000010u)\r
138 \r
139 #define GPIO_NUMBER           (16u)\r
140 /**\r
141   * @}\r
142   */\r
143 \r
144 /* Private macros ------------------------------------------------------------*/\r
145 /* Private variables ---------------------------------------------------------*/\r
146 /* Private function prototypes -----------------------------------------------*/\r
147 /* Exported functions --------------------------------------------------------*/\r
148 \r
149 /** @defgroup GPIO_Exported_Functions GPIO Exported Functions\r
150   * @{\r
151   */\r
152 \r
153 /** @defgroup GPIO_Exported_Functions_Group1 Initialization/de-initialization functions\r
154  *  @brief    Initialization and Configuration functions\r
155  *\r
156 @verbatim\r
157  ===============================================================================\r
158               ##### Initialization and de-initialization functions #####\r
159  ===============================================================================\r
160 \r
161 @endverbatim\r
162   * @{\r
163   */\r
164 \r
165 /**\r
166   * @brief  Initialize the GPIOx peripheral according to the specified parameters in the GPIO_Init.\r
167   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family\r
168   * @param  GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains\r
169   *         the configuration information for the specified GPIO peripheral.\r
170   * @retval None\r
171   */\r
172 void HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init)\r
173 {\r
174   uint32_t position = 0x00u;\r
175   uint32_t iocurrent;\r
176   uint32_t temp;\r
177 \r
178   /* Check the parameters */\r
179   assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));\r
180   assert_param(IS_GPIO_PIN(GPIO_Init->Pin));\r
181   assert_param(IS_GPIO_MODE(GPIO_Init->Mode));\r
182   assert_param(IS_GPIO_PULL(GPIO_Init->Pull));\r
183 \r
184   /* Configure the port pins */\r
185   while (((GPIO_Init->Pin) >> position) != 0x00u)\r
186   {\r
187     /* Get current io position */\r
188     iocurrent = (GPIO_Init->Pin) & (1uL << position);\r
189 \r
190     if (iocurrent != 0x00u)\r
191     {\r
192       /*--------------------- GPIO Mode Configuration ------------------------*/\r
193       /* In case of Alternate function mode selection */\r
194       if((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))\r
195       {\r
196         /* Check the Alternate function parameters */\r
197         assert_param(IS_GPIO_AF_INSTANCE(GPIOx));\r
198         assert_param(IS_GPIO_AF(GPIO_Init->Alternate));\r
199 \r
200         /* Configure Alternate function mapped with the current IO */\r
201         temp = GPIOx->AFR[position >> 3u];\r
202         temp &= ~(0xFu << ((position & 0x07u) * 4u));\r
203         temp |= ((GPIO_Init->Alternate) << ((position & 0x07u) * 4u));\r
204         GPIOx->AFR[position >> 3u] = temp;\r
205       }\r
206 \r
207       /* Configure IO Direction mode (Input, Output, Alternate or Analog) */\r
208       temp = GPIOx->MODER;\r
209       temp &= ~(GPIO_MODER_MODE0 << (position * 2u));\r
210       temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2u));\r
211       GPIOx->MODER = temp;\r
212 \r
213       /* In case of Output or Alternate function mode selection */\r
214       if((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||\r
215          (GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))\r
216       {\r
217         /* Check the Speed parameter */\r
218         assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));\r
219         /* Configure the IO Speed */\r
220         temp = GPIOx->OSPEEDR;\r
221         temp &= ~(GPIO_OSPEEDR_OSPEED0 << (position * 2u));\r
222         temp |= (GPIO_Init->Speed << (position * 2u));\r
223         GPIOx->OSPEEDR = temp;\r
224 \r
225         /* Configure the IO Output Type */\r
226         temp = GPIOx->OTYPER;\r
227         temp &= ~(GPIO_OTYPER_OT0 << position) ;\r
228         temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4u) << position);\r
229         GPIOx->OTYPER = temp;\r
230       }\r
231 \r
232 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)\r
233 \r
234       /* In case of Analog mode, check if ADC control mode is selected */\r
235       if((GPIO_Init->Mode & GPIO_MODE_ANALOG) == GPIO_MODE_ANALOG)\r
236       {\r
237         /* Configure the IO Output Type */\r
238         temp = GPIOx->ASCR;\r
239         temp &= ~(GPIO_ASCR_ASC0 << position) ;\r
240         temp |= (((GPIO_Init->Mode & ANALOG_MODE) >> 3) << position);\r
241         GPIOx->ASCR = temp;\r
242       }\r
243 \r
244 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */\r
245 \r
246       /* Activate the Pull-up or Pull down resistor for the current IO */\r
247       temp = GPIOx->PUPDR;\r
248       temp &= ~(GPIO_PUPDR_PUPD0 << (position * 2u));\r
249       temp |= ((GPIO_Init->Pull) << (position * 2u));\r
250       GPIOx->PUPDR = temp;\r
251 \r
252       /*--------------------- EXTI Mode Configuration ------------------------*/\r
253       /* Configure the External Interrupt or event for the current IO */\r
254       if((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)\r
255       {\r
256         /* Enable SYSCFG Clock */\r
257         __HAL_RCC_SYSCFG_CLK_ENABLE();\r
258 \r
259         temp = SYSCFG->EXTICR[position >> 2u];\r
260         temp &= ~(0x0FuL << (4u * (position & 0x03u)));\r
261         temp |= (GPIO_GET_INDEX(GPIOx) << (4u * (position & 0x03u)));\r
262         SYSCFG->EXTICR[position >> 2u] = temp;\r
263 \r
264         /* Clear EXTI line configuration */\r
265         temp = EXTI->IMR1;\r
266         temp &= ~(iocurrent);\r
267         if((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)\r
268         {\r
269           temp |= iocurrent;\r
270         }\r
271         EXTI->IMR1 = temp;\r
272 \r
273         temp = EXTI->EMR1;\r
274         temp &= ~(iocurrent);\r
275         if((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)\r
276         {\r
277           temp |= iocurrent;\r
278         }\r
279         EXTI->EMR1 = temp;\r
280 \r
281         /* Clear Rising Falling edge configuration */\r
282         temp = EXTI->RTSR1;\r
283         temp &= ~(iocurrent);\r
284         if((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)\r
285         {\r
286           temp |= iocurrent;\r
287         }\r
288         EXTI->RTSR1 = temp;\r
289 \r
290         temp = EXTI->FTSR1;\r
291         temp &= ~(iocurrent);\r
292         if((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)\r
293         {\r
294           temp |= iocurrent;\r
295         }\r
296         EXTI->FTSR1 = temp;\r
297       }\r
298     }\r
299 \r
300     position++;\r
301   }\r
302 }\r
303 \r
304 /**\r
305   * @brief  De-initialize the GPIOx peripheral registers to their default reset values.\r
306   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family\r
307   * @param  GPIO_Pin: specifies the port bit to be written.\r
308   *         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).\r
309   * @retval None\r
310   */\r
311 void HAL_GPIO_DeInit(GPIO_TypeDef  *GPIOx, uint32_t GPIO_Pin)\r
312 {\r
313   uint32_t position = 0x00u;\r
314   uint32_t iocurrent;\r
315   uint32_t tmp;\r
316 \r
317   /* Check the parameters */\r
318   assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));\r
319   assert_param(IS_GPIO_PIN(GPIO_Pin));\r
320 \r
321   /* Configure the port pins */\r
322   while ((GPIO_Pin >> position) != 0x00u)\r
323   {\r
324     /* Get current io position */\r
325     iocurrent = (GPIO_Pin) & (1uL << position);\r
326 \r
327     if (iocurrent != 0x00u)\r
328     {\r
329       /*------------------------- EXTI Mode Configuration --------------------*/\r
330       /* Clear the External Interrupt or Event for the current IO */\r
331 \r
332       tmp = SYSCFG->EXTICR[position >> 2u];\r
333       tmp &= (0x0FuL << (4u * (position & 0x03u)));\r
334       if (tmp == (GPIO_GET_INDEX(GPIOx) << (4u * (position & 0x03u))))\r
335       {\r
336         /* Clear EXTI line configuration */\r
337         EXTI->IMR1 &= ~(iocurrent);\r
338         EXTI->EMR1 &= ~(iocurrent);\r
339 \r
340         /* Clear Rising Falling edge configuration */\r
341         EXTI->RTSR1 &= ~(iocurrent);\r
342         EXTI->FTSR1 &= ~(iocurrent);\r
343 \r
344         tmp = 0x0FuL << (4u * (position & 0x03u));\r
345         SYSCFG->EXTICR[position >> 2u] &= ~tmp;\r
346       }\r
347 \r
348       /*------------------------- GPIO Mode Configuration --------------------*/\r
349       /* Configure IO in Analog Mode */\r
350       GPIOx->MODER |= (GPIO_MODER_MODE0 << (position * 2u));\r
351 \r
352       /* Configure the default Alternate Function in current IO */\r
353       GPIOx->AFR[position >> 3u] &= ~(0xFu << ((position & 0x07u) * 4u)) ;\r
354 \r
355       /* Configure the default value for IO Speed */\r
356       GPIOx->OSPEEDR &= ~(GPIO_OSPEEDR_OSPEED0 << (position * 2u));\r
357 \r
358       /* Configure the default value IO Output Type */\r
359       GPIOx->OTYPER  &= ~(GPIO_OTYPER_OT0 << position) ;\r
360 \r
361       /* Deactivate the Pull-up and Pull-down resistor for the current IO */\r
362       GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPD0 << (position * 2u));\r
363 \r
364 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)\r
365       /* Deactivate the Control bit of Analog mode for the current IO */\r
366       GPIOx->ASCR &= ~(GPIO_ASCR_ASC0<< position);\r
367 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */\r
368     }\r
369 \r
370     position++;\r
371   }\r
372 }\r
373 \r
374 /**\r
375   * @}\r
376   */\r
377 \r
378 /** @defgroup GPIO_Exported_Functions_Group2 IO operation functions\r
379  *  @brief GPIO Read, Write, Toggle, Lock and EXTI management functions.\r
380  *\r
381 @verbatim\r
382  ===============================================================================\r
383                        ##### IO operation functions #####\r
384  ===============================================================================\r
385 \r
386 @endverbatim\r
387   * @{\r
388   */\r
389 \r
390 /**\r
391   * @brief  Read the specified input port pin.\r
392   * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral for STM32L4 family\r
393   * @param  GPIO_Pin: specifies the port bit to read.\r
394   *         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).\r
395   * @retval The input port pin value.\r
396   */\r
397 GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)\r
398 {\r
399   GPIO_PinState bitstatus;\r
400 \r
401   /* Check the parameters */\r
402   assert_param(IS_GPIO_PIN(GPIO_Pin));\r
403 \r
404   if ((GPIOx->IDR & GPIO_Pin) != 0x00u)\r
405   {\r
406     bitstatus = GPIO_PIN_SET;\r
407   }\r
408   else\r
409   {\r
410     bitstatus = GPIO_PIN_RESET;\r
411   }\r
412   return bitstatus;\r
413 }\r
414 \r
415 /**\r
416   * @brief  Set or clear the selected data port bit.\r
417   *\r
418   * @note   This function uses GPIOx_BSRR and GPIOx_BRR registers to allow atomic read/modify\r
419   *         accesses. In this way, there is no risk of an IRQ occurring between\r
420   *         the read and the modify access.\r
421   *\r
422   * @param  GPIOx where x can be (A..H) to select the GPIO peripheral for STM32L4 family\r
423   * @param  GPIO_Pin specifies the port bit to be written.\r
424   *         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).\r
425   * @param  PinState specifies the value to be written to the selected bit.\r
426   *         This parameter can be one of the GPIO_PinState enum values:\r
427   *            @arg GPIO_PIN_RESET: to clear the port pin\r
428   *            @arg GPIO_PIN_SET: to set the port pin\r
429   * @retval None\r
430   */\r
431 void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)\r
432 {\r
433   /* Check the parameters */\r
434   assert_param(IS_GPIO_PIN(GPIO_Pin));\r
435   assert_param(IS_GPIO_PIN_ACTION(PinState));\r
436 \r
437   if(PinState != GPIO_PIN_RESET)\r
438   {\r
439     GPIOx->BSRR = (uint32_t)GPIO_Pin;\r
440   }\r
441   else\r
442   {\r
443     GPIOx->BRR = (uint32_t)GPIO_Pin;\r
444   }\r
445 }\r
446 \r
447 /**\r
448   * @brief  Toggle the specified GPIO pin.\r
449   * @param  GPIOx where x can be (A..H) to select the GPIO peripheral for STM32L4 family\r
450   * @param  GPIO_Pin specifies the pin to be toggled.\r
451   * @retval None\r
452   */\r
453 void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)\r
454 {\r
455   /* Check the parameters */\r
456   assert_param(IS_GPIO_PIN(GPIO_Pin));\r
457 \r
458   if ((GPIOx->ODR & GPIO_Pin) != 0x00u)\r
459   {\r
460     GPIOx->BRR = (uint32_t)GPIO_Pin;\r
461   }\r
462   else\r
463   {\r
464     GPIOx->BSRR = (uint32_t)GPIO_Pin;\r
465   }\r
466 }\r
467 \r
468 /**\r
469 * @brief  Lock GPIO Pins configuration registers.\r
470   * @note   The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,\r
471   *         GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.\r
472   * @note   The configuration of the locked GPIO pins can no longer be modified\r
473   *         until the next reset.\r
474   * @param  GPIOx where x can be (A..H) to select the GPIO peripheral for STM32L4 family\r
475   * @param  GPIO_Pin specifies the port bits to be locked.\r
476   *         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).\r
477   * @retval None\r
478   */\r
479 HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)\r
480 {\r
481   __IO uint32_t tmp = GPIO_LCKR_LCKK;\r
482 \r
483   /* Check the parameters */\r
484   assert_param(IS_GPIO_LOCK_INSTANCE(GPIOx));\r
485   assert_param(IS_GPIO_PIN(GPIO_Pin));\r
486 \r
487   /* Apply lock key write sequence */\r
488   tmp |= GPIO_Pin;\r
489   /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */\r
490   GPIOx->LCKR = tmp;\r
491   /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */\r
492   GPIOx->LCKR = GPIO_Pin;\r
493   /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */\r
494   GPIOx->LCKR = tmp;\r
495   /* Read LCKK register. This read is mandatory to complete key lock sequence */\r
496   tmp = GPIOx->LCKR;\r
497 \r
498   /* Read again in order to confirm lock is active */\r
499   if ((GPIOx->LCKR & GPIO_LCKR_LCKK) != 0x00u)\r
500   {\r
501     return HAL_OK;\r
502   }\r
503   else\r
504   {\r
505     return HAL_ERROR;\r
506   }\r
507 }\r
508 \r
509 /**\r
510   * @brief  Handle EXTI interrupt request.\r
511   * @param  GPIO_Pin Specifies the port pin connected to corresponding EXTI line.\r
512   * @retval None\r
513   */\r
514 void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)\r
515 {\r
516   /* EXTI line interrupt detected */\r
517   if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != 0x00u)\r
518   {\r
519     __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);\r
520     HAL_GPIO_EXTI_Callback(GPIO_Pin);\r
521   }\r
522 }\r
523 \r
524 /**\r
525   * @brief  EXTI line detection callback.\r
526   * @param  GPIO_Pin: Specifies the port pin connected to corresponding EXTI line.\r
527   * @retval None\r
528   */\r
529 __weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)\r
530 {\r
531   /* Prevent unused argument(s) compilation warning */\r
532   UNUSED(GPIO_Pin);\r
533 \r
534   /* NOTE: This function should not be modified, when the callback is needed,\r
535            the HAL_GPIO_EXTI_Callback could be implemented in the user file\r
536    */\r
537 }\r
538 \r
539 /**\r
540   * @}\r
541   */\r
542 \r
543 \r
544 /**\r
545   * @}\r
546   */\r
547 \r
548 #endif /* HAL_GPIO_MODULE_ENABLED */\r
549 /**\r
550   * @}\r
551   */\r
552 \r
553 /**\r
554   * @}\r
555   */\r
556 \r
557 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r