Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes | List of all members
Burger::Tick Class Reference

Low level timer manager. More...

Collaboration diagram for Burger::Tick:
Collaboration graph
[legend]

Classes

struct  Scaler_t
 

Static Public Member Functions

static Tickget_instance (void) noexcept
 Get the global instance of the timer system.
 
static void init (void) noexcept
 Initialize the low level timer manager.
 
static void shutdown (void) noexcept
 Shut down the low level timer manager.
 
static uint64_t get_high_precision_frequency (void) noexcept
 Get the frequency of the high precision timer.
 
static uint_t is_initialized (void) noexcept
 Check if the timer manager is initialized.
 
static uint64_t read_high_precision (void) noexcept
 Return the tick at the system's highest precision.
 
static uint32_t read (void) noexcept
 Retrieve the 60 hertz timer system time.
 
static uint32_t read_ms (void) noexcept
 Retrieve the 1Khz timer.
 
static uint32_t read_us (void) noexcept
 Retrieve the 1Mhz timer.
 
static uint32_t read_and_mark (void) noexcept
 Sync the 60 hertz timer.
 
static uint32_t get_mark (void) noexcept
 Get the 60 hertz timer sync value.
 
static void wait_one_tick (void) noexcept
 Sleep for a maximum of 1/60th of a second.
 
static void wait (uint_t uCount=1) noexcept
 Wait for a number of system ticks.
 
static uint_t wait_event (uint_t uCount=0) noexcept
 Sleep until a timeout or until a user input event.
 

Public Attributes

uint64_t m_uHighPrecisionFrequency
 High precision timer resolution in units per second.
 
uint32_t m_uLast60HertzMark
 Previously set 60 hertz tick value.
 
uint_t m_bInitialized
 TRUE if initialized
 

Static Public Attributes

static const uint32_t kTicksPerSecond = 60U
 Number of ticks per second.
 

Static Protected Member Functions

static uint64_t get_high_precision_rate (void) noexcept
 Return the ticks per second at the system's highest precision.
 

Static Protected Attributes

static Tick g_Tick
 Global instance of all data for timers.
 

Detailed Description

Low level timer manager.


Upon this class being started up, a global 60 hertz timer is created and via a background interrupt, it will increment 60 times a second. This is global and shared by all threads. The timer cannot stop.

The value can be zero for 1/60th of a second, so do not assume that a zero is an uninitialized state.

In addition to starting up this timer, higher precision timers are initialized so ticks accurate to milliseconds, microseconds and system precision.

Note
: The timer will wrap around 2 years. Do not assume it will not wrap around.
See also
read(), read_ms(), read_us() or FloatTimer

Member Function Documentation

◆ get_high_precision_frequency()

Burger::Tick::get_high_precision_frequency ( void )
inlinestaticnoexcept

Get the frequency of the high precision timer.


This value is in units per second. Divide the output of read_high_precision() by this number to determine the time in seconds.

See also
read(), read_ms(), read_us()

◆ get_high_precision_rate()

uint64_t BURGER_API Burger::Tick::get_high_precision_rate ( void )
staticprotectednoexcept

Return the ticks per second at the system's highest precision.


This platform specific code will ask the operating system what is the highest precision timer tick rate and then will return that value.

This value is cached and is available from get_high_precision_frequency()

See also
get_high_precision_frequency(), or read_high_precision()

◆ get_instance()

Burger::Tick::get_instance ( void )
inlinestaticnoexcept

Get the global instance of the timer system.


See also
init(), or shutdown()

◆ get_mark()

Burger::Tick::get_mark ( void )
inlinestaticnoexcept

Get the 60 hertz timer sync value.


When wait(), wait_event() and read_and_mark() are called, an internal sync value is updated. This function returns that value.

Note
This value will only change if any of the above calls are made. Otherwise the value will remain unchanging.
Returns
32 bit sync time value
See also
wait(), wait_event() or read_and_mark()

◆ init()

void BURGER_API Burger::Tick::init ( void )
staticnoexcept

Initialize the low level timer manager.


Start up the low level timer

See also
shutdown()

◆ is_initialized()

Burger::Tick::is_initialized ( void )
inlinestaticnoexcept

Check if the timer manager is initialized.


If TRUE, the timer has been initialized.

See also
init()

◆ read()

uint32_t BURGER_API Burger::Tick::read ( void )
staticnoexcept

Retrieve the 60 hertz timer system time.


When init() is called, a 60 hertz timer is created and via a background interrupt or other means, will increment 60 times a second.

The value can be zero for 1/60th of a second, so do not assume that a zero is an uninitialized state.

Returns
32 bit time value that increments 60 times a second
See also
read_and_mark()

◆ read_and_mark()

uint32_t BURGER_API Burger::Tick::read_and_mark ( void )
staticnoexcept

Sync the 60 hertz timer.


Read the current tick value and set the internal tick value it. Functions like wait() and wait_event() use this value to begin a time delay.

Returns
32 bit time value that increments 60 times a second
See also
read() or get_mark()

◆ read_high_precision()

uint64_t BURGER_API Burger::Tick::read_high_precision ( void )
staticnoexcept

Return the tick at the system's highest precision.


The value returns a tick that will increment at get_high_precision_frequency() ticks per second.

See also
get_high_precision_frequency()

◆ read_ms()

uint32_t BURGER_API Burger::Tick::read_ms ( void )
staticnoexcept

Retrieve the 1Khz timer.


Upon application start up, a 1Khz hertz timer is created and via a hardware timer, it will increment 1Mhz times a second.

The value can be zero for 1/1,000th of a second, so do not assume that a zero is an uninitialized state.

Note
Due to hardware limitations, do NOT assume this timer is accurate to 1/1,000th of a second. The granularity could be much courser, however, it will be incrementing at a rate to remain in sync to 1,000 ticks a second.
Returns
32 bit time value that increments at 1Khz
See also
Read() or read_us()

◆ read_us()

uint32_t BURGER_API Burger::Tick::read_us ( void )
staticnoexcept

Retrieve the 1Mhz timer.


Upon application start up, a 1Mhz hertz timer is created and via a hardward timer, it will increment 1Mhz times a second.

The value can be zero for 1/1,000,000th of a second, so do not assume that a zero is an uninitialized state.

Note
Due to hardware limitations, do NOT assume this timer is accurate to 1/1,000,000th of a second. The granularity could be much courser, however, it will be incrementing at a rate to remain in sync to 1,000,000 ticks a second.
Returns
32 bit time value that increments at 1Mhz
See also
read() or read_ms()

◆ shutdown()

void BURGER_API Burger::Tick::shutdown ( void )
staticnoexcept

Shut down the low level timer manager.


Shut down the low level timer

See also
init()

◆ wait()

void BURGER_API Burger::Tick::wait ( uint_t uCount = 1)
staticnoexcept

Wait for a number of system ticks.


Sleep the application for approximately the number of units in 1/60ths of a second. The delay is a maximum.

Note
If zero is passed, this function does not issue a delay
Parameters
uCountNumber of 1/60ths of a second to sleep.
See also
wait_one_tick(), wait_event() or read_and_mark()

◆ wait_event()

uint_t BURGER_API Burger::Tick::wait_event ( uint_t uCount = 0)
staticnoexcept

Sleep until a timeout or until a user input event.


Parameters
uCountNumber of 1/60ths of a second to sleep for a timeout. Zero is no timeout.
Returns
TRUE if an input event caused the function to end, FALSE if it timed out
See also
wait_one_tick(), wait() or read_and_mark()

◆ wait_one_tick()

void BURGER_API Burger::Tick::wait_one_tick ( void )
staticnoexcept

Sleep for a maximum of 1/60th of a second.


Sync to the current tick mark and sleep the application until the next time the timer increments.

See also
wait(), wait_event() or read_and_mark()

Member Data Documentation

◆ g_Tick

Burger::Tick Burger::Tick::g_Tick
staticprotected

Global instance of all data for timers.

◆ kTicksPerSecond

const uint32_t Burger::Tick::kTicksPerSecond = 60U
static

Number of ticks per second.

◆ m_bInitialized

uint_t Burger::Tick::m_bInitialized

TRUE if initialized

◆ m_uHighPrecisionFrequency

uint64_t Burger::Tick::m_uHighPrecisionFrequency

High precision timer resolution in units per second.

◆ m_uLast60HertzMark

uint32_t Burger::Tick::m_uLast60HertzMark

Previously set 60 hertz tick value.