From 6b4a8c94bc34bee2ee1410970fc0b228450aed38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rik=20B=C3=A4hnemann?= Date: Mon, 17 Jul 2023 19:14:46 +0200 Subject: [PATCH 1/3] Read proper accelerometer registers --- bmi08a.c | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/bmi08a.c b/bmi08a.c index 5bb9a89..d77475b 100644 --- a/bmi08a.c +++ b/bmi08a.c @@ -1515,36 +1515,28 @@ int8_t bmi08a_get_synchronized_data(struct bmi08_sensor_data *accel, /* Proceed if pointers are not NULL */ if ((accel != NULL) && (gyro != NULL)) { - /* Read accel x,y sensor data */ - reg_addr = BMI08_REG_ACCEL_GP_0; - rslt = bmi08a_get_regs(reg_addr, &data[0], 4, dev); + /* Read accel x,y, z sensor data */ + rslt = bmi08a_get_regs(BMI08_REG_ACCEL_X_LSB, &data[0], 6, dev); if (rslt == BMI08_OK) { - /* Read accel sensor data */ - reg_addr = BMI08_REG_ACCEL_GP_4; - rslt = bmi08a_get_regs(reg_addr, &data[4], 2, dev); + lsb = data[0]; + msb = data[1]; + msblsb = (msb << 8) | lsb; + accel->x = ((int16_t) msblsb); /* Data in X axis */ - if (rslt == BMI08_OK) - { - lsb = data[0]; - msb = data[1]; - msblsb = (msb << 8) | lsb; - accel->x = ((int16_t) msblsb); /* Data in X axis */ - - lsb = data[2]; - msb = data[3]; - msblsb = (msb << 8) | lsb; - accel->y = ((int16_t) msblsb); /* Data in Y axis */ - - lsb = data[4]; - msb = data[5]; - msblsb = (msb << 8) | lsb; - accel->z = ((int16_t) msblsb); /* Data in Z axis */ - - /* Read gyro sensor data */ - rslt = bmi08g_get_data(gyro, dev); - } + lsb = data[2]; + msb = data[3]; + msblsb = (msb << 8) | lsb; + accel->y = ((int16_t) msblsb); /* Data in Y axis */ + + lsb = data[4]; + msb = data[5]; + msblsb = (msb << 8) | lsb; + accel->z = ((int16_t) msblsb); /* Data in Z axis */ + + /* Read gyro sensor data */ + rslt = bmi08g_get_data(gyro, dev); } } else From c4d2cbe59ac8430fdc3ab003b346f81090d6dd4a Mon Sep 17 00:00:00 2001 From: Rik Girod Date: Wed, 27 Sep 2023 12:29:16 +0200 Subject: [PATCH 2/3] Fix BMI08_ACCEL_BW_MASK --- bmi08_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmi08_defs.h b/bmi08_defs.h index 69d1de5..7607e21 100644 --- a/bmi08_defs.h +++ b/bmi08_defs.h @@ -282,7 +282,7 @@ /**\name Mask definitions for odr, bandwidth and range */ #define BMI08_ACCEL_ODR_MASK UINT8_C(0x0F) -#define BMI08_ACCEL_BW_MASK UINT8_C(0xF0) +#define BMI08_ACCEL_BW_MASK UINT8_C(0x70) #define BMI08_ACCEL_RANGE_MASK UINT8_C(0x03) /**\name Position definitions for odr, bandwidth and range */ From 766d869ed720bc932d7021508584f95c4e163e0a Mon Sep 17 00:00:00 2001 From: Rik Girod Date: Wed, 27 Sep 2023 12:34:00 +0200 Subject: [PATCH 3/3] Revert BMI08_ACCEL_BW_MASK for this branch --- bmi08_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmi08_defs.h b/bmi08_defs.h index 7607e21..69d1de5 100644 --- a/bmi08_defs.h +++ b/bmi08_defs.h @@ -282,7 +282,7 @@ /**\name Mask definitions for odr, bandwidth and range */ #define BMI08_ACCEL_ODR_MASK UINT8_C(0x0F) -#define BMI08_ACCEL_BW_MASK UINT8_C(0x70) +#define BMI08_ACCEL_BW_MASK UINT8_C(0xF0) #define BMI08_ACCEL_RANGE_MASK UINT8_C(0x03) /**\name Position definitions for odr, bandwidth and range */