44 for (i = 0; i < 8; i++) {
54 for (i = 0; i < 16; i++) {
56 res ^= ((prom[i >> 1]) & 0x00FF);
59 res ^= (prom[i >> 1] >> 8);
61 for (j = 8; j > 0; j--) {
70 if (
crc == ((res >> 12) & 0xF)) {
83 int64_t dt, tempms, off, sens, t2, off2, sens2;
86 dt = ms->
d2 - (int64_t)ms->
c[5] * (1 << 8);
88 tempms = 2000 + ((int64_t)dt * ms->
c[6]) / (1 << 23);
90 off = ((int64_t)ms->
c[2] * (1 << 16)) + ((int64_t)ms->
c[4] * dt) / (1 << 7);
92 sens = ((int64_t)ms->
c[1] * (1 << 15)) + ((int64_t)ms->
c[3] * dt) / (1 << 8);
95 t2 = (dt * dt) / (1 << 31);
96 off2 = 5 * ((int64_t)(tempms - 2000) * (tempms - 2000)) / (1 << 1);
97 sens2 = 5 * ((int64_t)(tempms - 2000) * (tempms - 2000)) / (1 << 2);
99 off2 = off2 + 7 * (int64_t)(tempms + 1500) * (tempms + 1500);
100 sens2 = sens2 + 11 * ((int64_t)(tempms + 1500) * (tempms + 1500)) / (1 << 1);
102 tempms = tempms - t2;
108 uint32_t p = (((int64_t)ms->
d1 * sens) / (1 << 21) - off) / (1 << 15);
110 if ((tempms > -4000) && (tempms < 8500) && (
p > 1000) && (
p < 120000)) {
126 int64_t dt, tempms, off, sens, t2, off2, sens2;
129 dt = ms->
d2 - (int64_t)ms->
c[5] * (1 << 8);
131 tempms = 2000 + ((int64_t)dt * ms->
c[6]) / (1 << 23);
133 off = ((int64_t)ms->
c[2] * (1 << 17)) + ((int64_t)ms->
c[4] * dt) / (1 << 6);
135 sens = ((int64_t)ms->
c[1] * (1 << 16)) + ((int64_t)ms->
c[3] * dt) / (1 << 7);
138 t2 = (dt * dt) / (1 << 31);
139 off2 = 61 * ((int64_t)(tempms - 2000) * (tempms - 2000)) / (1 << 4);
140 sens2 = 2 * ((int64_t)(tempms - 2000) * (tempms - 2000));
141 if (tempms < -1500) {
142 off2 = off2 + 15 * (int64_t)(tempms + 1500) * (tempms + 1500);
143 sens2 = sens2 + 8 * ((int64_t)(tempms + 1500) * (tempms + 1500));
145 tempms = tempms - t2;
151 uint32_t p = (((int64_t)ms->
d1 * sens) / (1 << 21) - off) / (1 << 15);
153 if ((tempms > -4000) && (tempms < 8500) && (
p > 1000) && (
p < 120000)) {
bool ms5607_calc(struct Ms5611Data *ms)
Calculate temperature and compensated pressure for MS5607.
bool ms5611_prom_crc_ok(uint16_t *prom)
Check if CRC of PROM data is OK.
bool ms5611_calc(struct Ms5611Data *ms)
Calculate temperature and compensated pressure for MS5611.
MS5611 barometer driver common interface (I2C and SPI).
uint32_t pressure
pressure in Pascal (0.01mbar)
int32_t temperature
temperature with 0.01 degrees Celsius resolution
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.