2 ******************************************************************************
3 * @file stm32h7xx_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 General Purpose Input/Output (EXTI) peripheral:
8 * + Initialization and de-initialization functions
9 * + IO operation functions
11 ******************************************************************************
14 * Copyright (c) 2017 STMicroelectronics.
15 * All rights reserved.
17 * This software is licensed under terms that can be found in the LICENSE file
18 * in the root directory of this software component.
19 * If no LICENSE file comes with this software, it is provided AS-IS.
21 ******************************************************************************
23 ==============================================================================
24 ##### EXTI Peripheral features #####
25 ==============================================================================
27 (+) Each Exti line can be configured within this driver.
29 (+) Exti line can be configured in 3 different modes
30 (++) Interrupt (CORE1 or CORE2 in case of dual core line )
31 (++) Event (CORE1 or CORE2 in case of dual core line )
32 (++) a combination of the previous
34 (+) Configurable Exti lines can be configured with 3 different triggers
39 (+) When set in interrupt mode, configurable Exti lines have two diffenrents
40 interrupt pending registers which allow to distinguish which transition
42 (++) Rising edge pending interrupt
45 (+) Exti lines 0 to 15 are linked to gpio pin number 0 to 15. Gpio port can
46 be selected through multiplexer.
48 (+) PendClearSource used to set the D3 Smart Run Domain autoamtic pend clear source.
49 It is applicable for line with wkaeup target is Any (CPU1 , CPU2 and D3 smart run domain).
50 Value can be one of the following:
51 (++) EXTI_D3_PENDCLR_SRC_NONE : no pend clear source is selected :
52 In this case corresponding bit of D2PMRx register is set to 0
53 (+++) On a configurable Line : the D3 domain wakeup signal is
54 automatically cleared after after the Delay + Rising Edge detect
55 (+++) On a direct Line : the D3 domain wakeup signal is
56 cleared after the direct event input signal is cleared
58 (++) EXTI_D3_PENDCLR_SRC_DMACH6 : no pend clear source is selected :
59 In this case corresponding bit of D2PMRx register is set to 1
60 and corresponding bits(2) of D3PCRxL/H is set to b00 :
61 DMA ch6 event selected as D3 domain pendclear source
63 (++) EXTI_D3_PENDCLR_SRC_DMACH7 : no pend clear source is selected :
64 In this case corresponding bit of D2PMRx register is set to 1
65 and corresponding bits(2) of D3PCRxL/H is set to b01 :
66 DMA ch7 event selected as D3 domain pendclear source
68 (++) EXTI_D3_PENDCLR_SRC_LPTIM4 : no pend clear source is selected :
69 In this case corresponding bit of D2PMRx register is set to 1
70 and corresponding bits(2) of D3PCRxL/H is set to b10 :
71 LPTIM4 out selected as D3 domain pendclear source
73 (++) EXTI_D3_PENDCLR_SRC_LPTIM5 : no pend clear source is selected :
74 In this case corresponding bit of D2PMRx register is set to 1
75 and corresponding bits(2) of D3PCRxL/H is set to b11 :
76 LPTIM5 out selected as D3 domain pendclear source
79 ##### How to use this driver #####
80 ==============================================================================
83 (#) Configure the EXTI line using HAL_EXTI_SetConfigLine().
84 (++) Choose the interrupt line number by setting "Line" member from
85 EXTI_ConfigTypeDef structure.
86 (++) Configure the interrupt and/or event mode using "Mode" member from
87 EXTI_ConfigTypeDef structure.
88 (++) For configurable lines, configure rising and/or falling trigger
89 "Trigger" member from EXTI_ConfigTypeDef structure.
90 (++) For Exti lines linked to gpio, choose gpio port using "GPIOSel"
91 member from GPIO_InitTypeDef structure.
92 (++) For Exti lines with wkaeup target is Any (CPU1 , CPU2 and D3 smart run domain),
93 choose gpio D3 PendClearSource using PendClearSource
94 member from EXTI_PendClear_Source structure.
96 (#) Get current Exti configuration of a dedicated line using
97 HAL_EXTI_GetConfigLine().
98 (++) Provide exiting handle as parameter.
99 (++) Provide pointer on EXTI_ConfigTypeDef structure as second parameter.
101 (#) Clear Exti configuration of a dedicated line using HAL_EXTI_ClearConfigLine().
102 (++) Provide exiting handle as parameter.
104 (#) Register callback to treat Exti interrupts using HAL_EXTI_RegisterCallback().
105 (++) Provide exiting handle as first parameter.
106 (++) Provide which callback will be registered using one value from
107 EXTI_CallbackIDTypeDef.
108 (++) Provide callback function pointer.
110 (#) Get interrupt pending bit using HAL_EXTI_GetPending().
112 (#) Clear interrupt pending bit using HAL_EXTI_ClearPending().
114 (#) Generate software interrupt using HAL_EXTI_GenerateSWI().
119 /* Includes ------------------------------------------------------------------*/
120 #include "stm32h7xx_hal.h"
122 /** @addtogroup STM32H7xx_HAL_Driver
130 #ifdef HAL_EXTI_MODULE_ENABLED
132 /* Private typedef -----------------------------------------------------------*/
133 /* Private defines ------------------------------------------------------------*/
134 /** @defgroup EXTI_Private_Constants EXTI Private Constants
137 #define EXTI_MODE_OFFSET 0x04U /* 0x10: offset between CPU IMR/EMR registers */
138 #define EXTI_CONFIG_OFFSET 0x08U /* 0x20: offset between CPU Rising/Falling configuration registers */
143 /* Private macros ------------------------------------------------------------*/
144 /* Private variables ---------------------------------------------------------*/
145 /* Private function prototypes -----------------------------------------------*/
146 /* Exported functions --------------------------------------------------------*/
148 /** @addtogroup EXTI_Exported_Functions
152 /** @addtogroup EXTI_Exported_Functions_Group1
153 * @brief Configuration functions
156 ===============================================================================
157 ##### Configuration functions #####
158 ===============================================================================
165 * @brief Set configuration of a dedicated Exti line.
166 * @param hexti Exti handle.
167 * @param pExtiConfig Pointer on EXTI configuration to be set.
168 * @retval HAL Status.
170 HAL_StatusTypeDef
HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef
*hexti
, EXTI_ConfigTypeDef
*pExtiConfig
)
172 __IO
uint32_t *regaddr
;
179 /* Check null pointer */
180 if ((hexti
== NULL
) || (pExtiConfig
== NULL
))
185 /* Check the parameters */
186 assert_param(IS_EXTI_LINE(pExtiConfig
->Line
));
187 assert_param(IS_EXTI_MODE(pExtiConfig
->Mode
));
189 /* Assign line number to handle */
190 hexti
->Line
= pExtiConfig
->Line
;
192 /* compute line register offset and line mask */
193 offset
= ((pExtiConfig
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
194 linepos
= (pExtiConfig
->Line
& EXTI_PIN_MASK
);
195 maskline
= (1UL << linepos
);
197 /* Configure triggers for configurable lines */
198 if ((pExtiConfig
->Line
& EXTI_CONFIG
) != 0x00U
)
200 assert_param(IS_EXTI_TRIGGER(pExtiConfig
->Trigger
));
202 /* Configure rising trigger */
203 regaddr
= (__IO
uint32_t *)(&EXTI
->RTSR1
+ (EXTI_CONFIG_OFFSET
* offset
));
206 /* Mask or set line */
207 if ((pExtiConfig
->Trigger
& EXTI_TRIGGER_RISING
) != 0x00U
)
216 /* Store rising trigger mode */
219 /* Configure falling trigger */
220 regaddr
= (__IO
uint32_t *)(&EXTI
->FTSR1
+ (EXTI_CONFIG_OFFSET
* offset
));
223 /* Mask or set line */
224 if ((pExtiConfig
->Trigger
& EXTI_TRIGGER_FALLING
) != 0x00U
)
233 /* Store falling trigger mode */
236 /* Configure gpio port selection in case of gpio exti line */
237 if ((pExtiConfig
->Line
& EXTI_GPIO
) == EXTI_GPIO
)
239 assert_param(IS_EXTI_GPIO_PORT(pExtiConfig
->GPIOSel
));
240 assert_param(IS_EXTI_GPIO_PIN(linepos
));
242 regval
= SYSCFG
->EXTICR
[(linepos
>> 2U) & 0x03UL
];
243 regval
&= ~(SYSCFG_EXTICR1_EXTI0
<< (SYSCFG_EXTICR1_EXTI1_Pos
* (linepos
& 0x03U
)));
244 regval
|= (pExtiConfig
->GPIOSel
<< (SYSCFG_EXTICR1_EXTI1_Pos
* (linepos
& 0x03U
)));
245 SYSCFG
->EXTICR
[(linepos
>> 2U) & 0x03UL
] = regval
;
249 /* Configure interrupt mode : read current mode */
250 regaddr
= (__IO
uint32_t *)(&EXTI
->IMR1
+ (EXTI_MODE_OFFSET
* offset
));
253 /* Mask or set line */
254 if ((pExtiConfig
->Mode
& EXTI_MODE_INTERRUPT
) != 0x00U
)
263 /* Store interrupt mode */
266 /* The event mode cannot be configured if the line does not support it */
267 assert_param(((pExtiConfig
->Line
& EXTI_EVENT
) == EXTI_EVENT
) || ((pExtiConfig
->Mode
& EXTI_MODE_EVENT
) != EXTI_MODE_EVENT
));
269 /* Configure event mode : read current mode */
270 regaddr
= (__IO
uint32_t *)(&EXTI
->EMR1
+ (EXTI_MODE_OFFSET
* offset
));
273 /* Mask or set line */
274 if ((pExtiConfig
->Mode
& EXTI_MODE_EVENT
) != 0x00U
)
283 /* Store event mode */
286 #if defined (DUAL_CORE)
287 /* Configure interrupt mode for Core2 : read current mode */
288 regaddr
= (__IO
uint32_t *)(&EXTI
->C2IMR1
+ (EXTI_MODE_OFFSET
* offset
));
291 /* Mask or set line */
292 if ((pExtiConfig
->Mode
& EXTI_MODE_CORE2_INTERRUPT
) != 0x00U
)
301 /* Store interrupt mode */
304 /* The event mode cannot be configured if the line does not support it */
305 assert_param(((pExtiConfig
->Line
& EXTI_EVENT
) == EXTI_EVENT
) || ((pExtiConfig
->Mode
& EXTI_MODE_CORE2_EVENT
) != EXTI_MODE_CORE2_EVENT
));
307 /* Configure event mode : read current mode */
308 regaddr
= (__IO
uint32_t *)(&EXTI
->C2EMR1
+ (EXTI_MODE_OFFSET
* offset
));
311 /* Mask or set line */
312 if ((pExtiConfig
->Mode
& EXTI_MODE_CORE2_EVENT
) != 0x00U
)
321 /* Store event mode */
323 #endif /* DUAL_CORE */
325 /* Configure the D3 PendClear source in case of Wakeup target is Any */
326 if ((pExtiConfig
->Line
& EXTI_TARGET_MASK
) == EXTI_TARGET_MSK_ALL
)
328 assert_param(IS_EXTI_D3_PENDCLR_SRC(pExtiConfig
->PendClearSource
));
330 /*Calc the PMR register address for the given line */
331 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PMR1
+ (EXTI_CONFIG_OFFSET
* offset
));
334 if(pExtiConfig
->PendClearSource
== EXTI_D3_PENDCLR_SRC_NONE
)
336 /* Clear D3PMRx register for the given line */
338 /* Store D3PMRx register value */
343 /* Set D3PMRx register to 1 for the given line */
345 /* Store D3PMRx register value */
350 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PCR1L
+ (EXTI_CONFIG_OFFSET
* offset
));
351 pcrlinepos
= 1UL << linepos
;
355 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PCR1H
+ (EXTI_CONFIG_OFFSET
* offset
));
356 pcrlinepos
= 1UL << (linepos
- 16UL);
359 regval
= (*regaddr
& (~(pcrlinepos
* pcrlinepos
* 3UL))) | (pcrlinepos
* pcrlinepos
* (pExtiConfig
->PendClearSource
- 1UL));
369 * @brief Get configuration of a dedicated Exti line.
370 * @param hexti Exti handle.
371 * @param pExtiConfig Pointer on structure to store Exti configuration.
372 * @retval HAL Status.
374 HAL_StatusTypeDef
HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef
*hexti
, EXTI_ConfigTypeDef
*pExtiConfig
)
376 __IO
uint32_t *regaddr
;
383 /* Check null pointer */
384 if ((hexti
== NULL
) || (pExtiConfig
== NULL
))
389 /* Check the parameter */
390 assert_param(IS_EXTI_LINE(hexti
->Line
));
392 /* Store handle line number to configuration structure */
393 pExtiConfig
->Line
= hexti
->Line
;
395 /* compute line register offset and line mask */
396 offset
= ((pExtiConfig
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
397 linepos
= (pExtiConfig
->Line
& EXTI_PIN_MASK
);
398 maskline
= (1UL << linepos
);
400 /* 1] Get core mode : interrupt */
401 regaddr
= (__IO
uint32_t *)(&EXTI
->IMR1
+ (EXTI_MODE_OFFSET
* offset
));
404 pExtiConfig
->Mode
= EXTI_MODE_NONE
;
406 /* Check if selected line is enable */
407 if ((regval
& maskline
) != 0x00U
)
409 pExtiConfig
->Mode
= EXTI_MODE_INTERRUPT
;
413 regaddr
= (__IO
uint32_t *)(&EXTI
->EMR1
+ (EXTI_MODE_OFFSET
* offset
));
416 /* Check if selected line is enable */
417 if ((regval
& maskline
) != 0x00U
)
419 pExtiConfig
->Mode
|= EXTI_MODE_EVENT
;
421 #if defined (DUAL_CORE)
422 regaddr
= (__IO
uint32_t *)(&EXTI
->C2IMR1
+ (EXTI_MODE_OFFSET
* offset
));
425 /* Check if selected line is enable */
426 if ((regval
& maskline
) != 0x00U
)
428 pExtiConfig
->Mode
= EXTI_MODE_CORE2_INTERRUPT
;
432 regaddr
= (__IO
uint32_t *)(&EXTI
->C2EMR1
+ (EXTI_MODE_OFFSET
* offset
));
435 /* Check if selected line is enable */
436 if ((regval
& maskline
) != 0x00U
)
438 pExtiConfig
->Mode
|= EXTI_MODE_CORE2_EVENT
;
442 /* Get default Trigger and GPIOSel configuration */
443 pExtiConfig
->Trigger
= EXTI_TRIGGER_NONE
;
444 pExtiConfig
->GPIOSel
= 0x00U
;
446 /* 2] Get trigger for configurable lines : rising */
447 if ((pExtiConfig
->Line
& EXTI_CONFIG
) != 0x00U
)
449 regaddr
= (__IO
uint32_t *)(&EXTI
->RTSR1
+ (EXTI_CONFIG_OFFSET
* offset
));
452 /* Check if configuration of selected line is enable */
453 if ((regval
& maskline
) != 0x00U
)
455 pExtiConfig
->Trigger
= EXTI_TRIGGER_RISING
;
458 /* Get falling configuration */
459 regaddr
= (__IO
uint32_t *)(&EXTI
->FTSR1
+ (EXTI_CONFIG_OFFSET
* offset
));
462 /* Check if configuration of selected line is enable */
463 if ((regval
& maskline
) != 0x00U
)
465 pExtiConfig
->Trigger
|= EXTI_TRIGGER_FALLING
;
468 /* Get Gpio port selection for gpio lines */
469 if ((pExtiConfig
->Line
& EXTI_GPIO
) == EXTI_GPIO
)
471 assert_param(IS_EXTI_GPIO_PIN(linepos
));
473 regval
= SYSCFG
->EXTICR
[(linepos
>> 2U) & 0x03UL
];
474 pExtiConfig
->GPIOSel
= (regval
>> (SYSCFG_EXTICR1_EXTI1_Pos
* (linepos
& 0x03u
))) & SYSCFG_EXTICR1_EXTI0
;
478 /* Get default Pend Clear Source */
479 pExtiConfig
->PendClearSource
= EXTI_D3_PENDCLR_SRC_NONE
;
481 /* 3] Get D3 Pend Clear source */
482 if ((pExtiConfig
->Line
& EXTI_TARGET_MASK
) == EXTI_TARGET_MSK_ALL
)
484 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PMR1
+ (EXTI_CONFIG_OFFSET
* offset
));
485 if(((*regaddr
) & linepos
) != 0UL)
487 /* if wakeup target is any and PMR set, the read pend clear source from D3PCRxL/H */
490 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PCR1L
+ (EXTI_CONFIG_OFFSET
* offset
));
491 pcrlinepos
= 1UL << linepos
;
495 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PCR1H
+ (EXTI_CONFIG_OFFSET
* offset
));
496 pcrlinepos
= 1UL << (linepos
- 16UL);
499 pExtiConfig
->PendClearSource
= 1UL + ((*regaddr
& (pcrlinepos
* pcrlinepos
* 3UL)) / (pcrlinepos
* pcrlinepos
));
508 * @brief Clear whole configuration of a dedicated Exti line.
509 * @param hexti Exti handle.
510 * @retval HAL Status.
512 HAL_StatusTypeDef
HAL_EXTI_ClearConfigLine(const EXTI_HandleTypeDef
*hexti
)
514 __IO
uint32_t *regaddr
;
521 /* Check null pointer */
527 /* Check the parameter */
528 assert_param(IS_EXTI_LINE(hexti
->Line
));
530 /* compute line register offset and line mask */
531 offset
= ((hexti
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
532 linepos
= (hexti
->Line
& EXTI_PIN_MASK
);
533 maskline
= (1UL << linepos
);
535 /* 1] Clear interrupt mode */
536 regaddr
= (__IO
uint32_t *)(&EXTI
->IMR1
+ (EXTI_MODE_OFFSET
* offset
));
537 regval
= (*regaddr
& ~maskline
);
540 /* 2] Clear event mode */
541 regaddr
= (__IO
uint32_t *)(&EXTI
->EMR1
+ (EXTI_MODE_OFFSET
* offset
));
542 regval
= (*regaddr
& ~maskline
);
545 #if defined (DUAL_CORE)
546 /* 1] Clear CM4 interrupt mode */
547 regaddr
= (__IO
uint32_t *)(&EXTI
->C2IMR1
+ (EXTI_MODE_OFFSET
* offset
));
548 regval
= (*regaddr
& ~maskline
);
551 /* 2] Clear CM4 event mode */
552 regaddr
= (__IO
uint32_t *)(&EXTI
->C2EMR1
+ (EXTI_MODE_OFFSET
* offset
));
553 regval
= (*regaddr
& ~maskline
);
555 #endif /* DUAL_CORE */
557 /* 3] Clear triggers in case of configurable lines */
558 if ((hexti
->Line
& EXTI_CONFIG
) != 0x00U
)
560 regaddr
= (__IO
uint32_t *)(&EXTI
->RTSR1
+ (EXTI_CONFIG_OFFSET
* offset
));
561 regval
= (*regaddr
& ~maskline
);
564 regaddr
= (__IO
uint32_t *)(&EXTI
->FTSR1
+ (EXTI_CONFIG_OFFSET
* offset
));
565 regval
= (*regaddr
& ~maskline
);
568 /* Get Gpio port selection for gpio lines */
569 if ((hexti
->Line
& EXTI_GPIO
) == EXTI_GPIO
)
571 assert_param(IS_EXTI_GPIO_PIN(linepos
));
573 regval
= SYSCFG
->EXTICR
[(linepos
>> 2U) & 0x03UL
];
574 regval
&= ~(SYSCFG_EXTICR1_EXTI0
<< (SYSCFG_EXTICR1_EXTI1_Pos
* (linepos
& 0x03UL
)));
575 SYSCFG
->EXTICR
[(linepos
>> 2U) & 0x03UL
] = regval
;
579 /* 4] Clear D3 Config lines */
580 if ((hexti
->Line
& EXTI_TARGET_MASK
) == EXTI_TARGET_MSK_ALL
)
582 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PMR1
+ (EXTI_CONFIG_OFFSET
* offset
));
583 *regaddr
= (*regaddr
& ~maskline
);
587 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PCR1L
+ (EXTI_CONFIG_OFFSET
* offset
));
588 pcrlinepos
= 1UL << linepos
;
592 regaddr
= (__IO
uint32_t *)(&EXTI
->D3PCR1H
+ (EXTI_CONFIG_OFFSET
* offset
));
593 pcrlinepos
= 1UL << (linepos
- 16UL);
596 /*Clear D3 PendClear source */
597 *regaddr
&= (~(pcrlinepos
* pcrlinepos
* 3UL));
605 * @brief Register callback for a dedicated Exti line.
606 * @param hexti Exti handle.
607 * @param CallbackID User callback identifier.
608 * This parameter can be one of @arg @ref EXTI_CallbackIDTypeDef values.
609 * @param pPendingCbfn function pointer to be stored as callback.
610 * @retval HAL Status.
612 HAL_StatusTypeDef
HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef
*hexti
, EXTI_CallbackIDTypeDef CallbackID
, void (*pPendingCbfn
)(void))
614 HAL_StatusTypeDef status
= HAL_OK
;
616 /* Check null pointer */
624 case HAL_EXTI_COMMON_CB_ID
:
625 hexti
->PendingCallback
= pPendingCbfn
;
638 * @brief Store line number as handle private field.
639 * @param hexti Exti handle.
640 * @param ExtiLine Exti line number.
641 * This parameter can be from 0 to @ref EXTI_LINE_NB.
642 * @retval HAL Status.
644 HAL_StatusTypeDef
HAL_EXTI_GetHandle(EXTI_HandleTypeDef
*hexti
, uint32_t ExtiLine
)
646 /* Check the parameters */
647 assert_param(IS_EXTI_LINE(ExtiLine
));
649 /* Check null pointer */
656 /* Store line number as handle private field */
657 hexti
->Line
= ExtiLine
;
668 /** @addtogroup EXTI_Exported_Functions_Group2
669 * @brief EXTI IO functions.
672 ===============================================================================
673 ##### IO operation functions #####
674 ===============================================================================
681 * @brief Handle EXTI interrupt request.
682 * @param hexti Exti handle.
685 void HAL_EXTI_IRQHandler(const EXTI_HandleTypeDef
*hexti
)
687 __IO
uint32_t *regaddr
;
692 /* Compute line register offset and line mask */
693 offset
= ((hexti
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
694 maskline
= (1UL << (hexti
->Line
& EXTI_PIN_MASK
));
696 #if defined(DUAL_CORE)
697 if (HAL_GetCurrentCPUID() == CM7_CPUID
)
699 /* Get pending register address */
700 regaddr
= (__IO
uint32_t *)(&EXTI
->PR1
+ (EXTI_MODE_OFFSET
* offset
));
704 /* Get pending register address */
705 regaddr
= (__IO
uint32_t *)(&EXTI
->C2PR1
+ (EXTI_MODE_OFFSET
* offset
));
708 regaddr
= (__IO
uint32_t *)(&EXTI
->PR1
+ (EXTI_MODE_OFFSET
* offset
));
709 #endif /* DUAL_CORE */
711 /* Get pending bit */
712 regval
= (*regaddr
& maskline
);
716 /* Clear pending bit */
720 if (hexti
->PendingCallback
!= NULL
)
722 hexti
->PendingCallback();
729 * @brief Get interrupt pending bit of a dedicated line.
730 * @param hexti Exti handle.
731 * @param Edge Specify which pending edge as to be checked.
732 * This parameter can be one of the following values:
733 * @arg @ref EXTI_TRIGGER_RISING_FALLING
734 * This parameter is kept for compatibility with other series.
735 * @retval 1 if interrupt is pending else 0.
737 uint32_t HAL_EXTI_GetPending(const EXTI_HandleTypeDef
*hexti
, uint32_t Edge
)
739 const __IO
uint32_t *regaddr
;
745 /* Prevent unused argument(s) compilation warning */
748 /* Check parameters */
749 assert_param(IS_EXTI_LINE(hexti
->Line
));
750 assert_param(IS_EXTI_CONFIG_LINE(hexti
->Line
));
751 assert_param(IS_EXTI_PENDING_EDGE(Edge
));
753 /* compute line register offset and line mask */
754 offset
= ((hexti
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
755 linepos
= (hexti
->Line
& EXTI_PIN_MASK
);
756 maskline
= (1UL << linepos
);
758 #if defined(DUAL_CORE)
759 if (HAL_GetCurrentCPUID() == CM7_CPUID
)
761 /* Get pending register address */
762 regaddr
= (__IO
uint32_t *)(&EXTI
->PR1
+ (EXTI_MODE_OFFSET
* offset
));
766 /* Get pending register address */
767 regaddr
= (__IO
uint32_t *)(&EXTI
->C2PR1
+ (EXTI_MODE_OFFSET
* offset
));
770 regaddr
= (__IO
uint32_t *)(&EXTI
->PR1
+ (EXTI_MODE_OFFSET
* offset
));
771 #endif /* DUAL_CORE */
773 /* return 1 if bit is set else 0 */
774 regval
= ((*regaddr
& maskline
) >> linepos
);
780 * @brief Clear interrupt pending bit of a dedicated line.
781 * @param hexti Exti handle.
782 * @param Edge Specify which pending edge as to be clear.
783 * This parameter can be one of the following values:
784 * @arg @ref EXTI_TRIGGER_RISING_FALLING
785 * This parameter is kept for compatibility with other series.
788 void HAL_EXTI_ClearPending(const EXTI_HandleTypeDef
*hexti
, uint32_t Edge
)
790 __IO
uint32_t *regaddr
;
794 /* Prevent unused argument(s) compilation warning */
797 /* Check parameters */
798 assert_param(IS_EXTI_LINE(hexti
->Line
));
799 assert_param(IS_EXTI_CONFIG_LINE(hexti
->Line
));
800 assert_param(IS_EXTI_PENDING_EDGE(Edge
));
802 /* compute line register offset and line mask */
803 offset
= ((hexti
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
804 maskline
= (1UL << (hexti
->Line
& EXTI_PIN_MASK
));
806 #if defined(DUAL_CORE)
807 if (HAL_GetCurrentCPUID() == CM7_CPUID
)
809 /* Get pending register address */
810 regaddr
= (__IO
uint32_t *)(&EXTI
->PR1
+ (EXTI_MODE_OFFSET
* offset
));
814 /* Get pending register address */
815 regaddr
= (__IO
uint32_t *)(&EXTI
->C2PR1
+ (EXTI_MODE_OFFSET
* offset
));
818 regaddr
= (__IO
uint32_t *)(&EXTI
->PR1
+ (EXTI_MODE_OFFSET
* offset
));
819 #endif /* DUAL_CORE */
821 /* Clear Pending bit */
826 * @brief Generate a software interrupt for a dedicated line.
827 * @param hexti Exti handle.
830 void HAL_EXTI_GenerateSWI(const EXTI_HandleTypeDef
*hexti
)
832 __IO
uint32_t *regaddr
;
836 /* Check parameters */
837 assert_param(IS_EXTI_LINE(hexti
->Line
));
838 assert_param(IS_EXTI_CONFIG_LINE(hexti
->Line
));
840 /* compute line register offset and line mask */
841 offset
= ((hexti
->Line
& EXTI_REG_MASK
) >> EXTI_REG_SHIFT
);
842 maskline
= (1UL << (hexti
->Line
& EXTI_PIN_MASK
));
844 regaddr
= (__IO
uint32_t *)(&EXTI
->SWIER1
+ (EXTI_CONFIG_OFFSET
* offset
));
857 #endif /* HAL_EXTI_MODULE_ENABLED */