Skip to content

Commit 2f5bb5e

Browse files
committed
Add clear pending interrupt feature with attachInterruptWithClearPending API
1 parent 22ef1b4 commit 2f5bb5e

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

cores/arduino/WInterrupts.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,13 @@ void detachInterrupt(uint32_t pin)
8787
UNUSED(pin);
8888
#endif
8989
}
90+
91+
void clearPendingInterrupt(uint32_t pin)
92+
{
93+
#if !defined(HAL_EXTI_MODULE_DISABLED)
94+
PinName p = digitalPinToPinName(pin);
95+
stm32_clear_pending_interrupt(STM_GPIO_PIN(p));
96+
#else
97+
UNUSED(pin);
98+
#endif
99+
}

cores/arduino/WInterrupts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode);
3333

3434
void detachInterrupt(uint32_t pin);
3535

36+
void clearPendingInterrupt(uint32_t pin);
37+
3638
#endif /* _WIRING_INTERRUPTS_ */

cores/arduino/stm32/interrupt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
/* Exported functions ------------------------------------------------------- */
7070
void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, void (*callback)(void), uint32_t mode);
7171
void stm32_interrupt_disable(GPIO_TypeDef *port, uint16_t pin);
72+
void stm32_clear_pending_interrupt(uint16_t pin);
7273
#endif /* !HAL_EXTI_MODULE_DISABLED */
7374

7475
#endif /* __INTERRUPT_H */

libraries/SrcWrapper/src/stm32/interrupt.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ void stm32_interrupt_disable(GPIO_TypeDef *port, uint16_t pin)
232232
HAL_NVIC_DisableIRQ(gpio_irq_conf[id].irqnb);
233233
}
234234

235+
/**
236+
* @brief This function clear the pending interrupts on the selected pin
237+
* @param pin : one of the gpio pin
238+
* @retval None
239+
*/
240+
void stm32_clear_pending_interrupt(uint16_t pin)
241+
{
242+
uint8_t id = get_pin_id(pin);
243+
__HAL_GPIO_EXTI_CLEAR_IT(pin);
244+
HAL_NVIC_ClearPendingIRQ(gpio_irq_conf[id].irqnb);
245+
}
246+
235247
/**
236248
* @brief This function his called by the HAL if the IRQ is valid
237249
* @param GPIO_Pin : one of the gpio pin

0 commit comments

Comments
 (0)