#ifndef FREERTOS_CPP_TICKS_HPP #define FREERTOS_CPP_TICKS_HPP extern "C" { #include "FreeRTOS.h" #include "task.h" } namespace freertos { class Ticks final { public: explicit constexpr Ticks( TickType_t value ) noexcept : value_ { value } { } constexpr TickType_t count() const noexcept { return value_; } private: TickType_t value_; }; class TickPoint final { public: explicit constexpr TickPoint( TickType_t value ) noexcept : value_ { value } { } static TickPoint now() noexcept { return TickPoint { xTaskGetTickCount() }; } constexpr TickType_t count() const noexcept { return value_; } friend constexpr Ticks operator-( TickPoint later, TickPoint earlier ) noexcept { return Ticks { static_cast< TickType_t >( later.value_ - earlier.value_ ) }; } private: TickType_t value_; }; } // namespace freertos #endif