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:
parent
aee130f8d7
commit
98deebd29b
2 changed files with 18 additions and 0 deletions
|
@ -71,6 +71,11 @@ Architectures
|
|||
|
||||
* Xtensa
|
||||
|
||||
Kernel
|
||||
******
|
||||
|
||||
* Added :c:func:`k_uptime_seconds` function to simplify `k_uptime_get() / 1000` usage.
|
||||
|
||||
Bluetooth
|
||||
*********
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue