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