X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=CAN-binder%2Flow-can-binding%2Futils%2Ftimer.hpp;h=432d513de3808641ad1008a1fa4bed89fca15708;hb=e4a50a3e96aa39346ad7212cae984524276973dd;hp=f565904482b263995093372e698d16e68bbfa4c0;hpb=f44a5b1549bc4c8a84d0dedf4a8b1e4220a34f42;p=apps%2Fagl-service-can-low-level.git diff --git a/CAN-binder/low-can-binding/utils/timer.hpp b/CAN-binder/low-can-binding/utils/timer.hpp index f5659044..432d513d 100644 --- a/CAN-binder/low-can-binding/utils/timer.hpp +++ b/CAN-binder/low-can-binding/utils/timer.hpp @@ -17,6 +17,9 @@ #pragma once +#include +#include + /// @brief return epoch in milliseconds /// /// @return long long int epoch in milliseconds @@ -34,20 +37,21 @@ class frequency_clock_t private: float unit_; ///< unit_ - multiplicator to make operation to be in the right unit (milli, micro, nano, etc) float frequency_; ///< the clock frequency in Hz. - unsigned long last_tick_; ///< the last time (in milliseconds since startup) that the clock ticked. + uint64_t last_tick_; ///< the last time (in microseconds since startup) that the clock ticked. time_function_t time_function_; ///< a function returning current time public: frequency_clock_t(); frequency_clock_t(float frequency); - frequency_clock_t(float frequency, unsigned long last_tick, time_function_t time_function); + frequency_clock_t(float frequency, uint64_t last_tick, time_function_t time_function); float get_frequency() const; + const struct timeval get_timeval_from_period() const; - float frequency_to_period(); + float frequency_to_period() const; bool started(); time_function_t get_time_function(); bool elapsed(bool stagger); - void tick(); + void tick(uint64_t timestamp); }; \ No newline at end of file