Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/drivers/exti.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,15 @@ void EXTI_IRQHandler(void)
{
uint32_t exti_active = EXTI_REG_IMR & EXTI_REG_PR;

// Clear before dispatching (as Betaflight does): an edge on the same line
// while its handler runs must stay pending rather than be wiped when the
// handler returns.
EXTI_REG_PR = exti_active;

while (exti_active) {
unsigned idx = 31 - __builtin_clz(exti_active);
uint32_t mask = 1 << idx;
extiChannelRecs[idx].handler->fn(extiChannelRecs[idx].handler);
EXTI_REG_PR = mask; // clear pending mask (by writing 1)
exti_active &= ~mask;
}
}
Expand Down