aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRicardo Amezquita <ramezquitao@gmail.com>2018-06-17 19:59:29 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-07-24 11:16:05 -0400
commit756514adef4fcbd7e42e6e3e398a465923117cba (patch)
treedcc45fe46fb7a499940cc41f0bfb892108ff81a0 /src
parenteba252d3fd963ae10a51bea644f2b0c9e504e559 (diff)
downloadkutter-756514adef4fcbd7e42e6e3e398a465923117cba.tar.gz
kutter-756514adef4fcbd7e42e6e3e398a465923117cba.tar.xz
kutter-756514adef4fcbd7e42e6e3e398a465923117cba.zip
thermocouple: Add support for MAX6675 chip
The MAX6675 chip has a different read sequence than the MAX31855 chip. Signed-off-by: Ricardo Amézquita <ramezquitao@cihologramas.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/thermocouple.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/thermocouple.c b/src/thermocouple.c
index 5f4f7bb6..94dc42d2 100644
--- a/src/thermocouple.c
+++ b/src/thermocouple.c
@@ -16,7 +16,8 @@
enum {
TS_CHIP_MAX31855 = 1 << 0,
TS_CHIP_MAX31856 = 1 << 1,
- TS_CHIP_MAX31865 = 1 << 2
+ TS_CHIP_MAX31865 = 1 << 2,
+ TS_CHIP_MAX6675 = 1 << 3
};
struct thermocouple_spi {
@@ -48,7 +49,7 @@ void
command_config_thermocouple(uint32_t *args)
{
uint8_t chip_type = args[2];
- if (chip_type > TS_CHIP_MAX31865 || !chip_type)
+ if (chip_type > TS_CHIP_MAX6675 || !chip_type)
shutdown("Invalid thermocouple chip type");
struct thermocouple_spi *spi = oid_alloc(
args[0], command_config_thermocouple, sizeof(*spi));
@@ -90,7 +91,6 @@ thermocouple_respond(struct thermocouple_spi *spi, uint32_t next_begin_time
oid, next_begin_time, value, fault);
}
-/* Logic of thermocouple K readers MAX6675 and MAX31855 are same */
static void
thermocouple_handle_max31855(struct thermocouple_spi *spi
, uint32_t next_begin_time, uint8_t oid)
@@ -147,6 +147,21 @@ thermocouple_handle_max31865(struct thermocouple_spi *spi
try_shutdown("Thermocouple reader fault");
}
+static void
+thermocouple_handle_max6675(struct thermocouple_spi *spi
+ , uint32_t next_begin_time, uint8_t oid)
+{
+ uint8_t msg[2] = { 0x00, 0x00};
+ spidev_transfer(spi->spi, 1, sizeof(msg), msg);
+ uint16_t value;
+ memcpy(&value, msg, sizeof(msg));
+ value = be16_to_cpu(value);
+ thermocouple_respond(spi, next_begin_time, value, 0, oid);
+ // Kill after data send, host decode an error
+ if (value & 0x04)
+ try_shutdown("Thermocouple reader fault");
+}
+
// task to read thermocouple and send response
void
thermocouple_task(void)
@@ -172,6 +187,9 @@ thermocouple_task(void)
case TS_CHIP_MAX31865:
thermocouple_handle_max31865(spi, next_begin_time, oid);
break;
+ case TS_CHIP_MAX6675:
+ thermocouple_handle_max6675(spi, next_begin_time, oid);
+ break;
}
}
}