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
14 extern "C" {
15 #endif
16
17 /**
18 * @file
19 * @defgroup timeutil_unit_apis Time Units Helpers
20 * @ingroup timeutil_apis
21 *
22 * @brief Various helper APIs for converting between time units.
23 * @{
24 */
25
26 /** @brief System-wide macro to denote "forever" in milliseconds
27 *
28 * Usage of this macro is limited to APIs that want to expose a timeout value
29 * that can optionally be unlimited, or "forever".
30 * This macro can not be fed into kernel functions or macros directly. Use
31 * @ref SYS_TIMEOUT_MS instead.
32 */
33 #define SYS_FOREVER_MS (-1)
34
35 /** @brief System-wide macro to denote "forever" in microseconds
36 *
37 * See @ref SYS_FOREVER_MS.
38 */
39 #define SYS_FOREVER_US (-1)
40
41 /** @brief System-wide macro to initialize #k_timeout_t with a number of ticks
42 * converted from milliseconds.
43 */
44 #define SYS_TIMEOUT_MS_INIT(ms) \
45 Z_TIMEOUT_TICKS_INIT((ms) == SYS_FOREVER_MS ? \
46 K_TICKS_FOREVER : Z_TIMEOUT_MS_TICKS(ms))
47
48 /** @brief System-wide macro to convert milliseconds to kernel timeouts
49 */
50 #define SYS_TIMEOUT_MS(ms) ((k_timeout_t) SYS_TIMEOUT_MS_INIT(ms))
51
52 /* Exhaustively enumerated, highly optimized time unit conversion API */
53
54 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
55 __syscall int sys_clock_hw_cycles_per_sec_runtime_get(void);
56
z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)57 static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
58 {
59 extern int z_clock_hw_cycles_per_sec;
60
61 return z_clock_hw_cycles_per_sec;
62 }
63 #endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
64
65 #if defined(__cplusplus) && (__cplusplus >= 201402L)
66 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
67 #define TIME_CONSTEXPR
68 #else
69 #define TIME_CONSTEXPR constexpr
70 #endif
71 #else
72 #define TIME_CONSTEXPR
73 #endif
74
75 /**
76 * @brief Get the system timer frequency.
77 * @return system timer frequency in Hz
78 */
79 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
80 #define sys_clock_hw_cycles_per_sec() sys_clock_hw_cycles_per_sec_runtime_get()
81 #else
82 #define sys_clock_hw_cycles_per_sec() CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
83 #endif
84
85 /** @internal
86 * Macro determines if fast conversion algorithm can be used. It checks if
87 * maximum timeout represented in source frequency domain and multiplied by
88 * target frequency fits in 64 bits.
89 *
90 * @param from_hz Source frequency.
91 * @param to_hz Target frequency.
92 *
93 * @retval true Use faster algorithm.
94 * @retval false Use algorithm preventing overflow of intermediate value.
95 */
96 #define z_tmcvt_use_fast_algo(from_hz, to_hz) \
97 ((DIV_ROUND_UP(CONFIG_SYS_CLOCK_MAX_TIMEOUT_DAYS * 24ULL * 3600ULL * from_hz, \
98 UINT32_MAX) * to_hz) <= UINT32_MAX)
99
100 /* Time converter generator gadget. Selects from one of three
101 * conversion algorithms: ones that take advantage when the
102 * frequencies are an integer ratio (in either direction), or a full
103 * precision conversion. Clever use of extra arguments causes all the
104 * selection logic to be optimized out, and the generated code even
105 * reduces to 32 bit only if a ratio conversion is available and the
106 * result is 32 bits.
107 *
108 * This isn't intended to be used directly, instead being wrapped
109 * appropriately in a user-facing API. The boolean arguments are:
110 *
111 * const_hz - The hz arguments are known to be compile-time
112 * constants (because otherwise the modulus test would
113 * have to be done at runtime)
114 * result32 - The result will be truncated to 32 bits on use
115 * round_up - Return the ceiling of the resulting fraction
116 * round_off - Return the nearest value to the resulting fraction
117 * (pass both round_up/off as false to get "round_down")
118 *
119 * All of this must be implemented as expressions so that, when constant,
120 * the results may be used to initialize global variables.
121 */
122
123 /* true if the conversion is the identity */
124 #define z_tmcvt_is_identity(__from_hz, __to_hz) \
125 ((__to_hz) == (__from_hz))
126
127 /* true if the conversion requires a simple integer multiply */
128 #define z_tmcvt_is_int_mul(__from_hz, __to_hz) \
129 ((__to_hz) > (__from_hz) && (__to_hz) % (__from_hz) == 0U)
130
131 /* true if the conversion requires a simple integer division */
132 #define z_tmcvt_is_int_div(__from_hz, __to_hz) \
133 ((__from_hz) > (__to_hz) && (__from_hz) % (__to_hz) == 0U)
134
135 /*
136 * Compute the offset needed to round the result correctly when
137 * the conversion requires a simple integer division
138 */
139 #define z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) \
140 ((__round_off) ? ((__from_hz) / (__to_hz)) / 2 : \
141 (__round_up) ? ((__from_hz) / (__to_hz)) - 1 : \
142 0)
143
144 /*
145 * All users of this macro MUST ensure its output is never used when a/b
146 * is zero because it incorrectly but by design never returns zero.
147 *
148 * Some compiler versions emit a divide-by-zero warning for this code:
149 * "false ? 42/0 : 43". Dealing with (generated) dead code is hard:
150 * https://github.com/zephyrproject-rtos/zephyr/issues/63564
151 * https://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html
152 *
153 * To silence such divide-by-zero warnings, "cheat" and never return
154 * zero. Return 1 instead. Use octal "01u" as a breadcrumb to ease a
155 * little bit the huge pain of "reverse-engineering" pre-processor
156 * output.
157 *
158 * The "Elvis" operator "a/b ?: 1" is tempting because it avoids
159 * evaluating the same expression twice. However: 1. it's a non-standard
160 * GNU extension; 2. everything in this file is designed to be computed
161 * at compile time anyway.
162 */
163 #define z_tmcvt_divisor(a, b) ((a)/(b) ? (a)/(b) : 01u)
164
165 /*
166 * Compute the offset needed to round the result correctly when
167 * the conversion requires a full mul/div
168 */
169 #define z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off) \
170 ((__round_off) ? (__from_hz) / 2 : \
171 (__round_up) ? (__from_hz) - 1 : \
172 0)
173
174 /* Integer division 32-bit conversion */
175 #define z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
176 ((uint64_t) (__t) <= 0xffffffffU - \
177 z_tmcvt_off_div(__from_hz, __to_hz, __round_up, __round_off) ? \
178 ((uint32_t)((__t) + \
179 z_tmcvt_off_div(__from_hz, __to_hz, \
180 __round_up, __round_off)) / \
181 z_tmcvt_divisor(__from_hz, __to_hz)) \
182 : \
183 (uint32_t) (((uint64_t) (__t) + \
184 z_tmcvt_off_div(__from_hz, __to_hz, \
185 __round_up, __round_off)) / \
186 z_tmcvt_divisor(__from_hz, __to_hz)) \
187 )
188
189 /* Integer multiplication 32-bit conversion */
190 #define z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \
191 (uint32_t) (__t)*((__to_hz) / (__from_hz))
192
193 /* General 32-bit conversion */
194 #define z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
195 ((uint32_t) (((uint64_t) (__t)*(__to_hz) + \
196 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz)))
197
198 /* Integer division 64-bit conversion */
199 #define z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
200 (((uint64_t) (__t) + z_tmcvt_off_div(__from_hz, __to_hz, \
201 __round_up, __round_off)) / \
202 z_tmcvt_divisor(__from_hz, __to_hz))
203
204 /* Integer multiplication 64-bit conversion */
205 #define z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \
206 (uint64_t) (__t)*((__to_hz) / (__from_hz))
207
208 /* Fast 64-bit conversion. This relies on the multiply not overflowing */
209 #define z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) \
210 (((uint64_t) (__t)*(__to_hz) + \
211 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))
212
213 /* Slow 64-bit conversion. This avoids overflowing the multiply */
214 #define z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \
215 (((uint64_t) (__t) / (__from_hz))*(__to_hz) + \
216 (((uint64_t) (__t) % (__from_hz))*(__to_hz) + \
217 z_tmcvt_off_gen(__from_hz, __to_hz, __round_up, __round_off)) / (__from_hz))
218
219 /* General 64-bit conversion. Uses one of the two above macros */
220 #define z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
221 (z_tmcvt_use_fast_algo(__from_hz, __to_hz) ? \
222 z_tmcvt_gen_64_fast(__t, __from_hz, __to_hz, __round_up, __round_off) : \
223 z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off))
224
225 /* Convert, generating a 32-bit result */
226 #define z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \
227 ((__const_hz) ? \
228 ( \
229 z_tmcvt_is_identity(__from_hz, __to_hz) ? \
230 (uint32_t) (__t) \
231 : \
232 z_tmcvt_is_int_div(__from_hz, __to_hz) ? \
233 z_tmcvt_int_div_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
234 : \
235 z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \
236 z_tmcvt_int_mul_32(__t, __from_hz, __to_hz) \
237 : \
238 z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
239 ) \
240 : \
241 z_tmcvt_gen_32(__t, __from_hz, __to_hz, __round_up, __round_off) \
242 )
243
244 /* Convert, generating a 64-bit result */
245 #define z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) \
246 ((__const_hz) ? \
247 ( \
248 z_tmcvt_is_identity(__from_hz, __to_hz) ? \
249 (uint64_t) (__t) \
250 : \
251 z_tmcvt_is_int_div(__from_hz, __to_hz) ? \
252 z_tmcvt_int_div_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
253 : \
254 z_tmcvt_is_int_mul(__from_hz, __to_hz) ? \
255 z_tmcvt_int_mul_64(__t, __from_hz, __to_hz) \
256 : \
257 z_tmcvt_gen_64(__t, __from_hz, __to_hz, __round_up, __round_off) \
258 ) \
259 : \
260 z_tmcvt_gen_64_slow(__t, __from_hz, __to_hz, __round_up, __round_off) \
261 )
262
263 #define z_tmcvt(__t, __from_hz, __to_hz, __const_hz, __result32, __round_up, __round_off) \
264 ((__result32) ? \
265 z_tmcvt_32(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off) : \
266 z_tmcvt_64(__t, __from_hz, __to_hz, __const_hz, __round_up, __round_off))
267
268 /* The following code is programmatically generated using this perl
269 * code, which enumerates all possible combinations of units, rounding
270 * modes and precision. Do not edit directly.
271 *
272 * Note that nano/microsecond conversions are only defined with 64 bit
273 * precision. These units conversions were not available in 32 bit
274 * variants historically, and doing 32 bit math with units that small
275 * has precision traps that we probably don't want to support in an
276 * official API.
277 *
278 * #!/usr/bin/perl -w
279 * use strict;
280 *
281 * my %human = ("sec" => "seconds",
282 * "ms" => "milliseconds",
283 * "us" => "microseconds",
284 * "ns" => "nanoseconds",
285 * "cyc" => "hardware cycles",
286 * "ticks" => "ticks");
287 * my %human_round = ("ceil" => "Rounds up",
288 * "near" => "Round nearest",
289 * "floor" => "Truncates");
290 *
291 * sub big { return $_[0] eq "us" || $_[0] eq "ns"; }
292 * sub prefix { return $_[0] eq "sec" || $_[0] eq "ms" || $_[0] eq "us" || $_[0] eq "ns"; }
293 *
294 * for my $from_unit ("sec", "ms", "us", "ns", "cyc", "ticks") {
295 * for my $to_unit ("sec", "ms", "us", "ns", "cyc", "ticks") {
296 * next if $from_unit eq $to_unit;
297 * next if prefix($from_unit) && prefix($to_unit);
298 * for my $round ("floor", "near", "ceil") {
299 * for(my $big=0; $big <= 1; $big++) {
300 * my $sz = $big ? 64 : 32;
301 * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz";
302 * my $type = "uint${sz}_t";
303 * my $const_hz = ($from_unit eq "cyc" || $to_unit eq "cyc")
304 * ? "Z_CCYC" : "true";
305 * my $ret32 = $big ? "64" : "32";
306 * my $rup = $round eq "ceil" ? "true" : "false";
307 * my $roff = $round eq "near" ? "true" : "false";
308 *
309 * my $hfrom = $human{$from_unit};
310 * my $hto = $human{$to_unit};
311 * my $hround = $human_round{$round};
312 * print "/", "** \@brief Convert $hfrom to $hto. $ret32 bits. $hround.\n";
313 * print " *\n";
314 * print " * Converts time values in $hfrom to $hto.\n";
315 * print " * Computes result in $sz bit precision.\n";
316 * if ($round eq "ceil") {
317 * print " * Rounds up to the next highest output unit.\n";
318 * } elsif ($round eq "near") {
319 * print " * Rounds to the nearest output unit.\n";
320 * } else {
321 * print " * Truncates to the next lowest output unit.\n";
322 * }
323 * print " *\n";
324 * print " * \@warning Generated. Do not edit. See above.\n";
325 * print " *\n";
326 * print " * \@param t Source time in $hfrom. uint64_t\n";
327 * print " *\n";
328 * print " * \@return The converted time value in $hto. $type\n";
329 * print " *", "/\n";
330 * print "#define $sym(t) \\\n";
331 * print "\tz_tmcvt_$ret32(t, Z_HZ_$from_unit, Z_HZ_$to_unit,";
332 * print " $const_hz, $rup, $roff)\n";
333 * print "\n\n";
334 * }
335 * }
336 * }
337 * }
338 */
339
340 /* Some more concise declarations to simplify the generator script and
341 * save bytes below
342 */
343 #define Z_HZ_sec 1
344 #define Z_HZ_ms 1000
345 #define Z_HZ_us 1000000
346 #define Z_HZ_ns 1000000000
347 #define Z_HZ_cyc sys_clock_hw_cycles_per_sec()
348 #define Z_HZ_ticks CONFIG_SYS_CLOCK_TICKS_PER_SEC
349 #define Z_CCYC (!IS_ENABLED(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME))
350
351 /** @brief Convert seconds to hardware cycles. 32 bits. Truncates.
352 *
353 * Converts time values in seconds to hardware cycles.
354 * Computes result in 32 bit precision.
355 * Truncates to the next lowest output unit.
356 *
357 * @warning Generated. Do not edit. See above.
358 *
359 * @param t Source time in seconds. uint64_t
360 *
361 * @return The converted time value in hardware cycles. uint32_t
362 */
363 #define k_sec_to_cyc_floor32(t) \
364 z_tmcvt_32(t, Z_HZ_sec, Z_HZ_cyc, Z_CCYC, false, false)
365
366
367 /** @brief Convert seconds to hardware cycles. 64 bits. Truncates.
368 *
369 * Converts time values in seconds to hardware cycles.
370 * Computes result in 64 bit precision.
371 * Truncates to the next lowest output unit.
372 *
373 * @warning Generated. Do not edit. See above.
374 *
375 * @param t Source time in seconds. uint64_t
376 *
377 * @return The converted time value in hardware cycles. uint64_t
378 */
379 #define k_sec_to_cyc_floor64(t) \
380 z_tmcvt_64(t, Z_HZ_sec, Z_HZ_cyc, Z_CCYC, false, false)
381
382
383 /** @brief Convert seconds to hardware cycles. 32 bits. Round nearest.
384 *
385 * Converts time values in seconds to hardware cycles.
386 * Computes result in 32 bit precision.
387 * Rounds to the nearest output unit.
388 *
389 * @warning Generated. Do not edit. See above.
390 *
391 * @param t Source time in seconds. uint64_t
392 *
393 * @return The converted time value in hardware cycles. uint32_t
394 */
395 #define k_sec_to_cyc_near32(t) \
396 z_tmcvt_32(t, Z_HZ_sec, Z_HZ_cyc, Z_CCYC, false, true)
397
398
399 /** @brief Convert seconds to hardware cycles. 64 bits. Round nearest.
400 *
401 * Converts time values in seconds to hardware cycles.
402 * Computes result in 64 bit precision.
403 * Rounds to the nearest output unit.
404 *
405 * @warning Generated. Do not edit. See above.
406 *
407 * @param t Source time in seconds. uint64_t
408 *
409 * @return The converted time value in hardware cycles. uint64_t
410 */
411 #define k_sec_to_cyc_near64(t) \
412 z_tmcvt_64(t, Z_HZ_sec, Z_HZ_cyc, Z_CCYC, false, true)
413
414
415 /** @brief Convert seconds to hardware cycles. 32 bits. Rounds up.
416 *
417 * Converts time values in seconds to hardware cycles.
418 * Computes result in 32 bit precision.
419 * Rounds up to the next highest output unit.
420 *
421 * @warning Generated. Do not edit. See above.
422 *
423 * @param t Source time in seconds. uint64_t
424 *
425 * @return The converted time value in hardware cycles. uint32_t
426 */
427 #define k_sec_to_cyc_ceil32(t) \
428 z_tmcvt_32(t, Z_HZ_sec, Z_HZ_cyc, Z_CCYC, true, false)
429
430
431 /** @brief Convert seconds to hardware cycles. 64 bits. Rounds up.
432 *
433 * Converts time values in seconds to hardware cycles.
434 * Computes result in 64 bit precision.
435 * Rounds up to the next highest output unit.
436 *
437 * @warning Generated. Do not edit. See above.
438 *
439 * @param t Source time in seconds. uint64_t
440 *
441 * @return The converted time value in hardware cycles. uint64_t
442 */
443 #define k_sec_to_cyc_ceil64(t) \
444 z_tmcvt_64(t, Z_HZ_sec, Z_HZ_cyc, Z_CCYC, true, false)
445
446
447 /** @brief Convert seconds to ticks. 32 bits. Truncates.
448 *
449 * Converts time values in seconds to ticks.
450 * Computes result in 32 bit precision.
451 * Truncates to the next lowest output unit.
452 *
453 * @warning Generated. Do not edit. See above.
454 *
455 * @param t Source time in seconds. uint64_t
456 *
457 * @return The converted time value in ticks. uint32_t
458 */
459 #define k_sec_to_ticks_floor32(t) \
460 z_tmcvt_32(t, Z_HZ_sec, Z_HZ_ticks, true, false, false)
461
462
463 /** @brief Convert seconds to ticks. 64 bits. Truncates.
464 *
465 * Converts time values in seconds to ticks.
466 * Computes result in 64 bit precision.
467 * Truncates to the next lowest output unit.
468 *
469 * @warning Generated. Do not edit. See above.
470 *
471 * @param t Source time in seconds. uint64_t
472 *
473 * @return The converted time value in ticks. uint64_t
474 */
475 #define k_sec_to_ticks_floor64(t) \
476 z_tmcvt_64(t, Z_HZ_sec, Z_HZ_ticks, true, false, false)
477
478
479 /** @brief Convert seconds to ticks. 32 bits. Round nearest.
480 *
481 * Converts time values in seconds to ticks.
482 * Computes result in 32 bit precision.
483 * Rounds to the nearest output unit.
484 *
485 * @warning Generated. Do not edit. See above.
486 *
487 * @param t Source time in seconds. uint64_t
488 *
489 * @return The converted time value in ticks. uint32_t
490 */
491 #define k_sec_to_ticks_near32(t) \
492 z_tmcvt_32(t, Z_HZ_sec, Z_HZ_ticks, true, false, true)
493
494
495 /** @brief Convert seconds to ticks. 64 bits. Round nearest.
496 *
497 * Converts time values in seconds to ticks.
498 * Computes result in 64 bit precision.
499 * Rounds to the nearest output unit.
500 *
501 * @warning Generated. Do not edit. See above.
502 *
503 * @param t Source time in seconds. uint64_t
504 *
505 * @return The converted time value in ticks. uint64_t
506 */
507 #define k_sec_to_ticks_near64(t) \
508 z_tmcvt_64(t, Z_HZ_sec, Z_HZ_ticks, true, false, true)
509
510
511 /** @brief Convert seconds to ticks. 32 bits. Rounds up.
512 *
513 * Converts time values in seconds to ticks.
514 * Computes result in 32 bit precision.
515 * Rounds up to the next highest output unit.
516 *
517 * @warning Generated. Do not edit. See above.
518 *
519 * @param t Source time in seconds. uint64_t
520 *
521 * @return The converted time value in ticks. uint32_t
522 */
523 #define k_sec_to_ticks_ceil32(t) \
524 z_tmcvt_32(t, Z_HZ_sec, Z_HZ_ticks, true, true, false)
525
526
527 /** @brief Convert seconds to ticks. 64 bits. Rounds up.
528 *
529 * Converts time values in seconds to ticks.
530 * Computes result in 64 bit precision.
531 * Rounds up to the next highest output unit.
532 *
533 * @warning Generated. Do not edit. See above.
534 *
535 * @param t Source time in seconds. uint64_t
536 *
537 * @return The converted time value in ticks. uint64_t
538 */
539 #define k_sec_to_ticks_ceil64(t) \
540 z_tmcvt_64(t, Z_HZ_sec, Z_HZ_ticks, true, true, false)
541
542
543 /** @brief Convert milliseconds to hardware cycles. 32 bits. Truncates.
544 *
545 * Converts time values in milliseconds to hardware cycles.
546 * Computes result in 32 bit precision.
547 * Truncates to the next lowest output unit.
548 *
549 * @warning Generated. Do not edit. See above.
550 *
551 * @param t Source time in milliseconds. uint64_t
552 *
553 * @return The converted time value in hardware cycles. uint32_t
554 */
555 #define k_ms_to_cyc_floor32(t) \
556 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false)
557
558
559 /** @brief Convert milliseconds to hardware cycles. 64 bits. Truncates.
560 *
561 * Converts time values in milliseconds to hardware cycles.
562 * Computes result in 64 bit precision.
563 * Truncates to the next lowest output unit.
564 *
565 * @warning Generated. Do not edit. See above.
566 *
567 * @param t Source time in milliseconds. uint64_t
568 *
569 * @return The converted time value in hardware cycles. uint64_t
570 */
571 #define k_ms_to_cyc_floor64(t) \
572 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, false)
573
574
575 /** @brief Convert milliseconds to hardware cycles. 32 bits. Round nearest.
576 *
577 * Converts time values in milliseconds to hardware cycles.
578 * Computes result in 32 bit precision.
579 * Rounds to the nearest output unit.
580 *
581 * @warning Generated. Do not edit. See above.
582 *
583 * @param t Source time in milliseconds. uint64_t
584 *
585 * @return The converted time value in hardware cycles. uint32_t
586 */
587 #define k_ms_to_cyc_near32(t) \
588 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true)
589
590
591 /** @brief Convert milliseconds to hardware cycles. 64 bits. Round nearest.
592 *
593 * Converts time values in milliseconds to hardware cycles.
594 * Computes result in 64 bit precision.
595 * Rounds to the nearest output unit.
596 *
597 * @warning Generated. Do not edit. See above.
598 *
599 * @param t Source time in milliseconds. uint64_t
600 *
601 * @return The converted time value in hardware cycles. uint64_t
602 */
603 #define k_ms_to_cyc_near64(t) \
604 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, false, true)
605
606
607 /** @brief Convert milliseconds to hardware cycles. 32 bits. Rounds up.
608 *
609 * Converts time values in milliseconds to hardware cycles.
610 * Computes result in 32 bit precision.
611 * Rounds up to the next highest output unit.
612 *
613 * @warning Generated. Do not edit. See above.
614 *
615 * @param t Source time in milliseconds. uint64_t
616 *
617 * @return The converted time value in hardware cycles. uint32_t
618 */
619 #define k_ms_to_cyc_ceil32(t) \
620 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false)
621
622
623 /** @brief Convert milliseconds to hardware cycles. 64 bits. Rounds up.
624 *
625 * Converts time values in milliseconds to hardware cycles.
626 * Computes result in 64 bit precision.
627 * Rounds up to the next highest output unit.
628 *
629 * @warning Generated. Do not edit. See above.
630 *
631 * @param t Source time in milliseconds. uint64_t
632 *
633 * @return The converted time value in hardware cycles. uint64_t
634 */
635 #define k_ms_to_cyc_ceil64(t) \
636 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_cyc, Z_CCYC, true, false)
637
638
639 /** @brief Convert milliseconds to ticks. 32 bits. Truncates.
640 *
641 * Converts time values in milliseconds to ticks.
642 * Computes result in 32 bit precision.
643 * Truncates to the next lowest output unit.
644 *
645 * @warning Generated. Do not edit. See above.
646 *
647 * @param t Source time in milliseconds. uint64_t
648 *
649 * @return The converted time value in ticks. uint32_t
650 */
651 #define k_ms_to_ticks_floor32(t) \
652 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, false)
653
654
655 /** @brief Convert milliseconds to ticks. 64 bits. Truncates.
656 *
657 * Converts time values in milliseconds to ticks.
658 * Computes result in 64 bit precision.
659 * Truncates to the next lowest output unit.
660 *
661 * @warning Generated. Do not edit. See above.
662 *
663 * @param t Source time in milliseconds. uint64_t
664 *
665 * @return The converted time value in ticks. uint64_t
666 */
667 #define k_ms_to_ticks_floor64(t) \
668 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, false)
669
670
671 /** @brief Convert milliseconds to ticks. 32 bits. Round nearest.
672 *
673 * Converts time values in milliseconds to ticks.
674 * Computes result in 32 bit precision.
675 * Rounds to the nearest output unit.
676 *
677 * @warning Generated. Do not edit. See above.
678 *
679 * @param t Source time in milliseconds. uint64_t
680 *
681 * @return The converted time value in ticks. uint32_t
682 */
683 #define k_ms_to_ticks_near32(t) \
684 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, false, true)
685
686
687 /** @brief Convert milliseconds to ticks. 64 bits. Round nearest.
688 *
689 * Converts time values in milliseconds to ticks.
690 * Computes result in 64 bit precision.
691 * Rounds to the nearest output unit.
692 *
693 * @warning Generated. Do not edit. See above.
694 *
695 * @param t Source time in milliseconds. uint64_t
696 *
697 * @return The converted time value in ticks. uint64_t
698 */
699 #define k_ms_to_ticks_near64(t) \
700 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, false, true)
701
702
703 /** @brief Convert milliseconds to ticks. 32 bits. Rounds up.
704 *
705 * Converts time values in milliseconds to ticks.
706 * Computes result in 32 bit precision.
707 * Rounds up to the next highest output unit.
708 *
709 * @warning Generated. Do not edit. See above.
710 *
711 * @param t Source time in milliseconds. uint64_t
712 *
713 * @return The converted time value in ticks. uint32_t
714 */
715 #define k_ms_to_ticks_ceil32(t) \
716 z_tmcvt_32(t, Z_HZ_ms, Z_HZ_ticks, true, true, false)
717
718
719 /** @brief Convert milliseconds to ticks. 64 bits. Rounds up.
720 *
721 * Converts time values in milliseconds to ticks.
722 * Computes result in 64 bit precision.
723 * Rounds up to the next highest output unit.
724 *
725 * @warning Generated. Do not edit. See above.
726 *
727 * @param t Source time in milliseconds. uint64_t
728 *
729 * @return The converted time value in ticks. uint64_t
730 */
731 #define k_ms_to_ticks_ceil64(t) \
732 z_tmcvt_64(t, Z_HZ_ms, Z_HZ_ticks, true, true, false)
733
734
735 /** @brief Convert microseconds to hardware cycles. 32 bits. Truncates.
736 *
737 * Converts time values in microseconds to hardware cycles.
738 * Computes result in 32 bit precision.
739 * Truncates to the next lowest output unit.
740 *
741 * @warning Generated. Do not edit. See above.
742 *
743 * @param t Source time in microseconds. uint64_t
744 *
745 * @return The converted time value in hardware cycles. uint32_t
746 */
747 #define k_us_to_cyc_floor32(t) \
748 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false)
749
750
751 /** @brief Convert microseconds to hardware cycles. 64 bits. Truncates.
752 *
753 * Converts time values in microseconds to hardware cycles.
754 * Computes result in 64 bit precision.
755 * Truncates to the next lowest output unit.
756 *
757 * @warning Generated. Do not edit. See above.
758 *
759 * @param t Source time in microseconds. uint64_t
760 *
761 * @return The converted time value in hardware cycles. uint64_t
762 */
763 #define k_us_to_cyc_floor64(t) \
764 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false)
765
766
767 /** @brief Convert microseconds to hardware cycles. 32 bits. Round nearest.
768 *
769 * Converts time values in microseconds to hardware cycles.
770 * Computes result in 32 bit precision.
771 * Rounds to the nearest output unit.
772 *
773 * @warning Generated. Do not edit. See above.
774 *
775 * @param t Source time in microseconds. uint64_t
776 *
777 * @return The converted time value in hardware cycles. uint32_t
778 */
779 #define k_us_to_cyc_near32(t) \
780 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true)
781
782
783 /** @brief Convert microseconds to hardware cycles. 64 bits. Round nearest.
784 *
785 * Converts time values in microseconds to hardware cycles.
786 * Computes result in 64 bit precision.
787 * Rounds to the nearest output unit.
788 *
789 * @warning Generated. Do not edit. See above.
790 *
791 * @param t Source time in microseconds. uint64_t
792 *
793 * @return The converted time value in hardware cycles. uint64_t
794 */
795 #define k_us_to_cyc_near64(t) \
796 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true)
797
798
799 /** @brief Convert microseconds to hardware cycles. 32 bits. Rounds up.
800 *
801 * Converts time values in microseconds to hardware cycles.
802 * Computes result in 32 bit precision.
803 * Rounds up to the next highest output unit.
804 *
805 * @warning Generated. Do not edit. See above.
806 *
807 * @param t Source time in microseconds. uint64_t
808 *
809 * @return The converted time value in hardware cycles. uint32_t
810 */
811 #define k_us_to_cyc_ceil32(t) \
812 z_tmcvt_32(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false)
813
814
815 /** @brief Convert microseconds to hardware cycles. 64 bits. Rounds up.
816 *
817 * Converts time values in microseconds to hardware cycles.
818 * Computes result in 64 bit precision.
819 * Rounds up to the next highest output unit.
820 *
821 * @warning Generated. Do not edit. See above.
822 *
823 * @param t Source time in microseconds. uint64_t
824 *
825 * @return The converted time value in hardware cycles. uint64_t
826 */
827 #define k_us_to_cyc_ceil64(t) \
828 z_tmcvt_64(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false)
829
830
831 /** @brief Convert microseconds to ticks. 32 bits. Truncates.
832 *
833 * Converts time values in microseconds to ticks.
834 * Computes result in 32 bit precision.
835 * Truncates to the next lowest output unit.
836 *
837 * @warning Generated. Do not edit. See above.
838 *
839 * @param t Source time in microseconds. uint64_t
840 *
841 * @return The converted time value in ticks. uint32_t
842 */
843 #define k_us_to_ticks_floor32(t) \
844 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, false)
845
846
847 /** @brief Convert microseconds to ticks. 64 bits. Truncates.
848 *
849 * Converts time values in microseconds to ticks.
850 * Computes result in 64 bit precision.
851 * Truncates to the next lowest output unit.
852 *
853 * @warning Generated. Do not edit. See above.
854 *
855 * @param t Source time in microseconds. uint64_t
856 *
857 * @return The converted time value in ticks. uint64_t
858 */
859 #define k_us_to_ticks_floor64(t) \
860 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, false)
861
862
863 /** @brief Convert microseconds to ticks. 32 bits. Round nearest.
864 *
865 * Converts time values in microseconds to ticks.
866 * Computes result in 32 bit precision.
867 * Rounds to the nearest output unit.
868 *
869 * @warning Generated. Do not edit. See above.
870 *
871 * @param t Source time in microseconds. uint64_t
872 *
873 * @return The converted time value in ticks. uint32_t
874 */
875 #define k_us_to_ticks_near32(t) \
876 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, false, true)
877
878
879 /** @brief Convert microseconds to ticks. 64 bits. Round nearest.
880 *
881 * Converts time values in microseconds to ticks.
882 * Computes result in 64 bit precision.
883 * Rounds to the nearest output unit.
884 *
885 * @warning Generated. Do not edit. See above.
886 *
887 * @param t Source time in microseconds. uint64_t
888 *
889 * @return The converted time value in ticks. uint64_t
890 */
891 #define k_us_to_ticks_near64(t) \
892 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, false, true)
893
894
895 /** @brief Convert microseconds to ticks. 32 bits. Rounds up.
896 *
897 * Converts time values in microseconds to ticks.
898 * Computes result in 32 bit precision.
899 * Rounds up to the next highest output unit.
900 *
901 * @warning Generated. Do not edit. See above.
902 *
903 * @param t Source time in microseconds. uint64_t
904 *
905 * @return The converted time value in ticks. uint32_t
906 */
907 #define k_us_to_ticks_ceil32(t) \
908 z_tmcvt_32(t, Z_HZ_us, Z_HZ_ticks, true, true, false)
909
910
911 /** @brief Convert microseconds to ticks. 64 bits. Rounds up.
912 *
913 * Converts time values in microseconds to ticks.
914 * Computes result in 64 bit precision.
915 * Rounds up to the next highest output unit.
916 *
917 * @warning Generated. Do not edit. See above.
918 *
919 * @param t Source time in microseconds. uint64_t
920 *
921 * @return The converted time value in ticks. uint64_t
922 */
923 #define k_us_to_ticks_ceil64(t) \
924 z_tmcvt_64(t, Z_HZ_us, Z_HZ_ticks, true, true, false)
925
926
927 /** @brief Convert nanoseconds to hardware cycles. 32 bits. Truncates.
928 *
929 * Converts time values in nanoseconds to hardware cycles.
930 * Computes result in 32 bit precision.
931 * Truncates to the next lowest output unit.
932 *
933 * @warning Generated. Do not edit. See above.
934 *
935 * @param t Source time in nanoseconds. uint64_t
936 *
937 * @return The converted time value in hardware cycles. uint32_t
938 */
939 #define k_ns_to_cyc_floor32(t) \
940 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false)
941
942
943 /** @brief Convert nanoseconds to hardware cycles. 64 bits. Truncates.
944 *
945 * Converts time values in nanoseconds to hardware cycles.
946 * Computes result in 64 bit precision.
947 * Truncates to the next lowest output unit.
948 *
949 * @warning Generated. Do not edit. See above.
950 *
951 * @param t Source time in nanoseconds. uint64_t
952 *
953 * @return The converted time value in hardware cycles. uint64_t
954 */
955 #define k_ns_to_cyc_floor64(t) \
956 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false)
957
958
959 /** @brief Convert nanoseconds to hardware cycles. 32 bits. Round nearest.
960 *
961 * Converts time values in nanoseconds to hardware cycles.
962 * Computes result in 32 bit precision.
963 * Rounds to the nearest output unit.
964 *
965 * @warning Generated. Do not edit. See above.
966 *
967 * @param t Source time in nanoseconds. uint64_t
968 *
969 * @return The converted time value in hardware cycles. uint32_t
970 */
971 #define k_ns_to_cyc_near32(t) \
972 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true)
973
974
975 /** @brief Convert nanoseconds to hardware cycles. 64 bits. Round nearest.
976 *
977 * Converts time values in nanoseconds to hardware cycles.
978 * Computes result in 64 bit precision.
979 * Rounds to the nearest output unit.
980 *
981 * @warning Generated. Do not edit. See above.
982 *
983 * @param t Source time in nanoseconds. uint64_t
984 *
985 * @return The converted time value in hardware cycles. uint64_t
986 */
987 #define k_ns_to_cyc_near64(t) \
988 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true)
989
990
991 /** @brief Convert nanoseconds to hardware cycles. 32 bits. Rounds up.
992 *
993 * Converts time values in nanoseconds to hardware cycles.
994 * Computes result in 32 bit precision.
995 * Rounds up to the next highest output unit.
996 *
997 * @warning Generated. Do not edit. See above.
998 *
999 * @param t Source time in nanoseconds. uint64_t
1000 *
1001 * @return The converted time value in hardware cycles. uint32_t
1002 */
1003 #define k_ns_to_cyc_ceil32(t) \
1004 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false)
1005
1006
1007 /** @brief Convert nanoseconds to hardware cycles. 64 bits. Rounds up.
1008 *
1009 * Converts time values in nanoseconds to hardware cycles.
1010 * Computes result in 64 bit precision.
1011 * Rounds up to the next highest output unit.
1012 *
1013 * @warning Generated. Do not edit. See above.
1014 *
1015 * @param t Source time in nanoseconds. uint64_t
1016 *
1017 * @return The converted time value in hardware cycles. uint64_t
1018 */
1019 #define k_ns_to_cyc_ceil64(t) \
1020 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false)
1021
1022
1023 /** @brief Convert nanoseconds to ticks. 32 bits. Truncates.
1024 *
1025 * Converts time values in nanoseconds to ticks.
1026 * Computes result in 32 bit precision.
1027 * Truncates to the next lowest output unit.
1028 *
1029 * @warning Generated. Do not edit. See above.
1030 *
1031 * @param t Source time in nanoseconds. uint64_t
1032 *
1033 * @return The converted time value in ticks. uint32_t
1034 */
1035 #define k_ns_to_ticks_floor32(t) \
1036 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, false)
1037
1038
1039 /** @brief Convert nanoseconds to ticks. 64 bits. Truncates.
1040 *
1041 * Converts time values in nanoseconds to ticks.
1042 * Computes result in 64 bit precision.
1043 * Truncates to the next lowest output unit.
1044 *
1045 * @warning Generated. Do not edit. See above.
1046 *
1047 * @param t Source time in nanoseconds. uint64_t
1048 *
1049 * @return The converted time value in ticks. uint64_t
1050 */
1051 #define k_ns_to_ticks_floor64(t) \
1052 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, false)
1053
1054
1055 /** @brief Convert nanoseconds to ticks. 32 bits. Round nearest.
1056 *
1057 * Converts time values in nanoseconds to ticks.
1058 * Computes result in 32 bit precision.
1059 * Rounds to the nearest output unit.
1060 *
1061 * @warning Generated. Do not edit. See above.
1062 *
1063 * @param t Source time in nanoseconds. uint64_t
1064 *
1065 * @return The converted time value in ticks. uint32_t
1066 */
1067 #define k_ns_to_ticks_near32(t) \
1068 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, false, true)
1069
1070
1071 /** @brief Convert nanoseconds to ticks. 64 bits. Round nearest.
1072 *
1073 * Converts time values in nanoseconds to ticks.
1074 * Computes result in 64 bit precision.
1075 * Rounds to the nearest output unit.
1076 *
1077 * @warning Generated. Do not edit. See above.
1078 *
1079 * @param t Source time in nanoseconds. uint64_t
1080 *
1081 * @return The converted time value in ticks. uint64_t
1082 */
1083 #define k_ns_to_ticks_near64(t) \
1084 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, false, true)
1085
1086
1087 /** @brief Convert nanoseconds to ticks. 32 bits. Rounds up.
1088 *
1089 * Converts time values in nanoseconds to ticks.
1090 * Computes result in 32 bit precision.
1091 * Rounds up to the next highest output unit.
1092 *
1093 * @warning Generated. Do not edit. See above.
1094 *
1095 * @param t Source time in nanoseconds. uint64_t
1096 *
1097 * @return The converted time value in ticks. uint32_t
1098 */
1099 #define k_ns_to_ticks_ceil32(t) \
1100 z_tmcvt_32(t, Z_HZ_ns, Z_HZ_ticks, true, true, false)
1101
1102
1103 /** @brief Convert nanoseconds to ticks. 64 bits. Rounds up.
1104 *
1105 * Converts time values in nanoseconds to ticks.
1106 * Computes result in 64 bit precision.
1107 * Rounds up to the next highest output unit.
1108 *
1109 * @warning Generated. Do not edit. See above.
1110 *
1111 * @param t Source time in nanoseconds. uint64_t
1112 *
1113 * @return The converted time value in ticks. uint64_t
1114 */
1115 #define k_ns_to_ticks_ceil64(t) \
1116 z_tmcvt_64(t, Z_HZ_ns, Z_HZ_ticks, true, true, false)
1117
1118
1119 /** @brief Convert hardware cycles to seconds. 32 bits. Truncates.
1120 *
1121 * Converts time values in hardware cycles to seconds.
1122 * Computes result in 32 bit precision.
1123 * Truncates to the next lowest output unit.
1124 *
1125 * @warning Generated. Do not edit. See above.
1126 *
1127 * @param t Source time in hardware cycles. uint64_t
1128 *
1129 * @return The converted time value in seconds. uint32_t
1130 */
1131 #define k_cyc_to_sec_floor32(t) \
1132 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_sec, Z_CCYC, false, false)
1133
1134
1135 /** @brief Convert hardware cycles to seconds. 64 bits. Truncates.
1136 *
1137 * Converts time values in hardware cycles to seconds.
1138 * Computes result in 64 bit precision.
1139 * Truncates to the next lowest output unit.
1140 *
1141 * @warning Generated. Do not edit. See above.
1142 *
1143 * @param t Source time in hardware cycles. uint64_t
1144 *
1145 * @return The converted time value in seconds. uint64_t
1146 */
1147 #define k_cyc_to_sec_floor64(t) \
1148 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_sec, Z_CCYC, false, false)
1149
1150
1151 /** @brief Convert hardware cycles to seconds. 32 bits. Round nearest.
1152 *
1153 * Converts time values in hardware cycles to seconds.
1154 * Computes result in 32 bit precision.
1155 * Rounds to the nearest output unit.
1156 *
1157 * @warning Generated. Do not edit. See above.
1158 *
1159 * @param t Source time in hardware cycles. uint64_t
1160 *
1161 * @return The converted time value in seconds. uint32_t
1162 */
1163 #define k_cyc_to_sec_near32(t) \
1164 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_sec, Z_CCYC, false, true)
1165
1166
1167 /** @brief Convert hardware cycles to seconds. 64 bits. Round nearest.
1168 *
1169 * Converts time values in hardware cycles to seconds.
1170 * Computes result in 64 bit precision.
1171 * Rounds to the nearest output unit.
1172 *
1173 * @warning Generated. Do not edit. See above.
1174 *
1175 * @param t Source time in hardware cycles. uint64_t
1176 *
1177 * @return The converted time value in seconds. uint64_t
1178 */
1179 #define k_cyc_to_sec_near64(t) \
1180 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_sec, Z_CCYC, false, true)
1181
1182
1183 /** @brief Convert hardware cycles to seconds. 32 bits. Rounds up.
1184 *
1185 * Converts time values in hardware cycles to seconds.
1186 * Computes result in 32 bit precision.
1187 * Rounds up to the next highest output unit.
1188 *
1189 * @warning Generated. Do not edit. See above.
1190 *
1191 * @param t Source time in hardware cycles. uint64_t
1192 *
1193 * @return The converted time value in seconds. uint32_t
1194 */
1195 #define k_cyc_to_sec_ceil32(t) \
1196 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_sec, Z_CCYC, true, false)
1197
1198
1199 /** @brief Convert hardware cycles to seconds. 64 bits. Rounds up.
1200 *
1201 * Converts time values in hardware cycles to seconds.
1202 * Computes result in 64 bit precision.
1203 * Rounds up to the next highest output unit.
1204 *
1205 * @warning Generated. Do not edit. See above.
1206 *
1207 * @param t Source time in hardware cycles. uint64_t
1208 *
1209 * @return The converted time value in seconds. uint64_t
1210 */
1211 #define k_cyc_to_sec_ceil64(t) \
1212 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_sec, Z_CCYC, true, false)
1213
1214
1215 /** @brief Convert hardware cycles to milliseconds. 32 bits. Truncates.
1216 *
1217 * Converts time values in hardware cycles to milliseconds.
1218 * Computes result in 32 bit precision.
1219 * Truncates to the next lowest output unit.
1220 *
1221 * @warning Generated. Do not edit. See above.
1222 *
1223 * @param t Source time in hardware cycles. uint64_t
1224 *
1225 * @return The converted time value in milliseconds. uint32_t
1226 */
1227 #define k_cyc_to_ms_floor32(t) \
1228 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false)
1229
1230
1231 /** @brief Convert hardware cycles to milliseconds. 64 bits. Truncates.
1232 *
1233 * Converts time values in hardware cycles to milliseconds.
1234 * Computes result in 64 bit precision.
1235 * Truncates to the next lowest output unit.
1236 *
1237 * @warning Generated. Do not edit. See above.
1238 *
1239 * @param t Source time in hardware cycles. uint64_t
1240 *
1241 * @return The converted time value in milliseconds. uint64_t
1242 */
1243 #define k_cyc_to_ms_floor64(t) \
1244 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, false)
1245
1246
1247 /** @brief Convert hardware cycles to milliseconds. 32 bits. Round nearest.
1248 *
1249 * Converts time values in hardware cycles to milliseconds.
1250 * Computes result in 32 bit precision.
1251 * Rounds to the nearest output unit.
1252 *
1253 * @warning Generated. Do not edit. See above.
1254 *
1255 * @param t Source time in hardware cycles. uint64_t
1256 *
1257 * @return The converted time value in milliseconds. uint32_t
1258 */
1259 #define k_cyc_to_ms_near32(t) \
1260 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true)
1261
1262
1263 /** @brief Convert hardware cycles to milliseconds. 64 bits. Round nearest.
1264 *
1265 * Converts time values in hardware cycles to milliseconds.
1266 * Computes result in 64 bit precision.
1267 * Rounds to the nearest output unit.
1268 *
1269 * @warning Generated. Do not edit. See above.
1270 *
1271 * @param t Source time in hardware cycles. uint64_t
1272 *
1273 * @return The converted time value in milliseconds. uint64_t
1274 */
1275 #define k_cyc_to_ms_near64(t) \
1276 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true)
1277
1278
1279 /** @brief Convert hardware cycles to milliseconds. 32 bits. Rounds up.
1280 *
1281 * Converts time values in hardware cycles to milliseconds.
1282 * Computes result in 32 bit precision.
1283 * Rounds up to the next highest output unit.
1284 *
1285 * @warning Generated. Do not edit. See above.
1286 *
1287 * @param t Source time in hardware cycles. uint64_t
1288 *
1289 * @return The converted time value in milliseconds. uint32_t
1290 */
1291 #define k_cyc_to_ms_ceil32(t) \
1292 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false)
1293
1294
1295 /** @brief Convert hardware cycles to milliseconds. 64 bits. Rounds up.
1296 *
1297 * Converts time values in hardware cycles to milliseconds.
1298 * Computes result in 64 bit precision.
1299 * Rounds up to the next highest output unit.
1300 *
1301 * @warning Generated. Do not edit. See above.
1302 *
1303 * @param t Source time in hardware cycles. uint64_t
1304 *
1305 * @return The converted time value in milliseconds. uint64_t
1306 */
1307 #define k_cyc_to_ms_ceil64(t) \
1308 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, true, false)
1309
1310
1311 /** @brief Convert hardware cycles to microseconds. 32 bits. Truncates.
1312 *
1313 * Converts time values in hardware cycles to microseconds.
1314 * Computes result in 32 bit precision.
1315 * Truncates to the next lowest output unit.
1316 *
1317 * @warning Generated. Do not edit. See above.
1318 *
1319 * @param t Source time in hardware cycles. uint64_t
1320 *
1321 * @return The converted time value in microseconds. uint32_t
1322 */
1323 #define k_cyc_to_us_floor32(t) \
1324 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false)
1325
1326
1327 /** @brief Convert hardware cycles to microseconds. 64 bits. Truncates.
1328 *
1329 * Converts time values in hardware cycles to microseconds.
1330 * Computes result in 64 bit precision.
1331 * Truncates to the next lowest output unit.
1332 *
1333 * @warning Generated. Do not edit. See above.
1334 *
1335 * @param t Source time in hardware cycles. uint64_t
1336 *
1337 * @return The converted time value in microseconds. uint64_t
1338 */
1339 #define k_cyc_to_us_floor64(t) \
1340 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false)
1341
1342
1343 /** @brief Convert hardware cycles to microseconds. 32 bits. Round nearest.
1344 *
1345 * Converts time values in hardware cycles to microseconds.
1346 * Computes result in 32 bit precision.
1347 * Rounds to the nearest output unit.
1348 *
1349 * @warning Generated. Do not edit. See above.
1350 *
1351 * @param t Source time in hardware cycles. uint64_t
1352 *
1353 * @return The converted time value in microseconds. uint32_t
1354 */
1355 #define k_cyc_to_us_near32(t) \
1356 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true)
1357
1358
1359 /** @brief Convert hardware cycles to microseconds. 64 bits. Round nearest.
1360 *
1361 * Converts time values in hardware cycles to microseconds.
1362 * Computes result in 64 bit precision.
1363 * Rounds to the nearest output unit.
1364 *
1365 * @warning Generated. Do not edit. See above.
1366 *
1367 * @param t Source time in hardware cycles. uint64_t
1368 *
1369 * @return The converted time value in microseconds. uint64_t
1370 */
1371 #define k_cyc_to_us_near64(t) \
1372 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true)
1373
1374
1375 /** @brief Convert hardware cycles to microseconds. 32 bits. Rounds up.
1376 *
1377 * Converts time values in hardware cycles to microseconds.
1378 * Computes result in 32 bit precision.
1379 * Rounds up to the next highest output unit.
1380 *
1381 * @warning Generated. Do not edit. See above.
1382 *
1383 * @param t Source time in hardware cycles. uint64_t
1384 *
1385 * @return The converted time value in microseconds. uint32_t
1386 */
1387 #define k_cyc_to_us_ceil32(t) \
1388 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false)
1389
1390
1391 /** @brief Convert hardware cycles to microseconds. 64 bits. Rounds up.
1392 *
1393 * Converts time values in hardware cycles to microseconds.
1394 * Computes result in 64 bit precision.
1395 * Rounds up to the next highest output unit.
1396 *
1397 * @warning Generated. Do not edit. See above.
1398 *
1399 * @param t Source time in hardware cycles. uint64_t
1400 *
1401 * @return The converted time value in microseconds. uint64_t
1402 */
1403 #define k_cyc_to_us_ceil64(t) \
1404 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false)
1405
1406
1407 /** @brief Convert hardware cycles to nanoseconds. 32 bits. Truncates.
1408 *
1409 * Converts time values in hardware cycles to nanoseconds.
1410 * Computes result in 32 bit precision.
1411 * Truncates to the next lowest output unit.
1412 *
1413 * @warning Generated. Do not edit. See above.
1414 *
1415 * @param t Source time in hardware cycles. uint64_t
1416 *
1417 * @return The converted time value in nanoseconds. uint32_t
1418 */
1419 #define k_cyc_to_ns_floor32(t) \
1420 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false)
1421
1422
1423 /** @brief Convert hardware cycles to nanoseconds. 64 bits. Truncates.
1424 *
1425 * Converts time values in hardware cycles to nanoseconds.
1426 * Computes result in 64 bit precision.
1427 * Truncates to the next lowest output unit.
1428 *
1429 * @warning Generated. Do not edit. See above.
1430 *
1431 * @param t Source time in hardware cycles. uint64_t
1432 *
1433 * @return The converted time value in nanoseconds. uint64_t
1434 */
1435 #define k_cyc_to_ns_floor64(t) \
1436 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false)
1437
1438
1439 /** @brief Convert hardware cycles to nanoseconds. 32 bits. Round nearest.
1440 *
1441 * Converts time values in hardware cycles to nanoseconds.
1442 * Computes result in 32 bit precision.
1443 * Rounds to the nearest output unit.
1444 *
1445 * @warning Generated. Do not edit. See above.
1446 *
1447 * @param t Source time in hardware cycles. uint64_t
1448 *
1449 * @return The converted time value in nanoseconds. uint32_t
1450 */
1451 #define k_cyc_to_ns_near32(t) \
1452 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true)
1453
1454
1455 /** @brief Convert hardware cycles to nanoseconds. 64 bits. Round nearest.
1456 *
1457 * Converts time values in hardware cycles to nanoseconds.
1458 * Computes result in 64 bit precision.
1459 * Rounds to the nearest output unit.
1460 *
1461 * @warning Generated. Do not edit. See above.
1462 *
1463 * @param t Source time in hardware cycles. uint64_t
1464 *
1465 * @return The converted time value in nanoseconds. uint64_t
1466 */
1467 #define k_cyc_to_ns_near64(t) \
1468 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, true)
1469
1470
1471 /** @brief Convert hardware cycles to nanoseconds. 32 bits. Rounds up.
1472 *
1473 * Converts time values in hardware cycles to nanoseconds.
1474 * Computes result in 32 bit precision.
1475 * Rounds up to the next highest output unit.
1476 *
1477 * @warning Generated. Do not edit. See above.
1478 *
1479 * @param t Source time in hardware cycles. uint64_t
1480 *
1481 * @return The converted time value in nanoseconds. uint32_t
1482 */
1483 #define k_cyc_to_ns_ceil32(t) \
1484 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false)
1485
1486
1487 /** @brief Convert hardware cycles to nanoseconds. 64 bits. Rounds up.
1488 *
1489 * Converts time values in hardware cycles to nanoseconds.
1490 * Computes result in 64 bit precision.
1491 * Rounds up to the next highest output unit.
1492 *
1493 * @warning Generated. Do not edit. See above.
1494 *
1495 * @param t Source time in hardware cycles. uint64_t
1496 *
1497 * @return The converted time value in nanoseconds. uint64_t
1498 */
1499 #define k_cyc_to_ns_ceil64(t) \
1500 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false)
1501
1502
1503 /** @brief Convert hardware cycles to ticks. 32 bits. Truncates.
1504 *
1505 * Converts time values in hardware cycles to ticks.
1506 * Computes result in 32 bit precision.
1507 * Truncates to the next lowest output unit.
1508 *
1509 * @warning Generated. Do not edit. See above.
1510 *
1511 * @param t Source time in hardware cycles. uint64_t
1512 *
1513 * @return The converted time value in ticks. uint32_t
1514 */
1515 #define k_cyc_to_ticks_floor32(t) \
1516 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false)
1517
1518
1519 /** @brief Convert hardware cycles to ticks. 64 bits. Truncates.
1520 *
1521 * Converts time values in hardware cycles to ticks.
1522 * Computes result in 64 bit precision.
1523 * Truncates to the next lowest output unit.
1524 *
1525 * @warning Generated. Do not edit. See above.
1526 *
1527 * @param t Source time in hardware cycles. uint64_t
1528 *
1529 * @return The converted time value in ticks. uint64_t
1530 */
1531 #define k_cyc_to_ticks_floor64(t) \
1532 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, false)
1533
1534
1535 /** @brief Convert hardware cycles to ticks. 32 bits. Round nearest.
1536 *
1537 * Converts time values in hardware cycles to ticks.
1538 * Computes result in 32 bit precision.
1539 * Rounds to the nearest output unit.
1540 *
1541 * @warning Generated. Do not edit. See above.
1542 *
1543 * @param t Source time in hardware cycles. uint64_t
1544 *
1545 * @return The converted time value in ticks. uint32_t
1546 */
1547 #define k_cyc_to_ticks_near32(t) \
1548 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true)
1549
1550
1551 /** @brief Convert hardware cycles to ticks. 64 bits. Round nearest.
1552 *
1553 * Converts time values in hardware cycles to ticks.
1554 * Computes result in 64 bit precision.
1555 * Rounds to the nearest output unit.
1556 *
1557 * @warning Generated. Do not edit. See above.
1558 *
1559 * @param t Source time in hardware cycles. uint64_t
1560 *
1561 * @return The converted time value in ticks. uint64_t
1562 */
1563 #define k_cyc_to_ticks_near64(t) \
1564 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, false, true)
1565
1566
1567 /** @brief Convert hardware cycles to ticks. 32 bits. Rounds up.
1568 *
1569 * Converts time values in hardware cycles to ticks.
1570 * Computes result in 32 bit precision.
1571 * Rounds up to the next highest output unit.
1572 *
1573 * @warning Generated. Do not edit. See above.
1574 *
1575 * @param t Source time in hardware cycles. uint64_t
1576 *
1577 * @return The converted time value in ticks. uint32_t
1578 */
1579 #define k_cyc_to_ticks_ceil32(t) \
1580 z_tmcvt_32(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false)
1581
1582
1583 /** @brief Convert hardware cycles to ticks. 64 bits. Rounds up.
1584 *
1585 * Converts time values in hardware cycles to ticks.
1586 * Computes result in 64 bit precision.
1587 * Rounds up to the next highest output unit.
1588 *
1589 * @warning Generated. Do not edit. See above.
1590 *
1591 * @param t Source time in hardware cycles. uint64_t
1592 *
1593 * @return The converted time value in ticks. uint64_t
1594 */
1595 #define k_cyc_to_ticks_ceil64(t) \
1596 z_tmcvt_64(t, Z_HZ_cyc, Z_HZ_ticks, Z_CCYC, true, false)
1597
1598
1599 /** @brief Convert ticks to seconds. 32 bits. Truncates.
1600 *
1601 * Converts time values in ticks to seconds.
1602 * Computes result in 32 bit precision.
1603 * Truncates to the next lowest output unit.
1604 *
1605 * @warning Generated. Do not edit. See above.
1606 *
1607 * @param t Source time in ticks. uint64_t
1608 *
1609 * @return The converted time value in seconds. uint32_t
1610 */
1611 #define k_ticks_to_sec_floor32(t) \
1612 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_sec, true, false, false)
1613
1614
1615 /** @brief Convert ticks to seconds. 64 bits. Truncates.
1616 *
1617 * Converts time values in ticks to seconds.
1618 * Computes result in 64 bit precision.
1619 * Truncates to the next lowest output unit.
1620 *
1621 * @warning Generated. Do not edit. See above.
1622 *
1623 * @param t Source time in ticks. uint64_t
1624 *
1625 * @return The converted time value in seconds. uint64_t
1626 */
1627 #define k_ticks_to_sec_floor64(t) \
1628 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_sec, true, false, false)
1629
1630
1631 /** @brief Convert ticks to seconds. 32 bits. Round nearest.
1632 *
1633 * Converts time values in ticks to seconds.
1634 * Computes result in 32 bit precision.
1635 * Rounds to the nearest output unit.
1636 *
1637 * @warning Generated. Do not edit. See above.
1638 *
1639 * @param t Source time in ticks. uint64_t
1640 *
1641 * @return The converted time value in seconds. uint32_t
1642 */
1643 #define k_ticks_to_sec_near32(t) \
1644 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_sec, true, false, true)
1645
1646
1647 /** @brief Convert ticks to seconds. 64 bits. Round nearest.
1648 *
1649 * Converts time values in ticks to seconds.
1650 * Computes result in 64 bit precision.
1651 * Rounds to the nearest output unit.
1652 *
1653 * @warning Generated. Do not edit. See above.
1654 *
1655 * @param t Source time in ticks. uint64_t
1656 *
1657 * @return The converted time value in seconds. uint64_t
1658 */
1659 #define k_ticks_to_sec_near64(t) \
1660 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_sec, true, false, true)
1661
1662
1663 /** @brief Convert ticks to seconds. 32 bits. Rounds up.
1664 *
1665 * Converts time values in ticks to seconds.
1666 * Computes result in 32 bit precision.
1667 * Rounds up to the next highest output unit.
1668 *
1669 * @warning Generated. Do not edit. See above.
1670 *
1671 * @param t Source time in ticks. uint64_t
1672 *
1673 * @return The converted time value in seconds. uint32_t
1674 */
1675 #define k_ticks_to_sec_ceil32(t) \
1676 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_sec, true, true, false)
1677
1678
1679 /** @brief Convert ticks to seconds. 64 bits. Rounds up.
1680 *
1681 * Converts time values in ticks to seconds.
1682 * Computes result in 64 bit precision.
1683 * Rounds up to the next highest output unit.
1684 *
1685 * @warning Generated. Do not edit. See above.
1686 *
1687 * @param t Source time in ticks. uint64_t
1688 *
1689 * @return The converted time value in seconds. uint64_t
1690 */
1691 #define k_ticks_to_sec_ceil64(t) \
1692 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_sec, true, true, false)
1693
1694
1695 /** @brief Convert ticks to milliseconds. 32 bits. Truncates.
1696 *
1697 * Converts time values in ticks to milliseconds.
1698 * Computes result in 32 bit precision.
1699 * Truncates to the next lowest output unit.
1700 *
1701 * @warning Generated. Do not edit. See above.
1702 *
1703 * @param t Source time in ticks. uint64_t
1704 *
1705 * @return The converted time value in milliseconds. uint32_t
1706 */
1707 #define k_ticks_to_ms_floor32(t) \
1708 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, false)
1709
1710
1711 /** @brief Convert ticks to milliseconds. 64 bits. Truncates.
1712 *
1713 * Converts time values in ticks to milliseconds.
1714 * Computes result in 64 bit precision.
1715 * Truncates to the next lowest output unit.
1716 *
1717 * @warning Generated. Do not edit. See above.
1718 *
1719 * @param t Source time in ticks. uint64_t
1720 *
1721 * @return The converted time value in milliseconds. uint64_t
1722 */
1723 #define k_ticks_to_ms_floor64(t) \
1724 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, false)
1725
1726
1727 /** @brief Convert ticks to milliseconds. 32 bits. Round nearest.
1728 *
1729 * Converts time values in ticks to milliseconds.
1730 * Computes result in 32 bit precision.
1731 * Rounds to the nearest output unit.
1732 *
1733 * @warning Generated. Do not edit. See above.
1734 *
1735 * @param t Source time in ticks. uint64_t
1736 *
1737 * @return The converted time value in milliseconds. uint32_t
1738 */
1739 #define k_ticks_to_ms_near32(t) \
1740 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, false, true)
1741
1742
1743 /** @brief Convert ticks to milliseconds. 64 bits. Round nearest.
1744 *
1745 * Converts time values in ticks to milliseconds.
1746 * Computes result in 64 bit precision.
1747 * Rounds to the nearest output unit.
1748 *
1749 * @warning Generated. Do not edit. See above.
1750 *
1751 * @param t Source time in ticks. uint64_t
1752 *
1753 * @return The converted time value in milliseconds. uint64_t
1754 */
1755 #define k_ticks_to_ms_near64(t) \
1756 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, false, true)
1757
1758
1759 /** @brief Convert ticks to milliseconds. 32 bits. Rounds up.
1760 *
1761 * Converts time values in ticks to milliseconds.
1762 * Computes result in 32 bit precision.
1763 * Rounds up to the next highest output unit.
1764 *
1765 * @warning Generated. Do not edit. See above.
1766 *
1767 * @param t Source time in ticks. uint64_t
1768 *
1769 * @return The converted time value in milliseconds. uint32_t
1770 */
1771 #define k_ticks_to_ms_ceil32(t) \
1772 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ms, true, true, false)
1773
1774
1775 /** @brief Convert ticks to milliseconds. 64 bits. Rounds up.
1776 *
1777 * Converts time values in ticks to milliseconds.
1778 * Computes result in 64 bit precision.
1779 * Rounds up to the next highest output unit.
1780 *
1781 * @warning Generated. Do not edit. See above.
1782 *
1783 * @param t Source time in ticks. uint64_t
1784 *
1785 * @return The converted time value in milliseconds. uint64_t
1786 */
1787 #define k_ticks_to_ms_ceil64(t) \
1788 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ms, true, true, false)
1789
1790
1791 /** @brief Convert ticks to microseconds. 32 bits. Truncates.
1792 *
1793 * Converts time values in ticks to microseconds.
1794 * Computes result in 32 bit precision.
1795 * Truncates to the next lowest output unit.
1796 *
1797 * @warning Generated. Do not edit. See above.
1798 *
1799 * @param t Source time in ticks. uint64_t
1800 *
1801 * @return The converted time value in microseconds. uint32_t
1802 */
1803 #define k_ticks_to_us_floor32(t) \
1804 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, false)
1805
1806
1807 /** @brief Convert ticks to microseconds. 64 bits. Truncates.
1808 *
1809 * Converts time values in ticks to microseconds.
1810 * Computes result in 64 bit precision.
1811 * Truncates to the next lowest output unit.
1812 *
1813 * @warning Generated. Do not edit. See above.
1814 *
1815 * @param t Source time in ticks. uint64_t
1816 *
1817 * @return The converted time value in microseconds. uint64_t
1818 */
1819 #define k_ticks_to_us_floor64(t) \
1820 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, false)
1821
1822
1823 /** @brief Convert ticks to microseconds. 32 bits. Round nearest.
1824 *
1825 * Converts time values in ticks to microseconds.
1826 * Computes result in 32 bit precision.
1827 * Rounds to the nearest output unit.
1828 *
1829 * @warning Generated. Do not edit. See above.
1830 *
1831 * @param t Source time in ticks. uint64_t
1832 *
1833 * @return The converted time value in microseconds. uint32_t
1834 */
1835 #define k_ticks_to_us_near32(t) \
1836 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, false, true)
1837
1838
1839 /** @brief Convert ticks to microseconds. 64 bits. Round nearest.
1840 *
1841 * Converts time values in ticks to microseconds.
1842 * Computes result in 64 bit precision.
1843 * Rounds to the nearest output unit.
1844 *
1845 * @warning Generated. Do not edit. See above.
1846 *
1847 * @param t Source time in ticks. uint64_t
1848 *
1849 * @return The converted time value in microseconds. uint64_t
1850 */
1851 #define k_ticks_to_us_near64(t) \
1852 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, false, true)
1853
1854
1855 /** @brief Convert ticks to microseconds. 32 bits. Rounds up.
1856 *
1857 * Converts time values in ticks to microseconds.
1858 * Computes result in 32 bit precision.
1859 * Rounds up to the next highest output unit.
1860 *
1861 * @warning Generated. Do not edit. See above.
1862 *
1863 * @param t Source time in ticks. uint64_t
1864 *
1865 * @return The converted time value in microseconds. uint32_t
1866 */
1867 #define k_ticks_to_us_ceil32(t) \
1868 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_us, true, true, false)
1869
1870
1871 /** @brief Convert ticks to microseconds. 64 bits. Rounds up.
1872 *
1873 * Converts time values in ticks to microseconds.
1874 * Computes result in 64 bit precision.
1875 * Rounds up to the next highest output unit.
1876 *
1877 * @warning Generated. Do not edit. See above.
1878 *
1879 * @param t Source time in ticks. uint64_t
1880 *
1881 * @return The converted time value in microseconds. uint64_t
1882 */
1883 #define k_ticks_to_us_ceil64(t) \
1884 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_us, true, true, false)
1885
1886
1887 /** @brief Convert ticks to nanoseconds. 32 bits. Truncates.
1888 *
1889 * Converts time values in ticks to nanoseconds.
1890 * Computes result in 32 bit precision.
1891 * Truncates to the next lowest output unit.
1892 *
1893 * @warning Generated. Do not edit. See above.
1894 *
1895 * @param t Source time in ticks. uint64_t
1896 *
1897 * @return The converted time value in nanoseconds. uint32_t
1898 */
1899 #define k_ticks_to_ns_floor32(t) \
1900 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, false)
1901
1902
1903 /** @brief Convert ticks to nanoseconds. 64 bits. Truncates.
1904 *
1905 * Converts time values in ticks to nanoseconds.
1906 * Computes result in 64 bit precision.
1907 * Truncates to the next lowest output unit.
1908 *
1909 * @warning Generated. Do not edit. See above.
1910 *
1911 * @param t Source time in ticks. uint64_t
1912 *
1913 * @return The converted time value in nanoseconds. uint64_t
1914 */
1915 #define k_ticks_to_ns_floor64(t) \
1916 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, false)
1917
1918
1919 /** @brief Convert ticks to nanoseconds. 32 bits. Round nearest.
1920 *
1921 * Converts time values in ticks to nanoseconds.
1922 * Computes result in 32 bit precision.
1923 * Rounds to the nearest output unit.
1924 *
1925 * @warning Generated. Do not edit. See above.
1926 *
1927 * @param t Source time in ticks. uint64_t
1928 *
1929 * @return The converted time value in nanoseconds. uint32_t
1930 */
1931 #define k_ticks_to_ns_near32(t) \
1932 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, false, true)
1933
1934
1935 /** @brief Convert ticks to nanoseconds. 64 bits. Round nearest.
1936 *
1937 * Converts time values in ticks to nanoseconds.
1938 * Computes result in 64 bit precision.
1939 * Rounds to the nearest output unit.
1940 *
1941 * @warning Generated. Do not edit. See above.
1942 *
1943 * @param t Source time in ticks. uint64_t
1944 *
1945 * @return The converted time value in nanoseconds. uint64_t
1946 */
1947 #define k_ticks_to_ns_near64(t) \
1948 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, false, true)
1949
1950
1951 /** @brief Convert ticks to nanoseconds. 32 bits. Rounds up.
1952 *
1953 * Converts time values in ticks to nanoseconds.
1954 * Computes result in 32 bit precision.
1955 * Rounds up to the next highest output unit.
1956 *
1957 * @warning Generated. Do not edit. See above.
1958 *
1959 * @param t Source time in ticks. uint64_t
1960 *
1961 * @return The converted time value in nanoseconds. uint32_t
1962 */
1963 #define k_ticks_to_ns_ceil32(t) \
1964 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_ns, true, true, false)
1965
1966
1967 /** @brief Convert ticks to nanoseconds. 64 bits. Rounds up.
1968 *
1969 * Converts time values in ticks to nanoseconds.
1970 * Computes result in 64 bit precision.
1971 * Rounds up to the next highest output unit.
1972 *
1973 * @warning Generated. Do not edit. See above.
1974 *
1975 * @param t Source time in ticks. uint64_t
1976 *
1977 * @return The converted time value in nanoseconds. uint64_t
1978 */
1979 #define k_ticks_to_ns_ceil64(t) \
1980 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_ns, true, true, false)
1981
1982
1983 /** @brief Convert ticks to hardware cycles. 32 bits. Truncates.
1984 *
1985 * Converts time values in ticks to hardware cycles.
1986 * Computes result in 32 bit precision.
1987 * Truncates to the next lowest output unit.
1988 *
1989 * @warning Generated. Do not edit. See above.
1990 *
1991 * @param t Source time in ticks. uint64_t
1992 *
1993 * @return The converted time value in hardware cycles. uint32_t
1994 */
1995 #define k_ticks_to_cyc_floor32(t) \
1996 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false)
1997
1998
1999 /** @brief Convert ticks to hardware cycles. 64 bits. Truncates.
2000 *
2001 * Converts time values in ticks to hardware cycles.
2002 * Computes result in 64 bit precision.
2003 * Truncates to the next lowest output unit.
2004 *
2005 * @warning Generated. Do not edit. See above.
2006 *
2007 * @param t Source time in ticks. uint64_t
2008 *
2009 * @return The converted time value in hardware cycles. uint64_t
2010 */
2011 #define k_ticks_to_cyc_floor64(t) \
2012 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, false)
2013
2014
2015 /** @brief Convert ticks to hardware cycles. 32 bits. Round nearest.
2016 *
2017 * Converts time values in ticks to hardware cycles.
2018 * Computes result in 32 bit precision.
2019 * Rounds to the nearest output unit.
2020 *
2021 * @warning Generated. Do not edit. See above.
2022 *
2023 * @param t Source time in ticks. uint64_t
2024 *
2025 * @return The converted time value in hardware cycles. uint32_t
2026 */
2027 #define k_ticks_to_cyc_near32(t) \
2028 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true)
2029
2030
2031 /** @brief Convert ticks to hardware cycles. 64 bits. Round nearest.
2032 *
2033 * Converts time values in ticks to hardware cycles.
2034 * Computes result in 64 bit precision.
2035 * Rounds to the nearest output unit.
2036 *
2037 * @warning Generated. Do not edit. See above.
2038 *
2039 * @param t Source time in ticks. uint64_t
2040 *
2041 * @return The converted time value in hardware cycles. uint64_t
2042 */
2043 #define k_ticks_to_cyc_near64(t) \
2044 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, false, true)
2045
2046
2047 /** @brief Convert ticks to hardware cycles. 32 bits. Rounds up.
2048 *
2049 * Converts time values in ticks to hardware cycles.
2050 * Computes result in 32 bit precision.
2051 * Rounds up to the next highest output unit.
2052 *
2053 * @warning Generated. Do not edit. See above.
2054 *
2055 * @param t Source time in ticks. uint64_t
2056 *
2057 * @return The converted time value in hardware cycles. uint32_t
2058 */
2059 #define k_ticks_to_cyc_ceil32(t) \
2060 z_tmcvt_32(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false)
2061
2062
2063 /** @brief Convert ticks to hardware cycles. 64 bits. Rounds up.
2064 *
2065 * Converts time values in ticks to hardware cycles.
2066 * Computes result in 64 bit precision.
2067 * Rounds up to the next highest output unit.
2068 *
2069 * @warning Generated. Do not edit. See above.
2070 *
2071 * @param t Source time in ticks. uint64_t
2072 *
2073 * @return The converted time value in hardware cycles. uint64_t
2074 */
2075 #define k_ticks_to_cyc_ceil64(t) \
2076 z_tmcvt_64(t, Z_HZ_ticks, Z_HZ_cyc, Z_CCYC, true, false)
2077
2078 #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
2079 #include <zephyr/syscalls/time_units.h>
2080 #endif
2081
2082 #undef TIME_CONSTEXPR
2083
2084 /**
2085 * @}
2086 */
2087
2088 #ifdef __cplusplus
2089 } /* extern "C" */
2090 #endif
2091
2092 #endif /* ZEPHYR_INCLUDE_TIME_UNITS_H_ */
2093