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 <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2021-10-27 13:20:23 +02:00 committed by Maureen Helm
commit c2db84ee8a

View file

@ -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