HAL_SITL: use uint64_div1000()

match ChibiOS
This commit is contained in:
Andrew Tridgell 2023-12-20 16:24:27 +11:00
parent 4a59097b5e
commit f3303c9272

View File

@ -9,6 +9,7 @@
#include <AP_HAL/system.h>
#include "Scheduler.h"
#include <AP_Math/div1000.h>
extern const AP_HAL::HAL& hal;
@ -179,18 +180,7 @@ uint64_t micros64()
uint64_t millis64()
{
const HALSITL::Scheduler* scheduler = HALSITL::Scheduler::from(hal.scheduler);
uint64_t stopped_usec = scheduler->stopped_clock_usec();
if (stopped_usec) {
return stopped_usec / 1000;
}
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;
return uint64_div1000(micros64());
}
} // namespace AP_HAL