Skip to content

Commit 3ffaaa9

Browse files
ananglcarlescufi
authored andcommitted
drivers: nrf_rtc_timer: Always announce actual number of elapsed ticks
In non-tickless mode, the timeout handler always announced maximum 1 tick to kernel, but in fact it cannot be guaranteed that the handler execution is not delayed and that the number of elapsed ticks does not exceed 1. Use the actual number instead. Switch also to using a 32-bit value for `dticks` to get a bit simpler generated code (ticks delta is not supposed to be that huge). Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent a98316b commit 3ffaaa9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/timer/nrf_rtc_timer.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static void sys_clock_timeout_handler(int32_t chan,
405405
void *user_data)
406406
{
407407
uint32_t cc_value = absolute_time_to_cc(expire_time);
408-
uint64_t dticks = (expire_time - last_count) / CYC_PER_TICK;
408+
uint32_t dticks = (uint32_t)(expire_time - last_count) / CYC_PER_TICK;
409409

410410
last_count += dticks * CYC_PER_TICK;
411411

@@ -419,8 +419,7 @@ static void sys_clock_timeout_handler(int32_t chan,
419419
sys_clock_timeout_handler, NULL);
420420
}
421421

422-
sys_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ?
423-
(int32_t)dticks : (dticks > 0));
422+
sys_clock_announce(dticks);
424423
}
425424

426425
static bool channel_processing_check_and_clear(int32_t chan)

0 commit comments

Comments
 (0)