AP_BoardConfig: fixed device semaphore in board detect

thanks to Mark for finding this
This commit is contained in:
Andrew Tridgell 2018-02-09 09:42:16 +11:00
parent 2b86c0e962
commit abd659212e
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}