From 578bd31908fb4c474f1e7999e8b70c0afee71dec Mon Sep 17 00:00:00 2001 From: Abdulkerim Altuntas Date: Mon, 18 May 2020 16:41:23 +0200 Subject: [PATCH] cpu/stm32_common: fix issue while clearing EXTI->PR reg Since the "EXTI->PR" is an "rc_w1" type of register, we need to be careful when clearing our interrupt flag in the register. When there are multiple interrupt flags set in the register, the "|=" operation will mistakenly clear all pending interrupts instead of just ours. --- cpu/stm32_common/periph/rtc.c | 4 ++-- cpu/stm32_common/periph/rtt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpu/stm32_common/periph/rtc.c b/cpu/stm32_common/periph/rtc.c index fa513f12d2..78c8fe546e 100644 --- a/cpu/stm32_common/periph/rtc.c +++ b/cpu/stm32_common/periph/rtc.c @@ -237,7 +237,7 @@ void rtc_init(void) EXTI->FTSR &= ~(EXTI_FTSR_BIT); EXTI->RTSR |= EXTI_RTSR_BIT; EXTI->IMR |= EXTI_IMR_BIT; - EXTI->PR |= EXTI_PR_BIT; + EXTI->PR = EXTI_PR_BIT; /* enable global RTC interrupt */ NVIC_EnableIRQ(IRQN); } @@ -351,7 +351,7 @@ void ISR_NAME(void) } RTC->ISR &= ~RTC_ISR_ALRAF; } - EXTI->PR |= EXTI_PR_BIT; + EXTI->PR = EXTI_PR_BIT; /* only clear the associated bit */ cortexm_isr_end(); } diff --git a/cpu/stm32_common/periph/rtt.c b/cpu/stm32_common/periph/rtt.c index 5b59f32903..5ede032e2b 100644 --- a/cpu/stm32_common/periph/rtt.c +++ b/cpu/stm32_common/periph/rtt.c @@ -115,7 +115,7 @@ void rtt_init(void) !defined(CPU_FAM_STM32WB) EXTI->FTSR_REG &= ~(EXTI_FTSR_BIT); EXTI->RTSR_REG |= EXTI_RTSR_BIT; - EXTI->PR_REG |= EXTI_PR_BIT; + EXTI->PR_REG = EXTI_PR_BIT; #endif NVIC_EnableIRQ(LPTIM1_IRQn); /* enable timer */ @@ -206,7 +206,7 @@ void isr_lptim1(void) LPTIM1->ICR = (LPTIM_ICR_ARRMCF | LPTIM_ICR_CMPMCF); #if !defined(CPU_FAM_STM32L4) && !defined(CPU_FAM_STM32L0) && \ !defined(CPU_FAM_STM32WB) - EXTI->PR_REG |= EXTI_PR_BIT; + EXTI->PR_REG = EXTI_PR_BIT; /* only clear the associated bit */ #endif cortexm_isr_end();