Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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/*
139 * All users of this macro MUST ensure its output is never used when a/b
140 * is zero because it incorrectly but by design never returns zero.
141 *
142 * Some compiler versions emit a divide-by-zero warning for this code:
143 * "false ? 42/0 : 43". Dealing with (generated) dead code is hard:
144 * https://github.com/zephyrproject-rtos/zephyr/issues/63564
145 * https://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html
146 *
147 * To silence such divide-by-zero warnings, "cheat" and never return
148 * zero. Return 1 instead. Use octal "01u" as a breadcrumb to ease a
149 * little bit the huge pain of "reverse-engineering" pre-processor
150 * output.
151 *
152 * The "Elvis" operator "a/b ?: 1" is tempting because it avoids
153 * evaluating the same expression twice. However: 1. it's a non-standard
154 * GNU extension; 2. everything in this file is designed to be computed
155 * at compile time anyway.
156 */
157#define z_tmcvt_divisor(a, b) ((a)/(b) ? (a)/(b) : 01u)
158
159/*
160 * Compute the offset needed to round the result correctly when
161 * the conversion requires a full mul/div
162 */
163#define z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off) \
164 ((__round_off) ? (__from_hz) / 2 : \
165 (__round_up) ? (__from_hz) - 1 : \
166 0)
167
168/* Integer division 32-bit conversion */
169#define z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
170 ((uint64_t) (__t) <= 0xffffffffU - \
171 z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) ? \
172 ((uint32_t)((__t) + \
173 z_tmcvt_off_div(__from_hz, __to_hz, \
174 __round_up, __round_off)) / \
175 z_tmcvt_divisor(__from_hz, __to_hz)) \
176 : \
177 (uint32_t) (((uint64_t) (__t) + \
178 z_tmcvt_off_div(__from_hz, __to_hz, \
179 __round_up, __round_off)) / \
180 z_tmcvt_divisor(__from_hz, __to_hz)) \
181 )
182
183/* Integer multiplication 32-bit conversion */
184#define z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \
185 (uint32_t) (__t)*((__to_hz) / (__from_hz))
186
187/* General 32-bit conversion */
188#define z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
189 ((uint32_t) (((uint64_t) (__t)*(__to_hz) + \
190 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz)))
191
192/* Integer division 64-bit conversion */
193#define z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
194 (((uint64_t) (__t) + z_tmcvt_off_div(__from_hz, __to_hz, \
195 __round_up, __round_off)) / \
196 z_tmcvt_divisor(__from_hz, __to_hz))
197
198/* Integer multiplcation 64-bit conversion */
199#define z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \
200 (uint64_t) (__t)*((__to_hz) / (__from_hz))
201
202/* Fast 64-bit conversion. This relies on the multiply not overflowing */
203#define z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) \
204 (((uint64_t) (__t)*(__to_hz) + \
205 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))
206
207/* Slow 64-bit conversion. This avoids overflowing the multiply */
208#define z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \
209 (((uint64_t) (__t) / (__from_hz))*(__to_hz) + \
210 (((uint64_t) (__t) % (__from_hz))*(__to_hz) + \
211 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))
212
213/* General 64-bit conversion. Uses one of the two above macros */
214#define z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
215 (z_tmcvt_use_fast_algo(__from_hz, __to_hz) ? \
216 z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) : \
217 z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off))
218
219/* Convert, generating a 32-bit result */
220#define z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \
221 ((__const_hz) ? \
222 ( \
223 z_tmcvt_is_identity(__from_hz, __to_hz) ? \
224 (uint32_t) (__t) \
225 : \
226 z_tmcvt_is_int_div(__from_hz, __to_hz) ? \
227 z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
228 : \
229 z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \
230 z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \
231 : \
232 z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
233 ) \
234 : \
235 z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
236 )
237
238/* Convert, generating a 64-bit result */
239#define z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \
240 ((__const_hz) ? \
241 ( \
242 z_tmcvt_is_identity(__from_hz, __to_hz) ? \
243 (uint64_t) (__t) \
244 : \
245 z_tmcvt_is_int_div(__from_hz, __to_hz) ? \
246 z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
247 : \
248 z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \
249 z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \
250 : \
251 z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
252 ) \
253 : \
254 z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \
255 )
256
257#define z_tmcvt(__t, __from_hz, __to_hz, __const_hz, __result32, __round_up, __round_off) \
258 ((__result32) ? \
259 z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) : \
260 z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off))
261
262/* The following code is programmatically generated using this perl
263 * code, which enumerates all possible combinations of units, rounding
264 * modes and precision. Do not edit directly.
265 *
266 * Note that nano/microsecond conversions are only defined with 64 bit
267 * precision. These units conversions were not available in 32 bit
268 * variants historically, and doing 32 bit math with units that small
269 * has precision traps that we probably don't want to support in an
270 * official API.
271 *
272 * #!/usr/bin/perl -w
273 * use strict;
274 *
275 * my %human = ("ms" => "milliseconds",
276 * "us" => "microseconds",
277 * "ns" => "nanoseconds",
278 * "cyc" => "hardware cycles",
279 * "ticks" => "ticks");
280 * my %human_round = ("ceil" => "Rounds up",
281 * "near" => "Round nearest",
282 * "floor" => "Truncates");
283 *
284 * sub big { return $_[0] eq "us" || $_[0] eq "ns"; }
285 * sub prefix { return $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; }
286 *
287 * for my $from_unit ("ms", "us", "ns", "cyc", "ticks") {
288 * for my $to_unit ("ms", "us", "ns", "cyc", "ticks") {
289 * next if $from_unit eq $to_unit;
290 * next if prefix($from_unit) && prefix($to_unit);
291 * for my $round ("floor", "near", "ceil") {
292 * for(my $big=0; $big <= 1; $big++) {
293 * my $sz = $big ? 64 : 32;
294 * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz";
295 * my $type = "uint${sz}_t";
296 * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc")
297 * ? "Z_CCYC" : "true";
298 * my $ret32 = $big ? "64" : "32";
299 * my $rup = $round eq "ceil" ? "true" : "false";
300 * my $roff = $round eq "near" ? "true" : "false";
301 *
302 * my $hfrom = $human{$from_unit};
303 * my $hto = $human{$to_unit};
304 * my $hround = $human_round{$round};
305 * print "/", "** \@brief Convert $hfrom to $hto. $ret32 bits. $hround.\n";
306 * print " *\n";
307 * print " * Converts time values in $hfrom to $hto.\n";
308 * print " * Computes result in $sz bit precision.\n";
309 * if ($round eq "ceil") {
310 * print " * Rounds up to the next highest output unit.\n";
311 * } elsif ($round eq "near") {
312 * print " * Rounds to the nearest output unit.\n";
313 * } else {
314 * print " * Truncates to the next lowest output unit.\n";
315 * }
316 * print " *\n";
317 * print " * \@param t Source time in $hfrom. uint64_t\n";
318 * print " *\n";
319 * print " * \@return The converted time value in $hto. $type\n";
320 * print " *", "/\n";
321 *
322 * print "/", "* Generated. Do not edit. See above. *", "/\n";
323 * print "#define $sym(t) \\\n";
324 * print "\tz_tmcvt_$ret32(t, Z_HZ_$from_unit, Z_HZ_$to_unit,";
325 * print " $const_hz, $rup, $roff)\n";
326 * print "\n\n";
327 * }
328 * }
329 * }
330 * }
331 */
332
333/* Some more concise declarations to simplify the generator script and
334 * save bytes below
335 */
336#define Z_HZ_ms 1000
337#define Z_HZ_us 1000000
338#define Z_HZ_ns 1000000000
339#define Z_HZ_cyc sys_clock_hw_cycles_per_sec()
340#define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC
341#define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME))
342
353/* Generated. Do not edit. See above. */
354#define k_ms_to_cyc_floor32(t) \
355 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false)
356
357
368/* Generated. Do not edit. See above. */
369#define k_ms_to_cyc_floor64(t) \
370 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false)
371
372
383/* Generated. Do not edit. See above. */
384#define k_ms_to_cyc_near32(t) \
385 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true)
386
387
398/* Generated. Do not edit. See above. */
399#define k_ms_to_cyc_near64(t) \
400 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true)
401
402
413/* Generated. Do not edit. See above. */
414#define k_ms_to_cyc_ceil32(t) \
415 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false)
416
417
428/* Generated. Do not edit. See above. */
429#define k_ms_to_cyc_ceil64(t) \
430 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false)
431
432
443/* Generated. Do not edit. See above. */
444#define k_ms_to_ticks_floor32(t) \
445 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, false)
446
447
458/* Generated. Do not edit. See above. */
459#define k_ms_to_ticks_floor64(t) \
460 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, false)
461
462
473/* Generated. Do not edit. See above. */
474#define k_ms_to_ticks_near32(t) \
475 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, true)
476
477
488/* Generated. Do not edit. See above. */
489#define k_ms_to_ticks_near64(t) \
490 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, true)
491
492
503/* Generated. Do not edit. See above. */
504#define k_ms_to_ticks_ceil32(t) \
505 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, true, false)
506
507
518/* Generated. Do not edit. See above. */
519#define k_ms_to_ticks_ceil64(t) \
520 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, true, false)
521
522
533/* Generated. Do not edit. See above. */
534#define k_us_to_cyc_floor32(t) \
535 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false)
536
537
548/* Generated. Do not edit. See above. */
549#define k_us_to_cyc_floor64(t) \
550 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false)
551
552
563/* Generated. Do not edit. See above. */
564#define k_us_to_cyc_near32(t) \
565 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true)
566
567
578/* Generated. Do not edit. See above. */
579#define k_us_to_cyc_near64(t) \
580 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true)
581
582
593/* Generated. Do not edit. See above. */
594#define k_us_to_cyc_ceil32(t) \
595 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false)
596
597
608/* Generated. Do not edit. See above. */
609#define k_us_to_cyc_ceil64(t) \
610 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false)
611
612
623/* Generated. Do not edit. See above. */
624#define k_us_to_ticks_floor32(t) \
625 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, false)
626
627
638/* Generated. Do not edit. See above. */
639#define k_us_to_ticks_floor64(t) \
640 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, false)
641
642
653/* Generated. Do not edit. See above. */
654#define k_us_to_ticks_near32(t) \
655 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, true)
656
657
668/* Generated. Do not edit. See above. */
669#define k_us_to_ticks_near64(t) \
670 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, true)
671
672
683/* Generated. Do not edit. See above. */
684#define k_us_to_ticks_ceil32(t) \
685 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, true, false)
686
687
698/* Generated. Do not edit. See above. */
699#define k_us_to_ticks_ceil64(t) \
700 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, true, false)
701
702
713/* Generated. Do not edit. See above. */
714#define k_ns_to_cyc_floor32(t) \
715 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false)
716
717
728/* Generated. Do not edit. See above. */
729#define k_ns_to_cyc_floor64(t) \
730 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false)
731
732
743/* Generated. Do not edit. See above. */
744#define k_ns_to_cyc_near32(t) \
745 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true)
746
747
758/* Generated. Do not edit. See above. */
759#define k_ns_to_cyc_near64(t) \
760 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true)
761
762
773/* Generated. Do not edit. See above. */
774#define k_ns_to_cyc_ceil32(t) \
775 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false)
776
777
788/* Generated. Do not edit. See above. */
789#define k_ns_to_cyc_ceil64(t) \
790 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false)
791
792
803/* Generated. Do not edit. See above. */
804#define k_ns_to_ticks_floor32(t) \
805 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, false)
806
807
818/* Generated. Do not edit. See above. */
819#define k_ns_to_ticks_floor64(t) \
820 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, false)
821
822
833/* Generated. Do not edit. See above. */
834#define k_ns_to_ticks_near32(t) \
835 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, true)
836
837
848/* Generated. Do not edit. See above. */
849#define k_ns_to_ticks_near64(t) \
850 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, true)
851
852
863/* Generated. Do not edit. See above. */
864#define k_ns_to_ticks_ceil32(t) \
865 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, true, false)
866
867
878/* Generated. Do not edit. See above. */
879#define k_ns_to_ticks_ceil64(t) \
880 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, true, false)
881
882
893/* Generated. Do not edit. See above. */
894#define k_cyc_to_ms_floor32(t) \
895 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false)
896
897
908/* Generated. Do not edit. See above. */
909#define k_cyc_to_ms_floor64(t) \
910 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false)
911
912
923/* Generated. Do not edit. See above. */
924#define k_cyc_to_ms_near32(t) \
925 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true)
926
927
938/* Generated. Do not edit. See above. */
939#define k_cyc_to_ms_near64(t) \
940 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true)
941
942
953/* Generated. Do not edit. See above. */
954#define k_cyc_to_ms_ceil32(t) \
955 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false)
956
957
968/* Generated. Do not edit. See above. */
969#define k_cyc_to_ms_ceil64(t) \
970 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false)
971
972
983/* Generated. Do not edit. See above. */
984#define k_cyc_to_us_floor32(t) \
985 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false)
986
987
998/* Generated. Do not edit. See above. */
999#define k_cyc_to_us_floor64(t) \
1000 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false)
1001
1002
1013/* Generated. Do not edit. See above. */
1014#define k_cyc_to_us_near32(t) \
1015 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true)
1016
1017
1028/* Generated. Do not edit. See above. */
1029#define k_cyc_to_us_near64(t) \
1030 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true)
1031
1032
1043/* Generated. Do not edit. See above. */
1044#define k_cyc_to_us_ceil32(t) \
1045 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false)
1046
1047
1058/* Generated. Do not edit. See above. */
1059#define k_cyc_to_us_ceil64(t) \
1060 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false)
1061
1062
1073/* Generated. Do not edit. See above. */
1074#define k_cyc_to_ns_floor32(t) \
1075 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false)
1076
1077
1088/* Generated. Do not edit. See above. */
1089#define k_cyc_to_ns_floor64(t) \
1090 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false)
1091
1092
1103/* Generated. Do not edit. See above. */
1104#define k_cyc_to_ns_near32(t) \
1105 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true)
1106
1107
1118/* Generated. Do not edit. See above. */
1119#define k_cyc_to_ns_near64(t) \
1120 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true)
1121
1122
1133/* Generated. Do not edit. See above. */
1134#define k_cyc_to_ns_ceil32(t) \
1135 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false)
1136
1137
1148/* Generated. Do not edit. See above. */
1149#define k_cyc_to_ns_ceil64(t) \
1150 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false)
1151
1152
1163/* Generated. Do not edit. See above. */
1164#define k_cyc_to_ticks_floor32(t) \
1165 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false)
1166
1167
1178/* Generated. Do not edit. See above. */
1179#define k_cyc_to_ticks_floor64(t) \
1180 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false)
1181
1182
1193/* Generated. Do not edit. See above. */
1194#define k_cyc_to_ticks_near32(t) \
1195 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true)
1196
1197
1208/* Generated. Do not edit. See above. */
1209#define k_cyc_to_ticks_near64(t) \
1210 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true)
1211
1212
1223/* Generated. Do not edit. See above. */
1224#define k_cyc_to_ticks_ceil32(t) \
1225 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false)
1226
1227
1238/* Generated. Do not edit. See above. */
1239#define k_cyc_to_ticks_ceil64(t) \
1240 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false)
1241
1242
1253/* Generated. Do not edit. See above. */
1254#define k_ticks_to_ms_floor32(t) \
1255 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, false)
1256
1257
1268/* Generated. Do not edit. See above. */
1269#define k_ticks_to_ms_floor64(t) \
1270 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, false)
1271
1272
1283/* Generated. Do not edit. See above. */
1284#define k_ticks_to_ms_near32(t) \
1285 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, true)
1286
1287
1298/* Generated. Do not edit. See above. */
1299#define k_ticks_to_ms_near64(t) \
1300 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, true)
1301
1302
1313/* Generated. Do not edit. See above. */
1314#define k_ticks_to_ms_ceil32(t) \
1315 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, true, false)
1316
1317
1328/* Generated. Do not edit. See above. */
1329#define k_ticks_to_ms_ceil64(t) \
1330 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, true, false)
1331
1332
1343/* Generated. Do not edit. See above. */
1344#define k_ticks_to_us_floor32(t) \
1345 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, false)
1346
1347
1358/* Generated. Do not edit. See above. */
1359#define k_ticks_to_us_floor64(t) \
1360 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, false)
1361
1362
1373/* Generated. Do not edit. See above. */
1374#define k_ticks_to_us_near32(t) \
1375 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, true)
1376
1377
1388/* Generated. Do not edit. See above. */
1389#define k_ticks_to_us_near64(t) \
1390 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, true)
1391
1392
1403/* Generated. Do not edit. See above. */
1404#define k_ticks_to_us_ceil32(t) \
1405 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, true, false)
1406
1407
1418/* Generated. Do not edit. See above. */
1419#define k_ticks_to_us_ceil64(t) \
1420 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, true, false)
1421
1422
1433/* Generated. Do not edit. See above. */
1434#define k_ticks_to_ns_floor32(t) \
1435 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, false)
1436
1437
1448/* Generated. Do not edit. See above. */
1449#define k_ticks_to_ns_floor64(t) \
1450 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, false)
1451
1452
1463/* Generated. Do not edit. See above. */
1464#define k_ticks_to_ns_near32(t) \
1465 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, true)
1466
1467
1478/* Generated. Do not edit. See above. */
1479#define k_ticks_to_ns_near64(t) \
1480 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, true)
1481
1482
1493/* Generated. Do not edit. See above. */
1494#define k_ticks_to_ns_ceil32(t) \
1495 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, true, false)
1496
1497
1508/* Generated. Do not edit. See above. */
1509#define k_ticks_to_ns_ceil64(t) \
1510 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, true, false)
1511
1512
1523/* Generated. Do not edit. See above. */
1524#define k_ticks_to_cyc_floor32(t) \
1525 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false)
1526
1527
1538/* Generated. Do not edit. See above. */
1539#define k_ticks_to_cyc_floor64(t) \
1540 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false)
1541
1542
1553/* Generated. Do not edit. See above. */
1554#define k_ticks_to_cyc_near32(t) \
1555 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true)
1556
1557
1568/* Generated. Do not edit. See above. */
1569#define k_ticks_to_cyc_near64(t) \
1570 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true)
1571
1572
1583/* Generated. Do not edit. See above. */
1584#define k_ticks_to_cyc_ceil32(t) \
1585 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false)
1586
1587
1598/* Generated. Do not edit. See above. */
1599#define k_ticks_to_cyc_ceil64(t) \
1600 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false)
1601
1602#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
1603#include <syscalls/time_units.h>
1604#endif
1605
1606#undef TIME_CONSTEXPR
1607
1612#ifdef __cplusplus
1613} /* extern "C" */
1614#endif
1615
1616#endif /* ZEPHYR_INCLUDE_TIME_UNITS_H_ */
Macros to abstract toolchain specific capabilities.
Misc utilities.