mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-09 01:13:57 -04:00
HAL_SITL: add methods to fetch native system clock info
This commit is contained in:
parent
c17aec07a2
commit
f0e6a8c535
@ -177,4 +177,45 @@ uint64_t millis64()
|
|||||||
return ret;
|
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
|
} // namespace AP_HAL
|
||||||
|
Loading…
Reference in New Issue
Block a user