mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Fixed bug when reading temperature (abstemp was not always set).
This commit is contained in:
parent
6ea7250af7
commit
d635c03b52
@ -181,11 +181,12 @@ tmp102_read_temp_simple (void)
|
||||
int16_t abstemp, temp_int;
|
||||
|
||||
raw = (int16_t) tmp102_read_reg (TMP102_TEMP);
|
||||
if (raw < 0)
|
||||
{
|
||||
abstemp = (raw ^ 0xFFFF) + 1;
|
||||
sign = -1;
|
||||
}
|
||||
if(raw < 0) {
|
||||
abstemp = (raw ^ 0xFFFF) + 1;
|
||||
sign = -1;
|
||||
} else {
|
||||
abstemp = raw;
|
||||
}
|
||||
|
||||
/* Integer part of the temperature value */
|
||||
temp_int = (abstemp >> 8) * sign;
|
||||
@ -200,6 +201,3 @@ tmp102_read_temp_simple (void)
|
||||
rd = (int8_t) (temp_int);
|
||||
return rd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user