Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Adafruit_MAX31865.h
00001 /*************************************************** 00002 This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865 00003 00004 Designed specifically to work with the Adafruit RTD Sensor 00005 ----> https://www.adafruit.com/products/3328 00006 00007 This sensor uses SPI to communicate, 4 pins are required to 00008 interface 00009 Adafruit invests time and resources providing this open source code, 00010 please support Adafruit and open-source hardware by purchasing 00011 products from Adafruit! 00012 00013 Written by Limor Fried/Ladyada for Adafruit Industries. 00014 BSD license, all text above must be included in any redistribution 00015 00016 Modified for mbed project - Dan Julio - 5/2017 00017 ****************************************************/ 00018 #ifndef ADAFRUIT_MAX31865_H 00019 #define ADAFRUIT_MAX31865_H 00020 00021 #include <stdint.h> 00022 #include "mbed.h" 00023 #include "swspi.h" 00024 00025 #define MAX31865_CONFIG_REG 0x00 00026 #define MAX31865_CONFIG_BIAS 0x80 00027 #define MAX31865_CONFIG_MODEAUTO 0x40 00028 #define MAX31865_CONFIG_MODEOFF 0x00 00029 #define MAX31865_CONFIG_1SHOT 0x20 00030 #define MAX31865_CONFIG_3WIRE 0x10 00031 #define MAX31865_CONFIG_24WIRE 0x00 00032 #define MAX31865_CONFIG_FAULTSTAT 0x02 00033 #define MAX31865_CONFIG_FILT50HZ 0x01 00034 #define MAX31865_CONFIG_FILT60HZ 0x00 00035 00036 #define MAX31865_RTDMSB_REG 0x01 00037 #define MAX31865_RTDLSB_REG 0x02 00038 #define MAX31865_HFAULTMSB_REG 0x03 00039 #define MAX31865_HFAULTLSB_REG 0x04 00040 #define MAX31865_LFAULTMSB_REG 0x05 00041 #define MAX31865_LFAULTLSB_REG 0x06 00042 #define MAX31865_FAULTSTAT_REG 0x07 00043 00044 00045 #define MAX31865_FAULT_HIGHTHRESH 0x80 00046 #define MAX31865_FAULT_LOWTHRESH 0x40 00047 #define MAX31865_FAULT_REFINLOW 0x20 00048 #define MAX31865_FAULT_REFINHIGH 0x10 00049 #define MAX31865_FAULT_RTDINLOW 0x08 00050 #define MAX31865_FAULT_OVUV 0x04 00051 00052 00053 #define RTD_A 3.9083e-3 00054 #define RTD_B -5.775e-7 00055 00056 typedef enum max31865_numwires { 00057 MAX31865_2WIRE = 0, 00058 MAX31865_3WIRE = 1, 00059 MAX31865_4WIRE = 0 00060 } max31865_numwires_t; 00061 00062 00063 class Adafruit_MAX31865 { 00064 public: 00065 Adafruit_MAX31865(swspi& spiO, int ssNum, PinName rdyPin); 00066 00067 bool begin(max31865_numwires_t x = MAX31865_2WIRE); 00068 00069 uint8_t readFault(void); 00070 void clearFault(void); 00071 uint16_t readRTD(); 00072 00073 void setWires(max31865_numwires_t wires); 00074 void autoConvert(bool b); 00075 void enableBias(bool b); 00076 bool isReady(uint16_t* rtdVal); 00077 float temperature(float RTDnominal, float refResistor, uint16_t rtdVal = 0); 00078 00079 private: 00080 bool debug; 00081 int ssN; // Slave select for swspi 00082 swspi& spi; 00083 DigitalIn* rdyP; // Ready Pin 00084 00085 void readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n); 00086 00087 uint8_t readRegister8(uint8_t addr); 00088 uint16_t readRegister16(uint8_t addr); 00089 00090 void writeRegister8(uint8_t addr, uint8_t reg); 00091 }; 00092 00093 00094 #endif
Generated on Wed Jul 13 2022 17:53:11 by
1.7.2