Branch data Line data Source code
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 <toolchain.h>
11 : :
12 : : #ifdef __cplusplus
13 : : extern "C" {
14 : : #endif
15 : :
16 : : /** @brief System-wide macro to denote "forever" in milliseconds
17 : : *
18 : : * Usage of this macro is limited to APIs that want to expose a timeout value
19 : : * that can optionally be unlimited, or "forever".
20 : : * This macro can not be fed into kernel functions or macros directly. Use
21 : : * @ref SYS_TIMEOUT_MS instead.
22 : : */
23 : : #define SYS_FOREVER_MS (-1)
24 : :
25 : : /** @brief System-wide macro to denote "forever" in microseconds
26 : : *
27 : : * See @ref SYS_FOREVER_MS.
28 : : */
29 : : #define SYS_FOREVER_US (-1)
30 : :
31 : : /** @brief System-wide macro to convert milliseconds to kernel timeouts
32 : : */
33 : : #define SYS_TIMEOUT_MS(ms) ((ms) == SYS_FOREVER_MS ? K_FOREVER : K_MSEC(ms))
34 : :
35 : : /* Exhaustively enumerated, highly optimized time unit conversion API */
36 : :
37 : : #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
38 : : __syscall int sys_clock_hw_cycles_per_sec_runtime_get(void);
39 : :
40 : : static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
41 : : {
42 : : extern int z_clock_hw_cycles_per_sec;
43 : :
44 : : return z_clock_hw_cycles_per_sec;
45 : : }
46 : : #endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
47 : :
48 : : #if defined(__cplusplus) && __cplusplus >= 201402L
49 : : #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
50 : : #define TIME_CONSTEXPR
51 : : #else
52 : : #define TIME_CONSTEXPR constexpr
53 : : #endif
54 : : #else
55 : : #define TIME_CONSTEXPR
56 : : #endif
57 : :
58 : 49 : static TIME_CONSTEXPR inline int sys_clock_hw_cycles_per_sec(void)
59 : : {
60 : : #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
61 : : return sys_clock_hw_cycles_per_sec_runtime_get();
62 : : #else
63 : 49 : return CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
64 : : #endif
65 : : }
66 : :
67 : : /** @internal
68 : : * Macro determines if fast conversion algorithm can be used. It checks if
69 : : * maximum timeout represented in source frequency domain and multiplied by
70 : : * target frequency fits in 64 bits.
71 : : *
72 : : * @param from_hz Source frequency.
73 : : * @param to_hz Target frequency.
74 : : *
75 : : * @retval true Use faster algorithm.
76 : : * @retval false Use algorithm preventing overflow of intermediate value.
77 : : */
78 : : #define Z_TMCVT_USE_FAST_ALGO(from_hz, to_hz) \
79 : : ((ceiling_fraction(CONFIG_SYS_CLOCK_MAX_TIMEOUT_DAYS * 24ULL * 3600ULL * from_hz, \
80 : : UINT32_MAX) * to_hz) <= UINT32_MAX)
81 : :
82 : : /* Time converter generator gadget. Selects from one of three
83 : : * conversion algorithms: ones that take advantage when the
84 : : * frequencies are an integer ratio (in either direction), or a full
85 : : * precision conversion. Clever use of extra arguments causes all the
86 : : * selection logic to be optimized out, and the generated code even
87 : : * reduces to 32 bit only if a ratio conversion is available and the
88 : : * result is 32 bits.
89 : : *
90 : : * This isn't intended to be used directly, instead being wrapped
91 : : * appropriately in a user-facing API. The boolean arguments are:
92 : : *
93 : : * const_hz - The hz arguments are known to be compile-time
94 : : * constants (because otherwise the modulus test would
95 : : * have to be done at runtime)
96 : : * result32 - The result will be truncated to 32 bits on use
97 : : * round_up - Return the ceiling of the resulting fraction
98 : : * round_off - Return the nearest value to the resulting fraction
99 : : * (pass both round_up/off as false to get "round_down")
100 : : */
101 : 2 : static TIME_CONSTEXPR ALWAYS_INLINE uint64_t z_tmcvt(uint64_t t, uint32_t from_hz,
102 : : uint32_t to_hz, bool const_hz,
103 : : bool result32, bool round_up,
104 : : bool round_off)
105 : : {
106 [ + + ]: 2 : bool mul_ratio = const_hz &&
107 [ + - - + ]: 4 : (to_hz > from_hz) && ((to_hz % from_hz) == 0U);
108 [ + + ]: 2 : bool div_ratio = const_hz &&
109 [ + - - + ]: 4 : (from_hz > to_hz) && ((from_hz % to_hz) == 0U);
110 : :
111 [ - + ]: 2 : if (from_hz == to_hz) {
112 [ # # ]: 0 : return result32 ? ((uint32_t)t) : t;
113 : : }
114 : :
115 : 2 : uint64_t off = 0;
116 : :
117 [ + - ]: 2 : if (!mul_ratio) {
118 [ - + ]: 2 : uint32_t rdivisor = div_ratio ? (from_hz / to_hz) : from_hz;
119 : :
120 [ + - ]: 2 : if (round_up) {
121 : 2 : off = rdivisor - 1U;
122 : : }
123 [ - + ]: 2 : if (round_off) {
124 : 0 : off = rdivisor / 2U;
125 : : }
126 : : }
127 : :
128 : : /* Select (at build time!) between three different expressions for
129 : : * the same mathematical relationship, each expressed with and
130 : : * without truncation to 32 bits (I couldn't find a way to make
131 : : * the compiler correctly guess at the 32 bit result otherwise).
132 : : */
133 [ - + ]: 2 : if (div_ratio) {
134 : 0 : t += off;
135 [ # # # # ]: 0 : if (result32 && (t < BIT64(32))) {
136 : 0 : return ((uint32_t)t) / (from_hz / to_hz);
137 : : } else {
138 : 0 : return t / ((uint64_t)from_hz / to_hz);
139 : : }
140 [ - + ]: 2 : } else if (mul_ratio) {
141 [ # # ]: 0 : if (result32) {
142 : 0 : return ((uint32_t)t) * (to_hz / from_hz);
143 : : } else {
144 : 0 : return t * ((uint64_t)to_hz / from_hz);
145 : : }
146 : : } else {
147 [ + - ]: 2 : if (result32) {
148 : 2 : return (uint32_t)((t * to_hz + off) / from_hz);
149 [ # # # # ]: 0 : } else if (const_hz && Z_TMCVT_USE_FAST_ALGO(from_hz, to_hz)) {
150 : : /* Faster algorithm but source is first multiplied by target frequency
151 : : * and it can overflow even though final result would not overflow.
152 : : * Kconfig option shall prevent use of this algorithm when there is a
153 : : * risk of overflow.
154 : : */
155 : 0 : return ((t * to_hz + off) / from_hz);
156 : : } else {
157 : : /* Slower algorithm but input is first divided before being multiplied
158 : : * which prevents overflow of intermediate value.
159 : : */
160 : 0 : return (t / from_hz) * to_hz + ((t % from_hz) * to_hz + off) / from_hz;
161 : : }
162 : : }
163 : : }
164 : :
165 : : /* The following code is programmatically generated using this perl
166 : : * code, which enumerates all possible combinations of units, rounding
167 : : * modes and precision. Do not edit directly.
168 : : *
169 : : * Note that nano/microsecond conversions are only defined with 64 bit
170 : : * precision. These units conversions were not available in 32 bit
171 : : * variants historically, and doing 32 bit math with units that small
172 : : * has precision traps that we probably don't want to support in an
173 : : * official API.
174 : : *
175 : : * #!/usr/bin/perl -w
176 : : * use strict;
177 : : *
178 : : * my %human = ("ms" => "milliseconds",
179 : : * "us" => "microseconds",
180 : : * "ns" => "nanoseconds",
181 : : * "cyc" => "hardware cycles",
182 : : * "ticks" => "ticks");
183 : : *
184 : : * sub big { return $_[0] eq "us" || $_[0] eq "ns"; }
185 : : * sub prefix { return $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; }
186 : : *
187 : : * for my $from_unit ("ms", "us", "ns", "cyc", "ticks") {
188 : : * for my $to_unit ("ms", "us", "ns", "cyc", "ticks") {
189 : : * next if $from_unit eq $to_unit;
190 : : * next if prefix($from_unit) && prefix($to_unit);
191 : : * for my $round ("floor", "near", "ceil") {
192 : : * for(my $big=0; $big <= 1; $big++) {
193 : : * my $sz = $big ? 64 : 32;
194 : : * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz";
195 : : * my $type = "u${sz}_t";
196 : : * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc")
197 : : * ? "Z_CCYC" : "true";
198 : : * my $ret32 = $big ? "false" : "true";
199 : : * my $rup = $round eq "ceil" ? "true" : "false";
200 : : * my $roff = $round eq "near" ? "true" : "false";
201 : : *
202 : : * my $hfrom = $human{$from_unit};
203 : : * my $hto = $human{$to_unit};
204 : : * print "/", "** \@brief Convert $hfrom to $hto\n";
205 : : * print " *\n";
206 : : * print " * Converts time values in $hfrom to $hto.\n";
207 : : * print " * Computes result in $sz bit precision.\n";
208 : : * if ($round eq "ceil") {
209 : : * print " * Rounds up to the next highest output unit.\n";
210 : : * } elsif ($round eq "near") {
211 : : * print " * Rounds to the nearest output unit.\n";
212 : : * } else {
213 : : * print " * Truncates to the next lowest output unit.\n";
214 : : * }
215 : : * print " *\n";
216 : : * print " * \@return The converted time value\n";
217 : : * print " *", "/\n";
218 : : *
219 : : * print "static TIME_CONSTEXPR inline $type $sym($type t)\n{\n\t";
220 : : * print "/", "* Generated. Do not edit. See above. *", "/\n\t";
221 : : * print "return z_tmcvt(t, Z_HZ_$from_unit, Z_HZ_$to_unit,";
222 : : * print " $const_hz, $ret32, $rup, $roff);\n";
223 : : * print "}\n\n";
224 : : * }
225 : : * }
226 : : * }
227 : : * }
228 : : */
229 : :
230 : : /* Some more concise declarations to simplify the generator script and
231 : : * save bytes below
232 : : */
233 : : #define Z_HZ_ms 1000
234 : : #define Z_HZ_us 1000000
235 : : #define Z_HZ_ns 1000000000
236 : : #define Z_HZ_cyc sys_clock_hw_cycles_per_sec()
237 : : #define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC
238 : : #define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME))
239 : :
240 : : /** @brief Convert milliseconds to hardware cycles
241 : : *
242 : : * Converts time values in milliseconds to hardware cycles.
243 : : * Computes result in 32 bit precision.
244 : : * Truncates to the next lowest output unit.
245 : : *
246 : : * @return The converted time value
247 : : */
248 : : static TIME_CONSTEXPR inline uint32_t k_ms_to_cyc_floor32(uint32_t t)
249 : : {
250 : : /* Generated. Do not edit. See above. */
251 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, false);
252 : : }
253 : :
254 : : /** @brief Convert milliseconds to hardware cycles
255 : : *
256 : : * Converts time values in milliseconds to hardware cycles.
257 : : * Computes result in 64 bit precision.
258 : : * Truncates to the next lowest output unit.
259 : : *
260 : : * @return The converted time value
261 : : */
262 : : static TIME_CONSTEXPR inline uint64_t k_ms_to_cyc_floor64(uint64_t t)
263 : : {
264 : : /* Generated. Do not edit. See above. */
265 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, false);
266 : : }
267 : :
268 : : /** @brief Convert milliseconds to hardware cycles
269 : : *
270 : : * Converts time values in milliseconds to hardware cycles.
271 : : * Computes result in 32 bit precision.
272 : : * Rounds to the nearest output unit.
273 : : *
274 : : * @return The converted time value
275 : : */
276 : : static TIME_CONSTEXPR inline uint32_t k_ms_to_cyc_near32(uint32_t t)
277 : : {
278 : : /* Generated. Do not edit. See above. */
279 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false, true);
280 : : }
281 : :
282 : : /** @brief Convert milliseconds to hardware cycles
283 : : *
284 : : * Converts time values in milliseconds to hardware cycles.
285 : : * Computes result in 64 bit precision.
286 : : * Rounds to the nearest output unit.
287 : : *
288 : : * @return The converted time value
289 : : */
290 : : static TIME_CONSTEXPR inline uint64_t k_ms_to_cyc_near64(uint64_t t)
291 : : {
292 : : /* Generated. Do not edit. See above. */
293 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false, true);
294 : : }
295 : :
296 : : /** @brief Convert milliseconds to hardware cycles
297 : : *
298 : : * Converts time values in milliseconds to hardware cycles.
299 : : * Computes result in 32 bit precision.
300 : : * Rounds up to the next highest output unit.
301 : : *
302 : : * @return The converted time value
303 : : */
304 : : static TIME_CONSTEXPR inline uint32_t k_ms_to_cyc_ceil32(uint32_t t)
305 : : {
306 : : /* Generated. Do not edit. See above. */
307 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, true, false);
308 : : }
309 : :
310 : : /** @brief Convert milliseconds to hardware cycles
311 : : *
312 : : * Converts time values in milliseconds to hardware cycles.
313 : : * Computes result in 64 bit precision.
314 : : * Rounds up to the next highest output unit.
315 : : *
316 : : * @return The converted time value
317 : : */
318 : : static TIME_CONSTEXPR inline uint64_t k_ms_to_cyc_ceil64(uint64_t t)
319 : : {
320 : : /* Generated. Do not edit. See above. */
321 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true, false);
322 : : }
323 : :
324 : : /** @brief Convert milliseconds to ticks
325 : : *
326 : : * Converts time values in milliseconds to ticks.
327 : : * Computes result in 32 bit precision.
328 : : * Truncates to the next lowest output unit.
329 : : *
330 : : * @return The converted time value
331 : : */
332 : : static TIME_CONSTEXPR inline uint32_t k_ms_to_ticks_floor32(uint32_t t)
333 : : {
334 : : /* Generated. Do not edit. See above. */
335 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, false);
336 : : }
337 : :
338 : : /** @brief Convert milliseconds to ticks
339 : : *
340 : : * Converts time values in milliseconds to ticks.
341 : : * Computes result in 64 bit precision.
342 : : * Truncates to the next lowest output unit.
343 : : *
344 : : * @return The converted time value
345 : : */
346 : : static TIME_CONSTEXPR inline uint64_t k_ms_to_ticks_floor64(uint64_t t)
347 : : {
348 : : /* Generated. Do not edit. See above. */
349 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, false);
350 : : }
351 : :
352 : : /** @brief Convert milliseconds to ticks
353 : : *
354 : : * Converts time values in milliseconds to ticks.
355 : : * Computes result in 32 bit precision.
356 : : * Rounds to the nearest output unit.
357 : : *
358 : : * @return The converted time value
359 : : */
360 : : static TIME_CONSTEXPR inline uint32_t k_ms_to_ticks_near32(uint32_t t)
361 : : {
362 : : /* Generated. Do not edit. See above. */
363 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, false, true);
364 : : }
365 : :
366 : : /** @brief Convert milliseconds to ticks
367 : : *
368 : : * Converts time values in milliseconds to ticks.
369 : : * Computes result in 64 bit precision.
370 : : * Rounds to the nearest output unit.
371 : : *
372 : : * @return The converted time value
373 : : */
374 : : static TIME_CONSTEXPR inline uint64_t k_ms_to_ticks_near64(uint64_t t)
375 : : {
376 : : /* Generated. Do not edit. See above. */
377 : : return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, false, true);
378 : : }
379 : :
380 : : /** @brief Convert milliseconds to ticks
381 : : *
382 : : * Converts time values in milliseconds to ticks.
383 : : * Computes result in 32 bit precision.
384 : : * Rounds up to the next highest output unit.
385 : : *
386 : : * @return The converted time value
387 : : */
388 : 1 : static TIME_CONSTEXPR inline uint32_t k_ms_to_ticks_ceil32(uint32_t t)
389 : : {
390 : : /* Generated. Do not edit. See above. */
391 : 1 : return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, true, true, false);
392 : : }
393 : :
394 : : /** @brief Convert milliseconds to ticks
395 : : *
396 : : * Converts time values in milliseconds to ticks.
397 : : * Computes result in 64 bit precision.
398 : : * Rounds up to the next highest output unit.
399 : : *
400 : : * @return The converted time value
401 : : */
402 : 0 : static TIME_CONSTEXPR inline uint64_t k_ms_to_ticks_ceil64(uint64_t t)
403 : : {
404 : : /* Generated. Do not edit. See above. */
405 : 0 : return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, true, false);
406 : : }
407 : :
408 : : /** @brief Convert microseconds to hardware cycles
409 : : *
410 : : * Converts time values in microseconds to hardware cycles.
411 : : * Computes result in 32 bit precision.
412 : : * Truncates to the next lowest output unit.
413 : : *
414 : : * @return The converted time value
415 : : */
416 : : static TIME_CONSTEXPR inline uint32_t k_us_to_cyc_floor32(uint32_t t)
417 : : {
418 : : /* Generated. Do not edit. See above. */
419 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, false);
420 : : }
421 : :
422 : : /** @brief Convert microseconds to hardware cycles
423 : : *
424 : : * Converts time values in microseconds to hardware cycles.
425 : : * Computes result in 64 bit precision.
426 : : * Truncates to the next lowest output unit.
427 : : *
428 : : * @return The converted time value
429 : : */
430 : : static TIME_CONSTEXPR inline uint64_t k_us_to_cyc_floor64(uint64_t t)
431 : : {
432 : : /* Generated. Do not edit. See above. */
433 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, false);
434 : : }
435 : :
436 : : /** @brief Convert microseconds to hardware cycles
437 : : *
438 : : * Converts time values in microseconds to hardware cycles.
439 : : * Computes result in 32 bit precision.
440 : : * Rounds to the nearest output unit.
441 : : *
442 : : * @return The converted time value
443 : : */
444 : : static TIME_CONSTEXPR inline uint32_t k_us_to_cyc_near32(uint32_t t)
445 : : {
446 : : /* Generated. Do not edit. See above. */
447 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, true);
448 : : }
449 : :
450 : : /** @brief Convert microseconds to hardware cycles
451 : : *
452 : : * Converts time values in microseconds to hardware cycles.
453 : : * Computes result in 64 bit precision.
454 : : * Rounds to the nearest output unit.
455 : : *
456 : : * @return The converted time value
457 : : */
458 : : static TIME_CONSTEXPR inline uint64_t k_us_to_cyc_near64(uint64_t t)
459 : : {
460 : : /* Generated. Do not edit. See above. */
461 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, true);
462 : : }
463 : :
464 : : /** @brief Convert microseconds to hardware cycles
465 : : *
466 : : * Converts time values in microseconds to hardware cycles.
467 : : * Computes result in 32 bit precision.
468 : : * Rounds up to the next highest output unit.
469 : : *
470 : : * @return The converted time value
471 : : */
472 : : static TIME_CONSTEXPR inline uint32_t k_us_to_cyc_ceil32(uint32_t t)
473 : : {
474 : : /* Generated. Do not edit. See above. */
475 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, true, false);
476 : : }
477 : :
478 : : /** @brief Convert microseconds to hardware cycles
479 : : *
480 : : * Converts time values in microseconds to hardware cycles.
481 : : * Computes result in 64 bit precision.
482 : : * Rounds up to the next highest output unit.
483 : : *
484 : : * @return The converted time value
485 : : */
486 : : static TIME_CONSTEXPR inline uint64_t k_us_to_cyc_ceil64(uint64_t t)
487 : : {
488 : : /* Generated. Do not edit. See above. */
489 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true, false);
490 : : }
491 : :
492 : : /** @brief Convert microseconds to ticks
493 : : *
494 : : * Converts time values in microseconds to ticks.
495 : : * Computes result in 32 bit precision.
496 : : * Truncates to the next lowest output unit.
497 : : *
498 : : * @return The converted time value
499 : : */
500 : : static TIME_CONSTEXPR inline uint32_t k_us_to_ticks_floor32(uint32_t t)
501 : : {
502 : : /* Generated. Do not edit. See above. */
503 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, false);
504 : : }
505 : :
506 : : /** @brief Convert microseconds to ticks
507 : : *
508 : : * Converts time values in microseconds to ticks.
509 : : * Computes result in 64 bit precision.
510 : : * Truncates to the next lowest output unit.
511 : : *
512 : : * @return The converted time value
513 : : */
514 : : static TIME_CONSTEXPR inline uint64_t k_us_to_ticks_floor64(uint64_t t)
515 : : {
516 : : /* Generated. Do not edit. See above. */
517 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, false);
518 : : }
519 : :
520 : : /** @brief Convert microseconds to ticks
521 : : *
522 : : * Converts time values in microseconds to ticks.
523 : : * Computes result in 32 bit precision.
524 : : * Rounds to the nearest output unit.
525 : : *
526 : : * @return The converted time value
527 : : */
528 : : static TIME_CONSTEXPR inline uint32_t k_us_to_ticks_near32(uint32_t t)
529 : : {
530 : : /* Generated. Do not edit. See above. */
531 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, true);
532 : : }
533 : :
534 : : /** @brief Convert microseconds to ticks
535 : : *
536 : : * Converts time values in microseconds to ticks.
537 : : * Computes result in 64 bit precision.
538 : : * Rounds to the nearest output unit.
539 : : *
540 : : * @return The converted time value
541 : : */
542 : : static TIME_CONSTEXPR inline uint64_t k_us_to_ticks_near64(uint64_t t)
543 : : {
544 : : /* Generated. Do not edit. See above. */
545 : : return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, true);
546 : : }
547 : :
548 : : /** @brief Convert microseconds to ticks
549 : : *
550 : : * Converts time values in microseconds to ticks.
551 : : * Computes result in 32 bit precision.
552 : : * Rounds up to the next highest output unit.
553 : : *
554 : : * @return The converted time value
555 : : */
556 : 0 : static TIME_CONSTEXPR inline uint32_t k_us_to_ticks_ceil32(uint32_t t)
557 : : {
558 : : /* Generated. Do not edit. See above. */
559 : 0 : return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, true, false);
560 : : }
561 : :
562 : : /** @brief Convert microseconds to ticks
563 : : *
564 : : * Converts time values in microseconds to ticks.
565 : : * Computes result in 64 bit precision.
566 : : * Rounds up to the next highest output unit.
567 : : *
568 : : * @return The converted time value
569 : : */
570 : 0 : static TIME_CONSTEXPR inline uint64_t k_us_to_ticks_ceil64(uint64_t t)
571 : : {
572 : : /* Generated. Do not edit. See above. */
573 : 0 : return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, true, false);
574 : : }
575 : :
576 : : /** @brief Convert nanoseconds to hardware cycles
577 : : *
578 : : * Converts time values in nanoseconds to hardware cycles.
579 : : * Computes result in 32 bit precision.
580 : : * Truncates to the next lowest output unit.
581 : : *
582 : : * @return The converted time value
583 : : */
584 : : static TIME_CONSTEXPR inline uint32_t k_ns_to_cyc_floor32(uint32_t t)
585 : : {
586 : : /* Generated. Do not edit. See above. */
587 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, false);
588 : : }
589 : :
590 : : /** @brief Convert nanoseconds to hardware cycles
591 : : *
592 : : * Converts time values in nanoseconds to hardware cycles.
593 : : * Computes result in 64 bit precision.
594 : : * Truncates to the next lowest output unit.
595 : : *
596 : : * @return The converted time value
597 : : */
598 : : static TIME_CONSTEXPR inline uint64_t k_ns_to_cyc_floor64(uint64_t t)
599 : : {
600 : : /* Generated. Do not edit. See above. */
601 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, false);
602 : : }
603 : :
604 : : /** @brief Convert nanoseconds to hardware cycles
605 : : *
606 : : * Converts time values in nanoseconds to hardware cycles.
607 : : * Computes result in 32 bit precision.
608 : : * Rounds to the nearest output unit.
609 : : *
610 : : * @return The converted time value
611 : : */
612 : : static TIME_CONSTEXPR inline uint32_t k_ns_to_cyc_near32(uint32_t t)
613 : : {
614 : : /* Generated. Do not edit. See above. */
615 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, true);
616 : : }
617 : :
618 : : /** @brief Convert nanoseconds to hardware cycles
619 : : *
620 : : * Converts time values in nanoseconds to hardware cycles.
621 : : * Computes result in 64 bit precision.
622 : : * Rounds to the nearest output unit.
623 : : *
624 : : * @return The converted time value
625 : : */
626 : : static TIME_CONSTEXPR inline uint64_t k_ns_to_cyc_near64(uint64_t t)
627 : : {
628 : : /* Generated. Do not edit. See above. */
629 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, true);
630 : : }
631 : :
632 : : /** @brief Convert nanoseconds to hardware cycles
633 : : *
634 : : * Converts time values in nanoseconds to hardware cycles.
635 : : * Computes result in 32 bit precision.
636 : : * Rounds up to the next highest output unit.
637 : : *
638 : : * @return The converted time value
639 : : */
640 : : static TIME_CONSTEXPR inline uint32_t k_ns_to_cyc_ceil32(uint32_t t)
641 : : {
642 : : /* Generated. Do not edit. See above. */
643 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, true, false);
644 : : }
645 : :
646 : : /** @brief Convert nanoseconds to hardware cycles
647 : : *
648 : : * Converts time values in nanoseconds to hardware cycles.
649 : : * Computes result in 64 bit precision.
650 : : * Rounds up to the next highest output unit.
651 : : *
652 : : * @return The converted time value
653 : : */
654 : : static TIME_CONSTEXPR inline uint64_t k_ns_to_cyc_ceil64(uint64_t t)
655 : : {
656 : : /* Generated. Do not edit. See above. */
657 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true, false);
658 : : }
659 : :
660 : : /** @brief Convert nanoseconds to ticks
661 : : *
662 : : * Converts time values in nanoseconds to ticks.
663 : : * Computes result in 32 bit precision.
664 : : * Truncates to the next lowest output unit.
665 : : *
666 : : * @return The converted time value
667 : : */
668 : : static TIME_CONSTEXPR inline uint32_t k_ns_to_ticks_floor32(uint32_t t)
669 : : {
670 : : /* Generated. Do not edit. See above. */
671 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, false);
672 : : }
673 : :
674 : : /** @brief Convert nanoseconds to ticks
675 : : *
676 : : * Converts time values in nanoseconds to ticks.
677 : : * Computes result in 64 bit precision.
678 : : * Truncates to the next lowest output unit.
679 : : *
680 : : * @return The converted time value
681 : : */
682 : : static TIME_CONSTEXPR inline uint64_t k_ns_to_ticks_floor64(uint64_t t)
683 : : {
684 : : /* Generated. Do not edit. See above. */
685 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, false);
686 : : }
687 : :
688 : : /** @brief Convert nanoseconds to ticks
689 : : *
690 : : * Converts time values in nanoseconds to ticks.
691 : : * Computes result in 32 bit precision.
692 : : * Rounds to the nearest output unit.
693 : : *
694 : : * @return The converted time value
695 : : */
696 : : static TIME_CONSTEXPR inline uint32_t k_ns_to_ticks_near32(uint32_t t)
697 : : {
698 : : /* Generated. Do not edit. See above. */
699 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, true);
700 : : }
701 : :
702 : : /** @brief Convert nanoseconds to ticks
703 : : *
704 : : * Converts time values in nanoseconds to ticks.
705 : : * Computes result in 64 bit precision.
706 : : * Rounds to the nearest output unit.
707 : : *
708 : : * @return The converted time value
709 : : */
710 : : static TIME_CONSTEXPR inline uint64_t k_ns_to_ticks_near64(uint64_t t)
711 : : {
712 : : /* Generated. Do not edit. See above. */
713 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, true);
714 : : }
715 : :
716 : : /** @brief Convert nanoseconds to ticks
717 : : *
718 : : * Converts time values in nanoseconds to ticks.
719 : : * Computes result in 32 bit precision.
720 : : * Rounds up to the next highest output unit.
721 : : *
722 : : * @return The converted time value
723 : : */
724 : : static TIME_CONSTEXPR inline uint32_t k_ns_to_ticks_ceil32(uint32_t t)
725 : : {
726 : : /* Generated. Do not edit. See above. */
727 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, true, false);
728 : : }
729 : :
730 : : /** @brief Convert nanoseconds to ticks
731 : : *
732 : : * Converts time values in nanoseconds to ticks.
733 : : * Computes result in 64 bit precision.
734 : : * Rounds up to the next highest output unit.
735 : : *
736 : : * @return The converted time value
737 : : */
738 : : static TIME_CONSTEXPR inline uint64_t k_ns_to_ticks_ceil64(uint64_t t)
739 : : {
740 : : /* Generated. Do not edit. See above. */
741 : : return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, true, false);
742 : : }
743 : :
744 : : /** @brief Convert hardware cycles to milliseconds
745 : : *
746 : : * Converts time values in hardware cycles to milliseconds.
747 : : * Computes result in 32 bit precision.
748 : : * Truncates to the next lowest output unit.
749 : : *
750 : : * @return The converted time value
751 : : */
752 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ms_floor32(uint32_t t)
753 : : {
754 : : /* Generated. Do not edit. See above. */
755 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, false);
756 : : }
757 : :
758 : : /** @brief Convert hardware cycles to milliseconds
759 : : *
760 : : * Converts time values in hardware cycles to milliseconds.
761 : : * Computes result in 64 bit precision.
762 : : * Truncates to the next lowest output unit.
763 : : *
764 : : * @return The converted time value
765 : : */
766 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ms_floor64(uint64_t t)
767 : : {
768 : : /* Generated. Do not edit. See above. */
769 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, false);
770 : : }
771 : :
772 : : /** @brief Convert hardware cycles to milliseconds
773 : : *
774 : : * Converts time values in hardware cycles to milliseconds.
775 : : * Computes result in 32 bit precision.
776 : : * Rounds to the nearest output unit.
777 : : *
778 : : * @return The converted time value
779 : : */
780 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ms_near32(uint32_t t)
781 : : {
782 : : /* Generated. Do not edit. See above. */
783 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false, true);
784 : : }
785 : :
786 : : /** @brief Convert hardware cycles to milliseconds
787 : : *
788 : : * Converts time values in hardware cycles to milliseconds.
789 : : * Computes result in 64 bit precision.
790 : : * Rounds to the nearest output unit.
791 : : *
792 : : * @return The converted time value
793 : : */
794 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ms_near64(uint64_t t)
795 : : {
796 : : /* Generated. Do not edit. See above. */
797 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false, true);
798 : : }
799 : :
800 : : /** @brief Convert hardware cycles to milliseconds
801 : : *
802 : : * Converts time values in hardware cycles to milliseconds.
803 : : * Computes result in 32 bit precision.
804 : : * Rounds up to the next highest output unit.
805 : : *
806 : : * @return The converted time value
807 : : */
808 : 1 : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ms_ceil32(uint32_t t)
809 : : {
810 : : /* Generated. Do not edit. See above. */
811 : 1 : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, true, false);
812 : : }
813 : :
814 : : /** @brief Convert hardware cycles to milliseconds
815 : : *
816 : : * Converts time values in hardware cycles to milliseconds.
817 : : * Computes result in 64 bit precision.
818 : : * Rounds up to the next highest output unit.
819 : : *
820 : : * @return The converted time value
821 : : */
822 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ms_ceil64(uint64_t t)
823 : : {
824 : : /* Generated. Do not edit. See above. */
825 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true, false);
826 : : }
827 : :
828 : : /** @brief Convert hardware cycles to microseconds
829 : : *
830 : : * Converts time values in hardware cycles to microseconds.
831 : : * Computes result in 32 bit precision.
832 : : * Truncates to the next lowest output unit.
833 : : *
834 : : * @return The converted time value
835 : : */
836 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_us_floor32(uint32_t t)
837 : : {
838 : : /* Generated. Do not edit. See above. */
839 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, false);
840 : : }
841 : :
842 : : /** @brief Convert hardware cycles to microseconds
843 : : *
844 : : * Converts time values in hardware cycles to microseconds.
845 : : * Computes result in 64 bit precision.
846 : : * Truncates to the next lowest output unit.
847 : : *
848 : : * @return The converted time value
849 : : */
850 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_us_floor64(uint64_t t)
851 : : {
852 : : /* Generated. Do not edit. See above. */
853 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, false);
854 : : }
855 : :
856 : : /** @brief Convert hardware cycles to microseconds
857 : : *
858 : : * Converts time values in hardware cycles to microseconds.
859 : : * Computes result in 32 bit precision.
860 : : * Rounds to the nearest output unit.
861 : : *
862 : : * @return The converted time value
863 : : */
864 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_us_near32(uint32_t t)
865 : : {
866 : : /* Generated. Do not edit. See above. */
867 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, true);
868 : : }
869 : :
870 : : /** @brief Convert hardware cycles to microseconds
871 : : *
872 : : * Converts time values in hardware cycles to microseconds.
873 : : * Computes result in 64 bit precision.
874 : : * Rounds to the nearest output unit.
875 : : *
876 : : * @return The converted time value
877 : : */
878 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_us_near64(uint64_t t)
879 : : {
880 : : /* Generated. Do not edit. See above. */
881 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, true);
882 : : }
883 : :
884 : : /** @brief Convert hardware cycles to microseconds
885 : : *
886 : : * Converts time values in hardware cycles to microseconds.
887 : : * Computes result in 32 bit precision.
888 : : * Rounds up to the next highest output unit.
889 : : *
890 : : * @return The converted time value
891 : : */
892 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_us_ceil32(uint32_t t)
893 : : {
894 : : /* Generated. Do not edit. See above. */
895 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, true, false);
896 : : }
897 : :
898 : : /** @brief Convert hardware cycles to microseconds
899 : : *
900 : : * Converts time values in hardware cycles to microseconds.
901 : : * Computes result in 64 bit precision.
902 : : * Rounds up to the next highest output unit.
903 : : *
904 : : * @return The converted time value
905 : : */
906 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_us_ceil64(uint64_t t)
907 : : {
908 : : /* Generated. Do not edit. See above. */
909 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true, false);
910 : : }
911 : :
912 : : /** @brief Convert hardware cycles to nanoseconds
913 : : *
914 : : * Converts time values in hardware cycles to nanoseconds.
915 : : * Computes result in 32 bit precision.
916 : : * Truncates to the next lowest output unit.
917 : : *
918 : : * @return The converted time value
919 : : */
920 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ns_floor32(uint32_t t)
921 : : {
922 : : /* Generated. Do not edit. See above. */
923 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, false);
924 : : }
925 : :
926 : : /** @brief Convert hardware cycles to nanoseconds
927 : : *
928 : : * Converts time values in hardware cycles to nanoseconds.
929 : : * Computes result in 64 bit precision.
930 : : * Truncates to the next lowest output unit.
931 : : *
932 : : * @return The converted time value
933 : : */
934 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ns_floor64(uint64_t t)
935 : : {
936 : : /* Generated. Do not edit. See above. */
937 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, false);
938 : : }
939 : :
940 : : /** @brief Convert hardware cycles to nanoseconds
941 : : *
942 : : * Converts time values in hardware cycles to nanoseconds.
943 : : * Computes result in 32 bit precision.
944 : : * Rounds to the nearest output unit.
945 : : *
946 : : * @return The converted time value
947 : : */
948 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ns_near32(uint32_t t)
949 : : {
950 : : /* Generated. Do not edit. See above. */
951 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, true);
952 : : }
953 : :
954 : : /** @brief Convert hardware cycles to nanoseconds
955 : : *
956 : : * Converts time values in hardware cycles to nanoseconds.
957 : : * Computes result in 64 bit precision.
958 : : * Rounds to the nearest output unit.
959 : : *
960 : : * @return The converted time value
961 : : */
962 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ns_near64(uint64_t t)
963 : : {
964 : : /* Generated. Do not edit. See above. */
965 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, true);
966 : : }
967 : :
968 : : /** @brief Convert hardware cycles to nanoseconds
969 : : *
970 : : * Converts time values in hardware cycles to nanoseconds.
971 : : * Computes result in 32 bit precision.
972 : : * Rounds up to the next highest output unit.
973 : : *
974 : : * @return The converted time value
975 : : */
976 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ns_ceil32(uint32_t t)
977 : : {
978 : : /* Generated. Do not edit. See above. */
979 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, true, false);
980 : : }
981 : :
982 : : /** @brief Convert hardware cycles to nanoseconds
983 : : *
984 : : * Converts time values in hardware cycles to nanoseconds.
985 : : * Computes result in 64 bit precision.
986 : : * Rounds up to the next highest output unit.
987 : : *
988 : : * @return The converted time value
989 : : */
990 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ns_ceil64(uint64_t t)
991 : : {
992 : : /* Generated. Do not edit. See above. */
993 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true, false);
994 : : }
995 : :
996 : : /** @brief Convert hardware cycles to ticks
997 : : *
998 : : * Converts time values in hardware cycles to ticks.
999 : : * Computes result in 32 bit precision.
1000 : : * Truncates to the next lowest output unit.
1001 : : *
1002 : : * @return The converted time value
1003 : : */
1004 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ticks_floor32(uint32_t t)
1005 : : {
1006 : : /* Generated. Do not edit. See above. */
1007 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, false);
1008 : : }
1009 : :
1010 : : /** @brief Convert hardware cycles to ticks
1011 : : *
1012 : : * Converts time values in hardware cycles to ticks.
1013 : : * Computes result in 64 bit precision.
1014 : : * Truncates to the next lowest output unit.
1015 : : *
1016 : : * @return The converted time value
1017 : : */
1018 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ticks_floor64(uint64_t t)
1019 : : {
1020 : : /* Generated. Do not edit. See above. */
1021 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, false);
1022 : : }
1023 : :
1024 : : /** @brief Convert hardware cycles to ticks
1025 : : *
1026 : : * Converts time values in hardware cycles to ticks.
1027 : : * Computes result in 32 bit precision.
1028 : : * Rounds to the nearest output unit.
1029 : : *
1030 : : * @return The converted time value
1031 : : */
1032 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ticks_near32(uint32_t t)
1033 : : {
1034 : : /* Generated. Do not edit. See above. */
1035 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false, true);
1036 : : }
1037 : :
1038 : : /** @brief Convert hardware cycles to ticks
1039 : : *
1040 : : * Converts time values in hardware cycles to ticks.
1041 : : * Computes result in 64 bit precision.
1042 : : * Rounds to the nearest output unit.
1043 : : *
1044 : : * @return The converted time value
1045 : : */
1046 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ticks_near64(uint64_t t)
1047 : : {
1048 : : /* Generated. Do not edit. See above. */
1049 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false, true);
1050 : : }
1051 : :
1052 : : /** @brief Convert hardware cycles to ticks
1053 : : *
1054 : : * Converts time values in hardware cycles to ticks.
1055 : : * Computes result in 32 bit precision.
1056 : : * Rounds up to the next highest output unit.
1057 : : *
1058 : : * @return The converted time value
1059 : : */
1060 : : static TIME_CONSTEXPR inline uint32_t k_cyc_to_ticks_ceil32(uint32_t t)
1061 : : {
1062 : : /* Generated. Do not edit. See above. */
1063 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, true, false);
1064 : : }
1065 : :
1066 : : /** @brief Convert hardware cycles to ticks
1067 : : *
1068 : : * Converts time values in hardware cycles to ticks.
1069 : : * Computes result in 64 bit precision.
1070 : : * Rounds up to the next highest output unit.
1071 : : *
1072 : : * @return The converted time value
1073 : : */
1074 : : static TIME_CONSTEXPR inline uint64_t k_cyc_to_ticks_ceil64(uint64_t t)
1075 : : {
1076 : : /* Generated. Do not edit. See above. */
1077 : : return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true, false);
1078 : : }
1079 : :
1080 : : /** @brief Convert ticks to milliseconds
1081 : : *
1082 : : * Converts time values in ticks to milliseconds.
1083 : : * Computes result in 32 bit precision.
1084 : : * Truncates to the next lowest output unit.
1085 : : *
1086 : : * @return The converted time value
1087 : : */
1088 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_ms_floor32(uint32_t t)
1089 : : {
1090 : : /* Generated. Do not edit. See above. */
1091 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, false);
1092 : : }
1093 : :
1094 : : /** @brief Convert ticks to milliseconds
1095 : : *
1096 : : * Converts time values in ticks to milliseconds.
1097 : : * Computes result in 64 bit precision.
1098 : : * Truncates to the next lowest output unit.
1099 : : *
1100 : : * @return The converted time value
1101 : : */
1102 : 0 : static TIME_CONSTEXPR inline uint64_t k_ticks_to_ms_floor64(uint64_t t)
1103 : : {
1104 : : /* Generated. Do not edit. See above. */
1105 : 0 : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, false);
1106 : : }
1107 : :
1108 : : /** @brief Convert ticks to milliseconds
1109 : : *
1110 : : * Converts time values in ticks to milliseconds.
1111 : : * Computes result in 32 bit precision.
1112 : : * Rounds to the nearest output unit.
1113 : : *
1114 : : * @return The converted time value
1115 : : */
1116 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_ms_near32(uint32_t t)
1117 : : {
1118 : : /* Generated. Do not edit. See above. */
1119 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, false, true);
1120 : : }
1121 : :
1122 : : /** @brief Convert ticks to milliseconds
1123 : : *
1124 : : * Converts time values in ticks to milliseconds.
1125 : : * Computes result in 64 bit precision.
1126 : : * Rounds to the nearest output unit.
1127 : : *
1128 : : * @return The converted time value
1129 : : */
1130 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_ms_near64(uint64_t t)
1131 : : {
1132 : : /* Generated. Do not edit. See above. */
1133 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, false, true);
1134 : : }
1135 : :
1136 : : /** @brief Convert ticks to milliseconds
1137 : : *
1138 : : * Converts time values in ticks to milliseconds.
1139 : : * Computes result in 32 bit precision.
1140 : : * Rounds up to the next highest output unit.
1141 : : *
1142 : : * @return The converted time value
1143 : : */
1144 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_ms_ceil32(uint32_t t)
1145 : : {
1146 : : /* Generated. Do not edit. See above. */
1147 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, true, true, false);
1148 : : }
1149 : :
1150 : : /** @brief Convert ticks to milliseconds
1151 : : *
1152 : : * Converts time values in ticks to milliseconds.
1153 : : * Computes result in 64 bit precision.
1154 : : * Rounds up to the next highest output unit.
1155 : : *
1156 : : * @return The converted time value
1157 : : */
1158 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_ms_ceil64(uint64_t t)
1159 : : {
1160 : : /* Generated. Do not edit. See above. */
1161 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, true, false);
1162 : : }
1163 : :
1164 : : /** @brief Convert ticks to microseconds
1165 : : *
1166 : : * Converts time values in ticks to microseconds.
1167 : : * Computes result in 32 bit precision.
1168 : : * Truncates to the next lowest output unit.
1169 : : *
1170 : : * @return The converted time value
1171 : : */
1172 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_us_floor32(uint32_t t)
1173 : : {
1174 : : /* Generated. Do not edit. See above. */
1175 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, false);
1176 : : }
1177 : :
1178 : : /** @brief Convert ticks to microseconds
1179 : : *
1180 : : * Converts time values in ticks to microseconds.
1181 : : * Computes result in 64 bit precision.
1182 : : * Truncates to the next lowest output unit.
1183 : : *
1184 : : * @return The converted time value
1185 : : */
1186 : 0 : static TIME_CONSTEXPR inline uint64_t k_ticks_to_us_floor64(uint64_t t)
1187 : : {
1188 : : /* Generated. Do not edit. See above. */
1189 : 0 : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, false);
1190 : : }
1191 : :
1192 : : /** @brief Convert ticks to microseconds
1193 : : *
1194 : : * Converts time values in ticks to microseconds.
1195 : : * Computes result in 32 bit precision.
1196 : : * Rounds to the nearest output unit.
1197 : : *
1198 : : * @return The converted time value
1199 : : */
1200 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_us_near32(uint32_t t)
1201 : : {
1202 : : /* Generated. Do not edit. See above. */
1203 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, true);
1204 : : }
1205 : :
1206 : : /** @brief Convert ticks to microseconds
1207 : : *
1208 : : * Converts time values in ticks to microseconds.
1209 : : * Computes result in 64 bit precision.
1210 : : * Rounds to the nearest output unit.
1211 : : *
1212 : : * @return The converted time value
1213 : : */
1214 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_us_near64(uint64_t t)
1215 : : {
1216 : : /* Generated. Do not edit. See above. */
1217 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, true);
1218 : : }
1219 : :
1220 : : /** @brief Convert ticks to microseconds
1221 : : *
1222 : : * Converts time values in ticks to microseconds.
1223 : : * Computes result in 32 bit precision.
1224 : : * Rounds up to the next highest output unit.
1225 : : *
1226 : : * @return The converted time value
1227 : : */
1228 : 0 : static TIME_CONSTEXPR inline uint32_t k_ticks_to_us_ceil32(uint32_t t)
1229 : : {
1230 : : /* Generated. Do not edit. See above. */
1231 : 0 : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, true, false);
1232 : : }
1233 : :
1234 : : /** @brief Convert ticks to microseconds
1235 : : *
1236 : : * Converts time values in ticks to microseconds.
1237 : : * Computes result in 64 bit precision.
1238 : : * Rounds up to the next highest output unit.
1239 : : *
1240 : : * @return The converted time value
1241 : : */
1242 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_us_ceil64(uint64_t t)
1243 : : {
1244 : : /* Generated. Do not edit. See above. */
1245 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, true, false);
1246 : : }
1247 : :
1248 : : /** @brief Convert ticks to nanoseconds
1249 : : *
1250 : : * Converts time values in ticks to nanoseconds.
1251 : : * Computes result in 32 bit precision.
1252 : : * Truncates to the next lowest output unit.
1253 : : *
1254 : : * @return The converted time value
1255 : : */
1256 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_ns_floor32(uint32_t t)
1257 : : {
1258 : : /* Generated. Do not edit. See above. */
1259 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, false);
1260 : : }
1261 : :
1262 : : /** @brief Convert ticks to nanoseconds
1263 : : *
1264 : : * Converts time values in ticks to nanoseconds.
1265 : : * Computes result in 64 bit precision.
1266 : : * Truncates to the next lowest output unit.
1267 : : *
1268 : : * @return The converted time value
1269 : : */
1270 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_ns_floor64(uint64_t t)
1271 : : {
1272 : : /* Generated. Do not edit. See above. */
1273 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, false);
1274 : : }
1275 : :
1276 : : /** @brief Convert ticks to nanoseconds
1277 : : *
1278 : : * Converts time values in ticks to nanoseconds.
1279 : : * Computes result in 32 bit precision.
1280 : : * Rounds to the nearest output unit.
1281 : : *
1282 : : * @return The converted time value
1283 : : */
1284 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_ns_near32(uint32_t t)
1285 : : {
1286 : : /* Generated. Do not edit. See above. */
1287 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, true);
1288 : : }
1289 : :
1290 : : /** @brief Convert ticks to nanoseconds
1291 : : *
1292 : : * Converts time values in ticks to nanoseconds.
1293 : : * Computes result in 64 bit precision.
1294 : : * Rounds to the nearest output unit.
1295 : : *
1296 : : * @return The converted time value
1297 : : */
1298 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_ns_near64(uint64_t t)
1299 : : {
1300 : : /* Generated. Do not edit. See above. */
1301 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, true);
1302 : : }
1303 : :
1304 : : /** @brief Convert ticks to nanoseconds
1305 : : *
1306 : : * Converts time values in ticks to nanoseconds.
1307 : : * Computes result in 32 bit precision.
1308 : : * Rounds up to the next highest output unit.
1309 : : *
1310 : : * @return The converted time value
1311 : : */
1312 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_ns_ceil32(uint32_t t)
1313 : : {
1314 : : /* Generated. Do not edit. See above. */
1315 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, true, false);
1316 : : }
1317 : :
1318 : : /** @brief Convert ticks to nanoseconds
1319 : : *
1320 : : * Converts time values in ticks to nanoseconds.
1321 : : * Computes result in 64 bit precision.
1322 : : * Rounds up to the next highest output unit.
1323 : : *
1324 : : * @return The converted time value
1325 : : */
1326 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_ns_ceil64(uint64_t t)
1327 : : {
1328 : : /* Generated. Do not edit. See above. */
1329 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, true, false);
1330 : : }
1331 : :
1332 : : /** @brief Convert ticks to hardware cycles
1333 : : *
1334 : : * Converts time values in ticks to hardware cycles.
1335 : : * Computes result in 32 bit precision.
1336 : : * Truncates to the next lowest output unit.
1337 : : *
1338 : : * @return The converted time value
1339 : : */
1340 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_cyc_floor32(uint32_t t)
1341 : : {
1342 : : /* Generated. Do not edit. See above. */
1343 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, false);
1344 : : }
1345 : :
1346 : : /** @brief Convert ticks to hardware cycles
1347 : : *
1348 : : * Converts time values in ticks to hardware cycles.
1349 : : * Computes result in 64 bit precision.
1350 : : * Truncates to the next lowest output unit.
1351 : : *
1352 : : * @return The converted time value
1353 : : */
1354 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_cyc_floor64(uint64_t t)
1355 : : {
1356 : : /* Generated. Do not edit. See above. */
1357 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, false);
1358 : : }
1359 : :
1360 : : /** @brief Convert ticks to hardware cycles
1361 : : *
1362 : : * Converts time values in ticks to hardware cycles.
1363 : : * Computes result in 32 bit precision.
1364 : : * Rounds to the nearest output unit.
1365 : : *
1366 : : * @return The converted time value
1367 : : */
1368 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_cyc_near32(uint32_t t)
1369 : : {
1370 : : /* Generated. Do not edit. See above. */
1371 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false, true);
1372 : : }
1373 : :
1374 : : /** @brief Convert ticks to hardware cycles
1375 : : *
1376 : : * Converts time values in ticks to hardware cycles.
1377 : : * Computes result in 64 bit precision.
1378 : : * Rounds to the nearest output unit.
1379 : : *
1380 : : * @return The converted time value
1381 : : */
1382 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_cyc_near64(uint64_t t)
1383 : : {
1384 : : /* Generated. Do not edit. See above. */
1385 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false, true);
1386 : : }
1387 : :
1388 : : /** @brief Convert ticks to hardware cycles
1389 : : *
1390 : : * Converts time values in ticks to hardware cycles.
1391 : : * Computes result in 32 bit precision.
1392 : : * Rounds up to the next highest output unit.
1393 : : *
1394 : : * @return The converted time value
1395 : : */
1396 : : static TIME_CONSTEXPR inline uint32_t k_ticks_to_cyc_ceil32(uint32_t t)
1397 : : {
1398 : : /* Generated. Do not edit. See above. */
1399 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, true, false);
1400 : : }
1401 : :
1402 : : /** @brief Convert ticks to hardware cycles
1403 : : *
1404 : : * Converts time values in ticks to hardware cycles.
1405 : : * Computes result in 64 bit precision.
1406 : : * Rounds up to the next highest output unit.
1407 : : *
1408 : : * @return The converted time value
1409 : : */
1410 : : static TIME_CONSTEXPR inline uint64_t k_ticks_to_cyc_ceil64(uint64_t t)
1411 : : {
1412 : : /* Generated. Do not edit. See above. */
1413 : : return z_tmcvt(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true, false);
1414 : : }
1415 : :
1416 : : #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
1417 : : #include <syscalls/time_units.h>
1418 : : #endif
1419 : :
1420 : : #undef TIME_CONSTEXPR
1421 : :
1422 : : #ifdef __cplusplus
1423 : : } /* extern "C" */
1424 : : #endif
1425 : :
1426 : : #endif /* ZEPHYR_INCLUDE_TIME_UNITS_H_ */
|