From 75f7ffb2c925fa183c4e29a90a5654c48e630785 Mon Sep 17 00:00:00 2001 From: Dawid Niedzwiecki Date: Tue, 28 Nov 2023 13:09:27 +0100 Subject: [PATCH] Revert "timer: cortex_m_systick: handle cycle count overflow with idle timer" This reverts commit 2ae09993cae8a8892d0f586877c8ce1e65f50387. Signed-off-by: Dawid Niedzwiecki --- drivers/timer/cortex_m_systick.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/timer/cortex_m_systick.c b/drivers/timer/cortex_m_systick.c index abd60f5ad7..b5f859ae57 100644 --- a/drivers/timer/cortex_m_systick.c +++ b/drivers/timer/cortex_m_systick.c @@ -366,13 +366,13 @@ void sys_clock_idle_exit(void) { #ifdef CONFIG_CORTEX_M_SYSTICK_IDLE_TIMER if (timeout_idle) { - cycle_t cycle_post_idle, systick_diff, missed_cycles; + cycle_t systick_diff, missed_cycles; uint32_t idle_timer_diff, idle_timer_post, dcycles, dticks; uint64_t systick_us, idle_timer_us; /* Get current values for both timers */ counter_get_value(idle_timer, &idle_timer_post); - cycle_post_idle = cycle_count + elapsed(); + systick_diff = cycle_count + elapsed() - cycle_pre_idle; /* Calculate has much time has pasted since last measurement for both timers */ /* Check IDLE timer overflow */ @@ -385,17 +385,6 @@ void sys_clock_idle_exit(void) idle_timer_diff = idle_timer_post - idle_timer_pre_idle; } idle_timer_us = counter_ticks_to_us(idle_timer, idle_timer_diff); - -#ifndef CONFIG_CORTEX_M_SYSTICK_64BIT_CYCLE_COUNTER - /* Check cycle counter overflow when using uint32_t */ - if (cycle_pre_idle > cycle_post_idle) { - systick_diff = (UINT32_MAX - cycle_pre_idle) + cycle_post_idle + 1; - } else { - systick_diff = cycle_post_idle - cycle_pre_idle; - } -#else - systick_diff = cycle_post_idle - cycle_pre_idle; -#endif /* !CONFIG_CORTEX_M_SYSTICK_64BIT_CYCLE_COUNTER */ systick_us = ((uint64_t)systick_diff * USEC_PER_SEC) / sys_clock_hw_cycles_per_sec();