diff --git a/libraries/AP_HAL_ChibiOS/Scheduler.cpp b/libraries/AP_HAL_ChibiOS/Scheduler.cpp index 36637c0987..76560422a7 100644 --- a/libraries/AP_HAL_ChibiOS/Scheduler.cpp +++ b/libraries/AP_HAL_ChibiOS/Scheduler.cpp @@ -29,6 +29,7 @@ #include #include +#include "shared_dma.h" using namespace ChibiOS; @@ -207,6 +208,10 @@ void Scheduler::reboot(bool hold_in_bootloader) hal.rcout->force_safety_on(); hal.rcout->force_safety_no_wait(); + // lock all shared DMA channels. This has the effect of waiting + // till the sensor buses are idle + Shared_DMA::lock_all(); + // delay to ensure the async force_saftey operation completes delay(500); diff --git a/libraries/AP_HAL_ChibiOS/shared_dma.cpp b/libraries/AP_HAL_ChibiOS/shared_dma.cpp index a381edb0d2..65aa0c1eb0 100644 --- a/libraries/AP_HAL_ChibiOS/shared_dma.cpp +++ b/libraries/AP_HAL_ChibiOS/shared_dma.cpp @@ -136,3 +136,14 @@ void Shared_DMA::unlock_from_IRQ(void) have_lock = false; chSysUnlockFromISR(); } + +/* + lock all channels - used on reboot to ensure no sensor DMA is in + progress + */ +void Shared_DMA::lock_all(void) +{ + for (uint8_t i=0; i