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