149 , m_tick_per_msec(div_round<u64>(
ticks_per_sec << 32, 1000ull))
150 , m_tick_per_usec(div_round<u64>(
ticks_per_sec << 32, 1000000ull))
159 u64
const m_msec_per_tick;
160 u64
const m_usec_per_tick;
161 u64
const m_tick_per_msec;
162 u64
const m_tick_per_usec;
178 {
return u32((1000 * m_tick_per_msec) >> 32); }
180 {
return u32(m_tick_per_msec >> 32); }
182 {
return u32(m_tick_per_usec >> 32); }
203 u32
raw()
override {
return 0;}
211 constexpr
TimeRegister(
volatile u32* reg, u32 clkref_hz)
212 :
TimeRef(clkref_hz), m_reg(reg) {}
Placeholder used if no timer is available.
u32 raw() override
Read current time in arbitrary "ticks".
The TimeRef API provides access to a monotonic time-counter.
TimeVal checkpoint_msec(unsigned msec)
Create an oven-timer, set N milliseconds from now.
u32 ticks_per_msec() const
Stable accessors for unit conversion.
virtual u32 raw()=0
Read current time in arbitrary "ticks".
TimeVal now()
Create a TimeVal object using the tick-count from raw().
u32 ticks_per_usec() const
Stable accessors for unit conversion.
TimeVal checkpoint_usec(unsigned usec)
Create an oven-timer, set N microseconds from now.
constexpr TimeRef(u64 ticks_per_sec)
Constructor accepts a scale-factor for conversion to real-time.
u32 ticks_per_sec() const
Stable accessors for unit conversion.
void busywait_usec(unsigned usec)
If timer resolution allows, busywait for X microseconds.
Implement TimeRef API using a memory-mapped performance counter.
u32 raw() override
Read current time in arbitrary "ticks".
Timestamp for measuring elapsed time.
unsigned elapsed_usec() const
Elapsed time in microseconds.
bool interval_usec(unsigned usec)
Test an interval measured in microseconds.
unsigned elapsed_tick() const
Measure elapsed time in ticks.
TimeRef * clk
Pointer to the parent time reference.
bool checkpoint_elapsed()
Test if an oven-timer checkpoint has elapsed.
u32 tval
The value of this timestamp, measured in ticks.
bool interval_tick(u32 ticks)
Test an interval measured in ticks.
unsigned increment_msec()
Measure elapsed time in milliseconds, then increment by the returned quantized value.
unsigned elapsed_msec() const
Elapsed time in milliseconds.
bool interval_msec(unsigned msec)
Test an interval measured in milliseconds.
unsigned increment_usec()
Measure elapsed time in microseconds, then increment by the returned quantized value.
Basic type aliases and prototypes used throughout SatCat5.
Miscellaneous mathematical utility functions.
constexpr T div_ceil(T a, T b)
Integer division functions with various rounding options: