kernel/timeout: Add k_uptime_ticks() API
Add a call to get the system tick count as an official API (and redefine the existing millisecond API in terms of it). Sophisticated applications need to be able to count ticks directly, and the newer timeout API supports that. Uptime should too, for symmetry. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
5a5d3daf6f
commit
914205ca85
2 changed files with 20 additions and 6 deletions
|
@ -2057,6 +2057,17 @@ static inline void *z_impl_k_timer_user_data_get(struct k_timer *timer)
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get system uptime, in ticks.
|
||||
*
|
||||
* This routine returns the elapsed time since the system booted, in
|
||||
* ticks (c.f. :option:`CONFIG_SYS_CLOCK_TICKS_PER_SEC`), which is the
|
||||
* fundamental unit of resolution of kernel timekeeping.
|
||||
*
|
||||
* @return Current uptime in ticks.
|
||||
*/
|
||||
__syscall s64_t k_uptime_ticks(void);
|
||||
|
||||
/**
|
||||
* @brief Get system uptime.
|
||||
*
|
||||
|
@ -2072,7 +2083,10 @@ static inline void *z_impl_k_timer_user_data_get(struct k_timer *timer)
|
|||
*
|
||||
* @return Current uptime in milliseconds.
|
||||
*/
|
||||
__syscall s64_t k_uptime_get(void);
|
||||
static inline s64_t k_uptime_get(void)
|
||||
{
|
||||
return k_ticks_to_ms_floor64(k_uptime_ticks());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable clock always on in tickless kernel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue