From 25d078e2bd8d20cc97dac8610d20387bcec983b7 Mon Sep 17 00:00:00 2001 From: James Bielman Date: Thu, 10 Jan 2013 14:22:41 -0800 Subject: [PATCH] AP_Baro_MS5611: Don't panic if taking semaphore fails during init. - The MPU6000 holds on to the I2C semaphore for quite some time during init, which caused a panic when the MS5611 is also on I2C. --- libraries/AP_Baro/AP_Baro_MS5611.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/libraries/AP_Baro/AP_Baro_MS5611.cpp b/libraries/AP_Baro/AP_Baro_MS5611.cpp index ae623598c5..f0ec79ed00 100644 --- a/libraries/AP_Baro/AP_Baro_MS5611.cpp +++ b/libraries/AP_Baro/AP_Baro_MS5611.cpp @@ -119,10 +119,13 @@ bool AP_Baro_MS5611_SPI::sem_take_nonblocking() static int semfail_ctr = 0; bool got = _spi_sem->take_nonblocking(); if (!got) { - semfail_ctr++; - if (semfail_ctr > 100) { - hal.scheduler->panic(PSTR("PANIC: failed to take _spi_sem " - "100 times in a row, in AP_Baro_MS5611::_update")); + if (!hal.scheduler->system_initializing()) { + semfail_ctr++; + if (semfail_ctr > 100) { + hal.scheduler->panic(PSTR("PANIC: failed to take _spi_sem " + "100 times in a row, in " + "AP_Baro_MS5611::_update")); + } } return false; /* never reached */ } else { @@ -189,10 +192,13 @@ bool AP_Baro_MS5611_I2C::sem_take_nonblocking() static int semfail_ctr = 0; bool got = _i2c_sem->take_nonblocking(); if (!got) { - semfail_ctr++; - if (semfail_ctr > 100) { - hal.scheduler->panic(PSTR("PANIC: failed to take _i2c_sem " - "100 times in a row, in AP_Baro_MS5611::_update")); + if (!hal.scheduler->system_initializing()) { + semfail_ctr++; + if (semfail_ctr > 100) { + hal.scheduler->panic(PSTR("PANIC: failed to take _i2c_sem " + "100 times in a row, in " + "AP_Baro_MS5611::_update")); + } } return false; /* never reached */ } else {