Class hal::steady_clock
ClassList > hal > steady_clock
Hardware abstraction interface for a steady clock mechanism. More...
#include <steady_clock.hpp>
Inherited by the following classes: hal::cortex_m::dwt_counter, hal::mock::steady_clock, hal::soft::inert_steady_clock
Classes
Type | Name |
---|---|
struct | frequency_t Result from requesting the operating frequency of the steady clock. |
struct | uptime_t Result from calling uptime. |
Public Functions
Type | Name |
---|---|
frequency_t | frequency () Get the operating frequency of the steady clock. |
uptime_t | uptime () Get the current value of the steady clock. |
virtual | ~steady_clock () = default |
Detailed Description
Implementations of this interface must follow the same requirements as a std::chrono::steady_clock, in that the clock is monotonic & steady. An additional requirement is added to ensure that the clock is reliable. Meaning calls to the interface functions do not return errors because this clock should be infallible. To ensure this, this clock should be driven by the platform's peripheral drivers or some other mechanism that is unlikely to go offline while the platform is in a normal operating state.
This clock is steady meaning that subsequent calls to get the uptime of this clock cannot decrease as physical time moves forward and the time between ticks of this clock are constant and defined by the clock's frequency.
This can be used to get the time since the boot up, or to be more accurate, the time when the steady clock object is created. This clock is most suitable for measuring time intervals.
After creation of this clock, the operating frequency shall not change.
Public Functions Documentation
function frequency
Get the operating frequency of the steady clock.
inline frequency_t hal::steady_clock::frequency ()
Returns:
result<frequency_t> - operating frequency of the steady clock. Guaranteed to be a positive value by the implementing driver.
function uptime
Get the current value of the steady clock.
inline uptime_t hal::steady_clock::uptime ()
Returns:
uptime_t - uptime information
function ~steady_clock
virtual hal::steady_clock::~steady_clock () = default
The documentation for this class was generated from the following file libraries/include/libhal/steady_clock.hpp