From c2db84ee8af2d87db0f2b60a984a756cbbb6405b Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Wed, 27 Oct 2021 13:20:23 +0200 Subject: [PATCH] drivers: watchdog: stm32 iwdg starts with timeout install It Follows the sequence to configure and launch the IWDG watchdog for the stm32 mcus Signed-off-by: Francois Ramu --- drivers/watchdog/wdt_iwdg_stm32.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/wdt_iwdg_stm32.c b/drivers/watchdog/wdt_iwdg_stm32.c index d936f640a64..c13d3f77e57 100644 --- a/drivers/watchdog/wdt_iwdg_stm32.c +++ b/drivers/watchdog/wdt_iwdg_stm32.c @@ -77,7 +77,7 @@ static void iwdg_stm32_convert_timeout(uint32_t timeout, static int iwdg_stm32_setup(const struct device *dev, uint8_t options) { - IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev); + ARG_UNUSED(dev); /* Deactivate running when debugger is attached. */ if (options & WDT_OPT_PAUSE_HALTED_BY_DBG) { @@ -99,7 +99,7 @@ static int iwdg_stm32_setup(const struct device *dev, uint8_t options) return -ENOTSUP; } - LL_IWDG_Enable(iwdg); + /* Enable the IWDG only when the timeout is installed */ return 0; } @@ -134,6 +134,7 @@ static int iwdg_stm32_install_timeout(const struct device *dev, tickstart = k_uptime_get_32(); + LL_IWDG_Enable(iwdg); LL_IWDG_EnableWriteAccess(iwdg); LL_IWDG_SetPrescaler(iwdg, prescaler); @@ -172,12 +173,10 @@ static const struct wdt_driver_api iwdg_stm32_api = { static int iwdg_stm32_init(const struct device *dev) { #ifndef CONFIG_WDT_DISABLE_AT_BOOT - IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev); struct wdt_timeout_cfg config = { .window.max = CONFIG_IWDG_STM32_INITIAL_TIMEOUT }; - LL_IWDG_Enable(iwdg); iwdg_stm32_install_timeout(dev, &config); #endif