File tree 2 files changed +24
-1
lines changed 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,11 @@ float MAX31855Class::readTCTemperature() {
146
146
rawword = readSensor ();
147
147
148
148
// Check for reading error
149
- if (rawword & 0x7 ) {
149
+ lastFault = rawword & _faultMask;
150
+ if (_lastFault) {
150
151
return NAN;
151
152
}
153
+
152
154
// The cold junction temperature is stored in the last 14 word's bits
153
155
// whereas the ttermocouple temperature (non linearized) is in the topmost 18 bits
154
156
// sent by the Thermocouple-to-Digital Converter
@@ -221,6 +223,15 @@ void MAX31855Class::setColdOffset(float offset) {
221
223
_coldOffset = offset;
222
224
}
223
225
226
+ void MAX31855Class::setFaultChecks (uint8_t faults) {
227
+ _faultMask = faults & TC_FAULT_ALL;
228
+ }
229
+
230
+ uint8_t MAX31855Class::getLastFault () {
231
+ uint8_t tempLastFault = _lastFault;
232
+ _lastFault = 0 ;
233
+ return tempLastFault;
234
+ }
224
235
225
236
void MAX31855Class::setTCType (uint8_t type) {
226
237
_current_probe_type = type;
Original file line number Diff line number Diff line change 14
14
#define PROBE_J PROBE_TC_J
15
15
#define PROBE_T PROBE_TC_T
16
16
17
+ #define TC_FAULT_NONE (0x00 ) // Disable all fault checks
18
+ #define TC_FAULT_OPEN (0x01 ) // Enable open circuit fault check
19
+ #define TC_FAULT_SHORT_GND (0x02 ) // Enable short to GND fault check
20
+ #define TC_FAULT_SHORT_VCC (0x04 ) // Enable short to VCC fault check
21
+ #define TC_FAULT_ALL (0x07 ) // Enable all fault checks
22
+
17
23
class MAX31855Class {
18
24
public:
19
25
MAX31855Class (PinName cs = MC_TC_CS_PIN, SPIClass& spi = SPI);
@@ -24,11 +30,17 @@ class MAX31855Class {
24
30
float readTCTemperature ();
25
31
float readReferenceTemperature ();
26
32
void setColdOffset (float offset);
33
+
34
+ void setFaultChecks (uint8_t faults);
35
+ uint8_t getLastFault ();
36
+
27
37
void setTCType (uint8_t type);
28
38
29
39
private:
30
40
uint32_t readSensor ();
31
41
float _coldOffset;
42
+ uint8_t _faultMask = TC_FAULT_ALL;
43
+ uint8_t _lastFault = 0 ;
32
44
uint8_t _current_probe_type;
33
45
PinName _cs;
34
46
SPIClass* _spi;
You can’t perform that action at this time.
0 commit comments