From 7832f1a1b6a7d25c857a0fe64a11a0db9091e46e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 1 Nov 2016 21:34:59 +1100 Subject: [PATCH] AP_InertialSensor: allow for in-tree drivers for PX4 --- libraries/AP_InertialSensor/AP_InertialSensor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor.cpp b/libraries/AP_InertialSensor/AP_InertialSensor.cpp index f5bdf3c445..df38b9505e 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "AP_InertialSensor.h" #include "AP_InertialSensor_BMI160.h" @@ -587,6 +588,17 @@ AP_InertialSensor::detect_backends(void) _add_backend(AP_InertialSensor_MPU6000::probe(*this, hal.i2c_mgr->get_device(HAL_INS_MPU60x0_I2C_BUS, HAL_INS_MPU60x0_I2C_ADDR))); _add_backend(AP_InertialSensor_MPU9250::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME))); #elif HAL_INS_DEFAULT == HAL_INS_PX4 || HAL_INS_DEFAULT == HAL_INS_VRBRAIN + if (AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_TEST_V1) { + _add_backend(AP_InertialSensor_MPU6000::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME))); + } else if (AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_TEST_V2) { + _add_backend(AP_InertialSensor_MPU6000::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME))); + _add_backend(AP_InertialSensor_LSM9DS0::probe(*this, + hal.spi->get_device(HAL_INS_LSM9DS0_G_NAME), + hal.spi->get_device(HAL_INS_LSM9DS0_A_NAME))); + } else if (AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_TEST_V4) { + _add_backend(AP_InertialSensor_MPU6000::probe(*this, hal.spi->get_device(HAL_INS_MPU60x0_NAME))); + } + // also add any PX4 backends (eg. canbus sensors) _add_backend(AP_InertialSensor_PX4::detect(*this)); #elif HAL_INS_DEFAULT == HAL_INS_MPU9250_SPI _add_backend(AP_InertialSensor_MPU9250::probe(*this, hal.spi->get_device(HAL_INS_MPU9250_NAME)));