60 } __attribute__((packed));
89 write(®,
sizeof(reg));
92 if (res !=
sizeof(
m_param))
return (
false);
95 uint16_t* p = (uint16_t*) &
m_param;
96 for (
size_t i = 0; i <
sizeof(
param_t) /
sizeof(uint16_t); i++, p++)
110 if (
m_cmd != 0)
return (
false);
115 if (!
acquire())
return (
false);
116 write(req,
sizeof(req));
117 if (!
release())
return (
false);
136 uint16_t run = millis() -
m_start;
142 if (!
acquire())
return (
false);
143 write(®,
sizeof(reg));
144 read(&UT,
sizeof(UT));
145 if (!
release())
return (
false);
175 if (
m_cmd != 0)
return (
false);
178 if (!
acquire())
return (
false);
181 write(&req,
sizeof(req));
182 if (!
release())
return (
false);
197 static const uint8_t PRESSURE_CONV_MS[] PROGMEM = {
206 uint16_t run = millis() -
m_start;
207 uint16_t ms = pgm_read_byte(&PRESSURE_CONV_MS[
m_mode]);
208 if (run < ms) delay(ms - run);
217 if (!
acquire())
return (
false);
218 write(®,
sizeof(reg));
219 read(&res.as_uint8[1], 3);
220 if (!
release())
return (
false);
223 int32_t UP = bswap32(res.as_int32) >> (8 -
m_mode);
224 int32_t B3, B6, X1, X2, X3;
229 X1 = (
m_param.
b2 * ((B6 * B6) >> 12)) >> 11;
234 X2 = (
m_param.
b1 * ((B6 * B6) >> 12)) >> 16;
235 X3 = ((X1 + X2) + 2) >> 2;
236 B4 = (
m_param.
ac4 * (uint32_t) (X3 + 32768)) >> 15;
237 B7 = ((uint32_t) UP - B3) * (50000 >>
m_mode);
238 m_pressure = (B7 < 0x80000000) ? (B7 << 1) / B4 : (B7 / B4) << 1;
240 X1 = (X1 * 3038) >> 16;
253 __attribute__((always_inline))
265 __attribute__((always_inline))
275 __attribute__((always_inline))
277 return ((
B5 + 8) >> 4);
310 } __attribute__((packed));
320 } __attribute__((packed));
328 } __attribute__((packed));
static const uint16_t TEMP_CONV_MS
Temperature conversion command.
bool sample_pressure_request()
bool sample_temperature()
Result register address (16-bit).
bool begin(Mode mode=ULTRA_LOW_POWER)
Pressure conversion command.
Hardware::TWI twi(100000UL)
Command register address (8-bit).
bool sample_temperature_request()
int write(const void *buf, size_t count)
Device(TWI &twi, uint8_t addr)
int16_t temperature() const
int read(void *buf, size_t count)
Calibration coefficients register address.