diff --git a/src/Utils/Timers.cpp b/src/Utils/Timers.cpp index e7136930..d8a54585 100644 --- a/src/Utils/Timers.cpp +++ b/src/Utils/Timers.cpp @@ -8,6 +8,17 @@ uint64_t GetTimeNow() return sys_time_get_system_time() / 1000; } +uint64_t GetCurrentTick() +{ + uint64_t freq = sys_time_get_timebase_frequency(); // This function returns the Time Base frequency in Hz + double dFreq = ((double)freq) / 1000.0; + + uint64_t newTime; + SYS_TIMEBASE_GET(newTime); // Get the current Time Base + + return (uint64_t)((double(newTime)) / dFreq); +} + void Sleep(uint64_t ms) { sys_timer_usleep(ms * 1000); diff --git a/src/Utils/Timers.hpp b/src/Utils/Timers.hpp index 67829c74..a5d071b1 100644 --- a/src/Utils/Timers.hpp +++ b/src/Utils/Timers.hpp @@ -3,9 +3,11 @@ #include #include #include +#include #include "vsh/vshmath.h" uint64_t GetTimeNow(); +uint64_t GetCurrentTick(); void Sleep(uint64_t ms); constexpr int MAX_VALUE_TIMERS = 20;