SatCat5
timeref.h File Reference

Detailed Description

TimeRef and TimeVal define the API for monotonic timers.

The TimeRef API (formerly GenericTimer) provides various methods for measuring elapsed time with a tick-counting time reference.

A SatCat5 design may have many TimeRef objects. The global "timekeeper" (see polling.h) selects one as the preferred general-purpose system reference. Access the system reference using the SATCAT5_CLOCK macro, which returns a TimeRef pointer.

Each TimeRef may be backed by a hardware counter, a timer interrupt, or software. User-defined implementations must meet the following:

  • Override the "raw()" method to return the current tick count.
  • The counter must tick upwards monotonically at a fixed rate.
    • Supported tick rate of 1 kHz to 1 GHz.
    • Preferred tick rate of 1-100 MHz.
  • The counter must rollover from UINT32_MAX back to zero.

SatCat5 provides several reference implementations:

  • cfg::Timer (satcat5/cfgbus_timer.h) Backing reference is a ConfigBus hardware timer (cfgbus_timer.vhd).
  • freertos::TickTimer (hal_freertos/tick_timer.h) Backing reference is the FreeRTOS system tick (xTaskGetTickCount).
  • util::PosixTimer (hal_posix/posix_utils.h) Backing reference is a POSIX monotonic clock (clock_gettime).
  • util::TimeRegister (this file) Backing reference is a memory-mapped address.

Definition in file timeref.h.

#include <satcat5/types.h>
#include <satcat5/utils.h>
Include dependency graph for timeref.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  satcat5::util::TimeVal
 Timestamp for measuring elapsed time. More...
 
class  satcat5::util::TimeRef
 The TimeRef API provides access to a monotonic time-counter. More...
 
class  satcat5::util::NullTimer
 Placeholder used if no timer is available. More...
 
class  satcat5::util::TimeRegister
 Implement TimeRef API using a memory-mapped performance counter. More...