From 68fe536da3d8a5132d852d06b6751531c9073325 Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Thu, 23 Jun 2016 12:30:54 -0300 Subject: [PATCH] AP_InertialSensor: use BMI160 for Intel Aero --- libraries/AP_InertialSensor/AP_InertialSensor.cpp | 8 ++++++++ .../AP_InertialSensor/AP_InertialSensor_BMI160.cpp | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor.cpp b/libraries/AP_InertialSensor/AP_InertialSensor.cpp index a68602a468..134bdf8554 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor.cpp @@ -567,6 +567,14 @@ AP_InertialSensor::detect_backends(void) } else { hal.console->printf("MPU9250: External IMU not detected\n"); } +#elif HAL_INS_DEFAULT == HAL_INS_AERO + auto *backend = AP_InertialSensor_BMI160::probe(*this, + hal.spi->get_device("bmi160")); + if (backend) { + _add_backend(backend); + } else { + hal.console->printf("aero: onboard IMU not detected\n"); + } #else #error Unrecognised HAL_INS_TYPE setting #endif diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_BMI160.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_BMI160.cpp index 087565bd0e..7faab178bb 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_BMI160.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_BMI160.cpp @@ -99,7 +99,11 @@ #define BMI160_READ_FLAG 0x80 #define BMI160_HARDWARE_INIT_MAX_TRIES 5 -#define BMI160_INT1_GPIO -1 +#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_AERO +# define BMI160_INT1_GPIO AERO_GPIO_BMI160_INT1 +#else +# define BMI160_INT1_GPIO -1 +#endif extern const AP_HAL::HAL& hal; @@ -384,6 +388,11 @@ read_fifo_read_data: (float)(int16_t)le16toh(raw_data[i].gyro.y), (float)(int16_t)le16toh(raw_data[i].gyro.z)}; +#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_AERO + accel.rotate(ROTATION_ROLL_180); + gyro.rotate(ROTATION_ROLL_180); +#endif + accel *= _accel_scale; gyro *= _gyro_scale;