35 static void cb(uint8_t result);
37 #define REBOOT_PERIOD_MS 1000 * 60 * 30 // reboot the device every 30 minutes 64 bool got_valid_prom =
false;
65 for (
int i = 0;
i < 5;
i++)
73 got_valid_prom =
true;
102 uint32_t now_ms =
millis();
154 uint8_t buf[2] = {0, 0};
157 for (
int i = 0;
i < 8;
i++)
161 prom[
i] = static_cast<uint16_t>(buf[0] << 8 | buf[1]);
178 uint8_t crc =
prom[7] & 0xF;
183 for (
int i = 0;
i < 16;
i++)
190 res ^= ((
prom[
i >> 1]) & 0x00FF);
192 res ^= (
prom[
i >> 1] >> 8);
193 for (
int j = 8; j > 0; j--)
201 if (!blank && crc == ((res >> 12) & 0xF))
245 int32_t dT =
temp_raw_ - (
static_cast<int32_t
>(
prom[5]) << 8);
246 int64_t off = (
static_cast<int64_t
>(
prom[2]) << 16) + ((
static_cast<int64_t
>(
prom[4]) * dT) >> 7);
247 int64_t sens = (
static_cast<int64_t
>(
prom[1]) << 15) + ((
static_cast<int64_t
>(
prom[3]) * dT) >> 8);
248 temp = 2000 + ((dT *
static_cast<int64_t
>(
prom[6])) >> 23);
254 delta = 5 * delta * delta;
262 delta = delta * delta;
264 sens -= (11 * delta) >> 1;
267 temp -= ((dT * dT) >> 31);
270 press = (((
static_cast<uint64_t
>(
pres_raw_) * sens) >> 21) - off) >> 15;
427 void cb(uint8_t result)
void temp_start_cb(uint8_t result)
volatile uint32_t millis(void)
callback_type_t callback_type_
void temp_read_cb2(uint8_t result)
void pres_read_cb2(uint8_t result)
static void cb(uint8_t result)
void pres_read_cb1(uint8_t result)
void reset_cb(uint8_t result)
static volatile int16_t temp
void temp_read_cb1(uint8_t result)
void master_cb(uint8_t result)
int8_t write(uint8_t addr, uint8_t reg, uint8_t data, void(*callback)(uint8_t), bool blocking=false)
void pres_start_cb(uint8_t result)
int8_t read(uint8_t addr, uint8_t reg, uint8_t num_bytes, uint8_t *data, void(*callback)(uint8_t)=nullptr, bool blocking=false)
void write_zero_cb(uint8_t result)
void read(float *press, float *temp)
static const uint8_t ADDR