clock: add k_cycle_get_64
This change adds `k_cycle_get_64()` on platforms that support a 64-bit cycle counter. The interface functions `arch_k_cycle_get_64()` and `sys_clock_cycle_get_64()` are also introduced. Fixes #39934 Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This commit is contained in:
parent
90ed7557e7
commit
918a574c88
25 changed files with 205 additions and 4 deletions
|
@ -1639,6 +1639,27 @@ static inline uint32_t k_cycle_get_32(void)
|
|||
return arch_k_cycle_get_32();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the 64-bit hardware clock.
|
||||
*
|
||||
* This routine returns the current time in 64-bits, as measured by the
|
||||
* system's hardware clock, if available.
|
||||
*
|
||||
* @see CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
|
||||
*
|
||||
* @return Current hardware clock up-counter (in cycles).
|
||||
*/
|
||||
static inline uint64_t k_cycle_get_64(void)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER)) {
|
||||
__ASSERT(0, "64-bit cycle counter not enabled on this platform. "
|
||||
"See CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return arch_k_cycle_get_64();
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue