NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ > Struct Template Reference

Class template representing a physical Clock with fixed timing characteristics. More...

#include <NanoTime.h>

Inheritance diagram for NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >:

Public Types

using TickType = TickType_
 
template<uint64_t ticks>
using TicksConst = TicksConst< Clock, ticks >
 
template<Unit unit, uint64_t time>
using TimeConst = TimeConst< Clock, unit, time >
 
template<Unit unit>
using TicksPerUnit = std::ratio_divide< std::ratio< frequency_ >, UnitTickRatio< unit > >
 
template<Unit unit, typename TimeType >
using TimeSource = TimeSource< Clock, unit, TimeType >
 
template<typename T >
using Ticks = Ticks< Clock, T >
 
using MaxTicks = TicksConst< maxTicks_ >
 
template<Unit unit>
using MaxTime = typename MaxTicks::template TimeConst< unit >
 

Static Public Member Functions

static constexpr const char * typeName ()
 
static constexpr uint32_t frequency ()
 
static constexpr MaxTicks maxTicks ()
 
template<Unit unit>
static constexpr MaxTime< unit > maxTime ()
 
static Ratio32 ticksPerUnit (Unit unit)
 Get ticks per unit as a Ratio object. More...
 
template<Unit unit, uint64_t time>
static constexpr TimeConst< unit, timetimeConst ()
 Class template defining a fixed time quantity. More...
 
template<uint64_t ticks>
static constexpr TicksConst< ticks > ticksConst ()
 Class template defining a fixed tick quantity. More...
 
template<Unit unit, typename TimeType >
static constexpr TimeSource< unit, TimeType > timeSource ()
 Create a Time Source for this Clock. More...
 
template<Unit unit, typename TimeType >
static Ticks< TimeType > timeToTicks (TimeType time)
 Get the number of ticks for a given time. More...
 
template<Unit unit, typename TimeType >
static Time< TimeType > ticksToTime (TimeType ticks)
 Get the time for a given number of clock ticks. More...
 
static String toString ()
 

Detailed Description

template<typename ClockDef, uint32_t frequency_, typename TickType_, TickType_ maxTicks_>
struct NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >

Class template representing a physical Clock with fixed timing characteristics.

Template Parameters
ClockDefThe actual Clock being constructed (so we can query its properties)
frequency_Clock frequency in Hz
TickType_Variable type representing the clock's tick value
maxTicks_Maximum count value for the clock
Note
Physical clocks are implemented using this as a base. The provided frequency accounts for any prescaler setting in force. Fixing this at compile time helps to avoid expensive runtime calculations and permits static range checks.
See also
Use TimeSource to work with a Clock in specific time units

Member Typedef Documentation

◆ MaxTicks

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::MaxTicks = TicksConst<maxTicks_>

◆ MaxTime

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit>
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::MaxTime = typename MaxTicks::template TimeConst<unit>

◆ Ticks

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<typename T >
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::Ticks = Ticks<Clock, T>

◆ TicksConst

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<uint64_t ticks>
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::TicksConst = TicksConst<Clock, ticks>

◆ TicksPerUnit

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit>
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::TicksPerUnit = std::ratio_divide<std::ratio<frequency_>, UnitTickRatio<unit> >

◆ TickType

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::TickType = TickType_

◆ TimeConst

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit, uint64_t time>
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::TimeConst = TimeConst<Clock, unit, time>

◆ TimeSource

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit, typename TimeType >
using NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::TimeSource = TimeSource<Clock, unit, TimeType>

Member Function Documentation

◆ frequency()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
static constexpr uint32_t NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::frequency ( )
inlinestaticconstexpr

◆ maxTicks()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
static constexpr MaxTicks NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::maxTicks ( )
inlinestaticconstexpr

◆ maxTime()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit>
static constexpr MaxTime<unit> NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::maxTime ( )
inlinestaticconstexpr

◆ ticksConst()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<uint64_t ticks>
static constexpr TicksConst<ticks> NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::ticksConst ( )
inlinestaticconstexpr

Class template defining a fixed tick quantity.

Template Parameters
ticks
Return values
TicksConst<Clock,ticks>

◆ ticksPerUnit()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
static Ratio32 NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::ticksPerUnit ( Unit  unit)
inlinestatic

Get ticks per unit as a Ratio object.

Return values
BasicRatio32

◆ ticksToTime()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit, typename TimeType >
static Time<TimeType> NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::ticksToTime ( TimeType  ticks)
inlinestatic

Get the time for a given number of clock ticks.

Parameters
ticks
Return values
TimeTypeTime count, rounded to the nearest unit

◆ timeConst()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit, uint64_t time>
static constexpr TimeConst<unit, time> NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::timeConst ( )
inlinestaticconstexpr

Class template defining a fixed time quantity.

Template Parameters
time
Return values
TimeConst

◆ timeSource()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit, typename TimeType >
static constexpr TimeSource<unit, TimeType> NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::timeSource ( )
inlinestaticconstexpr

Create a Time Source for this Clock.

Template Parameters
unit
TimeType

◆ timeToTicks()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
template<Unit unit, typename TimeType >
static Ticks<TimeType> NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::timeToTicks ( TimeType  time)
inlinestatic

Get the number of ticks for a given time.

Parameters
time
Return values
TimeTypeTick count, rounded to the nearest tick

◆ toString()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
static String NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::toString ( )
inlinestatic

◆ typeName()

template<typename ClockDef , uint32_t frequency_, typename TickType_ , TickType_ maxTicks_>
static constexpr const char* NanoTime::Clock< ClockDef, frequency_, TickType_, maxTicks_ >::typeName ( )
inlinestaticconstexpr

The documentation for this struct was generated from the following file: