drivers: watchdog: stm32 iwdg starts with wdt_setup()
the watchdog is enabled by the wdt_setup() coming after the wdt_install_timeout. Due to PR #44972, the code did not follow that. This PR fixes the correct other in the sequence. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
86ee2104b3
commit
9400de333e
1 changed files with 6 additions and 9 deletions
|
@ -79,7 +79,7 @@ static void iwdg_stm32_convert_timeout(uint32_t timeout,
|
||||||
|
|
||||||
static int iwdg_stm32_setup(const struct device *dev, uint8_t options)
|
static int iwdg_stm32_setup(const struct device *dev, uint8_t options)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(dev);
|
IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev);
|
||||||
|
|
||||||
/* Deactivate running when debugger is attached. */
|
/* Deactivate running when debugger is attached. */
|
||||||
if (options & WDT_OPT_PAUSE_HALTED_BY_DBG) {
|
if (options & WDT_OPT_PAUSE_HALTED_BY_DBG) {
|
||||||
|
@ -101,7 +101,9 @@ static int iwdg_stm32_setup(const struct device *dev, uint8_t options)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable the IWDG only when the timeout is installed */
|
/* Enable the IWDG now (timeout has been installed previoulsy) */
|
||||||
|
LL_IWDG_Enable(iwdg); /* No need to Reload counter */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,22 +138,17 @@ static int iwdg_stm32_install_timeout(const struct device *dev,
|
||||||
|
|
||||||
tickstart = k_uptime_get_32();
|
tickstart = k_uptime_get_32();
|
||||||
|
|
||||||
LL_IWDG_Enable(iwdg);
|
/* Do not enable the wdg during install but during wdt_setup() */
|
||||||
LL_IWDG_EnableWriteAccess(iwdg);
|
LL_IWDG_EnableWriteAccess(iwdg);
|
||||||
|
|
||||||
LL_IWDG_SetPrescaler(iwdg, prescaler);
|
LL_IWDG_SetPrescaler(iwdg, prescaler);
|
||||||
LL_IWDG_SetReloadCounter(iwdg, reload);
|
|
||||||
|
|
||||||
/* Wait for the update operation completed */
|
/* Wait for the update operation completed */
|
||||||
while (LL_IWDG_IsReady(iwdg) == 0) {
|
while (LL_IWDG_IsActiveFlag_PVU(iwdg) == 0) {
|
||||||
if ((k_uptime_get_32() - tickstart) > IWDG_SR_UPDATE_TIMEOUT) {
|
if ((k_uptime_get_32() - tickstart) > IWDG_SR_UPDATE_TIMEOUT) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reload counter just before leaving */
|
|
||||||
LL_IWDG_ReloadCounter(iwdg);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue