AP_InertialSensor: fixed _dump_registers() for MPU6000

need to take the semaphore to prevent bus errors
This commit is contained in:
Andrew Tridgell 2014-06-29 12:11:21 +10:00
parent 068febda1f
commit ece01da10e

View File

@ -575,14 +575,17 @@ bool AP_InertialSensor_MPU6000::_sample_available()
void AP_InertialSensor_MPU6000::_dump_registers(void) void AP_InertialSensor_MPU6000::_dump_registers(void)
{ {
hal.console->println_P(PSTR("MPU6000 registers")); hal.console->println_P(PSTR("MPU6000 registers"));
for (uint8_t reg=MPUREG_PRODUCT_ID; reg<=108; reg++) { if (_spi_sem->take(100)) {
uint8_t v = _register_read(reg); for (uint8_t reg=MPUREG_PRODUCT_ID; reg<=108; reg++) {
hal.console->printf_P(PSTR("%02x:%02x "), (unsigned)reg, (unsigned)v); uint8_t v = _register_read(reg);
if ((reg - (MPUREG_PRODUCT_ID-1)) % 16 == 0) { hal.console->printf_P(PSTR("%02x:%02x "), (unsigned)reg, (unsigned)v);
hal.console->println(); if ((reg - (MPUREG_PRODUCT_ID-1)) % 16 == 0) {
hal.console->println();
}
} }
hal.console->println();
_spi_sem->give();
} }
hal.console->println();
} }
#endif #endif