46 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(interface->get_device_id())),
47 _px4_baro(interface->get_device_id()),
48 _interface(interface),
73 PX4_WARN(
"failed to reset baro during init");
78 PX4_WARN(
"id of your baro is not: 0x%02x",
BMP3_CHIP_ID);
85 PX4_WARN(
"failed to get baro cal init");
90 PX4_WARN(
"failed to validate trim param");
95 PX4_WARN(
"failed to set sensor settings");
101 PX4_WARN(
"measure failed");
109 PX4_WARN(
"collect failed");
168 PX4_WARN(
"failed to set operating mode");
201 float temperature = (float)(
data.temperature / 100.0f);
202 float pressure = (float)(
data.pressure / 100.0f);
203 pressure = pressure / 100.0f;
254 for (i = 0; i < 8; i++) {
255 if ((seed & 0x80) ^ (data & 0x80)) {
262 seed = (seed & 0x7F) << 1;
263 data = (data & 0x7F) << 1;
264 seed = seed ^ (uint8_t)(poly * var2);
287 crc = (uint8_t)
cal_crc(crc, trim_param[i]);
294 if (stored_crc == crc) {
317 uint32_t meas_time_us = 0;
330 meas_time_us = 13300;
334 meas_time_us = 22500;
341 meas_time_us = 43300;
345 meas_time_us = 68900;
366 PX4_WARN(
"unsupported oversampling selected");
371 uint8_t pwc_ctl_reg = 0;
378 PX4_WARN(
"failed to set settings BMP3_PWR_CTRL_ADDR");
383 uint8_t osr_ctl_reg = 0;
390 PX4_WARN(
"failed to set settings BMP3_OSR_ADDR");
395 uint8_t odr_ctl_reg = 0;
401 PX4_WARN(
"failed to set output data rate register");
405 uint8_t iir_ctl_reg = 0;
410 PX4_WARN(
"failed to set IIR settings");
427 uint8_t last_set_mode;
428 uint8_t op_mode_reg_val;
432 last_set_mode =
BMP3_GET_BITS(op_mode_reg_val, BMP3_OP_MODE);
448 op_mode_reg_val =
BMP3_SET_BITS(op_mode_reg_val, BMP3_OP_MODE, op_mode);
473 data_xlsb = (uint32_t)reg_data[0];
474 data_lsb = (uint32_t)reg_data[1] << 8;
475 data_msb = (uint32_t)reg_data[2] << 16;
476 uncomp_data->
pressure = data_msb | data_lsb | data_xlsb;
478 data_xlsb = (uint32_t)reg_data[3];
479 data_lsb = (uint32_t)reg_data[4] << 8;
480 data_msb = (uint32_t)reg_data[5] << 16;
481 uncomp_data->
temperature = data_msb | data_lsb | data_xlsb;
494 int64_t partial_data1;
495 int64_t partial_data2;
496 int64_t partial_data3;
497 int64_t partial_data4;
498 int64_t partial_data5;
499 int64_t partial_data6;
504 partial_data3 = (partial_data1 * partial_data1);
506 partial_data5 = ((int64_t)(partial_data2 * 262144) + partial_data4);
507 partial_data6 = partial_data5 / 4294967296;
511 comp_temp = (int64_t)((partial_data6 * 25) / 16384);
527 int64_t partial_data1;
528 int64_t partial_data2;
529 int64_t partial_data3;
530 int64_t partial_data4;
531 int64_t partial_data5;
532 int64_t partial_data6;
537 partial_data1 = reg_calib_data->
t_lin * reg_calib_data->
t_lin;
538 partial_data2 = partial_data1 / 64;
539 partial_data3 = (partial_data2 * reg_calib_data->
t_lin) / 256;
540 partial_data4 = (reg_calib_data->
par_p8 * partial_data3) / 32;
541 partial_data5 = (reg_calib_data->
par_p7 * partial_data1) * 16;
542 partial_data6 = (reg_calib_data->
par_p6 * reg_calib_data->
t_lin) * 4194304;
543 offset = (reg_calib_data->
par_p5 * 140737488355328) + partial_data4 + partial_data5 + partial_data6;
544 partial_data2 = (reg_calib_data->
par_p4 * partial_data3) / 32;
545 partial_data4 = (reg_calib_data->
par_p3 * partial_data1) * 4;
546 partial_data5 = (reg_calib_data->
par_p2 - 16384) * reg_calib_data->
t_lin * 2097152;
547 sensitivity = ((reg_calib_data->
par_p1 - 16384) * 70368744177664) + partial_data2 + partial_data4 + partial_data5;
548 partial_data1 = (sensitivity / 16777216) * uncomp_data->
pressure;
549 partial_data2 = reg_calib_data->
par_p10 * reg_calib_data->
t_lin;
550 partial_data3 = partial_data2 + (65536 * reg_calib_data->
par_p9);
551 partial_data4 = (partial_data3 * uncomp_data->
pressure) / 8192;
553 partial_data5 = (uncomp_data->
pressure * (partial_data4 / 10)) / 512;
554 partial_data5 = partial_data5 * 10;
555 partial_data6 = (int64_t)((uint64_t)uncomp_data->
pressure * (uint64_t)uncomp_data->
pressure);
556 partial_data2 = (reg_calib_data->
par_p11 * partial_data6) / 65536;
557 partial_data3 = (partial_data2 * uncomp_data->
pressure) / 128;
558 partial_data4 = (offset / 4) + partial_data1 + partial_data5 + partial_data3;
559 comp_press = (((uint64_t)partial_data4 * 25) / (uint64_t)1099511627776);
578 memcpy(reg_calib_data,
_cal, 21);
580 if ((uncomp_data != NULL) && (comp_data != NULL)) {
#define BMP3_SENS_STATUS_REG_ADDR
uint16_t par_t1
@ Trim Variables
#define BMP3_OVERSAMPLING_2X
#define BPM3_CMD_SOFT_RESET
#define BMP3_PWR_CTRL_ADDR
void set_temperature(float temperature)
static struct vehicle_status_s status
#define BMP3_POST_RESET_WAIT_TIME
#define BMP3_CALIB_DATA_ADDR
measure the time elapsed performing an event
bool set_op_mode(uint8_t op_mode)
This API sets the power mode of the sensor.
void set_error_count(uint64_t error_count)
uint32_t get_measurement_time(uint8_t osr_t, uint8_t osr_p)
#define BMP3_OVERSAMPLING_8X
#define BMP3_SET_BITS_POS_0(reg_data, bitname, data)
bool set_sensor_settings()
This API sets the power control(pressure enable and temperature enable), over sampling, odr and filter settings in the sensor.
virtual uint8_t get_reg(uint8_t addr)=0
#define BMP3_GET_BITS(reg_data, bitname)
perf_counter_t _comms_errors
#define BMP3_CHIP_ID_ADDR
bool validate_trimming_param()
count the number of times an event occurs
static uint64_t compensate_pressure(const struct bmp3_uncomp_data *uncomp_data, const struct bmp3_calib_data *calib_data)
This internal API is used to compensate the raw pressure data and return the compensated pressure dat...
#define DRV_DEVTYPE_BMP388
unsigned _measure_interval
static int8_t cal_crc(uint8_t seed, uint8_t data)
#define BMP3_POST_SLEEP_WAIT_TIME
void perf_count(perf_counter_t handle)
Count a performance event.
void perf_free(perf_counter_t handle)
Free a counter.
perf_counter_t _sample_perf
perf_counter_t _measure_perf
#define BMP3_ERR_REG_ADDR
void update(hrt_abstime timestamp, float pressure)
virtual calibration_s * get_calibration(uint8_t addr)=0
bool compensate_data(uint8_t sensor_comp, const struct bmp3_uncomp_data *uncomp_data, struct bmp3_data *comp_data)
This internal API is used to compensate the pressure or temperature or both the data according to the...
BMP388(IBMP388 *interface)
virtual int get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len)=0
void perf_end(perf_counter_t handle)
End a performance event.
#define BMP3_SET_BITS(reg_data, bitname, data)
#define BMP3_NO_OVERSAMPLING
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
#define BMP3_OVERSAMPLING_32X
static void parse_sensor_data(const uint8_t *reg_data, struct bmp3_uncomp_data *uncomp_data)
This internal API is used to parse the pressure or temperature or both the data and store it in the b...
#define BMP3_OVERSAMPLING_4X
virtual int set_reg(uint8_t value, uint8_t addr)=0
Shared defines for the bmp388 driver.
bool get_sensor_data(uint8_t sensor_comp, struct bmp3_data *comp_data)
This API reads the pressure, temperature or both data from the sensor, compensates the data and store...
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
#define BMP3_OVERSAMPLING_16X
void perf_cancel(perf_counter_t handle)
Cancel a performance event.
#define BMP3_P_T_DATA_LEN
static int64_t compensate_temperature(const struct bmp3_uncomp_data *uncomp_data, struct bmp3_calib_data *calib_data)
This internal API is used to compensate the raw temperature data and return the compensated temperatu...
struct bmp3_reg_calib_data reg_calib_data
#define BMP3_CALIB_DATA_LEN
bool soft_reset()
This API performs the soft reset of the sensor.
#define BMP3_TRIM_CRC_DATA_ADDR
void perf_begin(perf_counter_t handle)
Begin a performance event.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
void set_device_type(uint8_t devtype)