kernel: add k_uptime_seconds

Add a helper function for retrieving the system uptime in seconds
without having to do a second division.

Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
Jordan Yates 2024-05-10 11:09:23 +10:00 committed by Henrik Brix Andersen
commit 98deebd29b
2 changed files with 18 additions and 0 deletions

View file

@ -71,6 +71,11 @@ Architectures
* Xtensa
Kernel
******
* Added :c:func:`k_uptime_seconds` function to simplify `k_uptime_get() / 1000` usage.
Bluetooth
*********

View file

@ -1774,6 +1774,19 @@ static inline uint32_t k_uptime_get_32(void)
return (uint32_t)k_uptime_get();
}
/**
* @brief Get system uptime in seconds.
*
* This routine returns the elapsed time since the system booted,
* in seconds.
*
* @return Current uptime in seconds.
*/
static inline uint32_t k_uptime_seconds(void)
{
return k_ticks_to_sec_floor32(k_uptime_ticks());
}
/**
* @brief Get elapsed time.
*