Skip to content

Commit 5af2621

Browse files
committed
HAL_SITL: added delay_microseconds_boost()
1 parent 5aad466 commit 5af2621

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libraries/AP_HAL_SITL/Scheduler.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,23 @@ void Scheduler::delay_microseconds(uint16_t usec)
136136
} while (true);
137137
}
138138

139+
/*
140+
delay from AP_InertialSensor wait for IMU sample
141+
*/
142+
void Scheduler::delay_microseconds_boost(uint16_t usec)
143+
{
144+
if (in_main_thread() && !hal.util->get_soft_armed() && usec >= 500) {
145+
const uint32_t start_us = AP_HAL::micros();
146+
call_delay_cb();
147+
const uint32_t dt_us = AP_HAL::micros() - start_us;
148+
if (dt_us >= usec) {
149+
return;
150+
}
151+
usec -= dt_us;
152+
}
153+
delay_microseconds(usec);
154+
}
155+
139156
void Scheduler::delay(uint16_t ms)
140157
{
141158
uint32_t start = AP_HAL::millis();

libraries/AP_HAL_SITL/Scheduler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class HALSITL::Scheduler : public AP_HAL::Scheduler {
2121
void init() override;
2222
void delay(uint16_t ms) override;
2323
void delay_microseconds(uint16_t us) override;
24+
void delay_microseconds_boost(uint16_t us) override;
2425

2526
void register_timer_process(AP_HAL::MemberProc) override;
2627
void register_io_process(AP_HAL::MemberProc) override;

0 commit comments

Comments
 (0)