From 0af89e4766e5a25abb9d5d9667e2f187c4cec7c1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 12 Mar 2019 12:58:04 -0400 Subject: thermocouple: Define thermocouple types using enumerations Signed-off-by: Kevin O'Connor --- src/thermocouple.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/thermocouple.c b/src/thermocouple.c index 2389e7b6..412317fb 100644 --- a/src/thermocouple.c +++ b/src/thermocouple.c @@ -14,12 +14,14 @@ #include "spicmds.h" // spidev_transfer enum { - TS_CHIP_MAX31855 = 1 << 0, - TS_CHIP_MAX31856 = 1 << 1, - TS_CHIP_MAX31865 = 1 << 2, - TS_CHIP_MAX6675 = 1 << 3 + TS_CHIP_MAX31855, TS_CHIP_MAX31856, TS_CHIP_MAX31865, TS_CHIP_MAX6675 }; +DECL_ENUMERATION("thermocouple_type", "MAX31855", TS_CHIP_MAX31855); +DECL_ENUMERATION("thermocouple_type", "MAX31856", TS_CHIP_MAX31856); +DECL_ENUMERATION("thermocouple_type", "MAX31865", TS_CHIP_MAX31865); +DECL_ENUMERATION("thermocouple_type", "MAX6675", TS_CHIP_MAX6675); + struct thermocouple_spi { struct timer timer; uint32_t rest_time; @@ -49,7 +51,7 @@ void command_config_thermocouple(uint32_t *args) { uint8_t chip_type = args[2]; - if (chip_type > TS_CHIP_MAX6675 || !chip_type) + if (chip_type > TS_CHIP_MAX6675) shutdown("Invalid thermocouple chip type"); struct thermocouple_spi *spi = oid_alloc( args[0], command_config_thermocouple, sizeof(*spi)); @@ -58,7 +60,7 @@ command_config_thermocouple(uint32_t *args) spi->chip_type = chip_type; } DECL_COMMAND(command_config_thermocouple, - "config_thermocouple oid=%c spi_oid=%c chip_type=%c"); + "config_thermocouple oid=%c spi_oid=%c thermocouple_type=%c"); void command_query_thermocouple(uint32_t *args) -- cgit v1.2.3-70-g09d2