distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
TickClock.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_TICKCLOCK_HPP_
13 #define INCLUDE_DISTORTOS_TICKCLOCK_HPP_
14 
16 
17 #include <chrono>
18 
19 namespace distortos
20 {
21 
28 class TickClock
29 {
30 public:
31 
33  using rep = int64_t;
34 
36  using period = std::ratio<1, DISTORTOS_TICK_FREQUENCY>;
37 
39  using duration = std::chrono::duration<rep, period>;
40 
42  using time_point = std::chrono::time_point<TickClock>;
43 
48  static time_point now();
49 
51  constexpr static bool is_steady {true};
52 };
53 
54 } // namespace distortos
55 
56 #endif // INCLUDE_DISTORTOS_TICKCLOCK_HPP_
int64_t rep
type of tick counter
Definition: TickClock.hpp:33
static constexpr bool is_steady
this is a steady clock - it cannot be adjusted
Definition: TickClock.hpp:51
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
static time_point now()
Definition: TickClock.cpp:20
distortos configuration
Top-level namespace of distortos project.
Definition: buttons.hpp:33
std::chrono::duration< rep, period > duration
basic duration type of clock
Definition: TickClock.hpp:39
std::ratio< 1, DISTORTOS_TICK_FREQUENCY > period
std::ratio type representing the tick period of the clock, seconds
Definition: TickClock.hpp:36
TickClock is a std::chrono clock, equivalent of std::chrono::steady_clock.
Definition: TickClock.hpp:28