-
Notifications
You must be signed in to change notification settings - Fork 93
/
Adafruit_MAX31855.h
62 lines (54 loc) · 1.87 KB
/
Adafruit_MAX31855.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*!
* @file Adafruit_MAX31855.h
*
* This is the documentation for Adafruit's MAX31855 thermocouple breakout
* driver for the Arduino platform. It is designed specifically to work with
* the Adafruit MAX31855 breakout: https://www.adafruit.com/products/269
*
* These sensors use SPI to communicate, 3 pins are required
* to interface with the breakout.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Written by Limor Fried/Ladyada for Adafruit Industries.
*
* BSD license, all text above must be included in any redistribution.
*
*/
#ifndef ADAFRUIT_MAX31855_H
#define ADAFRUIT_MAX31855_H
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Adafruit_SPIDevice.h>
#define MAX31855_FAULT_NONE (0x00) ///< Disable all fault checks
#define MAX31855_FAULT_OPEN (0x01) ///< Enable open circuit fault check
#define MAX31855_FAULT_SHORT_GND (0x02) ///< Enable short to GND fault check
#define MAX31855_FAULT_SHORT_VCC (0x04) ///< Enable short to VCC fault check
#define MAX31855_FAULT_ALL (0x07) ///< Enable all fault checks
/**************************************************************************/
/*!
@brief Sensor driver for the Adafruit MAX31855 thermocouple breakout.
*/
/**************************************************************************/
class Adafruit_MAX31855 {
public:
Adafruit_MAX31855(int8_t _sclk, int8_t _cs, int8_t _miso);
Adafruit_MAX31855(int8_t _cs, SPIClass *_spi = &SPI);
bool begin(void);
double readInternal(void);
double readCelsius(void);
double readFahrenheit(void);
uint8_t readError();
void setFaultChecks(uint8_t faults);
private:
Adafruit_SPIDevice spi_dev;
bool initialized = false;
uint8_t faultMask = MAX31855_FAULT_ALL;
uint32_t spiread32(void);
};
#endif