Browse Source

HAL_SITL: add methods to fetch native system clock info

c415-sdk
Siddharth Purohit 5 years ago committed by Andrew Tridgell
parent
commit
f0e6a8c535
  1. 41
      libraries/AP_HAL_SITL/system.cpp

41
libraries/AP_HAL_SITL/system.cpp

@ -177,4 +177,45 @@ uint64_t millis64() @@ -177,4 +177,45 @@ uint64_t millis64()
return ret;
}
uint32_t native_micros()
{
return native_micros64() & 0xFFFFFFFF;
}
uint32_t native_millis()
{
return native_millis64() & 0xFFFFFFFF;
}
/*
we define a millis16() here to avoid an issue with sitl builds in cygwin
*/
uint16_t native_millis16()
{
return native_millis64() & 0xFFFF;
}
uint64_t native_micros64()
{
struct timeval tp;
gettimeofday(&tp, nullptr);
uint64_t ret = 1.0e6 * ((tp.tv_sec + (tp.tv_usec * 1.0e-6)) -
(state.start_time.tv_sec +
(state.start_time.tv_usec * 1.0e-6)));
return ret;
}
uint64_t native_millis64()
{
struct timeval tp;
gettimeofday(&tp, nullptr);
uint64_t ret = 1.0e3*((tp.tv_sec + (tp.tv_usec*1.0e-6)) -
(state.start_time.tv_sec +
(state.start_time.tv_usec*1.0e-6)));
return ret;
}
} // namespace AP_HAL

Loading…
Cancel
Save