Skip to content

Commit

Permalink
Add GetCurrentTick()
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRouletteBoi committed Sep 16, 2022
1 parent cb1ad40 commit 3955573
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Utils/Timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/Utils/Timers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <unistd.h>
#include <sys/sys_time.h>
#include <sys/timer.h>
#include <sys/time_util.h>
#include "vsh/vshmath.h"

uint64_t GetTimeNow();
uint64_t GetCurrentTick();
void Sleep(uint64_t ms);

constexpr int MAX_VALUE_TIMERS = 20;
Expand Down

0 comments on commit 3955573

Please sign in to comment.