1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers, lps331ap: fix overshift error on 8Bit MCUs

This commit is contained in:
smlng 2017-08-31 16:24:12 +02:00
parent 9399951546
commit 5ff7cb6e0c

View File

@ -86,7 +86,7 @@ int lps331ap_read_temp(const lps331ap_t *dev)
val |= tmp;
i2c_read_reg(dev->i2c, dev->address, LPS331AP_REG_TEMP_OUT_H, &tmp);
i2c_release(dev->i2c);
val |= (tmp << 8);
val |= ((uint16_t)tmp << 8);
/* compute actual temperature value in °C */
res += ((float)val) / TEMP_DIVIDER;
@ -105,13 +105,13 @@ int lps331ap_read_pres(const lps331ap_t *dev)
i2c_read_reg(dev->i2c, dev->address, LPS331AP_REG_PRESS_OUT_XL, &tmp);
val |= tmp;
i2c_read_reg(dev->i2c, dev->address, LPS331AP_REG_PRESS_OUT_L, &tmp);
val |= (tmp << 8);
val |= ((uint32_t)tmp << 8);
i2c_read_reg(dev->i2c, dev->address, LPS331AP_REG_PRESS_OUT_H, &tmp);
i2c_release(dev->i2c);
val |= (tmp << 16);
val |= ((uint32_t)tmp << 16);
/* see if value is negative */
if (tmp & 0x80) {
val |= (0xff << 24);
val |= ((uint32_t)0xff << 24);
}
/* compute actual pressure value in mbar */