SatCat5
satcat5::util::TimeRegister Class Referencefinal

Detailed Description

Implement TimeRef API using a memory-mapped performance counter.

(i.e., A read-only register that reports elapsed clock cycles.) Note: The register MUST roll-over from UINT32_MAX to zero.

Definition at line 209 of file timeref.h.

#include <timeref.h>

Inheritance diagram for satcat5::util::TimeRegister:
[legend]
Collaboration diagram for satcat5::util::TimeRegister:
[legend]

Public Member Functions

constexpr TimeRegister (volatile u32 *reg, u32 clkref_hz)
 
u32 raw () override
 Read current time in arbitrary "ticks". More...
 
TimeVal now ()
 Create a TimeVal object using the tick-count from raw().
 
TimeVal checkpoint_usec (unsigned usec)
 Create an oven-timer, set N microseconds from now. More...
 
TimeVal checkpoint_msec (unsigned msec)
 Create an oven-timer, set N milliseconds from now. More...
 
void busywait_usec (unsigned usec)
 If timer resolution allows, busywait for X microseconds. More...
 
u32 ticks_per_sec () const
 Stable accessors for unit conversion. More...
 
u32 ticks_per_msec () const
 Stable accessors for unit conversion. More...
 
u32 ticks_per_usec () const
 Stable accessors for unit conversion. More...
 

Private Attributes

volatile u32 * m_reg
 
u64 const m_msec_per_tick
 
u64 const m_usec_per_tick
 
u64 const m_tick_per_msec
 
u64 const m_tick_per_usec
 

Member Function Documentation

◆ busywait_usec()

void TimeRef::busywait_usec ( unsigned  usec)
inherited

If timer resolution allows, busywait for X microseconds.

(May return immediately if backing reference is too coarse.)

Definition at line 93 of file timeref.cc.

◆ checkpoint_msec()

TimeVal TimeRef::checkpoint_msec ( unsigned  msec)
inherited

Create an oven-timer, set N milliseconds from now.

An over-timer TimeVal is a timestamp a short time in the future. To use it, create the TimeVal and then poll checkpoint_elapsed(). (The returned TimeVal is intended to be used exactly once.)

Definition at line 73 of file timeref.cc.

◆ checkpoint_usec()

TimeVal TimeRef::checkpoint_usec ( unsigned  usec)
inherited

Create an oven-timer, set N microseconds from now.

An over-timer TimeVal is a timestamp a short time in the future. To use it, create the TimeVal and then poll checkpoint_elapsed(). (The returned TimeVal is intended to be used exactly once.)

Definition at line 69 of file timeref.cc.

◆ raw()

u32 TimeRegister::raw ( )
overridevirtual

Read current time in arbitrary "ticks".

Tick-count MUST roll-over from UINT32_MAX to zero. Roll-over MUST NOT occur more than once per second. (Child class MUST define this method.)

Implements satcat5::util::TimeRef.

Definition at line 100 of file timeref.cc.

◆ ticks_per_msec()

u32 satcat5::util::TimeRef::ticks_per_msec ( ) const
inlineinherited

Stable accessors for unit conversion.

If the tick rate is low, these may return zero.

Definition at line 179 of file timeref.h.

◆ ticks_per_sec()

u32 satcat5::util::TimeRef::ticks_per_sec ( ) const
inlineinherited

Stable accessors for unit conversion.

If the tick rate is low, these may return zero.

Definition at line 177 of file timeref.h.

◆ ticks_per_usec()

u32 satcat5::util::TimeRef::ticks_per_usec ( ) const
inlineinherited

Stable accessors for unit conversion.

If the tick rate is low, these may return zero.

Definition at line 181 of file timeref.h.


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