9 uint16_t remainder = 0;
10 for (uint8_t
byte = 0;
byte < 16; ++
byte) {
11 uint16_t word = prom->
word[
byte / 2];
16 (
byte & 1U) ? (uint16_t)(word & 0xFFU) : (uint16_t)(word >> 8);
17 for (uint8_t bit = 0; bit < 8; ++bit) {
21 uint16_t shifted = (uint16_t)(remainder << 1);
23 (remainder & 0x8000U) ? (uint16_t)(shifted ^ 0x3000U) : shifted;
26 return (uint8_t)((remainder >> 12) & 0x0FU);
33 uint16_t all_and = 0xFFFF, all_or = 0;
34 for (uint8_t i = 0; i < 8; ++i) {
35 const uint8_t tx[3] = {(uint8_t)(
CMD_PROM_READ + 2U * i), 0, 0};
37 if (bus->xfer(bus->ctx, tx, rx,
sizeof(tx)) !=
DEV_OK) {
40 prom->
word[i] = (uint16_t)(rx[1] << 8 | rx[2]);
41 all_and &= prom->
word[i];
42 all_or |= prom->
word[i];
44 if (all_and == 0xFFFF || all_or == 0) {
73 int32_t* temp_c100, int32_t* pressure_pa) {
74 const int64_t c1 = prom->
word[1], c2 = prom->
word[2], c3 = prom->
word[3];
75 const int64_t c4 = prom->
word[4], c5 = prom->
word[5], c6 = prom->
word[6];
77 const int64_t dt = (int64_t)
d2 - c5 * 256;
78 int64_t
temp = 2000 + dt * c6 / 8388608;
79 int64_t off = c2 * 65536 + c4 * dt / 128;
80 int64_t sens = c1 * 32768 + c3 * dt / 256;
83 const int64_t t2 = dt * dt / 2147483648LL;
84 const int64_t low = (
temp - 2000) * (
temp - 2000);
85 int64_t off2 = 5 * low / 2;
86 int64_t sens2 = 5 * low / 4;
88 const int64_t very_low = (
temp + 1500) * (
temp + 1500);
90 sens2 += 11 * very_low / 2;
96 *temp_c100 = (int32_t)
temp;
97 *pressure_pa = (int32_t)(((int64_t)
d1 * sens / 2097152 - off) /