driver: timer: stm32_lptim set_timeout limit values

set the min and max values of the given ticks from 0
to LPTIM_TIMEBASE which is the full register value
In case the timeout is FOREVER, then lptimer is stopped

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2020-05-11 15:28:49 +02:00 committed by Carles Cufí
commit fcfcc1d6ea

View file

@ -193,17 +193,7 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
* treated identically: it simply indicates the kernel would like the
* next tick announcement as soon as possible.
*/
if (ticks <= (s32_t)1) {
ticks = 1;
} else {
ticks = (ticks - 1);
}
/* maximise Tick to keep next_arr on 32bit values,
* in anycase the ARR cannot exceed LPTIM_TIMEBASE
*/
if (ticks > (s32_t)0xFFFF) {
ticks = 0xFFFF;
}
ticks = MAX(MIN(ticks - 1, (s32_t)LPTIM_TIMEBASE), 1);
k_spinlock_key_t key = k_spin_lock(&lock);