From 1cfc6f5a84586ac37648dc2ff8de216f87e0e185 Mon Sep 17 00:00:00 2001 From: caternuson Date: Wed, 29 Jun 2022 16:13:14 -0700 Subject: [PATCH 1/2] add fault check cycle modes --- Adafruit_MAX31865.cpp | 21 ++++++++++++++++++++- Adafruit_MAX31865.h | 9 ++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Adafruit_MAX31865.cpp b/Adafruit_MAX31865.cpp index 32bac94..9673470 100644 --- a/Adafruit_MAX31865.cpp +++ b/Adafruit_MAX31865.cpp @@ -74,7 +74,26 @@ bool Adafruit_MAX31865::begin(max31865_numwires_t wires) { @return The raw unsigned 8-bit FAULT status register */ /**************************************************************************/ -uint8_t Adafruit_MAX31865::readFault(void) { +uint8_t Adafruit_MAX31865::readFault(max31865_fault_cycle_t fault_cycle) { + if (fault_cycle) { + uint8_t cfg_reg = readRegister8(MAX31865_CONFIG_REG); + cfg_reg &= 0x11; // mask out wire and filter bits + switch (fault_cycle) { + case MAX31865_FAULT_AUTO: + writeRegister8(MAX31865_CONFIG_REG, (cfg_reg | 0b10000100)); + delay(1); + break; + case MAX31865_FAULT_MANUAL_RUN: + writeRegister8(MAX31865_CONFIG_REG, (cfg_reg | 0b10001000)); + return 0; + case MAX31865_FAULT_MANUAL_FINISH: + writeRegister8(MAX31865_CONFIG_REG, (cfg_reg | 0b10001100)); + return 0; + case MAX31865_FAULT_NONE: + default: + break; + } + } return readRegister8(MAX31865_FAULTSTAT_REG); } diff --git a/Adafruit_MAX31865.h b/Adafruit_MAX31865.h index bad2d45..e2a4210 100644 --- a/Adafruit_MAX31865.h +++ b/Adafruit_MAX31865.h @@ -60,6 +60,13 @@ typedef enum max31865_numwires { MAX31865_4WIRE = 0 } max31865_numwires_t; +typedef enum { + MAX31865_FAULT_NONE = 0, + MAX31865_FAULT_AUTO, + MAX31865_FAULT_MANUAL_RUN, + MAX31865_FAULT_MANUAL_FINISH +} max31865_fault_cycle_t; + /*! Interface class for the MAX31865 RTD Sensor reader */ class Adafruit_MAX31865 { public: @@ -69,7 +76,7 @@ class Adafruit_MAX31865 { bool begin(max31865_numwires_t x = MAX31865_2WIRE); - uint8_t readFault(void); + uint8_t readFault(max31865_fault_cycle_t fault_cycle = MAX31865_FAULT_AUTO); void clearFault(void); uint16_t readRTD(); From efced8af0bb38c68be7b085b5c48371f55179431 Mon Sep 17 00:00:00 2001 From: caternuson Date: Wed, 29 Jun 2022 16:27:37 -0700 Subject: [PATCH 2/2] docs --- Adafruit_MAX31865.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Adafruit_MAX31865.cpp b/Adafruit_MAX31865.cpp index 9673470..2d89014 100644 --- a/Adafruit_MAX31865.cpp +++ b/Adafruit_MAX31865.cpp @@ -71,6 +71,9 @@ bool Adafruit_MAX31865::begin(max31865_numwires_t wires) { /**************************************************************************/ /*! @brief Read the raw 8-bit FAULTSTAT register + @param fault_cycle The fault cycle type to run. Can be MAX31865_FAULT_NONE, + MAX31865_FAULT_AUTO, MAX31865_FAULT_MANUAL_RUN, or + MAX31865_FAULT_MANUAL_FINISH @return The raw unsigned 8-bit FAULT status register */ /**************************************************************************/