IMGJulian closed pull request #804: Sensors MPU6050: accelerometer range calculation fix URL: https://github.com/apache/mynewt-core/pull/804
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/hw/drivers/sensors/mpu6050/src/mpu6050.c b/hw/drivers/sensors/mpu6050/src/mpu6050.c index 6acb78f84..2d15ba587 100644 --- a/hw/drivers/sensors/mpu6050/src/mpu6050.c +++ b/hw/drivers/sensors/mpu6050/src/mpu6050.c @@ -529,11 +529,11 @@ mpu6050_sensor_read(struct sensor *sensor, sensor_type_t type, return rc; } - x = (int16_t)((payload[0] << 8) | payload[1]); - y = (int16_t)((payload[2] << 8) | payload[3]); - z = (int16_t)((payload[4] << 8) | payload[5]); + x = (((int16_t)payload[0]) << 8) | payload[1]; + y = (((int16_t)payload[2]) << 8) | payload[3]; + z = (((int16_t)payload[4]) << 8) | payload[5]; - switch (mpu->cfg.gyro_range) { + switch (mpu->cfg.accel_range) { case MPU6050_ACCEL_RANGE_2: /* +/- 2g - 16384 LSB/g */ /* Falls through */ default: @@ -571,9 +571,9 @@ mpu6050_sensor_read(struct sensor *sensor, sensor_type_t type, return rc; } - x = (int16_t)((payload[0] << 8) | payload[1]); - y = (int16_t)((payload[2] << 8) | payload[3]); - z = (int16_t)((payload[4] << 8) | payload[5]); + x = (((int16_t)payload[0]) << 8) | payload[1]; + y = (((int16_t)payload[2]) << 8) | payload[3]; + z = (((int16_t)payload[4]) << 8) | payload[5]; switch (mpu->cfg.gyro_range) { case MPU6050_GYRO_RANGE_250: /* +/- 250 Deg/s - 131 LSB/Deg/s */ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services