From edef2ceb56880511a5b4987c11657374f02c88d4 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 1 Nov 2021 18:18:52 +1100 Subject: [PATCH] SITL: usleep only on AP_HAL_SITL --- libraries/SITL/SIM_Aircraft.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index 00f355a336..5c5f9d5f2b 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -40,6 +40,8 @@ using namespace SITL; +extern const AP_HAL::HAL& hal; + /* parent class for all simulator types */ @@ -281,7 +283,13 @@ void Aircraft::sync_frame_time(void) } if (sleep_debt_us > min_sleep_time) { // sleep if we have built up a debt of min_sleep_tim +#if CONFIG_HAL_BOARD == HAL_BOARD_SITL usleep(sleep_debt_us); +#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS + hal.scheduler->delay_microseconds(sleep_debt_us); +#else + // ?? +#endif sleep_debt_us -= (get_wall_time_us() - now); } last_wall_time_us = get_wall_time_us();