29 static const uint8_t
ADDR = 0x77;
32 #define CMD_RESET 0x1E // ADC reset command 33 #define CMD_ADC_READ 0x00 // ADC read command 34 #define CMD_ADC_CONV 0x40 // ADC conversion command 35 #define CMD_ADC_D1 0x00 // ADC D1 conversion 36 #define CMD_ADC_D2 0x10 // ADC D2 conversion 37 #define CMD_ADC_256 0x00 // ADC OSR=256 38 #define CMD_ADC_512 0x02 // ADC OSR=512 39 #define CMD_ADC_1024 0x04 // ADC OSR=1024 40 #define CMD_ADC_2048 0x06 // ADC OSR=2048 41 #define CMD_ADC_4096 0x08 // ADC OSR=4096 42 #define CMD_PROM_RD 0xA0 // Prom read command 46 #define REBOOT_PERIOD_MS 1000 * 60 * 30 // reboot the device every 30 minutes 97 uint8_t buf[2] = {0, 0};
100 for (
int i = 0;
i < 8;
i++)
104 prom[
i] = (uint16_t)(buf[0] << 8 | buf[1]);
121 uint8_t crc =
prom[7] & 0xF;
126 for (
int i = 0;
i < 16;
i++)
133 res ^= ((
prom[
i >> 1]) & 0x00FF);
135 res ^= (
prom[
i >> 1] >> 8);
136 for (
int j = 8; j > 0; j--)
144 if (!blank && crc == ((res >> 12) & 0xF))
173 bool got_valid_prom =
false;
174 for (
int i = 0;
i < 5;
i++)
182 got_valid_prom =
true;
220 int64_t off = ((int64_t)(
prom[2]) << 16) + (((int64_t)(
prom[4]) * dT) >> 7);
221 int64_t sens = ((int64_t)(
prom[1]) << 15) + (((int64_t)(
prom[3]) * dT) >> 8);
222 temp = 2000 + ((dT * (int64_t)(
prom[6])) >> 23);
228 delta = 5 * delta * delta;
236 delta = delta * delta;
238 sens -= (11 * delta) >> 1;
241 temp -= ((dT * dT) >> 31);
244 press = ((((uint64_t)(
pres_raw_) * sens) >> 21) - off) >> 15;
407 uint32_t now_ms =
millis();
static const uint8_t ADDR
bool i2cRead(uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t *buf)
volatile uint32_t millis(void)
void temp_start_cb(uint8_t result)
void temp_read_cb1(uint8_t result)
void delayMicroseconds(uint32_t us)
static const uint8_t PROM_RD
void write_zero_cb(uint8_t result)
void pres_read_cb1(uint8_t result)
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
ROSLIB_DECL std::string command(const std::string &cmd)
void temp_read_cb2(uint8_t result)
static volatile int16_t temp
void pres_start_cb(uint8_t result)
void reset_cb(uint8_t result)
void i2c_queue_job(i2cJobType_t type, uint8_t addr_, uint8_t reg_, uint8_t *data, uint8_t length, volatile uint8_t *status_, void(*CB)(uint8_t))
void pres_read_cb2(uint8_t result)
static callback_type_t callback_type_
void ms5611_async_update()
static void master_cb(uint8_t result)
void ms5611_async_read(float *pressure, float *temperature)