AP_HAL: allow mutexes in bootloader

This commit is contained in:
Andrew Tridgell 2024-01-17 09:11:26 +11:00
parent 07fee626d9
commit b48a01dbc8
1 changed files with 4 additions and 0 deletions

View File

@ -12,14 +12,18 @@ WithSemaphore::WithSemaphore(AP_HAL::Semaphore *mtx, uint32_t line) :
WithSemaphore::WithSemaphore(AP_HAL::Semaphore &mtx, uint32_t line) :
_mtx(mtx)
{
#ifndef HAL_BOOTLOADER_BUILD
bool in_main = hal.scheduler->in_main_thread();
if (in_main) {
hal.util->persistent_data.semaphore_line = line;
}
#endif
_mtx.take_blocking();
#ifndef HAL_BOOTLOADER_BUILD
if (in_main) {
hal.util->persistent_data.semaphore_line = 0;
}
#endif
}
WithSemaphore::~WithSemaphore()