Skip to content

Commit 278d8e2

Browse files
FRASTMkartben
authored andcommitted
drivers: watchdog: stm32 wwdg enable Early WKUP int with pclk
Enable the early WakeUp Interrupt at init, once the WWDG instance is correclty cloked. Else deadlock can occur. Signed-off-by: Francois Ramu <[email protected]>
1 parent 3e3b3d1 commit 278d8e2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/watchdog/wdt_wwdg_stm32.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,20 @@ static int wwdg_stm32_init(const struct device *dev)
282282
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
283283
const struct wwdg_stm32_config *cfg = WWDG_STM32_CFG(dev);
284284

285-
wwdg_stm32_irq_config(dev);
286-
287285
if (!device_is_ready(clk)) {
288286
LOG_ERR("clock control device not ready");
289287
return -ENODEV;
290288
}
291289

292-
return clock_control_on(clk, (clock_control_subsys_t) &cfg->pclken);
290+
if (clock_control_on(clk, (clock_control_subsys_t)&cfg->pclken) != 0) {
291+
LOG_ERR("clock control on failed");
292+
return -EIO;
293+
}
294+
295+
/* Enable IRQ, especially EWKUP, once the peripheral is clocked */
296+
wwdg_stm32_irq_config(dev);
297+
298+
return 0;
293299
}
294300

295301
static struct wwdg_stm32_data wwdg_stm32_dev_data = {
@@ -318,5 +324,7 @@ static void wwdg_stm32_irq_config(const struct device *dev)
318324
DT_INST_IRQ(0, priority),
319325
wwdg_stm32_isr, DEVICE_DT_INST_GET(0), 0);
320326
irq_enable(DT_INST_IRQN(0));
327+
328+
LL_WWDG_ClearFlag_EWKUP(wwdg);
321329
LL_WWDG_EnableIT_EWKUP(wwdg);
322330
}

0 commit comments

Comments
 (0)