diff --git a/libraries/AP_Baro/AP_Baro_MS5611.cpp b/libraries/AP_Baro/AP_Baro_MS5611.cpp index 91487cb918..edf118a0c7 100644 --- a/libraries/AP_Baro/AP_Baro_MS5611.cpp +++ b/libraries/AP_Baro/AP_Baro_MS5611.cpp @@ -69,7 +69,9 @@ bool volatile AP_Baro_MS5611::_updated; AP_Baro_MS5611_Serial* AP_Baro_MS5611::_serial = NULL; AP_Baro_MS5611_SPI AP_Baro_MS5611::spi; +#if MS5611_WITH_I2C AP_Baro_MS5611_I2C AP_Baro_MS5611::i2c; +#endif // SPI Device ////////////////////////////////////////////////////////////////// @@ -154,7 +156,7 @@ void AP_Baro_MS5611_SPI::sem_give() } // I2C Device ////////////////////////////////////////////////////////////////// - +#if MS5611_WITH_I2C /** I2C address of the MS5611 on the PX4 board. */ #define MS5611_ADDR 0x76 @@ -225,6 +227,7 @@ void AP_Baro_MS5611_I2C::sem_give() { _i2c_sem->give(); } +#endif // MS5611_WITH_I2C // Public Methods ////////////////////////////////////////////////////////////// diff --git a/libraries/AP_Baro/AP_Baro_MS5611.h b/libraries/AP_Baro/AP_Baro_MS5611.h index 7ba488e991..6dd15cf610 100644 --- a/libraries/AP_Baro/AP_Baro_MS5611.h +++ b/libraries/AP_Baro/AP_Baro_MS5611.h @@ -6,6 +6,13 @@ #include #include "AP_Baro.h" +#if CONFIG_HAL_BOARD != HAL_BOARD_APM2 +#define MS5611_WITH_I2C 1 +#else +#define MS5611_WITH_I2C 0 +#endif + + /** Abstract serial device driver for MS5611. */ class AP_Baro_MS5611_Serial { @@ -49,6 +56,7 @@ private: AP_HAL::Semaphore *_spi_sem; }; +#if MS5611_WITH_I2C /** I2C serial device. */ class AP_Baro_MS5611_I2C : public AP_Baro_MS5611_Serial { @@ -64,6 +72,7 @@ public: private: AP_HAL::Semaphore *_i2c_sem; }; +#endif // MS5611_WITH_I2C class AP_Baro_MS5611 : public AP_Baro { @@ -82,7 +91,9 @@ public: /* Serial port drivers to pass to "init". */ static AP_Baro_MS5611_SPI spi; +#if MS5611_WITH_I2C static AP_Baro_MS5611_I2C i2c; +#endif private: void _calculate();