RTLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
System Class Referencefinal

HAL implementation for system clock. More...

#include <system.h>

Public Types

enum  ClockResolution : uint32_t { kLowRes = 1, kStdRes = 1000, kHighRes = 1000000 }
 Enumeration of clock resolution. More...
 

Public Member Functions

 System ()=delete
 Default constructor for System. More...
 

Static Public Member Functions

static void Init (ClockResolution clock_res=kStdRes)
 Initializes the timekeeping functionality. More...
 
static uint64_t GetUs ()
 Returns the time since clock initialization. More...
 
static uint64_t GetMs ()
 Returns the time since clock initialization. More...
 
static uint64_t GetS ()
 Returns the time since clock initialization. More...
 
static void DelayUs (uint64_t wait_us)
 Temporarily halt program execution. More...
 
static void DelayMs (uint64_t wait_ms)
 Temporarily halt program execution. More...
 
static void DelayS (uint64_t wait_s)
 Temporarily halt program execution. More...
 

Detailed Description

HAL implementation for system clock.

This abstraction layer provides timekeeping functionality. Since there is only one system clock, member functions can be called directly.

To use this class, Init() must be called. Otherwise, any of the member functions will not work as intended.

Member Enumeration Documentation

enum System::ClockResolution : uint32_t

Enumeration of clock resolution.

Generally, System::kStdRes will be used for its balance between accuracy and performance. Other accuracies are only for testing purposes.

Enumerator
kLowRes 

Low Clock Resolution.

System clock will update once every 1 second.

kStdRes 

Standard Clock Resolution.

System clock will update once every 1 millisecond.

kHighRes 

High Clock Resolution.

System clock will update once every 1 microsecond.

Constructor & Destructor Documentation

System::System ( )
delete

Default constructor for System.

This constructor is disabled to enforce a static class (singleton) pattern.

Member Function Documentation

void System::DelayMs ( uint64_t  wait_ms)
static

Temporarily halt program execution.

It is recommended to use this function if you use a standard resolution clock.

Note
If using low resolution clock, the wait time will be rounded to the nearest 1s.
Parameters
wait_msMilliseconds to wait.

Here is the call graph for this function:

void System::DelayS ( uint64_t  wait_s)
static

Temporarily halt program execution.

It is recommended to use this function if you use a low resolution clock.

Parameters
wait_sSeconds to wait.

Here is the call graph for this function:

void System::DelayUs ( uint64_t  wait_us)
static

Temporarily halt program execution.

It is recommended to use this function if you use a high resolution clock.

Note
If using standard or low resolution clock, the wait time will be rounded to the nearest 1ms (for standard resolution) or 1s (for low resolution).
Parameters
wait_usMicroseconds to wait.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t System::GetMs ( )
static

Returns the time since clock initialization.

It is recommended to use this function if you use a standard resolution clock.

Note
If using high or low resolution clock, the values will be clamped down to the nearest 1ms (for high resolution) or 1000ms (for low resolution).
Returns
Milliseconds since clock initialization.

Here is the call graph for this function:

uint64_t System::GetS ( )
static

Returns the time since clock initialization.

It is recommended to use this function if you use a low resolution clock.

Note
If using standard or high resolution clock, the values will be clamped down to the nearest 1s.
Returns
Seconds since clock initialization.

Here is the call graph for this function:

uint64_t System::GetUs ( )
static

Returns the time since clock initialization.

It is recommended to use this function if you use a high resolution clock.

Note
If using standard or low resolution clocks, the values will be clamped down to the nearest 1000us (for standard resolution) or 1000000us (for low resolution).
Returns
Microseconds since clock initialization.

Here is the caller graph for this function:

void System::Init ( ClockResolution  clock_res = kStdRes)
static

Initializes the timekeeping functionality.

Warning
This function should be invoked first before using other auxiliary functions. Failure to do so will cause incorrect times to be reported, and infinitely delaying loops.
Parameters
clock_resResolution of the clock. Defaults to 1 ms/update.

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