drivers: timer: silabs: Fix calculation of next tick

In the case where more than a full tick was unannounced when
sys_clock_set_timeout() was called, the timer driver would
subtract it from the next timeout. However, this is already
done by the caller through the elapsed() function in timeout.c,
leading to the timer interrupt firing too early.

With this fix, SYS_CLOCK_TICKS_PER_SEC can be increased to the
full speed of the low frequency timer. The underlying sleeptimer
API must be called with a timeout of at least 1, and will if needed
increase the value to the minimum value required by the hardware.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
This commit is contained in:
Aksel Skauge Mellbye 2025-03-12 20:13:59 +01:00 committed by Benjamin Cabé
commit 7dc6fb442f
2 changed files with 10 additions and 16 deletions

View file

@ -10,7 +10,9 @@ configdefault SYS_CLOCK_HW_CYCLES_PER_SEC
default 32768
configdefault SYS_CLOCK_TICKS_PER_SEC
default 1024 if SILABS_SLEEPTIMER_TIMER || GECKO_BURTC_TIMER
default 128 if !TICKLESS_KERNEL && (SILABS_SLEEPTIMER_TIMER || GECKO_BURTC_TIMER)
default 32768 if SILABS_SLEEPTIMER_TIMER
default 1024 if GECKO_BURTC_TIMER
configdefault SILABS_SLEEPTIMER_TIMER
default y