32 : slave(bus, cs, config), type(type)
57 spi.writeRegister(CR0, CR0_CMODE);
70 spi.writeRegister(CR0, CR0_CMODE | CR0_OCFAULT_0);
74 miosix::Thread::sleep(100);
77 auto fault = spi.readRegister(SR);
80 spi.writeRegister(CR0, CR0_CMODE);
82 return !(fault & SR_OPEN);
88 spi.writeRegister(CR1,
static_cast<uint8_t
>(type));
94 spi.writeRegister(CJTO,
95 static_cast<int8_t
>(offset * 1 / CJ_TEMP_LSB_VALUE));
101 int16_t cjRaw = spi.readRegister16(CJTH);
102 int32_t tcRaw = spi.readRegister24(LTCBH);
117 tcRaw = tcRaw >> (8 + 5);
124 result.temperature =
static_cast<float>(tcRaw) * TC_TEMP_LSB_VALUE;
127 result.coldJunctionTemperature =
128 static_cast<float>(cjRaw) * CJ_TEMP_LSB_VALUE;
MAX31856Data sampleImpl() override
Read a data sample from the sensor. In case of errors, the method should return the last available co...
bool checkConnected()
Checks whether the thermocouple is connected or not.
bool selfTest()
Check if the sensor is working.
bool init()
Initialize the sensor.
static SPIBusConfig getDefaultSPIConfig()
void setColdJunctionOffset(float offset)
void setThermocoupleType(ThermocoupleType type)
MAX31856(SPIBusInterface &bus, miosix::GpioPin cs, SPIBusConfig config=getDefaultSPIConfig(), ThermocoupleType type=ThermocoupleType::K_TYPE)
Interface for low level access of a SPI bus as a master.
Provides high-level access to the SPI Bus for a single transaction.
@ MODE_1
CPOL = 1, CPHA = 0 -> Clock high when idle, sample on first edge.
@ INVERTED
Inverted write bit settings (1 for write, 0 for reads)
uint64_t getTimestamp()
Returns the current timer value in microseconds.
This file includes all the types the logdecoder script will decode.
SPI Bus configuration for a specific slave.
SPI::ClockDivider clockDivider
< Peripheral clock division
uint64_t temperatureTimestamp