33 : spiSlave(spiBus, cs, spiConfig), temperatureDivider(temperatureDivider)
54 "sens={:X}, off={:X}, tcs={:X}, tco={:X}, tref={:X}, tempsens={:X}",
55 calibrationData.
sens, calibrationData.
off, calibrationData.
tcs,
79 uint32_t tmpRawTemperature =
84 if (tmpRawTemperature != 0)
85 rawTemperature = tmpRawTemperature;
87 LOG_ERR(logger,
"The read raw temperature isn't valid");
97 uint32_t tmpRawPressure = transaction.readRegister24(
REG_ADC_READ);
100 if (tmpRawPressure != 0)
101 rawPressure = tmpRawPressure;
103 LOG_ERR(logger,
"The read raw pressure isn't valid");
108 if (tempCounter % temperatureDivider == 0)
131 int32_t dt = rawTemperature - (((uint32_t)calibrationData.
tref) << 8);
132 int32_t temp = 2000 + (((uint64_t)dt * calibrationData.
tempsens) >> 23);
134 int64_t offs = ((int64_t)calibrationData.
off << 16) +
135 (((int64_t)calibrationData.
tco * dt) >> 7);
136 int64_t sens = ((int64_t)calibrationData.
sens << 15) +
137 (((int64_t)calibrationData.
tcs * dt) >> 8);
139 int64_t t2 = 0, off2 = 0, sens2 = 0;
144 t2 = (((int64_t)dt) * dt) >> 31;
145 off2 = 3 * (temp - 2000) * (temp - 2000);
146 sens2 = (7 * (temp - 2000) * (temp - 2000)) >> 3;
149 sens2 = sens2 + 2 * (temp + 1500) * (temp + 1500);
151 else if (temp >= 4500)
153 sens2 = sens2 - (((temp - 4500) * (temp - 4500)) >> 3);
161 (((((int64_t)rawPressure) * sens) / 2097152.0) - offs) / 32786.0;
165 lastTemperatureTimestamp, temp / 100.0f);
#define LOG_INFO(logger,...)
#define LOG_ERR(logger,...)
MS5803(SPIBusInterface &spiBus, miosix::GpioPin cs, SPIBusConfig spiConfig={}, uint16_t temperatureDivider=1)
bool init() override
Initialize the sensor.
MS5803Data sampleImpl() override
bool selfTest() override
Check if the sensor is working.
Interface for low level access of a SPI bus as a master.
Provides high-level access to the SPI Bus for a single transaction.
@ DISABLED
Do not set write bit in any way.
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::WriteBit writeBit
How long to wait before starting a tranmission after CS is set (us)