| 71 | * This class template provides basic C-style callbacks for best performance |
| 72 | */ |
| 73 | template <typename TimerApi> class CallbackTimer : protected TimerApi |
| 74 | { |
| 75 | public: |
| 76 | using typename TimerApi::Clock; |
| 77 | using typename TimerApi::TickType; |
| 78 | using typename TimerApi::TimeType; |
| 79 | using Millis = NanoTime::TimeSource<Clock, NanoTime::Milliseconds, uint32_t>; |
| 80 | using Micros = NanoTime::TimeSource<Clock, NanoTime::Microseconds, TimeType>; |
| 81 | |
| 82 | using TimerApi::maxTicks; |
| 83 | using TimerApi::minTicks; |
| 84 | using TimerApi::toString; |
| 85 | using TimerApi::typeName; |
| 86 | using TimerApi::operator String; |
| 87 | |
| 88 | /** @brief Get a millisecond time source */ |
| 89 | static constexpr Millis millis() |
| 90 | { |
| 91 | return Millis(); |
| 92 | } |
| 93 | |
| 94 | /** @brief Get a microsecond time source */ |
| 95 | static constexpr Micros micros() |
| 96 | { |
| 97 | return Micros(); |
| 98 | } |
| 99 | |
| 100 | /** @brief Convert microsecond count into timer ticks */ |
| 101 | template <uint64_t us> static constexpr uint64_t usToTicks() |
| 102 | { |
| 103 | return Micros::template timeToTicks<us>(); |
| 104 | } |
| 105 | |
| 106 | /** @brief Convert microsecond count into timer ticks */ |
| 107 | static TickType usToTicks(TimeType time) |
| 108 | { |
| 109 | return Micros::timeToTicks(time); |
| 110 | } |
| 111 | |
| 112 | /** @brief Convert timer ticks into microseconds */ |
| 113 | template <uint64_t ticks> static constexpr uint64_t ticksToUs() |
| 114 | { |
| 115 | return Micros::template ticksToTime<ticks>(); |
| 116 | } |
| 117 | |
| 118 | /** @brief Convert timer ticks into microseconds */ |
| 119 | static TimeType ticksToUs(TickType ticks) |
| 120 | { |
| 121 | return Micros::ticksToTime(ticks); |
| 122 | } |
| 123 | |
| 124 | /** @brief Initialise timer with an interval (static check) and callback |
| 125 | * @tparam unit Time unit for interval |
| 126 | * @tparam time Timer interval |
| 127 | * @param callback Callback function to call when timer triggers |
| 128 | * @param arg Optional argument passed to callback |
| 129 | * @retval CallbackTimer& Reference to timer |
| 130 | * @note If interval out of range compilation will fail with error |
nothing calls this directly
no test coverage detected