driver: watchdog: stm32 install watchdog

This patches add a delay after setting the watchdog
to wait for the register (Prescaler and Counter registers)
to be updated before leaving (until LL_IWDG_IsReady is true)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2020-02-25 16:06:24 +01:00 committed by Maureen Helm
parent 1ef16e6d96
commit 0b4fbb916e

View file

@ -114,17 +114,20 @@ static int iwdg_stm32_install_timeout(struct device *dev,
tickstart = k_uptime_get_32();
while (LL_IWDG_IsReady(iwdg) == 0) {
/* Wait until WVU, RVU, PVU are reset before updating */
LL_IWDG_EnableWriteAccess(iwdg);
LL_IWDG_SetPrescaler(iwdg, prescaler);
LL_IWDG_SetReloadCounter(iwdg, reload);
/* Wait for the update operation completed */
while (LL_IWDG_IsReady(iwdg) != 0) {
if ((k_uptime_get_32() - tickstart) > IWDG_DEFAULT_TIMEOUT) {
return -ENODEV;
}
}
LL_IWDG_EnableWriteAccess(iwdg);
LL_IWDG_SetPrescaler(iwdg, prescaler);
LL_IWDG_SetReloadCounter(iwdg, reload);
/* Reload counter just before leaving */
LL_IWDG_ReloadCounter(iwdg);
return 0;
}