diff --git a/include/sys/time_units.h b/include/sys/time_units.h index ec48f2e0c8f..77a5d4549ca 100644 --- a/include/sys/time_units.h +++ b/include/sys/time_units.h @@ -132,7 +132,6 @@ static ALWAYS_INLINE u64_t z_tmcvt(u64_t t, u32_t from_hz, u32_t to_hz, * next if prefix($from_unit) && prefix($to_unit); * for my $round ("floor", "near", "ceil") { * for(my $big=0; $big <= 1; $big++) { - * next if !$big && (big($from_unit) || big($to_unit)); * my $sz = $big ? 64 : 32; * my $sym = "k_${from_unit}_to_${to_unit}_$round$sz"; * my $type = "u${sz}_t"; @@ -348,6 +347,20 @@ static inline u64_t k_ms_to_ticks_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_ms, Z_HZ_ticks, true, false, true, false); } +/** @brief Convert microseconds to hardware cycles + * + * Converts time values in microseconds to hardware cycles. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_us_to_cyc_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, false); +} + /** @brief Convert microseconds to hardware cycles * * Converts time values in microseconds to hardware cycles. @@ -362,6 +375,20 @@ static inline u64_t k_us_to_cyc_floor64(u64_t t) return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, false); } +/** @brief Convert microseconds to hardware cycles + * + * Converts time values in microseconds to hardware cycles. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_us_to_cyc_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, false, true); +} + /** @brief Convert microseconds to hardware cycles * * Converts time values in microseconds to hardware cycles. @@ -376,6 +403,20 @@ static inline u64_t k_us_to_cyc_near64(u64_t t) return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, false, true); } +/** @brief Convert microseconds to hardware cycles + * + * Converts time values in microseconds to hardware cycles. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_us_to_cyc_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, true, true, false); +} + /** @brief Convert microseconds to hardware cycles * * Converts time values in microseconds to hardware cycles. @@ -390,6 +431,20 @@ static inline u64_t k_us_to_cyc_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_us, Z_HZ_cyc, Z_CCYC, false, true, false); } +/** @brief Convert microseconds to ticks + * + * Converts time values in microseconds to ticks. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_us_to_ticks_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, false); +} + /** @brief Convert microseconds to ticks * * Converts time values in microseconds to ticks. @@ -404,6 +459,20 @@ static inline u64_t k_us_to_ticks_floor64(u64_t t) return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, false); } +/** @brief Convert microseconds to ticks + * + * Converts time values in microseconds to ticks. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_us_to_ticks_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, false, true); +} + /** @brief Convert microseconds to ticks * * Converts time values in microseconds to ticks. @@ -418,6 +487,20 @@ static inline u64_t k_us_to_ticks_near64(u64_t t) return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, false, true); } +/** @brief Convert microseconds to ticks + * + * Converts time values in microseconds to ticks. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_us_to_ticks_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, true, true, false); +} + /** @brief Convert microseconds to ticks * * Converts time values in microseconds to ticks. @@ -432,6 +515,20 @@ static inline u64_t k_us_to_ticks_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_us, Z_HZ_ticks, true, false, true, false); } +/** @brief Convert nanoseconds to hardware cycles + * + * Converts time values in nanoseconds to hardware cycles. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ns_to_cyc_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, false); +} + /** @brief Convert nanoseconds to hardware cycles * * Converts time values in nanoseconds to hardware cycles. @@ -446,6 +543,20 @@ static inline u64_t k_ns_to_cyc_floor64(u64_t t) return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, false); } +/** @brief Convert nanoseconds to hardware cycles + * + * Converts time values in nanoseconds to hardware cycles. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ns_to_cyc_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, false, true); +} + /** @brief Convert nanoseconds to hardware cycles * * Converts time values in nanoseconds to hardware cycles. @@ -460,6 +571,20 @@ static inline u64_t k_ns_to_cyc_near64(u64_t t) return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, false, true); } +/** @brief Convert nanoseconds to hardware cycles + * + * Converts time values in nanoseconds to hardware cycles. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ns_to_cyc_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, true, true, false); +} + /** @brief Convert nanoseconds to hardware cycles * * Converts time values in nanoseconds to hardware cycles. @@ -474,6 +599,20 @@ static inline u64_t k_ns_to_cyc_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_ns, Z_HZ_cyc, Z_CCYC, false, true, false); } +/** @brief Convert nanoseconds to ticks + * + * Converts time values in nanoseconds to ticks. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ns_to_ticks_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, false); +} + /** @brief Convert nanoseconds to ticks * * Converts time values in nanoseconds to ticks. @@ -488,6 +627,20 @@ static inline u64_t k_ns_to_ticks_floor64(u64_t t) return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, false); } +/** @brief Convert nanoseconds to ticks + * + * Converts time values in nanoseconds to ticks. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ns_to_ticks_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, false, true); +} + /** @brief Convert nanoseconds to ticks * * Converts time values in nanoseconds to ticks. @@ -502,6 +655,20 @@ static inline u64_t k_ns_to_ticks_near64(u64_t t) return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, false, false, true); } +/** @brief Convert nanoseconds to ticks + * + * Converts time values in nanoseconds to ticks. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ns_to_ticks_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ns, Z_HZ_ticks, true, true, true, false); +} + /** @brief Convert nanoseconds to ticks * * Converts time values in nanoseconds to ticks. @@ -600,6 +767,20 @@ static inline u64_t k_cyc_to_ms_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ms, Z_CCYC, false, true, false); } +/** @brief Convert hardware cycles to microseconds + * + * Converts time values in hardware cycles to microseconds. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_cyc_to_us_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, false); +} + /** @brief Convert hardware cycles to microseconds * * Converts time values in hardware cycles to microseconds. @@ -614,6 +795,20 @@ static inline u64_t k_cyc_to_us_floor64(u64_t t) return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, false); } +/** @brief Convert hardware cycles to microseconds + * + * Converts time values in hardware cycles to microseconds. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_cyc_to_us_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, false, true); +} + /** @brief Convert hardware cycles to microseconds * * Converts time values in hardware cycles to microseconds. @@ -628,6 +823,20 @@ static inline u64_t k_cyc_to_us_near64(u64_t t) return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, false, true); } +/** @brief Convert hardware cycles to microseconds + * + * Converts time values in hardware cycles to microseconds. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_cyc_to_us_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, true, true, false); +} + /** @brief Convert hardware cycles to microseconds * * Converts time values in hardware cycles to microseconds. @@ -642,6 +851,20 @@ static inline u64_t k_cyc_to_us_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_cyc, Z_HZ_us, Z_CCYC, false, true, false); } +/** @brief Convert hardware cycles to nanoseconds + * + * Converts time values in hardware cycles to nanoseconds. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_cyc_to_ns_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, false); +} + /** @brief Convert hardware cycles to nanoseconds * * Converts time values in hardware cycles to nanoseconds. @@ -656,6 +879,20 @@ static inline u64_t k_cyc_to_ns_floor64(u64_t t) return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, false); } +/** @brief Convert hardware cycles to nanoseconds + * + * Converts time values in hardware cycles to nanoseconds. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_cyc_to_ns_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, false, true); +} + /** @brief Convert hardware cycles to nanoseconds * * Converts time values in hardware cycles to nanoseconds. @@ -670,6 +907,20 @@ static inline u64_t k_cyc_to_ns_near64(u64_t t) return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, false, false, true); } +/** @brief Convert hardware cycles to nanoseconds + * + * Converts time values in hardware cycles to nanoseconds. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_cyc_to_ns_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_cyc, Z_HZ_ns, Z_CCYC, true, true, false); +} + /** @brief Convert hardware cycles to nanoseconds * * Converts time values in hardware cycles to nanoseconds. @@ -852,6 +1103,20 @@ static inline u64_t k_ticks_to_ms_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ms, true, false, true, false); } +/** @brief Convert ticks to microseconds + * + * Converts time values in ticks to microseconds. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ticks_to_us_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, false); +} + /** @brief Convert ticks to microseconds * * Converts time values in ticks to microseconds. @@ -866,6 +1131,20 @@ static inline u64_t k_ticks_to_us_floor64(u64_t t) return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, false); } +/** @brief Convert ticks to microseconds + * + * Converts time values in ticks to microseconds. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ticks_to_us_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, false, true); +} + /** @brief Convert ticks to microseconds * * Converts time values in ticks to microseconds. @@ -880,6 +1159,20 @@ static inline u64_t k_ticks_to_us_near64(u64_t t) return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, false, true); } +/** @brief Convert ticks to microseconds + * + * Converts time values in ticks to microseconds. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ticks_to_us_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, true, true, false); +} + /** @brief Convert ticks to microseconds * * Converts time values in ticks to microseconds. @@ -894,6 +1187,20 @@ static inline u64_t k_ticks_to_us_ceil64(u64_t t) return z_tmcvt(t, Z_HZ_ticks, Z_HZ_us, true, false, true, false); } +/** @brief Convert ticks to nanoseconds + * + * Converts time values in ticks to nanoseconds. + * Computes result in 32 bit precision. + * Truncates to the next lowest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ticks_to_ns_floor32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, false); +} + /** @brief Convert ticks to nanoseconds * * Converts time values in ticks to nanoseconds. @@ -908,6 +1215,20 @@ static inline u64_t k_ticks_to_ns_floor64(u64_t t) return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, false); } +/** @brief Convert ticks to nanoseconds + * + * Converts time values in ticks to nanoseconds. + * Computes result in 32 bit precision. + * Rounds to the nearest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ticks_to_ns_near32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, false, true); +} + /** @brief Convert ticks to nanoseconds * * Converts time values in ticks to nanoseconds. @@ -922,6 +1243,20 @@ static inline u64_t k_ticks_to_ns_near64(u64_t t) return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, false, false, true); } +/** @brief Convert ticks to nanoseconds + * + * Converts time values in ticks to nanoseconds. + * Computes result in 32 bit precision. + * Rounds up to the next highest output unit. + * + * @return The converted time value + */ +static inline u32_t k_ticks_to_ns_ceil32(u32_t t) +{ + /* Generated. Do not edit. See above. */ + return z_tmcvt(t, Z_HZ_ticks, Z_HZ_ns, true, true, true, false); +} + /** @brief Convert ticks to nanoseconds * * Converts time values in ticks to nanoseconds.