From 0dbd6d70d50dec663c4b8a796a91168f0487594a Mon Sep 17 00:00:00 2001 From: dino Date: Wed, 27 Nov 2019 12:27:52 +0100 Subject: [PATCH] Fixed gyro com errors. Error check was triggering if board was not moved --- src/drivers/imu/bmi088/BMI088_gyro.cpp | 15 +++++++-------- src/drivers/imu/bmi088/BMI088_gyro.hpp | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/drivers/imu/bmi088/BMI088_gyro.cpp b/src/drivers/imu/bmi088/BMI088_gyro.cpp index e040ea3d31..35d96bbc54 100644 --- a/src/drivers/imu/bmi088/BMI088_gyro.cpp +++ b/src/drivers/imu/bmi088/BMI088_gyro.cpp @@ -357,7 +357,7 @@ BMI088_gyro::measure() /* * Fetch the full set of measurements from the BMI088 gyro in one pass. */ - bmi_gyroreport.cmd = BMI088_GYR_X_L | DIR_READ; + bmi_gyroreport.cmd = BMI088_GYR_CHIP_ID | DIR_READ; const hrt_abstime timestamp_sample = hrt_absolute_time(); @@ -371,20 +371,19 @@ BMI088_gyro::measure() // Get the last temperature from the accelerometer (the Gyro does not have its own temperature measurement) _last_temperature = _accel_last_temperature_copy; + report.gyro_x = bmi_gyroreport.gyro_x; report.gyro_y = bmi_gyroreport.gyro_y; report.gyro_z = bmi_gyroreport.gyro_z; - if (report.gyro_x == 0 && - report.gyro_y == 0 && - report.gyro_z == 0) { + if ((bmi_gyroreport.chip_id & 0x0f) != BMI088_GYR_WHO_AM_I) { // all zero data - probably an SPI bus error perf_count(_bad_transfers); perf_end(_sample_perf); - // note that we don't call reset() here as a reset() - // costs 20ms with interrupts disabled. That means if - // the bmi088 does go bad it would cause a FMU failure, - // regardless of whether another sensor is available, + // // note that we don't call reset() here as a reset() + // // costs 20ms with interrupts disabled. That means if + // // the bmi088 does go bad it would cause a FMU failure, + // // regardless of whether another sensor is available, return; } diff --git a/src/drivers/imu/bmi088/BMI088_gyro.hpp b/src/drivers/imu/bmi088/BMI088_gyro.hpp index 4fc87f3850..feac4abbaa 100644 --- a/src/drivers/imu/bmi088/BMI088_gyro.hpp +++ b/src/drivers/imu/bmi088/BMI088_gyro.hpp @@ -251,6 +251,7 @@ private: */ struct BMI_GyroReport { uint8_t cmd; + uint16_t chip_id; int16_t gyro_x; int16_t gyro_y; int16_t gyro_z;