diff --git a/libraries/AP_BoardConfig/board_drivers.cpp b/libraries/AP_BoardConfig/board_drivers.cpp index dc96951e70..7b70747efc 100644 --- a/libraries/AP_BoardConfig/board_drivers.cpp +++ b/libraries/AP_BoardConfig/board_drivers.cpp @@ -120,11 +120,16 @@ bool AP_BoardConfig::spi_check_register(const char *devname, uint8_t regnum, uin return false; } dev->set_read_flag(read_flag); + if (!dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) { + return false; + } uint8_t v; if (!dev->read_registers(regnum, &v, 1)) { hal.console->printf("%s: reg %02x read fail\n", devname, (unsigned)regnum); + dev->get_semaphore()->give(); return false; } + dev->get_semaphore()->give(); hal.console->printf("%s: reg %02x expected:%02x got:%02x\n", devname, (unsigned)regnum, (unsigned)value, (unsigned)v); return v == value; }