32 : bus(bus), temperatureDivider(temperatureDivider)
48 "sens={:X}, off={:X}, tcs={:X}, tco={:X}, tref={:X}, tempsens={:X}",
49 calibrationData.
sens, calibrationData.
off, calibrationData.
tcs,
67 if (!bus.
write(slaveConfig, &val, 1))
84 uint32_t tmpRawTemperature = (uint32_t)buffer[2] |
85 ((uint32_t)buffer[1] << 8) |
86 ((uint32_t)buffer[0] << 16);
90 if (tmpRawTemperature != 0)
91 rawTemperature = tmpRawTemperature;
93 LOG_ERR(logger,
"The read raw temperature isn't valid");
97 if (!bus.
write(slaveConfig, &val, 1))
114 uint32_t tmpRawPressure = (uint32_t)buffer[2] |
115 ((uint32_t)buffer[1] << 8) |
116 ((uint32_t)buffer[0] << 16);
119 if (tmpRawPressure != 0)
120 rawPressure = tmpRawPressure;
122 LOG_ERR(logger,
"The read raw pressure isn't valid");
127 if (tempCounter % temperatureDivider == 0)
131 if (!bus.
write(slaveConfig, &val, 1))
142 if (!bus.
write(slaveConfig, &val, 1))
160 int32_t dt = rawTemperature - (((uint32_t)calibrationData.
tref) << 8);
161 int32_t temp = 2000 + (((uint64_t)dt * calibrationData.
tempsens) >> 23);
163 int64_t offs = ((int64_t)calibrationData.
off << 16) +
164 (((int64_t)calibrationData.
tco * dt) >> 7);
165 int64_t sens = ((int64_t)calibrationData.
sens << 15) +
166 (((int64_t)calibrationData.
tcs * dt) >> 8);
168 int64_t t2 = 0, off2 = 0, sens2 = 0;
173 t2 = (((int64_t)dt) * dt) >> 31;
174 off2 = 3 * (temp - 2000) * (temp - 2000);
175 sens2 = (7 * (temp - 2000) * (temp - 2000)) >> 3;
178 sens2 = sens2 + 2 * (temp + 1500) * (temp + 1500);
180 else if (temp >= 4500)
182 sens2 = sens2 - (((temp - 4500) * (temp - 4500)) >> 3);
190 (((((int64_t)rawPressure) * sens) / 2097152.0) - offs) / 32786.0;
194 lastTemperatureTimestamp, temp / 100.0f);
197uint16_t MS5803I2C::readReg(uint8_t reg)
207 uint16_t data = (rcv[0] << 8) | rcv[1];
#define LOG_INFO(logger,...)
#define LOG_ERR(logger,...)
High level driver for the I2C peripherals.
bool readFromRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, void *buffer, const size_t nBytes)
Non blocking operation to read n-bytes from register from a slave.
bool write(const I2CDriver::I2CSlaveConfig &slaveConfig, const void *buffer, const size_t nBytes)
Non blocking write operation to write nBytes.
bool init() override
Initialize the sensor.
bool selfTest() override
Check if the sensor is working.
MS5803I2C(I2C &bus, uint16_t temperatureDivider=1)
MS5803Data sampleImpl() override
uint64_t getTimestamp()
Returns the current timer value in microseconds.
This file includes all the types the logdecoder script will decode.