drivers/lsm303agr: fixed bug incorrectly assembling signed 16 bit integer from bytes

This commit is contained in:
garfieldG 2021-01-06 04:37:08 +02:00 committed by GitHub
parent 01e3f0d586
commit 3fb8f5df62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -315,9 +315,9 @@ int LSM303AGR::collect()
const hrt_abstime timestamp_sample = hrt_absolute_time();
// switch to right hand coordinate system in place
float x_raw = read_reg(OUTX_L_REG_M) + (read_reg(OUTX_H_REG_M) << 8);
float y_raw = read_reg(OUTY_L_REG_M) + (read_reg(OUTY_H_REG_M) << 8);
float z_raw = -(read_reg(OUTZ_L_REG_M) + (read_reg(OUTZ_H_REG_M) << 8));
int16_t x_raw = read_reg(OUTX_L_REG_M) + (read_reg(OUTX_H_REG_M) << 8);
int16_t y_raw = read_reg(OUTY_L_REG_M) + (read_reg(OUTY_H_REG_M) << 8);
int16_t z_raw = -(read_reg(OUTZ_L_REG_M) + (read_reg(OUTZ_H_REG_M) << 8));
_px4_mag.update(timestamp_sample, x_raw, y_raw, z_raw);