From e9b65b10dd535a8673af9d9cf429e693eaafdcb1 Mon Sep 17 00:00:00 2001 From: Michel Pastor Date: Fri, 8 Feb 2019 02:35:33 +0100 Subject: [PATCH] DS18B20 factorize --- src/main/drivers/temperature/ds18b20.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/drivers/temperature/ds18b20.c b/src/main/drivers/temperature/ds18b20.c index 3b68c87c57f..918ff870f4b 100644 --- a/src/main/drivers/temperature/ds18b20.c +++ b/src/main/drivers/temperature/ds18b20.c @@ -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) */