Fixed bug when reading temperature (abstemp was not always set).
This commit is contained in:
parent
6ea7250af7
commit
d635c03b52
1 changed files with 6 additions and 8 deletions
|
@ -181,11 +181,12 @@ tmp102_read_temp_simple (void)
|
||||||
int16_t abstemp, temp_int;
|
int16_t abstemp, temp_int;
|
||||||
|
|
||||||
raw = (int16_t) tmp102_read_reg (TMP102_TEMP);
|
raw = (int16_t) tmp102_read_reg (TMP102_TEMP);
|
||||||
if (raw < 0)
|
if(raw < 0) {
|
||||||
{
|
abstemp = (raw ^ 0xFFFF) + 1;
|
||||||
abstemp = (raw ^ 0xFFFF) + 1;
|
sign = -1;
|
||||||
sign = -1;
|
} else {
|
||||||
}
|
abstemp = raw;
|
||||||
|
}
|
||||||
|
|
||||||
/* Integer part of the temperature value */
|
/* Integer part of the temperature value */
|
||||||
temp_int = (abstemp >> 8) * sign;
|
temp_int = (abstemp >> 8) * sign;
|
||||||
|
@ -200,6 +201,3 @@ tmp102_read_temp_simple (void)
|
||||||
rd = (int8_t) (temp_int);
|
rd = (int8_t) (temp_int);
|
||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue