1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_hal_exti.c
4   * @author  MCD Application Team
5   * @brief   EXTI HAL module driver.
6   *          This file provides firmware functions to manage the following
7   *          functionalities of the Extended Interrupts and events controller (EXTI) peripheral:
8   *           + Initialization and de-initialization functions
9   *           + IO operation functions
10   *
11   @verbatim
12   ==============================================================================
13                     ##### EXTI Peripheral features #####
14   ==============================================================================
15   [..]
16     (+) Each Exti line can be configured within this driver.
17 
18     (+) Exti line can be configured in 3 different modes
19         (++) Interrupt
20         (++) Event
21         (++) Both of them
22 
23     (+) Configurable Exti lines can be configured with 3 different triggers
24         (++) Rising
25         (++) Falling
26         (++) Both of them
27 
28     (+) When set in interrupt mode, configurable Exti lines have two different
29         interrupts pending registers which allow to distinguish which transition
30         occurs:
31         (++) Rising edge pending interrupt
32         (++) Falling
33 
34     (+) Exti lines 0 to 15 are linked to gpio pin number 0 to 15. Gpio port can
35         be selected through multiplexer.
36 
37                      ##### How to use this driver #####
38   ==============================================================================
39   [..]
40 
41     (#) Configure the EXTI line using HAL_EXTI_SetConfigLine().
42         (++) Choose the interrupt line number by setting "Line" member from
43              EXTI_ConfigTypeDef structure.
44         (++) Configure the interrupt and/or event mode using "Mode" member from
45              EXTI_ConfigTypeDef structure.
46         (++) For configurable lines, configure rising and/or falling trigger
47              "Trigger" member from EXTI_ConfigTypeDef structure.
48         (++) For Exti lines linked to gpio, choose gpio port using "GPIOSel"
49              member from GPIO_InitTypeDef structure.
50 
51     (#) Get current Exti configuration of a dedicated line using
52         HAL_EXTI_GetConfigLine().
53         (++) Provide exiting handle as parameter.
54         (++) Provide pointer on EXTI_ConfigTypeDef structure as second parameter.
55 
56     (#) Clear Exti configuration of a dedicated line using HAL_EXTI_GetConfigLine().
57         (++) Provide exiting handle as parameter.
58 
59     (#) Register callback to treat Exti interrupts using HAL_EXTI_RegisterCallback().
60         (++) Provide exiting handle as first parameter.
61         (++) Provide which callback will be registered using one value from
62              EXTI_CallbackIDTypeDef.
63         (++) Provide callback function pointer.
64 
65     (#) Get interrupt pending bit using HAL_EXTI_GetPending().
66 
67     (#) Clear interrupt pending bit using HAL_EXTI_GetPending().
68 
69     (#) Generate software interrupt using HAL_EXTI_GenerateSWI().
70 
71   @endverbatim
72   ******************************************************************************
73   * @attention
74   *
75   * <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
76   *
77   * Redistribution and use in source and binary forms, with or without modification,
78   * are permitted provided that the following conditions are met:
79   *   1. Redistributions of source code must retain the above copyright notice,
80   *      this list of conditions and the following disclaimer.
81   *   2. Redistributions in binary form must reproduce the above copyright notice,
82   *      this list of conditions and the following disclaimer in the documentation
83   *      and/or other materials provided with the distribution.
84   *   3. Neither the name of STMicroelectronics nor the names of its contributors
85   *      may be used to endorse or promote products derived from this software
86   *      without specific prior written permission.
87   *
88   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
89   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
90   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
91   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
92   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
93   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
94   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
95   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
96   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
97   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98   *
99   ******************************************************************************
100   */
101 
102 /* Includes ------------------------------------------------------------------*/
103 #include "stm32l4xx_hal.h"
104 
105 /** @addtogroup STM32L4xx_HAL_Driver
106   * @{
107   */
108 
109 /** @addtogroup EXTI
110   * @{
111   */
112 /** MISRA C:2012 deviation rule has been granted for following rule:
113   * Rule-18.1_b - Medium: Array `EXTICR' 1st subscript interval [0,7] may be out
114   * of bounds [0,3] in following API :
115   * HAL_EXTI_SetConfigLine
116   * HAL_EXTI_GetConfigLine
117   * HAL_EXTI_ClearConfigLine
118   */
119 
120 #ifdef HAL_EXTI_MODULE_ENABLED
121 
122 /* Private typedef -----------------------------------------------------------*/
123 /* Private defines ------------------------------------------------------------*/
124 /** @defgroup EXTI_Private_Constants EXTI Private Constants
125   * @{
126   */
127 #define EXTI_MODE_OFFSET                    0x08u   /* 0x20: offset between MCU IMR/EMR registers */
128 #define EXTI_CONFIG_OFFSET                  0x08u   /* 0x20: offset between MCU Rising/Falling configuration registers */
129 /**
130   * @}
131   */
132 
133 /* Private macros ------------------------------------------------------------*/
134 /* Private variables ---------------------------------------------------------*/
135 /* Private function prototypes -----------------------------------------------*/
136 /* Exported functions --------------------------------------------------------*/
137 
138 /** @addtogroup EXTI_Exported_Functions
139   * @{
140   */
141 
142 /** @addtogroup EXTI_Exported_Functions_Group1
143  *  @brief    Configuration functions
144  *
145 @verbatim
146  ===============================================================================
147               ##### Configuration functions #####
148  ===============================================================================
149 
150 @endverbatim
151   * @{
152   */
153 
154 /**
155   * @brief  Set configuration of a dedicated Exti line.
156   * @param  hexti Exti handle.
157   * @param  pExtiConfig Pointer on EXTI configuration to be set.
158   * @retval HAL Status.
159   */
HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef * hexti,EXTI_ConfigTypeDef * pExtiConfig)160 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
161 {
162   __IO uint32_t *regaddr;
163   uint32_t regval;
164   uint32_t linepos;
165   uint32_t maskline;
166   uint32_t offset;
167 
168   /* Check null pointer */
169   if ((hexti == NULL) || (pExtiConfig == NULL))
170   {
171     return HAL_ERROR;
172   }
173 
174   /* Check parameters */
175   assert_param(IS_EXTI_LINE(pExtiConfig->Line));
176   assert_param(IS_EXTI_MODE(pExtiConfig->Mode));
177 
178   /* Assign line number to handle */
179   hexti->Line = pExtiConfig->Line;
180 
181   /* Compute line register offset and line mask */
182   offset = ((pExtiConfig->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
183   linepos = (pExtiConfig->Line & EXTI_PIN_MASK);
184   maskline = (1uL << linepos);
185 
186   /* Configure triggers for configurable lines */
187   if ((pExtiConfig->Line & EXTI_CONFIG) != 0x00u)
188   {
189     assert_param(IS_EXTI_TRIGGER(pExtiConfig->Trigger));
190 
191     /* Configure rising trigger */
192     regaddr = (&EXTI->RTSR1 + (EXTI_CONFIG_OFFSET * offset));
193     regval = *regaddr;
194 
195     /* Mask or set line */
196     if ((pExtiConfig->Trigger & EXTI_TRIGGER_RISING) != 0x00u)
197     {
198       regval |= maskline;
199     }
200     else
201     {
202       regval &= ~maskline;
203     }
204 
205     /* Store rising trigger mode */
206     *regaddr = regval;
207 
208     /* Configure falling trigger */
209     regaddr = (&EXTI->FTSR1 + (EXTI_CONFIG_OFFSET * offset));
210     regval = *regaddr;
211 
212     /* Mask or set line */
213     if ((pExtiConfig->Trigger & EXTI_TRIGGER_FALLING) != 0x00u)
214     {
215       regval |= maskline;
216     }
217     else
218     {
219       regval &= ~maskline;
220     }
221 
222     /* Store falling trigger mode */
223     *regaddr = regval;
224 
225     /* Configure gpio port selection in case of gpio exti line */
226     if ((pExtiConfig->Line & EXTI_GPIO) == EXTI_GPIO)
227     {
228       assert_param(IS_EXTI_GPIO_PORT(pExtiConfig->GPIOSel));
229       assert_param(IS_EXTI_GPIO_PIN(linepos));
230 
231       regval = SYSCFG->EXTICR[linepos >> 2u];
232       regval &= ~(SYSCFG_EXTICR1_EXTI0 << (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u)));
233       regval |= (pExtiConfig->GPIOSel << (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u)));
234       SYSCFG->EXTICR[linepos >> 2u] = regval;
235     }
236   }
237 
238   /* Configure interrupt mode : read current mode */
239   regaddr = (&EXTI->IMR1 + (EXTI_MODE_OFFSET * offset));
240   regval = *regaddr;
241 
242   /* Mask or set line */
243   if ((pExtiConfig->Mode & EXTI_MODE_INTERRUPT) != 0x00u)
244   {
245     regval |= maskline;
246   }
247   else
248   {
249     regval &= ~maskline;
250   }
251 
252   /* Store interrupt mode */
253   *regaddr = regval;
254 
255   /* The event mode cannot be configured if the line does not support it */
256   assert_param(((pExtiConfig->Line & EXTI_EVENT) == EXTI_EVENT) || ((pExtiConfig->Mode & EXTI_MODE_EVENT) != EXTI_MODE_EVENT));
257 
258   /* Configure event mode : read current mode */
259   regaddr = (&EXTI->EMR1 + (EXTI_MODE_OFFSET * offset));
260   regval = *regaddr;
261 
262   /* Mask or set line */
263   if ((pExtiConfig->Mode & EXTI_MODE_EVENT) != 0x00u)
264   {
265     regval |= maskline;
266   }
267   else
268   {
269     regval &= ~maskline;
270   }
271 
272   /* Store event mode */
273   *regaddr = regval;
274 
275   return HAL_OK;
276 }
277 
278 
279 /**
280   * @brief  Get configuration of a dedicated Exti line.
281   * @param  hexti Exti handle.
282   * @param  pExtiConfig Pointer on structure to store Exti configuration.
283   * @retval HAL Status.
284   */
HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef * hexti,EXTI_ConfigTypeDef * pExtiConfig)285 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
286 {
287   __IO uint32_t *regaddr;
288   uint32_t regval;
289   uint32_t linepos;
290   uint32_t maskline;
291   uint32_t offset;
292 
293   /* Check null pointer */
294   if ((hexti == NULL) || (pExtiConfig == NULL))
295   {
296     return HAL_ERROR;
297   }
298 
299   /* Check the parameter */
300   assert_param(IS_EXTI_LINE(hexti->Line));
301 
302   /* Store handle line number to configuration structure */
303   pExtiConfig->Line = hexti->Line;
304 
305   /* Compute line register offset and line mask */
306   offset = ((pExtiConfig->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
307   linepos = (pExtiConfig->Line & EXTI_PIN_MASK);
308   maskline = (1uL << linepos);
309 
310   /* 1] Get core mode : interrupt */
311   regaddr = (&EXTI->IMR1 + (EXTI_MODE_OFFSET * offset));
312   regval = *regaddr;
313 
314   /* Check if selected line is enable */
315   if ((regval & maskline) != 0x00u)
316   {
317     pExtiConfig->Mode = EXTI_MODE_INTERRUPT;
318   }
319   else
320   {
321     pExtiConfig->Mode = EXTI_MODE_NONE;
322   }
323 
324   /* Get event mode */
325   regaddr = (&EXTI->EMR1 + (EXTI_MODE_OFFSET * offset));
326   regval = *regaddr;
327 
328   /* Check if selected line is enable */
329   if ((regval & maskline) != 0x00u)
330   {
331     pExtiConfig->Mode |= EXTI_MODE_EVENT;
332   }
333 
334   /* 2] Get trigger for configurable lines : rising */
335   if ((pExtiConfig->Line & EXTI_CONFIG) != 0x00u)
336   {
337     regaddr = (&EXTI->RTSR1 + (EXTI_CONFIG_OFFSET * offset));
338     regval = *regaddr;
339 
340     /* Check if configuration of selected line is enable */
341     if ((regval & maskline) != 0x00u)
342     {
343       pExtiConfig->Trigger = EXTI_TRIGGER_RISING;
344     }
345     else
346     {
347       pExtiConfig->Trigger = EXTI_TRIGGER_NONE;
348     }
349 
350     /* Get falling configuration */
351     regaddr = (&EXTI->FTSR1 + (EXTI_CONFIG_OFFSET * offset));
352     regval = *regaddr;
353 
354     /* Check if configuration of selected line is enable */
355     if ((regval & maskline) != 0x00u)
356     {
357       pExtiConfig->Trigger |= EXTI_TRIGGER_FALLING;
358     }
359 
360     /* Get Gpio port selection for gpio lines */
361     if ((pExtiConfig->Line & EXTI_GPIO) == EXTI_GPIO)
362     {
363       assert_param(IS_EXTI_GPIO_PIN(linepos));
364 
365       regval = SYSCFG->EXTICR[linepos >> 2u];
366       pExtiConfig->GPIOSel = ((regval << (SYSCFG_EXTICR1_EXTI1_Pos * (3uL - (linepos & 0x03u)))) >> 24);
367     }
368     else
369     {
370       pExtiConfig->GPIOSel = 0x00u;
371     }
372   }
373   else
374   {
375     pExtiConfig->Trigger = EXTI_TRIGGER_NONE;
376     pExtiConfig->GPIOSel = 0x00u;
377   }
378 
379   return HAL_OK;
380 }
381 
382 
383 /**
384   * @brief  Clear whole configuration of a dedicated Exti line.
385   * @param  hexti Exti handle.
386   * @retval HAL Status.
387   */
HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef * hexti)388 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti)
389 {
390   __IO uint32_t *regaddr;
391   uint32_t regval;
392   uint32_t linepos;
393   uint32_t maskline;
394   uint32_t offset;
395 
396   /* Check null pointer */
397   if (hexti == NULL)
398   {
399     return HAL_ERROR;
400   }
401 
402   /* Check the parameter */
403   assert_param(IS_EXTI_LINE(hexti->Line));
404 
405   /* compute line register offset and line mask */
406   offset = ((hexti->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
407   linepos = (hexti->Line & EXTI_PIN_MASK);
408   maskline = (1uL << linepos);
409 
410   /* 1] Clear interrupt mode */
411   regaddr = (&EXTI->IMR1 + (EXTI_MODE_OFFSET * offset));
412   regval = (*regaddr & ~maskline);
413   *regaddr = regval;
414 
415   /* 2] Clear event mode */
416   regaddr = (&EXTI->EMR1 + (EXTI_MODE_OFFSET * offset));
417   regval = (*regaddr & ~maskline);
418   *regaddr = regval;
419 
420   /* 3] Clear triggers in case of configurable lines */
421   if ((hexti->Line & EXTI_CONFIG) != 0x00u)
422   {
423     regaddr = (&EXTI->RTSR1 + (EXTI_CONFIG_OFFSET * offset));
424     regval = (*regaddr & ~maskline);
425     *regaddr = regval;
426 
427     regaddr = (&EXTI->FTSR1 + (EXTI_CONFIG_OFFSET * offset));
428     regval = (*regaddr & ~maskline);
429     *regaddr = regval;
430 
431     /* Get Gpio port selection for gpio lines */
432     if ((hexti->Line & EXTI_GPIO) == EXTI_GPIO)
433     {
434       assert_param(IS_EXTI_GPIO_PIN(linepos));
435 
436       regval = SYSCFG->EXTICR[linepos >> 2u];
437       regval &= ~(SYSCFG_EXTICR1_EXTI0 << (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u)));
438       SYSCFG->EXTICR[linepos >> 2u] = regval;
439     }
440   }
441 
442   return HAL_OK;
443 }
444 
445 
446 /**
447   * @brief  Register callback for a dedicated Exti line.
448   * @param  hexti Exti handle.
449   * @param  CallbackID User callback identifier.
450   *         This parameter can be one of @arg @ref EXTI_CallbackIDTypeDef values.
451   * @param  pPendingCbfn function pointer to be stored as callback.
452   * @retval HAL Status.
453   */
HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef * hexti,EXTI_CallbackIDTypeDef CallbackID,void (* pPendingCbfn)(void))454 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void))
455 {
456   HAL_StatusTypeDef status = HAL_OK;
457 
458   switch (CallbackID)
459   {
460     case  HAL_EXTI_COMMON_CB_ID:
461       hexti->PendingCallback = pPendingCbfn;
462       break;
463 
464     default:
465       status = HAL_ERROR;
466       break;
467   }
468 
469   return status;
470 }
471 
472 
473 /**
474   * @brief  Store line number as handle private field.
475   * @param  hexti Exti handle.
476   * @param  ExtiLine Exti line number.
477   *         This parameter can be from 0 to @ref EXTI_LINE_NB.
478   * @retval HAL Status.
479   */
HAL_EXTI_GetHandle(EXTI_HandleTypeDef * hexti,uint32_t ExtiLine)480 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine)
481 {
482   /* Check the parameters */
483   assert_param(IS_EXTI_LINE(ExtiLine));
484 
485   /* Check null pointer */
486   if (hexti == NULL)
487   {
488     return HAL_ERROR;
489   }
490   else
491   {
492     /* Store line number as handle private field */
493     hexti->Line = ExtiLine;
494 
495     return HAL_OK;
496   }
497 }
498 
499 
500 /**
501   * @}
502   */
503 
504 /** @addtogroup EXTI_Exported_Functions_Group2
505  *  @brief EXTI IO functions.
506  *
507 @verbatim
508  ===============================================================================
509                        ##### IO operation functions #####
510  ===============================================================================
511 
512 @endverbatim
513   * @{
514   */
515 
516 /**
517   * @brief  Handle EXTI interrupt request.
518   * @param  hexti Exti handle.
519   * @retval none.
520   */
HAL_EXTI_IRQHandler(EXTI_HandleTypeDef * hexti)521 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti)
522 {
523   __IO uint32_t *regaddr;
524   uint32_t regval;
525   uint32_t maskline;
526   uint32_t offset;
527 
528   /* Compute line register offset and line mask */
529   offset = ((hexti->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
530   maskline = (1uL << (hexti->Line & EXTI_PIN_MASK));
531 
532   /* Get pending bit  */
533   regaddr = (&EXTI->PR1 + (EXTI_CONFIG_OFFSET * offset));
534   regval = (*regaddr & maskline);
535 
536   if (regval != 0x00u)
537   {
538     /* Clear pending bit */
539     *regaddr = maskline;
540 
541     /* Call callback */
542     if (hexti->PendingCallback != NULL)
543     {
544       hexti->PendingCallback();
545     }
546   }
547 }
548 
549 
550 /**
551   * @brief  Get interrupt pending bit of a dedicated line.
552   * @param  hexti Exti handle.
553   * @param  Edge Specify which pending edge as to be checked.
554   *         This parameter can be one of the following values:
555   *           @arg @ref EXTI_TRIGGER_RISING_FALLING
556   *         This parameter is kept for compatibility with other series.
557   * @retval 1 if interrupt is pending else 0.
558   */
HAL_EXTI_GetPending(EXTI_HandleTypeDef * hexti,uint32_t Edge)559 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge)
560 {
561   __IO uint32_t *regaddr;
562   uint32_t regval;
563   uint32_t linepos;
564   uint32_t maskline;
565   uint32_t offset;
566 
567   /* Check parameters */
568   assert_param(IS_EXTI_LINE(hexti->Line));
569   assert_param(IS_EXTI_CONFIG_LINE(hexti->Line));
570   assert_param(IS_EXTI_PENDING_EDGE(Edge));
571 
572   /* Compute line register offset and line mask */
573   offset = ((hexti->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
574   linepos = (hexti->Line & EXTI_PIN_MASK);
575   maskline = (1uL << linepos);
576 
577   /* Get pending bit */
578   regaddr = (&EXTI->PR1 + (EXTI_CONFIG_OFFSET * offset));
579 
580   /* return 1 if bit is set else 0 */
581   regval = ((*regaddr & maskline) >> linepos);
582   return regval;
583 }
584 
585 
586 /**
587   * @brief  Clear interrupt pending bit of a dedicated line.
588   * @param  hexti Exti handle.
589   * @param  Edge Specify which pending edge as to be clear.
590   *         This parameter can be one of the following values:
591   *           @arg @ref EXTI_TRIGGER_RISING_FALLING
592   *         This parameter is kept for compatibility with other series.
593   * @retval None.
594   */
HAL_EXTI_ClearPending(EXTI_HandleTypeDef * hexti,uint32_t Edge)595 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge)
596 {
597   __IO uint32_t *regaddr;
598   uint32_t maskline;
599   uint32_t offset;
600 
601   /* Check parameters */
602   assert_param(IS_EXTI_LINE(hexti->Line));
603   assert_param(IS_EXTI_CONFIG_LINE(hexti->Line));
604   assert_param(IS_EXTI_PENDING_EDGE(Edge));
605 
606   /* compute line register offset and line mask */
607   offset = ((hexti->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
608   maskline = (1uL << (hexti->Line & EXTI_PIN_MASK));
609 
610   /* Get pending register address */
611   regaddr = (&EXTI->PR1 + (EXTI_CONFIG_OFFSET * offset));
612 
613   /* Clear Pending bit */
614   *regaddr =  maskline;
615 }
616 
617 
618 /**
619   * @brief  Generate a software interrupt for a dedicated line.
620   * @param  hexti Exti handle.
621   * @retval None.
622   */
HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef * hexti)623 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti)
624 {
625   __IO uint32_t *regaddr;
626   uint32_t maskline;
627   uint32_t offset;
628 
629   /* Check parameters */
630   assert_param(IS_EXTI_LINE(hexti->Line));
631   assert_param(IS_EXTI_CONFIG_LINE(hexti->Line));
632 
633   /* compute line register offset and line mask */
634   offset = ((hexti->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
635   maskline = (1uL << (hexti->Line & EXTI_PIN_MASK));
636 
637   regaddr = (&EXTI->SWIER1 + (EXTI_CONFIG_OFFSET * offset));
638   *regaddr = maskline;
639 }
640 
641 
642 /**
643   * @}
644   */
645 
646 /**
647   * @}
648   */
649 
650 #endif /* HAL_EXTI_MODULE_ENABLED */
651 /**
652   * @}
653   */
654 
655 /**
656   * @}
657   */
658 
659 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
660