Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
time_units.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TIME_UNITS_H_
8#define ZEPHYR_INCLUDE_TIME_UNITS_H_
9
10#include <zephyr/toolchain.h>
11#include <zephyr/sys/util.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
33#define SYS_FOREVER_MS (-1)
34
39#define SYS_FOREVER_US (-1)
40
43#define SYS_TIMEOUT_MS(ms) Z_TIMEOUT_TICKS((ms) == SYS_FOREVER_MS ? \
44 K_TICKS_FOREVER : Z_TIMEOUT_MS_TICKS(ms))
45
46/* Exhaustively enumerated, highly optimized time unit conversion API */
47
48#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
49__syscall int sys_clock_hw_cycles_per_sec_runtime_get(void);
50
51static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
52{
53 extern int z_clock_hw_cycles_per_sec;
54
55 return z_clock_hw_cycles_per_sec;
56}
57#endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
58
59#if defined(__cplusplus) && __cplusplus >= 201402L
60 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
61 #define TIME_CONSTEXPR
62 #else
63 #define TIME_CONSTEXPR constexpr
64 #endif
65#else
66 #define TIME_CONSTEXPR
67#endif
68
73#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
74#define sys_clock_hw_cycles_per_sec() sys_clock_hw_cycles_per_sec_runtime_get()
75#else
76#define sys_clock_hw_cycles_per_sec() CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
77#endif
78
90#define z_tmcvt_use_fast_algo(from_hz, to_hz) \
91 ((DIV_ROUND_UP(CONFIG_SYS_CLOCK_MAX_TIMEOUT_DAYS * 24ULL * 3600ULL * from_hz, \
92 UINT32_MAX) * to_hz) <= UINT32_MAX)
93
94/* Time converter generator gadget. Selects from one of three
95 * conversion algorithms: ones that take advantage when the
96 * frequencies are an integer ratio (in either direction), or a full
97 * precision conversion. Clever use of extra arguments causes all the
98 * selection logic to be optimized out, and the generated code even
99 * reduces to 32 bit only if a ratio conversion is available and the
100 * result is 32 bits.
101 *
102 * This isn't intended to be used directly, instead being wrapped
103 * appropriately in a user-facing API. The boolean arguments are:
104 *
105 * const_hz - The hz arguments are known to be compile-time
106 * constants (because otherwise the modulus test would
107 * have to be done at runtime)
108 * result32 - The result will be truncated to 32 bits on use
109 * round_up - Return the ceiling of the resulting fraction
110 * round_off - Return the nearest value to the resulting fraction
111 * (pass both round_up/off as false to get "round_down")
112 *
113 * All of this must be implemented as expressions so that, when constant,
114 * the results may be used to initialize global variables.
115 */
116
117/* true if the conversion is the identity */
118#define z_tmcvt_is_identity(__from_hz, __to_hz) \
119 ((__to_hz) == (__from_hz))
120
121/* true if the conversion requires a simple integer multiply */
122#define z_tmcvt_is_int_mul(__from_hz, __to_hz) \
123 ((__to_hz) > (__from_hz) && (__to_hz) % (__from_hz) == 0U)
124
125/* true if the conversion requires a simple integer division */
126#define z_tmcvt_is_int_div(__from_hz, __to_hz) \
127 ((__from_hz) > (__to_hz) && (__from_hz) % (__to_hz) == 0U)
128
129/*
130 * Compute the offset needed to round the result correctly when
131 * the conversion requires a simple integer division
132 */
133#define z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) \
134 ((__round_off) ? ((__from_hz) / (__to_hz)) / 2 : \
135 (__round_up) ? ((__from_hz) / (__to_hz)) - 1 : \
136 0)
137
138/* Clang emits a divide-by-zero warning even though the int_div macro
139 * results are only used when the divisor will not be zero. Work
140 * around this by substituting 1 to make the compiler happy.
141 */
142#ifdef __clang__
143#define z_tmcvt_divisor(a, b) ((a) / (b) ?: 1)
144#else
145#define z_tmcvt_divisor(a, b) ((a) / (b))
146#endif
147
148/*
149 * Compute the offset needed to round the result correctly when
150 * the conversion requires a full mul/div
151 */
152#define z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off) \
153 ((__round_off) ? (__from_hz) / 2 : \
154 (__round_up) ? (__from_hz) - 1 : \
155 0)
156
157/* Integer division 32-bit conversion */
158#define z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
159 ((uint64_t) (__t) <= 0xffffffffU - \
160 z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) ? \
161 ((uint32_t)((__t) + \
162 z_tmcvt_off_div(__from_hz, __to_hz, \
163 __round_up, __round_off)) / \
164 z_tmcvt_divisor(__from_hz, __to_hz)) \
165 : \
166 (uint32_t) (((uint64_t) (__t) + \
167 z_tmcvt_off_div(__from_hz, __to_hz, \
168 __round_up, __round_off)) / \
169 z_tmcvt_divisor(__from_hz, __to_hz)) \
170 )
171
172/* Integer multiplication 32-bit conversion */
173#define z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \
174 (uint32_t) (__t)*((__to_hz) / (__from_hz))
175
176/* General 32-bit conversion */
177#define z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
178 ((uint32_t) (((uint64_t) (__t)*(__to_hz) + \
179 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz)))
180
181/* Integer division 64-bit conversion */
182#define z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
183 (((uint64_t) (__t) + z_tmcvt_off_div(__from_hz, __to_hz, \
184 __round_up, __round_off)) / \
185 z_tmcvt_divisor(__from_hz, __to_hz))
186
187/* Integer multiplcation 64-bit conversion */
188#define z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \
189 (uint64_t) (__t)*((__to_hz) / (__from_hz))
190
191/* Fast 64-bit conversion. This relies on the multiply not overflowing */
192#define z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) \
193 (((uint64_t) (__t)*(__to_hz) + \
194 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))
195
196/* Slow 64-bit conversion. This avoids overflowing the multiply */
197#define z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \
198 (((uint64_t) (__t) / (__from_hz))*(__to_hz) + \
199 (((uint64_t) (__t) % (__from_hz))*(__to_hz) + \
200 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))
201
202/* General 64-bit conversion. Uses one of the two above macros */
203#define z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
204 (z_tmcvt_use_fast_algo(__from_hz, __to_hz) ? \
205 z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) : \
206 z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off))
207
208/* Convert, generating a 32-bit result */
209#define z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \
210 ((__const_hz) ? \
211 ( \
212 z_tmcvt_is_identity(__from_hz, __to_hz) ? \
213 (uint32_t) (__t) \
214 : \
215 z_tmcvt_is_int_div(__from_hz, __to_hz) ? \
216 z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
217 : \
218 z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \
219 z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \
220 : \
221 z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
222 ) \
223 : \
224 z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
225 )
226
227/* Convert, generating a 64-bit result */
228#define z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \
229 ((__const_hz) ? \
230 ( \
231 z_tmcvt_is_identity(__from_hz, __to_hz) ? \
232 (uint64_t) (__t) \
233 : \
234 z_tmcvt_is_int_div(__from_hz, __to_hz) ? \
235 z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
236 : \
237 z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \
238 z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \
239 : \
240 z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
241 ) \
242 : \
243 z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \
244 )
245
246#define z_tmcvt(__t, __from_hz, __to_hz, __const_hz, __result32, __round_up, __round_off) \
247 ((__result32) ? \
248 z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) : \
249 z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off))
250
251/* The following code is programmatically generated using this perl
252 * code, which enumerates all possible combinations of units, rounding
253 * modes and precision. Do not edit directly.
254 *
255 * Note that nano/microsecond conversions are only defined with 64 bit
256 * precision. These units conversions were not available in 32 bit
257 * variants historically, and doing 32 bit math with units that small
258 * has precision traps that we probably don't want to support in an
259 * official API.
260 *
261 * #!/usr/bin/perl -w
262 * use strict;
263 *
264 * my %human = ("ms" => "milliseconds",
265 * "us" => "microseconds",
266 * "ns" => "nanoseconds",
267 * "cyc" => "hardware cycles",
268 * "ticks" => "ticks");
269 * my %human_round = ("ceil" => "Rounds up",
270 * "near" => "Round nearest",
271 * "floor" => "Truncates");
272 *
273 * sub big { return $_[0] eq "us" || $_[0] eq "ns"; }
274 * sub prefix { return $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; }
275 *
276 * for my $from_unit ("ms", "us", "ns", "cyc", "ticks") {
277 * for my $to_unit ("ms", "us", "ns", "cyc", "ticks") {
278 * next if $from_unit eq $to_unit;
279 * next if prefix($from_unit) && prefix($to_unit);
280 * for my $round ("floor", "near", "ceil") {
281 * for(my $big=0; $big <= 1; $big++) {
282 * my $sz = $big ? 64 : 32;
283 * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz";
284 * my $type = "uint${sz}_t";
285 * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc")
286 * ? "Z_CCYC" : "true";
287 * my $ret32 = $big ? "64" : "32";
288 * my $rup = $round eq "ceil" ? "true" : "false";
289 * my $roff = $round eq "near" ? "true" : "false";
290 *
291 * my $hfrom = $human{$from_unit};
292 * my $hto = $human{$to_unit};
293 * my $hround = $human_round{$round};
294 * print "/", "** \@brief Convert $hfrom to $hto. $ret32 bits. $hround.\n";
295 * print " *\n";
296 * print " * Converts time values in $hfrom to $hto.\n";
297 * print " * Computes result in $sz bit precision.\n";
298 * if ($round eq "ceil") {
299 * print " * Rounds up to the next highest output unit.\n";
300 * } elsif ($round eq "near") {
301 * print " * Rounds to the nearest output unit.\n";
302 * } else {
303 * print " * Truncates to the next lowest output unit.\n";
304 * }
305 * print " *\n";
306 * print " * \@param t Source time in $hfrom. uint64_t\n";
307 * print " *\n";
308 * print " * \@return The converted time value in $hto. $type\n";
309 * print " *", "/\n";
310 *
311 * print "/", "* Generated. Do not edit. See above. *", "/\n";
312 * print "#define $sym(t) \\\n";
313 * print "\tz_tmcvt_$ret32(t, Z_HZ_$from_unit, Z_HZ_$to_unit,";
314 * print " $const_hz, $rup, $roff)\n";
315 * print "\n\n";
316 * }
317 * }
318 * }
319 * }
320 */
321
322/* Some more concise declarations to simplify the generator script and
323 * save bytes below
324 */
325#define Z_HZ_ms 1000
326#define Z_HZ_us 1000000
327#define Z_HZ_ns 1000000000
328#define Z_HZ_cyc sys_clock_hw_cycles_per_sec()
329#define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC
330#define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME))
331
342/* Generated. Do not edit. See above. */
343#define k_ms_to_cyc_floor32(t) \
344 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false)
345
346
357/* Generated. Do not edit. See above. */
358#define k_ms_to_cyc_floor64(t) \
359 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false)
360
361
372/* Generated. Do not edit. See above. */
373#define k_ms_to_cyc_near32(t) \
374 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true)
375
376
387/* Generated. Do not edit. See above. */
388#define k_ms_to_cyc_near64(t) \
389 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true)
390
391
402/* Generated. Do not edit. See above. */
403#define k_ms_to_cyc_ceil32(t) \
404 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false)
405
406
417/* Generated. Do not edit. See above. */
418#define k_ms_to_cyc_ceil64(t) \
419 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false)
420
421
432/* Generated. Do not edit. See above. */
433#define k_ms_to_ticks_floor32(t) \
434 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, false)
435
436
447/* Generated. Do not edit. See above. */
448#define k_ms_to_ticks_floor64(t) \
449 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, false)
450
451
462/* Generated. Do not edit. See above. */
463#define k_ms_to_ticks_near32(t) \
464 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, true)
465
466
477/* Generated. Do not edit. See above. */
478#define k_ms_to_ticks_near64(t) \
479 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, true)
480
481
492/* Generated. Do not edit. See above. */
493#define k_ms_to_ticks_ceil32(t) \
494 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, true, false)
495
496
507/* Generated. Do not edit. See above. */
508#define k_ms_to_ticks_ceil64(t) \
509 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, true, false)
510
511
522/* Generated. Do not edit. See above. */
523#define k_us_to_cyc_floor32(t) \
524 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false)
525
526
537/* Generated. Do not edit. See above. */
538#define k_us_to_cyc_floor64(t) \
539 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false)
540
541
552/* Generated. Do not edit. See above. */
553#define k_us_to_cyc_near32(t) \
554 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true)
555
556
567/* Generated. Do not edit. See above. */
568#define k_us_to_cyc_near64(t) \
569 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true)
570
571
582/* Generated. Do not edit. See above. */
583#define k_us_to_cyc_ceil32(t) \
584 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false)
585
586
597/* Generated. Do not edit. See above. */
598#define k_us_to_cyc_ceil64(t) \
599 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false)
600
601
612/* Generated. Do not edit. See above. */
613#define k_us_to_ticks_floor32(t) \
614 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, false)
615
616
627/* Generated. Do not edit. See above. */
628#define k_us_to_ticks_floor64(t) \
629 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, false)
630
631
642/* Generated. Do not edit. See above. */
643#define k_us_to_ticks_near32(t) \
644 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, true)
645
646
657/* Generated. Do not edit. See above. */
658#define k_us_to_ticks_near64(t) \
659 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, true)
660
661
672/* Generated. Do not edit. See above. */
673#define k_us_to_ticks_ceil32(t) \
674 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, true, false)
675
676
687/* Generated. Do not edit. See above. */
688#define k_us_to_ticks_ceil64(t) \
689 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, true, false)
690
691
702/* Generated. Do not edit. See above. */
703#define k_ns_to_cyc_floor32(t) \
704 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false)
705
706
717/* Generated. Do not edit. See above. */
718#define k_ns_to_cyc_floor64(t) \
719 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false)
720
721
732/* Generated. Do not edit. See above. */
733#define k_ns_to_cyc_near32(t) \
734 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true)
735
736
747/* Generated. Do not edit. See above. */
748#define k_ns_to_cyc_near64(t) \
749 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true)
750
751
762/* Generated. Do not edit. See above. */
763#define k_ns_to_cyc_ceil32(t) \
764 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false)
765
766
777/* Generated. Do not edit. See above. */
778#define k_ns_to_cyc_ceil64(t) \
779 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false)
780
781
792/* Generated. Do not edit. See above. */
793#define k_ns_to_ticks_floor32(t) \
794 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, false)
795
796
807/* Generated. Do not edit. See above. */
808#define k_ns_to_ticks_floor64(t) \
809 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, false)
810
811
822/* Generated. Do not edit. See above. */
823#define k_ns_to_ticks_near32(t) \
824 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, true)
825
826
837/* Generated. Do not edit. See above. */
838#define k_ns_to_ticks_near64(t) \
839 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, true)
840
841
852/* Generated. Do not edit. See above. */
853#define k_ns_to_ticks_ceil32(t) \
854 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, true, false)
855
856
867/* Generated. Do not edit. See above. */
868#define k_ns_to_ticks_ceil64(t) \
869 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, true, false)
870
871
882/* Generated. Do not edit. See above. */
883#define k_cyc_to_ms_floor32(t) \
884 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false)
885
886
897/* Generated. Do not edit. See above. */
898#define k_cyc_to_ms_floor64(t) \
899 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false)
900
901
912/* Generated. Do not edit. See above. */
913#define k_cyc_to_ms_near32(t) \
914 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true)
915
916
927/* Generated. Do not edit. See above. */
928#define k_cyc_to_ms_near64(t) \
929 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true)
930
931
942/* Generated. Do not edit. See above. */
943#define k_cyc_to_ms_ceil32(t) \
944 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false)
945
946
957/* Generated. Do not edit. See above. */
958#define k_cyc_to_ms_ceil64(t) \
959 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false)
960
961
972/* Generated. Do not edit. See above. */
973#define k_cyc_to_us_floor32(t) \
974 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false)
975
976
987/* Generated. Do not edit. See above. */
988#define k_cyc_to_us_floor64(t) \
989 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false)
990
991
1002/* Generated. Do not edit. See above. */
1003#define k_cyc_to_us_near32(t) \
1004 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true)
1005
1006
1017/* Generated. Do not edit. See above. */
1018#define k_cyc_to_us_near64(t) \
1019 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true)
1020
1021
1032/* Generated. Do not edit. See above. */
1033#define k_cyc_to_us_ceil32(t) \
1034 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false)
1035
1036
1047/* Generated. Do not edit. See above. */
1048#define k_cyc_to_us_ceil64(t) \
1049 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false)
1050
1051
1062/* Generated. Do not edit. See above. */
1063#define k_cyc_to_ns_floor32(t) \
1064 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false)
1065
1066
1077/* Generated. Do not edit. See above. */
1078#define k_cyc_to_ns_floor64(t) \
1079 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false)
1080
1081
1092/* Generated. Do not edit. See above. */
1093#define k_cyc_to_ns_near32(t) \
1094 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true)
1095
1096
1107/* Generated. Do not edit. See above. */
1108#define k_cyc_to_ns_near64(t) \
1109 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true)
1110
1111
1122/* Generated. Do not edit. See above. */
1123#define k_cyc_to_ns_ceil32(t) \
1124 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false)
1125
1126
1137/* Generated. Do not edit. See above. */
1138#define k_cyc_to_ns_ceil64(t) \
1139 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false)
1140
1141
1152/* Generated. Do not edit. See above. */
1153#define k_cyc_to_ticks_floor32(t) \
1154 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false)
1155
1156
1167/* Generated. Do not edit. See above. */
1168#define k_cyc_to_ticks_floor64(t) \
1169 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false)
1170
1171
1182/* Generated. Do not edit. See above. */
1183#define k_cyc_to_ticks_near32(t) \
1184 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true)
1185
1186
1197/* Generated. Do not edit. See above. */
1198#define k_cyc_to_ticks_near64(t) \
1199 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true)
1200
1201
1212/* Generated. Do not edit. See above. */
1213#define k_cyc_to_ticks_ceil32(t) \
1214 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false)
1215
1216
1227/* Generated. Do not edit. See above. */
1228#define k_cyc_to_ticks_ceil64(t) \
1229 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false)
1230
1231
1242/* Generated. Do not edit. See above. */
1243#define k_ticks_to_ms_floor32(t) \
1244 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, false)
1245
1246
1257/* Generated. Do not edit. See above. */
1258#define k_ticks_to_ms_floor64(t) \
1259 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, false)
1260
1261
1272/* Generated. Do not edit. See above. */
1273#define k_ticks_to_ms_near32(t) \
1274 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, true)
1275
1276
1287/* Generated. Do not edit. See above. */
1288#define k_ticks_to_ms_near64(t) \
1289 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, true)
1290
1291
1302/* Generated. Do not edit. See above. */
1303#define k_ticks_to_ms_ceil32(t) \
1304 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, true, false)
1305
1306
1317/* Generated. Do not edit. See above. */
1318#define k_ticks_to_ms_ceil64(t) \
1319 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, true, false)
1320
1321
1332/* Generated. Do not edit. See above. */
1333#define k_ticks_to_us_floor32(t) \
1334 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, false)
1335
1336
1347/* Generated. Do not edit. See above. */
1348#define k_ticks_to_us_floor64(t) \
1349 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, false)
1350
1351
1362/* Generated. Do not edit. See above. */
1363#define k_ticks_to_us_near32(t) \
1364 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, true)
1365
1366
1377/* Generated. Do not edit. See above. */
1378#define k_ticks_to_us_near64(t) \
1379 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, true)
1380
1381
1392/* Generated. Do not edit. See above. */
1393#define k_ticks_to_us_ceil32(t) \
1394 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, true, false)
1395
1396
1407/* Generated. Do not edit. See above. */
1408#define k_ticks_to_us_ceil64(t) \
1409 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, true, false)
1410
1411
1422/* Generated. Do not edit. See above. */
1423#define k_ticks_to_ns_floor32(t) \
1424 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, false)
1425
1426
1437/* Generated. Do not edit. See above. */
1438#define k_ticks_to_ns_floor64(t) \
1439 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, false)
1440
1441
1452/* Generated. Do not edit. See above. */
1453#define k_ticks_to_ns_near32(t) \
1454 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, true)
1455
1456
1467/* Generated. Do not edit. See above. */
1468#define k_ticks_to_ns_near64(t) \
1469 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, true)
1470
1471
1482/* Generated. Do not edit. See above. */
1483#define k_ticks_to_ns_ceil32(t) \
1484 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, true, false)
1485
1486
1497/* Generated. Do not edit. See above. */
1498#define k_ticks_to_ns_ceil64(t) \
1499 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, true, false)
1500
1501
1512/* Generated. Do not edit. See above. */
1513#define k_ticks_to_cyc_floor32(t) \
1514 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false)
1515
1516
1527/* Generated. Do not edit. See above. */
1528#define k_ticks_to_cyc_floor64(t) \
1529 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false)
1530
1531
1542/* Generated. Do not edit. See above. */
1543#define k_ticks_to_cyc_near32(t) \
1544 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true)
1545
1546
1557/* Generated. Do not edit. See above. */
1558#define k_ticks_to_cyc_near64(t) \
1559 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true)
1560
1561
1572/* Generated. Do not edit. See above. */
1573#define k_ticks_to_cyc_ceil32(t) \
1574 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false)
1575
1576
1587/* Generated. Do not edit. See above. */
1588#define k_ticks_to_cyc_ceil64(t) \
1589 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false)
1590
1591#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
1592#include <syscalls/time_units.h>
1593#endif
1594
1595#undef TIME_CONSTEXPR
1596
1601#ifdef __cplusplus
1602} /* extern "C" */
1603#endif
1604
1605#endif /* ZEPHYR_INCLUDE_TIME_UNITS_H_ */
Macros to abstract toolchain specific capabilities.
Misc utilities.