Skip to content
Snippets Groups Projects
Commit 5ff7cb6e authored by Sebastian Meiling's avatar Sebastian Meiling
Browse files

drivers, lps331ap: fix overshift error on 8Bit MCUs

parent 93999515
No related branches found
No related tags found
No related merge requests found
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment