From 1ba516f4758508f2657d1c68d31055c3c8e21b28 Mon Sep 17 00:00:00 2001 From: Krzysztof Blazewicz Date: Tue, 6 Sep 2016 17:22:43 +0200 Subject: [PATCH] stmhal/extint: Force 0 to 1 transition on swint(). If a user tries to call `swint()` while interrupt is disabled the flag in SWIER is set but the interrupt is not triggered and therefore the SWIER bit is not cleared. When the interrupt is again enabled the next call to `swint()` won't trigger the IRQ because a 0 to 1 transition will not occur. --- stmhal/extint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stmhal/extint.c b/stmhal/extint.c index c0471719b..02b06fde5 100644 --- a/stmhal/extint.c +++ b/stmhal/extint.c @@ -251,10 +251,13 @@ void extint_swint(uint line) { if (line >= EXTI_NUM_VECTORS) { return; } + // we need 0 to 1 transition to trigger the interrupt #if defined(MCU_SERIES_L4) - EXTI->SWIER1 = (1 << line); + EXTI->SWIER1 &= ~(1 << line); + EXTI->SWIER1 |= (1 << line); #else - EXTI->SWIER = (1 << line); + EXTI->SWIER &= ~(1 << line); + EXTI->SWIER |= (1 << line); #endif }