drivers: timer: stm32 lptimer when sleeping for -1

When CONFIG_SYSTEM_SLOPPY_IDLE is not set, then system
can sleep for -1 means waking Up at the max possible
counter value (INT_MAX)
When CONFIG_SYSTEM_SLOPPY_IDLE is set sleeping K_TICKS_FOREVER
means never wakingUp

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2023-12-18 11:16:58 +01:00 committed by Alberto Escolar
parent 88369606e2
commit 62e7b788aa

View file

@ -238,10 +238,18 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
return;
}
/*
* When CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE = y, ticks equals to -1
* is treated as a lptim off ; never waking up ; lptim not clocked anymore
*/
if (ticks == K_TICKS_FOREVER) {
clock_control_off(clk_ctrl, (clock_control_subsys_t) &lptim_clk[0]);
return;
}
/*
* When CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE = n, ticks equals to INT_MAX
* is treated as a maximum possible value LPTIM_MAX_TIMEBASE (16bit counter)
*/
/* if LPTIM clock was previously stopped, it must now be restored */
err = clock_control_on(clk_ctrl, (clock_control_subsys_t) &lptim_clk[0]);