mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-18 14:48:28 -04:00
HAL_SITL: fixed delay() for SITL threads
with the new thread_create() interface we need to handle delays a bit differently
This commit is contained in:
parent
785cf293cd
commit
10e9182c21
@ -56,15 +56,17 @@ void Scheduler::delay_microseconds(uint16_t usec)
|
|||||||
|
|
||||||
void Scheduler::delay(uint16_t ms)
|
void Scheduler::delay(uint16_t ms)
|
||||||
{
|
{
|
||||||
while (ms > 0) {
|
uint32_t start = AP_HAL::millis();
|
||||||
|
uint32_t now = start;
|
||||||
|
do {
|
||||||
delay_microseconds(1000);
|
delay_microseconds(1000);
|
||||||
ms--;
|
if (_min_delay_cb_ms <= (ms - (now - start))) {
|
||||||
if (_min_delay_cb_ms <= ms) {
|
|
||||||
if (in_main_thread()) {
|
if (in_main_thread()) {
|
||||||
call_delay_cb();
|
call_delay_cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
now = AP_HAL::millis();
|
||||||
|
} while (now - start < ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::register_timer_process(AP_HAL::MemberProc proc)
|
void Scheduler::register_timer_process(AP_HAL::MemberProc proc)
|
||||||
|
Loading…
Reference in New Issue
Block a user