File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 17
17
#define COUNTER_MAX 0x00ffffff
18
18
#define TIMER_STOPPED 0xff000000
19
19
20
- #define CYC_PER_TICK (sys_clock_hw_cycles_per_sec() \
21
- / CONFIG_SYS_CLOCK_TICKS_PER_SEC)
22
- #define MAX_TICKS ((k_ticks_t)(COUNTER_MAX / CYC_PER_TICK) - 1)
20
+
21
+ #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME )
22
+ extern unsigned int z_clock_hw_cycles_per_sec ;
23
+ #define CYC_PER_TICK (z_clock_hw_cycles_per_sec/CONFIG_SYS_CLOCK_TICKS_PER_SEC)
24
+ #else
25
+ #define CYC_PER_TICK (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC/CONFIG_SYS_CLOCK_TICKS_PER_SEC)
26
+ #endif
27
+
28
+ /* add MAX_TICKS protection */
29
+ #define _MAX_TICKS (int)((k_ticks_t)(COUNTER_MAX / CYC_PER_TICK) - 1)
30
+ #define MAX_TICKS ((_MAX_TICKS > 0) ? _MAX_TICKS : 1)
23
31
#define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK)
24
32
33
+ #if (COUNTER_MAX / CYC_PER_TICK ) == 1
34
+ #pragma message("tickless does nothing as CONFIG_SYS_CLOCK_TICKS_PER_SEC too low")
35
+ #endif
36
+
25
37
/* Minimum cycles in the future to try to program. Note that this is
26
38
* NOT simply "enough cycles to get the counter read and reprogrammed
27
39
* reliably" -- it becomes the minimum value of the LOAD register, and
You can’t perform that action at this time.
0 commit comments