Zoul: fix TMP102 value conversion

This commit is contained in:
Antonio Lignan 2016-08-24 16:34:02 +02:00
parent 6947fc7381
commit 32385b2910

View file

@ -58,7 +58,8 @@ tmp102_read(uint16_t *data)
if(i2c_single_send(TMP102_ADDR, TMP102_TEMP) == I2C_MASTER_ERR_NONE) {
/* Read two bytes only */
if(i2c_burst_receive(TMP102_ADDR, buf, 2) == I2C_MASTER_ERR_NONE) {
temp = (buf[0] << 8) + buf[1];
/* 12-bit value, TMP102 SBOS397F Table 8-9 */
temp = (buf[0] << 4) + (buf[1] >> 4);
if(temp > 2047) {
temp -= (1 << 12);
}