kernel: timer: Fix incorrect behavior for timers with K_FOREVER period
Zephyr docs state that timers will act as one-shot timers when started with a period of K_NO_WAIT or K_FOREVER. However the code adjusting period was setting K_FOREVER timeout ticks to 1 which caused the timer to expire every tick. This adds a check to not adjust K_FOREVER periods Signed-off-by: Eric Johnson <eric@liveathos.com>
This commit is contained in:
parent
98dbea0979
commit
b4aeef4d5b
|
@ -126,7 +126,8 @@ void z_impl_k_timer_start(struct k_timer *timer, k_timeout_t duration,
|
|||
* argument the same way k_sleep() does), but historical. The
|
||||
* timer_api test relies on this behavior.
|
||||
*/
|
||||
if (period.ticks != 0 && Z_TICK_ABS(period.ticks) < 0) {
|
||||
if (!K_TIMEOUT_EQ(period, K_FOREVER) && period.ticks != 0 &&
|
||||
Z_TICK_ABS(period.ticks) < 0) {
|
||||
period.ticks = MAX(period.ticks - 1, 1);
|
||||
}
|
||||
if (Z_TICK_ABS(duration.ticks) < 0) {
|
||||
|
|
Loading…
Reference in a new issue