Skip to content

Commit

Permalink
DS18B20 factorize
Browse files Browse the repository at this point in the history
  • Loading branch information
shellixyz committed Feb 8, 2019
1 parent e64adca commit e9b65b1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/drivers/temperature/ds18b20.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ bool ds18b20ReadTemperature(owDev_t *owDev, uint64_t rom, int16_t *temperature)
ack = ds18b20ReadScratchpadBuf(owDev, buf, 9);
if (!ack) return false;

if (buf[8] != ds_crc8(buf, 8)) return false;
*temperature = (int16_t)(((buf[0] | (buf[1] << 8)) >> 3) | ((buf[1] & 0x80) ? 0xE000 : 0)) * 5;
return true;
return ds18b20ReadTemperatureFromScratchPadBuf(buf, temperature);
}

#endif /* defined(USE_1WIRE) && defined(USE_TEMPERATURE_DS18B20) */

0 comments on commit e9b65b1

Please sign in to comment.