unified: implement k_uptime_{get,delta}()
Simple conversion from ticks for now. Change-Id: Ib81fc738d45641a6a3a88d2adec1f3eb861f3f97 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
a9604bd895
commit
ba5ddc189e
2 changed files with 75 additions and 0 deletions
|
@ -318,8 +318,57 @@ extern void k_timer_restart(struct k_timer *timer, int32_t duration,
|
||||||
extern void k_timer_stop(struct k_timer *timer);
|
extern void k_timer_stop(struct k_timer *timer);
|
||||||
extern int k_timer_test(struct k_timer *timer, void **data, int wait);
|
extern int k_timer_test(struct k_timer *timer, void **data, int wait);
|
||||||
extern int32_t k_timer_remaining_get(struct k_timer *timer);
|
extern int32_t k_timer_remaining_get(struct k_timer *timer);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the time elapsed since the system booted (uptime)
|
||||||
|
*
|
||||||
|
* @return The current uptime of the system in ms
|
||||||
|
*/
|
||||||
|
|
||||||
extern int64_t k_uptime_get(void);
|
extern int64_t k_uptime_get(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the lower 32-bit of time elapsed since the system booted (uptime)
|
||||||
|
*
|
||||||
|
* This function is potentially less onerous in both the time it takes to
|
||||||
|
* execute, the interrupt latency it introduces and the amount of 64-bit math
|
||||||
|
* it requires than k_uptime_get(), but it only provides an uptime value of
|
||||||
|
* 32-bits. The user must handle possible rollovers/spillovers.
|
||||||
|
*
|
||||||
|
* At a rate of increment of 1000 per second, it rolls over approximately every
|
||||||
|
* 50 days.
|
||||||
|
*
|
||||||
|
* @return The current uptime of the system in ms
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint32_t k_uptime_get_32(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the difference between a reference time and the current uptime
|
||||||
|
*
|
||||||
|
* @param reftime A pointer to a reference time. It is updated with the current
|
||||||
|
* uptime upon return.
|
||||||
|
*
|
||||||
|
* @return The delta between the reference time and the current uptime.
|
||||||
|
*/
|
||||||
|
|
||||||
extern int64_t k_uptime_delta(int64_t *reftime);
|
extern int64_t k_uptime_delta(int64_t *reftime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the difference between a reference time and the current uptime
|
||||||
|
*
|
||||||
|
* The 32-bit version of k_uptime_delta(). It has the same perks and issues as
|
||||||
|
* k_uptime_get_32().
|
||||||
|
*
|
||||||
|
* @param reftime A pointer to a reference time. It is updated with the current
|
||||||
|
* uptime upon return.
|
||||||
|
*
|
||||||
|
* @return The delta between the reference time and the current uptime.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern uint32_t k_uptime_delta_32(int64_t *reftime);
|
||||||
|
|
||||||
extern bool k_timer_pool_is_empty(void);
|
extern bool k_timer_pool_is_empty(void);
|
||||||
|
|
||||||
extern uint32_t k_cycle_get_32(void);
|
extern uint32_t k_cycle_get_32(void);
|
||||||
|
|
|
@ -56,6 +56,11 @@ uint32_t sys_tick_get_32(void)
|
||||||
return (uint32_t)_sys_clock_tick_count;
|
return (uint32_t)_sys_clock_tick_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t k_uptime_get_32(void)
|
||||||
|
{
|
||||||
|
return __ticks_to_ms(sys_tick_get_32());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Return the current system tick count
|
* @brief Return the current system tick count
|
||||||
|
@ -79,6 +84,11 @@ int64_t sys_tick_get(void)
|
||||||
return tmp_sys_clock_tick_count;
|
return tmp_sys_clock_tick_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t k_uptime_get(void)
|
||||||
|
{
|
||||||
|
return __ticks_to_ms(sys_tick_get());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Return number of ticks since a reference time
|
* @brief Return number of ticks since a reference time
|
||||||
|
@ -145,6 +155,22 @@ uint32_t sys_tick_delta_32(int64_t *reftime)
|
||||||
return (uint32_t)_nano_tick_delta(reftime);
|
return (uint32_t)_nano_tick_delta(reftime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t k_uptime_delta(int64_t *reftime)
|
||||||
|
{
|
||||||
|
int64_t uptime, delta;
|
||||||
|
|
||||||
|
uptime = k_uptime_get();
|
||||||
|
delta = uptime - *reftime;
|
||||||
|
*reftime = uptime;
|
||||||
|
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t k_uptime_delta_32(int64_t *reftime)
|
||||||
|
{
|
||||||
|
return (uint32_t)k_uptime_delta(reftime);
|
||||||
|
}
|
||||||
|
|
||||||
/* handle the expired timeouts in the nano timeout queue */
|
/* handle the expired timeouts in the nano timeout queue */
|
||||||
|
|
||||||
#if defined(CONFIG_NANO_TIMEOUTS) || defined(CONFIG_NANO_TIMERS)
|
#if defined(CONFIG_NANO_TIMEOUTS) || defined(CONFIG_NANO_TIMERS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue