From c4a092419cbfdd061019bcf33bd7baf59fb78f4c Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Thu, 16 May 2024 10:26:05 +0200 Subject: [PATCH] [nrf fromlist] tests: kernel: timer: Fix failing tests This commit provides an additional threshold value for comparison when a custom k_busy_wait() implementation is chosen. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73068 Signed-off-by: Adam Kondraciuk --- tests/kernel/timer/timer_api/src/main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/kernel/timer/timer_api/src/main.c b/tests/kernel/timer/timer_api/src/main.c index b996baa72e3..90ef86a2986 100644 --- a/tests/kernel/timer/timer_api/src/main.c +++ b/tests/kernel/timer/timer_api/src/main.c @@ -28,15 +28,22 @@ struct timer_data { */ #define INEXACT_MS_CONVERT ((CONFIG_SYS_CLOCK_TICKS_PER_SEC % MSEC_PER_SEC) != 0) -#if CONFIG_NRF_RTC_TIMER -/* On Nordic SOCs one or both of the tick and busy-wait clocks may - * derive from sources that have slews that sum to +/- 13%. +#if CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT && CONFIG_NRF_RTC_TIMER +/* On Nordic SOCs using RTC_TIMER as the system timer and custom k_busy_wait() implementation, + * one or both of the tick and busy-wait clocks may derive from sources that have slews that + * sum to +/- 13%. */ #define BUSY_TICK_SLEW_PPM 130000U +#elif CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT && CONFIG_NRF_GRTC_TIMER +/* On Nordic SOCs using GRTC_TIMER as the system timer and custom k_busy_wait() implementation, + * one or both of the tick and busy-wait clocks may derive from sources that have slews that + * sum to +/- 2%. + */ +#define BUSY_TICK_SLEW_PPM 20000U #else -/* On other platforms assume the clocks are perfectly aligned. */ +/* In other cases assume the clocks are perfectly aligned. */ #define BUSY_TICK_SLEW_PPM 0U -#endif +#endif /* CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT && CONFIG_NRF_RTC_TIMER */ #define PPM_DIVISOR 1000000U /* If the tick clock is faster or slower than the busywait clock the