driver: timer: stm32_lptim: fix deadlock when waiting ARROK flag

If ticks is K_TICKS_FOREVER the register autoreload isn't set.
So, on the next call to the z_clock_set_timeout function
the wait for the flag ARROK will be infinite.

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
This commit is contained in:
Julien D'Ascenzio 2020-06-03 13:55:57 +02:00 committed by Carles Cufí
commit 01ff7ba6e1

View file

@ -183,11 +183,6 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
return;
}
/* ARROK bit validates previous write operation to ARR register */
while (LL_LPTIM_IsActiveFlag_ARROK(LPTIM1) == 0) {
}
LL_LPTIM_ClearFlag_ARROK(LPTIM1);
if (ticks == K_TICKS_FOREVER) {
/* disable LPTIM */
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_LPTIM1);
@ -242,6 +237,12 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
NVIC_SetPendingIRQ(LPTIM1_IRQn);
lptim_fired = 1;
}
/* ARROK bit validates previous write operation to ARR register */
while (LL_LPTIM_IsActiveFlag_ARROK(LPTIM1) == 0) {
}
LL_LPTIM_ClearFlag_ARROK(LPTIM1);
/* run timer and wait for the reload match */
LL_LPTIM_SetAutoReload(LPTIM1, next_arr);