Skip to content

Commit

Permalink
tests: kernel: timer: Fix failing tests
Browse files Browse the repository at this point in the history
This commit provides an additional threshold value for comparison when
a custom k_busy_wait() implementation is chosen.

Signed-off-by: Adam Kondraciuk <[email protected]>
  • Loading branch information
adamkondraciuk committed May 21, 2024
1 parent 8716b6a commit 80f1268
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/kernel/timer/timer_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@ struct timer_data {
*/
#define INEXACT_MS_CONVERT ((CONFIG_SYS_CLOCK_TICKS_PER_SEC % MSEC_PER_SEC) != 0)

#if CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT
/* In case of custom k_busy_wait() implementation there might be a comparison between
* time sources based on different clocks. Thus the maximum slew error shall be taken
* into account.
*/
#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%.
*/
#define BUSY_TICK_SLEW_PPM 130000U
#else
/* On other platforms assume the clocks are perfectly aligned. */
#define BUSY_TICK_SLEW_PPM 0U
/* On other platforms the maximum skew allowed is +/- 2%. */
#define BUSY_TICK_SLEW_PPM 20000U
#endif
#else
/* On other platforms, for default k_busy_wait() implementation,
* assume the clocks are perfectly aligned.
*/
#define BUSY_TICK_SLEW_PPM 0U
#endif /* CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT */
#define PPM_DIVISOR 1000000U

/* If the tick clock is faster or slower than the busywait clock the
Expand Down

0 comments on commit 80f1268

Please sign in to comment.