From 5fc3f56125d365c6ae625d503541a0b64538fd6f Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Sat, 21 Sep 2024 22:34:08 -0300 Subject: [PATCH] drivers: counter: esp32: disable timer before int clear Make sure to stop timer counter before interrupt is cleared, otherwise it might re-trigger it due to default interrupt level mode. Signed-off-by: Sylvio Alves --- drivers/counter/counter_esp32_rtc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/counter/counter_esp32_rtc.c b/drivers/counter/counter_esp32_rtc.c index 9172e5e65d138c..2438819baae55d 100644 --- a/drivers/counter/counter_esp32_rtc.c +++ b/drivers/counter/counter_esp32_rtc.c @@ -148,12 +148,12 @@ static int counter_esp32_cancel_alarm(const struct device *dev, uint8_t chan_id) ARG_UNUSED(dev); ARG_UNUSED(chan_id); - /* RTC main timer interrupt disable */ - SET_PERI_REG_MASK(RTC_CNTL_INT_CLR_REG, RTC_CNTL_MAIN_TIMER_INT_CLR); - /* RTC main timer set alarm disable */ CLEAR_PERI_REG_MASK(RTC_CNTL_SLP_TIMER1_REG, RTC_CNTL_MAIN_TIMER_ALARM_EN); + /* RTC main timer interrupt disable */ + SET_PERI_REG_MASK(RTC_CNTL_INT_CLR_REG, RTC_CNTL_MAIN_TIMER_INT_CLR); + return 0; } @@ -235,9 +235,6 @@ static void counter_esp32_isr(void *arg) if (data->alarm_cfg.callback) { data->alarm_cfg.callback(dev, 0, now, data->alarm_cfg.user_data); } - - /* RTC timer clear interrupt status */ - SET_PERI_REG_MASK(RTC_CNTL_INT_CLR_REG, RTC_CNTL_MAIN_TIMER_INT_CLR); } DEVICE_DT_INST_DEFINE(0,