✏️ MAX31856 => MAX31865

This commit is contained in:
Scott Lahteine 2021-12-06 20:18:50 -06:00
parent c3b8b3e7e6
commit b77a5d4c8d
2 changed files with 31 additions and 31 deletions

View File

@ -166,7 +166,7 @@ void MAX31865::begin(max31865_numwires_t wires, float zero, float ref) {
" _miso: ", _miso, " _miso: ", _miso,
" _sclk: ", _sclk, " _sclk: ", _sclk,
" _mosi: ", _mosi, " _mosi: ", _mosi,
" config: ", readRegister8(MAX31856_CONFIG_REG) " config: ", readRegister8(MAX31865_CONFIG_REG)
); );
#endif #endif
} }
@ -177,14 +177,14 @@ void MAX31865::begin(max31865_numwires_t wires, float zero, float ref) {
* @return The raw unsigned 8-bit FAULT status register * @return The raw unsigned 8-bit FAULT status register
*/ */
uint8_t MAX31865::readFault() { uint8_t MAX31865::readFault() {
return readRegister8(MAX31856_FAULTSTAT_REG); return readRegister8(MAX31865_FAULTSTAT_REG);
} }
/** /**
* Clear all faults in FAULTSTAT. * Clear all faults in FAULTSTAT.
*/ */
void MAX31865::clearFault() { void MAX31865::clearFault() {
setConfig(MAX31856_CONFIG_FAULTSTAT, 1); setConfig(MAX31865_CONFIG_FAULTSTAT, 1);
} }
/** /**
@ -193,7 +193,7 @@ void MAX31865::clearFault() {
* @param b If true, auto conversion is enabled * @param b If true, auto conversion is enabled
*/ */
void MAX31865::autoConvert(bool b) { void MAX31865::autoConvert(bool b) {
setConfig(MAX31856_CONFIG_MODEAUTO, b); setConfig(MAX31865_CONFIG_MODEAUTO, b);
} }
/** /**
@ -202,7 +202,7 @@ void MAX31865::autoConvert(bool b) {
* @param b If true, 50Hz noise is filtered, else 60Hz(default) * @param b If true, 50Hz noise is filtered, else 60Hz(default)
*/ */
void MAX31865::enable50HzFilter(bool b) { void MAX31865::enable50HzFilter(bool b) {
setConfig(MAX31856_CONFIG_FILT50HZ, b); setConfig(MAX31865_CONFIG_FILT50HZ, b);
} }
/** /**
@ -211,7 +211,7 @@ void MAX31865::enable50HzFilter(bool b) {
* @param b If true bias is enabled, else disabled * @param b If true bias is enabled, else disabled
*/ */
void MAX31865::enableBias(bool b) { void MAX31865::enableBias(bool b) {
setConfig(MAX31856_CONFIG_BIAS, b); setConfig(MAX31865_CONFIG_BIAS, b);
// From the datasheet: // From the datasheet:
// Note that if VBIAS is off (to reduce supply current between conversions), any filter // Note that if VBIAS is off (to reduce supply current between conversions), any filter
@ -226,7 +226,7 @@ void MAX31865::enableBias(bool b) {
* Start a one-shot temperature reading. * Start a one-shot temperature reading.
*/ */
void MAX31865::oneShot() { void MAX31865::oneShot() {
setConfig(MAX31856_CONFIG_1SHOT, 1); setConfig(MAX31865_CONFIG_1SHOT, 1);
// From the datasheet: // From the datasheet:
// Note that a single conversion requires approximately 52ms in 60Hz filter // Note that a single conversion requires approximately 52ms in 60Hz filter
@ -242,12 +242,12 @@ void MAX31865::oneShot() {
* @param wires The number of wires in enum format * @param wires The number of wires in enum format
*/ */
void MAX31865::setWires(max31865_numwires_t wires) { void MAX31865::setWires(max31865_numwires_t wires) {
uint8_t t = readRegister8(MAX31856_CONFIG_REG); uint8_t t = readRegister8(MAX31865_CONFIG_REG);
if (wires == MAX31865_3WIRE) if (wires == MAX31865_3WIRE)
t |= MAX31856_CONFIG_3WIRE; t |= MAX31865_CONFIG_3WIRE;
else // 2 or 4 wire else // 2 or 4 wire
t &= ~MAX31856_CONFIG_3WIRE; t &= ~MAX31865_CONFIG_3WIRE;
writeRegister8(MAX31856_CONFIG_REG, t); writeRegister8(MAX31865_CONFIG_REG, t);
} }
/** /**
@ -261,7 +261,7 @@ uint16_t MAX31865::readRaw() {
enableBias(true); enableBias(true);
oneShot(); oneShot();
uint16_t rtd = readRegister16(MAX31856_RTDMSB_REG); uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG);
#ifdef MAX31865_DEBUG #ifdef MAX31865_DEBUG
SERIAL_ECHOLNPGM("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); SERIAL_ECHOLNPGM("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF));
@ -352,12 +352,12 @@ float MAX31865::temperature(float Rrtd) {
* @param enable whether to enable or disable the value * @param enable whether to enable or disable the value
*/ */
void MAX31865::setConfig(uint8_t config, bool enable) { void MAX31865::setConfig(uint8_t config, bool enable) {
uint8_t t = readRegister8(MAX31856_CONFIG_REG); uint8_t t = readRegister8(MAX31865_CONFIG_REG);
if (enable) if (enable)
t |= config; t |= config;
else else
t &= ~config; // disable t &= ~config; // disable
writeRegister8(MAX31856_CONFIG_REG, t); writeRegister8(MAX31865_CONFIG_REG, t);
} }
/** /**

View File

@ -45,24 +45,24 @@
#include "../HAL/shared/Delay.h" #include "../HAL/shared/Delay.h"
#include HAL_PATH(../HAL, MarlinSPI.h) #include HAL_PATH(../HAL, MarlinSPI.h)
#define MAX31856_CONFIG_REG 0x00 #define MAX31865_CONFIG_REG 0x00
#define MAX31856_CONFIG_BIAS 0x80 #define MAX31865_CONFIG_BIAS 0x80
#define MAX31856_CONFIG_MODEAUTO 0x40 #define MAX31865_CONFIG_MODEAUTO 0x40
#define MAX31856_CONFIG_MODEOFF 0x00 #define MAX31865_CONFIG_MODEOFF 0x00
#define MAX31856_CONFIG_1SHOT 0x20 #define MAX31865_CONFIG_1SHOT 0x20
#define MAX31856_CONFIG_3WIRE 0x10 #define MAX31865_CONFIG_3WIRE 0x10
#define MAX31856_CONFIG_24WIRE 0x00 #define MAX31865_CONFIG_24WIRE 0x00
#define MAX31856_CONFIG_FAULTSTAT 0x02 #define MAX31865_CONFIG_FAULTSTAT 0x02
#define MAX31856_CONFIG_FILT50HZ 0x01 #define MAX31865_CONFIG_FILT50HZ 0x01
#define MAX31856_CONFIG_FILT60HZ 0x00 #define MAX31865_CONFIG_FILT60HZ 0x00
#define MAX31856_RTDMSB_REG 0x01 #define MAX31865_RTDMSB_REG 0x01
#define MAX31856_RTDLSB_REG 0x02 #define MAX31865_RTDLSB_REG 0x02
#define MAX31856_HFAULTMSB_REG 0x03 #define MAX31865_HFAULTMSB_REG 0x03
#define MAX31856_HFAULTLSB_REG 0x04 #define MAX31865_HFAULTLSB_REG 0x04
#define MAX31856_LFAULTMSB_REG 0x05 #define MAX31865_LFAULTMSB_REG 0x05
#define MAX31856_LFAULTLSB_REG 0x06 #define MAX31865_LFAULTLSB_REG 0x06
#define MAX31856_FAULTSTAT_REG 0x07 #define MAX31865_FAULTSTAT_REG 0x07
#define MAX31865_FAULT_HIGHTHRESH 0x80 // D7 #define MAX31865_FAULT_HIGHTHRESH 0x80 // D7
#define MAX31865_FAULT_LOWTHRESH 0x40 // D6 #define MAX31865_FAULT_LOWTHRESH 0x40 // D6