1# SPDX-License-Identifier: Apache-2.0
2# Copyright (c) 2022 Intel Corporation
3
4mainmenu "Timer Behavior Test"
5
6config SYS_CLOCK_TICKS_PER_SEC
7	default 8192 if NRF_RTC_TIMER && TICKLESS_KERNEL
8
9source "Kconfig.zephyr"
10
11config TIMER_TEST_SAMPLES
12	int "The number of timer samples to gather for statistics"
13	default 1000 if (SRAM_SIZE <= 24)
14	default 2000 if (SRAM_SIZE <= 32)
15	default 3000 if (SRAM_SIZE <= 48)
16	default 5000 if (SRAM_SIZE <= 64)
17	default 7000 if (SRAM_SIZE <= 96)
18	default 10000
19
20config TIMER_TEST_PERIOD
21	int "The number of microseconds to for the timer period"
22	default 1000
23
24config TIMER_TEST_MAX_STDDEV
25	int "Maximum standard deviation in microseconds allowed"
26	default 33 if NPCX_ITIM_TIMER
27	default 33 if ITE_IT8XXX2_TIMER
28	default 10
29
30config TIMER_TEST_MAX_DRIFT
31	int "Maximum drift in microseconds allowed (should be about 1 period allowance)"
32	default 1000
33
34config TIMER_TEST_PERIOD_MAX_DRIFT_PERCENT
35	int "Maximum drift percentage for the timer period"
36	# Use 13% on nRF platforms using the RTC timer because one tick there is
37	# ~122 us (see SYS_CLOCK_TICKS_PER_SEC configuration above) and one tick
38	# difference in the test period is nothing unusual (it can happen for
39	# example if a new tick elapses right after the kernel gets the number
40	# of elapsed ticks when scheduling a new timeout but before the timer
41	# driver sets up that timeout).
42	default 13 if NRF_RTC_TIMER && TICKLESS_KERNEL
43	default 10
44	help
45	  A value of 10 means 10%.
46
47config TIMER_EXTERNAL_TEST
48	bool "Perform test using an external tool"
49	help
50	  Toggles a GPIO pin, on every period, that can be used by an external
51	  tool (such as a logic analyzer) to gather timing data. A pytest harness
52	  is used to get the data collected by the tool and evaluate it.
53
54if TIMER_EXTERNAL_TEST
55
56config TIMER_EXTERNAL_TEST_MAX_DRIFT_PPM
57	int "Maximum drift in PPM for tests using external tool"
58	default 4500
59	help
60	  Parts Per Million of allowed drift when using an external tool
61	  connected to a GPIO pin is used to measure time behaviour.
62
63config TIMER_EXTERNAL_TEST_PERIOD_MAX_DRIFT_PPM
64	int "Maximum timer period drift in PPM for tests using external tool"
65	default 100000
66	help
67	  Parts Per Million of allowed period drift when using an external tool
68	  connected to a GPIO pin is used to measure time behaviour.
69
70config TIMER_EXTERNAL_TEST_SYNC_DELAY
71	int "Delay, in seconds, between tests, so that external tool can be ready"
72	default 3
73
74endif # TIMER_EXTERNAL_TEST
75