From e7dce1817b9beac424859710a860b0d2b35d613a Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Wed, 19 Oct 2016 22:41:43 +0200 Subject: [PATCH] MAX6675: change evaluation of spi result https://cdn-shop.adafruit.com/datasheets/MAX6675.pdf When thermocouple is open (bit2), we send a "not ready", reset active and hopefully we get a result next time. --- temp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/temp.c b/temp.c index 37ad925..10ac04e 100644 --- a/temp.c +++ b/temp.c @@ -250,11 +250,14 @@ static uint16_t temp_max6675_read(temp_sensor_t i) { spi_deselect_max6675(); - if ((temp & 0x8002) == 0) { - // Got "device id". - if ((temp & 4) == 0) { - temp = temp >> 3; - } + if ((temp & 0x4) == 0) { + temp = temp >> 3; + } + else { + // thermocouple open, send "not ready" + temp = TEMP_NOT_READY; + // and we will read it next time. + temp_sensors_runtime[i].active = 0; } return temp;