SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::hw::HiResClock Class Reference

High-resolution clock for high-precision measurements. More...

#include <stk_arch.h>

Static Public Member Functions

static Cycles GetCycles ()
 Get number of clock cycles elapsed.
static uint32_t GetFrequency ()
 Get clock frequency.
static Ticks GetTimeUs ()
 Get elapsed time in microseconds.

Detailed Description

High-resolution clock for high-precision measurements.

Warning
Calling hw::HiResClock directly requires a Privileged/Secure context. On TrustZone targets, Non-Secure/unprivileged callers must go through the NSC (Non-Secure Callable) gateway functions (NSC_stk_hw_HiResClock_GetFrequency, NSC_stk_hw_HiResClock_GetCycles) provided by the ARM Cortex-M back-end instead of calling this class directly.

Definition at line 674 of file stk_arch.h.

Member Function Documentation

◆ GetCycles()

Cycles stk::hw::HiResClock::GetCycles ( )
static

Get number of clock cycles elapsed.

Note
ISR-safe.
Returns
Clock cycles.

Referenced by GetTimeUs(), and stk_hires_cycles().

Here is the caller graph for this function:

◆ GetFrequency()

uint32_t stk::hw::HiResClock::GetFrequency ( )
static

Get clock frequency.

Note
ISR-safe.
Returns
Frequency in Hz.

Referenced by GetTimeUs(), and stk_hires_frequency().

Here is the caller graph for this function:

◆ GetTimeUs()

Ticks stk::hw::HiResClock::GetTimeUs ( )
inlinestatic

Get elapsed time in microseconds.

Note
ISR-safe.
Returns
Microseconds.

Definition at line 692 of file stk_arch.h.

693 {
694 Ticks ticks = 0LL;
695 const uint32_t freq = GetFrequency();
696
697 if (freq != 0U)
698 {
699 const Cycles cycles = GetCycles();
700 const Cycles ticksu = (cycles * 1000000ULL) / static_cast<Cycles>(freq);
701
702 ticks = static_cast<Ticks>(ticksu);
703 }
704
705 return ticks;
706 }
int64_t Ticks
Ticks value.
Definition stk_common.h:158
uint64_t Cycles
Cycles value.
Definition stk_common.h:168
static uint32_t GetFrequency()
Get clock frequency.
static Cycles GetCycles()
Get number of clock cycles elapsed.

References __stk_forceinline, GetCycles(), and GetFrequency().

Referenced by stk_hires_time_us().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: