AP_Baro: robust spi device

This commit is contained in:
Pat Hickey 2012-12-05 18:22:03 -08:00 committed by Andrew Tridgell
parent 60f7788be4
commit bfd03ab40c

View File

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