Commit d48246a2 authored by Iulian Gheorghiu's avatar Iulian Gheorghiu

Fix soft timers, in some cases on some platforms a tick will take longer that is setup to happen.

parent 71a4d280
......@@ -23,7 +23,7 @@ GI::Sys::Timer::Timer()
GI::Sys::Timer::Timer(u64 interval)
{
memset(this, 0, sizeof(*this));
sTimmerInterval = interval & (u64)__INT64_MAX__;
sTimmerInterval = interval & (u64)0x7fffffffffffffff;
enable(true);
}
//#####################################################
......@@ -35,9 +35,9 @@ GI::Sys::Timer::~Timer()
void GI::Sys::Timer::interval(u64 interval)
{
#ifdef USE_RTC_100_MS
sTimmerInterval = (interval & (u64)INT64_MAX) / 10;
sTimmerInterval = (interval & (u64)0x7fffffffffffffff) / 10;
#else
sTimmerInterval = interval & (u64)__INT64_MAX__;
sTimmerInterval = interval & (u64)0x7fffffffffffffff;
#endif
enable(true);
}
......@@ -46,22 +46,22 @@ void GI::Sys::Timer::enable(bool action)
{
if (action)
{
sTimmerTickValue = (sTimmerInterval + STimerCnt)&(u64)__INT64_MAX__;
sTimmerTickValue = (sTimmerInterval + STimerCnt)&(u64)0x7fffffffffffffff;
}
else
{
sTimmerTickValue = sTimmerTickValue | (u64)(-__INT64_MAX__ - 1);
sTimmerTickValue = sTimmerTickValue | (u64)(-0x7fffffffffffffff - 1);
}
}
//#####################################################
bool GI::Sys::Timer::tick()
{
if(!(sTimmerTickValue & (u64)(-__INT64_MAX__ - 1)))
if(!(sTimmerTickValue & (u64)(-0x7fffffffffffffff - 1)))
{
u64 Temp1 = sTimmerTickValue & (u64)__INT64_MAX__;
u64 Temp2 = STimerCnt & (u64)__INT64_MAX__;
u64 Temp = (Temp1 - Temp2 - 1)& (u64)(-__INT64_MAX__ - 1);
if(Temp)
u64 Temp1 = sTimmerTickValue & (u64)0x7fffffffffffffff;
u64 Temp2 = STimerCnt & (u64)0x7fffffffffffffff;
//u64 Temp = (Temp1 - Temp2 - 1)& (u64)(-0x7fffffffffffffff - 1);
if(Temp2 >= Temp1)
{
enable(true);
return true;
......@@ -72,7 +72,7 @@ bool GI::Sys::Timer::tick()
//#####################################################
bool GI::Sys::Timer::enabled()
{
if(sTimmerTickValue & (u64)(-__INT64_MAX__ - 1))
if(sTimmerTickValue & (u64)(-0x7fffffffffffffff - 1))
return false;
else
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment