Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BMI085 scaling issue #21960

Merged
merged 1 commit into from Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions libraries/AP_InertialSensor/AP_InertialSensor_BMI088.cpp
Expand Up @@ -155,7 +155,7 @@ static const struct {
uint8_t value;
} accel_config[] = {
{ REGA_CONF, 0xAC },
// setup 24g range
// setup 24g range (16g for BMI085)
{ REGA_RANGE, 0x03 },
// disable low-power mode
{ REGA_PWR_CONF, 0 },
Expand Down Expand Up @@ -207,10 +207,12 @@ bool AP_InertialSensor_BMI088::accel_init()
switch (v) {
case 0x1E:
_accel_devtype = DEVTYPE_INS_BMI088;
accel_range = 24.0;
hal.console->printf("BMI088: Found device\n");
break;
case 0x1F:
_accel_devtype = DEVTYPE_INS_BMI085;
accel_range = 16.0;
hal.console->printf("BMI085: Found device\n");
break;
default:
Expand Down Expand Up @@ -317,8 +319,8 @@ void AP_InertialSensor_BMI088::read_fifo_accel(void)
_inc_accel_error_count(accel_instance);
return;
}
// assume configured for 24g range
const float scale = (1.0/32768.0) * GRAVITY_MSS * 24.0;
// use new accel_range depending on sensor type
const float scale = (1.0/32768.0) * GRAVITY_MSS * accel_range;
const uint8_t *p = &data[0];
while (fifo_length >= 7) {
/*
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_InertialSensor/AP_InertialSensor_BMI088.h
Expand Up @@ -82,6 +82,7 @@ class AP_InertialSensor_BMI088 : public AP_InertialSensor_Backend {
enum Rotation rotation;
uint8_t temperature_counter;
enum DevTypes _accel_devtype;
float accel_range;

bool done_accel_config;
uint32_t accel_config_count;
Expand Down