From bfd03ab40cdc807c6bd3215078d9a0c22d1eab5d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 5 Dec 2012 18:22:03 -0800 Subject: [PATCH] AP_Baro: robust spi device --- libraries/AP_Baro/AP_Baro_MS5611.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Baro/AP_Baro_MS5611.cpp b/libraries/AP_Baro/AP_Baro_MS5611.cpp index 69038f97b9..ef94728a45 100644 --- a/libraries/AP_Baro/AP_Baro_MS5611.cpp +++ b/libraries/AP_Baro/AP_Baro_MS5611.cpp @@ -112,10 +112,16 @@ void AP_Baro_MS5611::_spi_write(uint8_t reg) // SPI should be initialized externally bool AP_Baro_MS5611::init() { - hal.scheduler->suspend_timer_procs(); _spi = hal.spi->device(AP_HAL::SPIDevice_MS5611); + if (_spi == NULL) { + hal.console->println_P(PSTR("PANIC: AP_Baro_MS5611 could not get " + "valid SPI device driver!")); + return false; + } _spi_sem = _spi->get_semaphore(); + hal.scheduler->suspend_timer_procs(); + _spi_write(CMD_MS5611_RESET); hal.scheduler->delay(4);