Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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#ifdef __cplusplus
11extern "C" {
12#endif
13
21#define SYS_FOREVER_MS (-1)
22
25#define SYS_TIMEOUT_MS(ms) ((ms) == SYS_FOREVER_MS ? K_FOREVER : K_MSEC(ms))
26
27/* Exhaustively enumerated, highly optimized time unit conversion API */
28
29#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
30__syscall int sys_clock_hw_cycles_per_sec_runtime_get(void);
31
32static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
33{
34 extern int z_clock_hw_cycles_per_sec;
35
36 return z_clock_hw_cycles_per_sec;
37}
38#endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
39
40#if defined(__cplusplus) && __cplusplus >= 201402L
41 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
42 #define TIME_CONSTEXPR
43 #else
44 #define TIME_CONSTEXPR constexpr
45 #endif
46#else
47 #define TIME_CONSTEXPR
48#endif
49
51{
52#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
53 return sys_clock_hw_cycles_per_sec_runtime_get();
54#else
56#endif
57}
58
59/* Time converter generator gadget. Selects from one of three
60 * conversion algorithms: ones that take advantage when the
61 * frequencies are an integer ratio (in either direction), or a full
62 * precision conversion. Clever use of extra arguments causes all the
63 * selection logic to be optimized out, and the generated code even
64 * reduces to 32 bit only if a ratio conversion is available and the
65 * result is 32 bits.
66 *
67 * This isn't intended to be used directly, instead being wrapped
68 * appropriately in a user-facing API. The boolean arguments are:
69 *
70 * const_hz - The hz arguments are known to be compile-time
71 * constants (because otherwise the modulus test would
72 * have to be done at runtime)
73 * result32 - The result will be truncated to 32 bits on use
74 * round_up - Return the ceiling of the resulting fraction
75 * round_off - Return the nearest value to the resulting fraction
76 * (pass both round_up/off as false to get "round_down")
77 */
79 uint32_t to_hz, bool const_hz,
80 bool result32, bool round_up,
81 bool round_off)
82{
83 bool mul_ratio = const_hz &&
84 (to_hz > from_hz) && ((to_hz % from_hz) == 0U);
85 bool div_ratio = const_hz &&
86 (from_hz > to_hz) && ((from_hz % to_hz) == 0U);
87
88 if (from_hz == to_hz) {
89 return result32 ? ((uint32_t)t) : t;
90 }
91
92 uint64_t off = 0;
93
94 if (!mul_ratio) {
95 uint32_t rdivisor = div_ratio ? (from_hz / to_hz) : from_hz;
96
97 if (round_up) {
98 off = rdivisor - 1U;
99 }
100 if (round_off) {
101 off = rdivisor / 2U;
102 }
103 }
104
105 /* Select (at build time!) between three different expressions for
106 * the same mathematical relationship, each expressed with and
107 * without truncation to 32 bits (I couldn't find a way to make
108 * the compiler correctly guess at the 32 bit result otherwise).
109 */
110 if (div_ratio) {
111 t += off;
112 if (result32 && (t < BIT64(32))) {
113 return ((uint32_t)t) / (from_hz / to_hz);
114 } else {
115 return t / ((uint64_t)from_hz / to_hz);
116 }
117 } else if (mul_ratio) {
118 if (result32) {
119 return ((uint32_t)t) * (to_hz / from_hz);
120 } else {
121 return t * ((uint64_t)to_hz / from_hz);
122 }
123 } else {
124 if (result32) {
125 return (uint32_t)((t * to_hz + off) / from_hz);
126 } else {
127 return (t * to_hz + off) / from_hz;
128 }
129 }
130}
131
132/* The following code is programmatically generated using this perl
133 * code, which enumerates all possible combinations of units, rounding
134 * modes and precision. Do not edit directly.
135 *
136 * Note that nano/microsecond conversions are only defined with 64 bit
137 * precision. These units conversions were not available in 32 bit
138 * variants historically, and doing 32 bit math with units that small
139 * has precision traps that we probably don't want to support in an
140 * official API.
141 *
142 * #!/usr/bin/perl -w
143 * use strict;
144 *
145 * my %human = ("ms" => "milliseconds",
146 * "us" => "microseconds",
147 * "ns" => "nanoseconds",
148 * "cyc" => "hardware cycles",
149 * "ticks" => "ticks");
150 *
151 * sub big { return $_[0] eq "us" || $_[0] eq "ns"; }
152 * sub prefix { return $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; }
153 *
154 * for my $from_unit ("ms", "us", "ns", "cyc", "ticks") {
155 * for my $to_unit ("ms", "us", "ns", "cyc", "ticks") {
156 * next if $from_unit eq $to_unit;
157 * next if prefix($from_unit) && prefix($to_unit);
158 * for my $round ("floor", "near", "ceil") {
159 * for(my $big=0; $big <= 1; $big++) {
160 * my $sz = $big ? 64 : 32;
161 * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz";
162 * my $type = "u${sz}_t";
163 * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc")
164 * ? "Z_CCYC" : "true";
165 * my $ret32 = $big ? "false" : "true";
166 * my $rup = $round eq "ceil" ? "true" : "false";
167 * my $roff = $round eq "near" ? "true" : "false";
168 *
169 * my $hfrom = $human{$from_unit};
170 * my $hto = $human{$to_unit};
171 * print "/", "** \@brief Convert $hfrom to $hto\n";
172 * print " *\n";
173 * print " * Converts time values in $hfrom to $hto.\n";
174 * print " * Computes result in $sz bit precision.\n";
175 * if ($round eq "ceil") {
176 * print " * Rounds up to the next highest output unit.\n";
177 * } elsif ($round eq "near") {
178 * print " * Rounds to the nearest output unit.\n";
179 * } else {
180 * print " * Truncates to the next lowest output unit.\n";
181 * }
182 * print " *\n";
183 * print " * \@return The converted time value\n";
184 * print " *", "/\n";
185 *
186 * print "static TIME_CONSTEXPR inline $type $sym($type t)\n{\n\t";
187 * print "/", "* Generated. Do not edit. See above. *", "/\n\t";
188 * print "return z_tmcvt(t, Z_HZ_$from_unit, Z_HZ_$to_unit,";
189 * print " $const_hz, $ret32, $rup, $roff);\n";
190 * print "}\n\n";
191 * }
192 * }
193 * }
194 * }
195 */
196
197/* Some more concise declarations to simplify the generator script and
198 * save bytes below
199 */
200#define Z_HZ_ms 1000
201#define Z_HZ_us 1000000
202#define Z_HZ_ns 1000000000
203#define Z_HZ_cyc sys_clock_hw_cycles_per_sec()
204#define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC
205#define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME))
206
216{
217 /* Generated. Do not edit. See above. */
218 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, false);
219}
220
230{
231 /* Generated. Do not edit. See above. */
232 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, false);
233}
234
244{
245 /* Generated. Do not edit. See above. */
246 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, true);
247}
248
258{
259 /* Generated. Do not edit. See above. */
260 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, true);
261}
262
272{
273 /* Generated. Do not edit. See above. */
274 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, true, false);
275}
276
286{
287 /* Generated. Do not edit. See above. */
288 return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true, false);
289}
290
300{
301 /* Generated. Do not edit. See above. */
302 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, false);
303}
304
314{
315 /* Generated. Do not edit. See above. */
316 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, false);
317}
318
328{
329 /* Generated. Do not edit. See above. */
330 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, true);
331}
332
342{
343 /* Generated. Do not edit. See above. */
344 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, true);
345}
346
356{
357 /* Generated. Do not edit. See above. */
358 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, true, false);
359}
360
370{
371 /* Generated. Do not edit. See above. */
372 return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, true, false);
373}
374
384{
385 /* Generated. Do not edit. See above. */
386 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, false);
387}
388
398{
399 /* Generated. Do not edit. See above. */
400 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, false);
401}
402
412{
413 /* Generated. Do not edit. See above. */
414 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, true);
415}
416
426{
427 /* Generated. Do not edit. See above. */
428 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, true);
429}
430
440{
441 /* Generated. Do not edit. See above. */
442 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, true, false);
443}
444
454{
455 /* Generated. Do not edit. See above. */
456 return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true, false);
457}
458
468{
469 /* Generated. Do not edit. See above. */
470 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, false);
471}
472
482{
483 /* Generated. Do not edit. See above. */
484 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, false);
485}
486
496{
497 /* Generated. Do not edit. See above. */
498 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, true);
499}
500
510{
511 /* Generated. Do not edit. See above. */
512 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, true);
513}
514
524{
525 /* Generated. Do not edit. See above. */
526 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, true, false);
527}
528
538{
539 /* Generated. Do not edit. See above. */
540 return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, true, false);
541}
542
552{
553 /* Generated. Do not edit. See above. */
554 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, false);
555}
556
566{
567 /* Generated. Do not edit. See above. */
568 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, false);
569}
570
580{
581 /* Generated. Do not edit. See above. */
582 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, true);
583}
584
594{
595 /* Generated. Do not edit. See above. */
596 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, true);
597}
598
608{
609 /* Generated. Do not edit. See above. */
610 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, true, false);
611}
612
622{
623 /* Generated. Do not edit. See above. */
624 return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true, false);
625}
626
636{
637 /* Generated. Do not edit. See above. */
638 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, false);
639}
640
650{
651 /* Generated. Do not edit. See above. */
652 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, false);
653}
654
664{
665 /* Generated. Do not edit. See above. */
666 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, true);
667}
668
678{
679 /* Generated. Do not edit. See above. */
680 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, true);
681}
682
692{
693 /* Generated. Do not edit. See above. */
694 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, true, false);
695}
696
706{
707 /* Generated. Do not edit. See above. */
708 return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, true, false);
709}
710
720{
721 /* Generated. Do not edit. See above. */
722 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, false);
723}
724
734{
735 /* Generated. Do not edit. See above. */
736 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, false);
737}
738
748{
749 /* Generated. Do not edit. See above. */
750 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, true);
751}
752
762{
763 /* Generated. Do not edit. See above. */
764 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, true);
765}
766
776{
777 /* Generated. Do not edit. See above. */
778 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, true, false);
779}
780
790{
791 /* Generated. Do not edit. See above. */
792 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true, false);
793}
794
804{
805 /* Generated. Do not edit. See above. */
806 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, false);
807}
808
818{
819 /* Generated. Do not edit. See above. */
820 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, false);
821}
822
832{
833 /* Generated. Do not edit. See above. */
834 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, true);
835}
836
846{
847 /* Generated. Do not edit. See above. */
848 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, true);
849}
850
860{
861 /* Generated. Do not edit. See above. */
862 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, true, false);
863}
864
874{
875 /* Generated. Do not edit. See above. */
876 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true, false);
877}
878
888{
889 /* Generated. Do not edit. See above. */
890 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, false);
891}
892
902{
903 /* Generated. Do not edit. See above. */
904 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, false);
905}
906
916{
917 /* Generated. Do not edit. See above. */
918 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, true);
919}
920
930{
931 /* Generated. Do not edit. See above. */
932 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, true);
933}
934
944{
945 /* Generated. Do not edit. See above. */
946 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, true, false);
947}
948
958{
959 /* Generated. Do not edit. See above. */
960 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true, false);
961}
962
972{
973 /* Generated. Do not edit. See above. */
974 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, false);
975}
976
986{
987 /* Generated. Do not edit. See above. */
988 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, false);
989}
990
1000{
1001 /* Generated. Do not edit. See above. */
1002 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, true);
1003}
1004
1014{
1015 /* Generated. Do not edit. See above. */
1016 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, true);
1017}
1018
1028{
1029 /* Generated. Do not edit. See above. */
1030 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, true, false);
1031}
1032
1042{
1043 /* Generated. Do not edit. See above. */
1044 return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true, false);
1045}
1046
1056{
1057 /* Generated. Do not edit. See above. */
1058 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, false);
1059}
1060
1070{
1071 /* Generated. Do not edit. See above. */
1072 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, false);
1073}
1074
1084{
1085 /* Generated. Do not edit. See above. */
1086 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, true);
1087}
1088
1098{
1099 /* Generated. Do not edit. See above. */
1100 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, true);
1101}
1102
1112{
1113 /* Generated. Do not edit. See above. */
1114 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, true, false);
1115}
1116
1126{
1127 /* Generated. Do not edit. See above. */
1128 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, true, false);
1129}
1130
1140{
1141 /* Generated. Do not edit. See above. */
1142 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, false);
1143}
1144
1154{
1155 /* Generated. Do not edit. See above. */
1156 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, false);
1157}
1158
1168{
1169 /* Generated. Do not edit. See above. */
1170 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, true);
1171}
1172
1182{
1183 /* Generated. Do not edit. See above. */
1184 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, true);
1185}
1186
1196{
1197 /* Generated. Do not edit. See above. */
1198 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, true, false);
1199}
1200
1210{
1211 /* Generated. Do not edit. See above. */
1212 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, true, false);
1213}
1214
1224{
1225 /* Generated. Do not edit. See above. */
1226 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, false);
1227}
1228
1238{
1239 /* Generated. Do not edit. See above. */
1240 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, false);
1241}
1242
1252{
1253 /* Generated. Do not edit. See above. */
1254 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, true);
1255}
1256
1266{
1267 /* Generated. Do not edit. See above. */
1268 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, true);
1269}
1270
1280{
1281 /* Generated. Do not edit. See above. */
1282 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, true, false);
1283}
1284
1294{
1295 /* Generated. Do not edit. See above. */
1296 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, true, false);
1297}
1298
1308{
1309 /* Generated. Do not edit. See above. */
1310 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, false);
1311}
1312
1322{
1323 /* Generated. Do not edit. See above. */
1324 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, false);
1325}
1326
1336{
1337 /* Generated. Do not edit. See above. */
1338 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, true);
1339}
1340
1350{
1351 /* Generated. Do not edit. See above. */
1352 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, true);
1353}
1354
1364{
1365 /* Generated. Do not edit. See above. */
1366 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, true, false);
1367}
1368
1378{
1379 /* Generated. Do not edit. See above. */
1380 return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true, false);
1381}
1382
1383#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
1384#include <syscalls/time_units.h>
1385#endif
1386
1387#undef TIME_CONSTEXPR
1388
1389#ifdef __cplusplus
1390} /* extern "C" */
1391#endif
1392
1393#endif /* ZEPHYR_INCLUDE_TIME_UNITS_H_ */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa off
Definition: asm-macro-32-bit-gnu.h:17
#define ALWAYS_INLINE
Definition: common.h:116
#define BIT64(_n)
64-bit unsigned integer with bit position _n set.
Definition: util_macro.h:49
struct k_thread t
Definition: kobject.c:1316
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
static uint32_t k_ms_to_cyc_floor32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:215
static uint64_t k_cyc_to_ns_near64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:929
static uint64_t k_ticks_to_ns_floor64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1237
static uint64_t k_ms_to_cyc_near64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:257
static uint64_t k_ms_to_cyc_ceil64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:285
static uint32_t k_ticks_to_ms_near32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1083
static uint32_t k_ns_to_cyc_floor32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:551
static uint32_t k_ticks_to_ns_near32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1251
static uint32_t k_us_to_ticks_near32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:495
static uint32_t k_ns_to_ticks_floor32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:635
static uint64_t k_ns_to_ticks_ceil64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:705
static uint64_t k_cyc_to_ticks_floor64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:985
static int sys_clock_hw_cycles_per_sec(void)
Definition: time_units.h:50
static uint64_t k_ticks_to_ns_near64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1265
static uint64_t k_cyc_to_ms_floor64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:733
static uint64_t k_us_to_cyc_ceil64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:453
static uint64_t k_ns_to_cyc_floor64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:565
static uint64_t k_us_to_ticks_floor64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:481
static uint32_t k_cyc_to_us_ceil32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:859
static uint32_t k_cyc_to_ns_floor32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:887
static uint64_t k_ms_to_ticks_floor64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:313
static uint64_t k_cyc_to_ms_ceil64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:789
static uint32_t k_us_to_cyc_ceil32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:439
#define TIME_CONSTEXPR
Definition: time_units.h:47
static uint32_t k_ticks_to_ms_ceil32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1111
static uint32_t k_ticks_to_cyc_floor32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1307
static uint64_t k_ticks_to_cyc_ceil64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1377
static uint32_t k_us_to_ticks_floor32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:467
static uint32_t k_ns_to_ticks_near32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:663
static uint64_t k_ns_to_ticks_floor64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:649
static uint64_t k_ms_to_ticks_near64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:341
static uint32_t k_ticks_to_ns_ceil32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1279
static uint64_t k_us_to_cyc_near64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:425
static uint32_t k_ns_to_cyc_near32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:579
static uint64_t k_us_to_cyc_floor64(uint64_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:397
static uint32_t k_ticks_to_ns_floor32(uint32_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1223
static uint64_t k_cyc_to_ms_near64(uint64_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:761
static uint32_t k_us_to_cyc_near32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:411
static uint64_t k_ticks_to_ms_floor64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1069
static uint32_t k_ns_to_ticks_ceil32(uint32_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:691
static uint32_t k_cyc_to_ms_near32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:747
static uint32_t k_cyc_to_ms_ceil32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:775
static uint64_t k_ns_to_ticks_near64(uint64_t t)
Convert nanoseconds to ticks.
Definition: time_units.h:677
static uint64_t k_ticks_to_us_near64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1181
static uint32_t k_cyc_to_ticks_ceil32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1027
static uint64_t k_ns_to_cyc_ceil64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:621
static uint32_t k_ms_to_cyc_ceil32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:271
static uint32_t k_ticks_to_ms_floor32(uint32_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1055
static uint32_t k_ms_to_ticks_floor32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:299
static uint64_t k_cyc_to_ticks_near64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1013
static uint64_t k_ticks_to_us_floor64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1153
static uint64_t k_cyc_to_ns_floor64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:901
static uint32_t k_cyc_to_ns_ceil32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:943
static uint32_t k_cyc_to_us_floor32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:803
static uint64_t k_cyc_to_us_floor64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:817
static uint32_t k_us_to_cyc_floor32(uint32_t t)
Convert microseconds to hardware cycles.
Definition: time_units.h:383
static uint64_t k_ms_to_ticks_ceil64(uint64_t t)
Convert milliseconds to ticks.
Definition: time_units.h:369
static uint32_t k_us_to_ticks_ceil32(uint32_t t)
Convert microseconds to ticks.
Definition: time_units.h:523
static uint32_t k_ticks_to_us_near32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1167
static uint32_t k_cyc_to_ticks_floor32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:971
static uint32_t k_ticks_to_us_ceil32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1195
static uint32_t k_ms_to_ticks_near32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:327
static uint64_t k_cyc_to_ns_ceil64(uint64_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:957
static uint32_t k_ns_to_cyc_ceil32(uint32_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:607
static uint32_t k_ticks_to_cyc_ceil32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1363
static uint64_t k_cyc_to_us_ceil64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:873
static uint32_t k_ms_to_cyc_near32(uint32_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:243
static uint32_t k_ticks_to_us_floor32(uint32_t t)
Convert ticks to microseconds.
Definition: time_units.h:1139
static uint32_t k_cyc_to_ms_floor32(uint32_t t)
Convert hardware cycles to milliseconds.
Definition: time_units.h:719
static uint64_t k_ticks_to_ms_near64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1097
static uint64_t k_ticks_to_us_ceil64(uint64_t t)
Convert ticks to microseconds.
Definition: time_units.h:1209
static uint64_t k_us_to_ticks_near64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:509
static uint32_t k_cyc_to_ns_near32(uint32_t t)
Convert hardware cycles to nanoseconds.
Definition: time_units.h:915
static uint32_t k_ticks_to_cyc_near32(uint32_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1335
static uint64_t k_cyc_to_ticks_ceil64(uint64_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:1041
static uint32_t k_ms_to_ticks_ceil32(uint32_t t)
Convert milliseconds to ticks.
Definition: time_units.h:355
static uint64_t k_ticks_to_ms_ceil64(uint64_t t)
Convert ticks to milliseconds.
Definition: time_units.h:1125
static uint64_t k_ticks_to_cyc_floor64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1321
static uint64_t k_cyc_to_us_near64(uint64_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:845
static uint64_t k_ticks_to_cyc_near64(uint64_t t)
Convert ticks to hardware cycles.
Definition: time_units.h:1349
static uint64_t k_ms_to_cyc_floor64(uint64_t t)
Convert milliseconds to hardware cycles.
Definition: time_units.h:229
static uint64_t k_ticks_to_ns_ceil64(uint64_t t)
Convert ticks to nanoseconds.
Definition: time_units.h:1293
static uint32_t k_cyc_to_ticks_near32(uint32_t t)
Convert hardware cycles to ticks.
Definition: time_units.h:999
static uint64_t k_ns_to_cyc_near64(uint64_t t)
Convert nanoseconds to hardware cycles.
Definition: time_units.h:593
static uint64_t k_us_to_ticks_ceil64(uint64_t t)
Convert microseconds to ticks.
Definition: time_units.h:537
static uint32_t k_cyc_to_us_near32(uint32_t t)
Convert hardware cycles to microseconds.
Definition: time_units.h:831
#define CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
Definition: ztest.h:40