Skip to content

Commit db171f3

Browse files
committed
HAL_ChibiOS: allow delay callback in delay_microseconds_boost()
this makes for much faster disarmed mavlink processing
1 parent 24ffebc commit db171f3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libraries/AP_HAL_ChibiOS/Scheduler.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,21 @@ void Scheduler::boost_end(void)
196196
*/
197197
void Scheduler::delay_microseconds_boost(uint16_t usec)
198198
{
199-
if (!_priority_boosted && in_main_thread()) {
199+
const bool main_thread = in_main_thread();
200+
if (!_priority_boosted && main_thread) {
200201
set_high_priority();
201202
_priority_boosted = true;
202203
_called_boost = true;
203204
}
205+
if (main_thread && !hal.util->get_soft_armed() && usec >= 500) {
206+
const uint32_t start_us = AP_HAL::micros();
207+
call_delay_cb();
208+
const uint32_t dt_us = AP_HAL::micros() - start_us;
209+
if (dt_us >= usec) {
210+
return;
211+
}
212+
usec -= dt_us;
213+
}
204214
delay_microseconds(usec); //Suspends Thread for desired microseconds
205215
}
206216

0 commit comments

Comments
 (0)