46 #include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp> 49 #include "board_config.h" 53 #define BMP3_CHIP_ID (0x50) 56 #define BMP3_NO_OVERSAMPLING (0x00) 57 #define BMP3_OVERSAMPLING_2X (0x01) 58 #define BMP3_OVERSAMPLING_4X (0x02) 59 #define BMP3_OVERSAMPLING_8X (0x03) 60 #define BMP3_OVERSAMPLING_16X (0x04) 61 #define BMP3_OVERSAMPLING_32X (0x05) 64 #define BMP3_IIR_FILTER_DISABLE (0x00) 65 #define BMP3_IIR_FILTER_COEFF_1 (0x01) 66 #define BMP3_IIR_FILTER_COEFF_3 (0x02) 67 #define BMP3_IIR_FILTER_COEFF_7 (0x03) 68 #define BMP3_IIR_FILTER_COEFF_15 (0x04) 69 #define BMP3_IIR_FILTER_COEFF_31 (0x05) 70 #define BMP3_IIR_FILTER_COEFF_63 (0x06) 71 #define BMP3_IIR_FILTER_COEFF_127 (0x07) 74 #define BMP3_ODR_200_HZ (0x00) 75 #define BMP3_ODR_100_HZ (0x01) 76 #define BMP3_ODR_50_HZ (0x02) 77 #define BMP3_ODR_25_HZ (0x03) 80 #define BMP3_CHIP_ID_ADDR (0x00) 81 #define BMP3_ERR_REG_ADDR (0x02) 82 #define BMP3_SENS_STATUS_REG_ADDR (0x03) 83 #define BMP3_DATA_ADDR (0x04) 84 #define BMP3_PWR_CTRL_ADDR (0x1B) 85 #define BMP3_OSR_ADDR (0X1C) 86 #define BMP3_CALIB_DATA_ADDR (0x31) 87 #define BMP3_CMD_ADDR (0x7E) 90 #define BMP3_FATAL_ERR (0x01) 91 #define BMP3_CMD_ERR (0x02) 92 #define BMP3_CONF_ERR (0x04) 95 #define BMP3_CMD_RDY (0x10) 96 #define BMP3_DRDY_PRESS (0x20) 97 #define BMP3_DRDY_TEMP (0x40) 100 #define BMP3_SLEEP_MODE (0x00) 101 #define BMP3_FORCED_MODE (0x01) 102 #define BMP3_NORMAL_MODE (0x03) 104 #define BMP3_ENABLE (0x01) 105 #define BMP3_DISABLE (0x00) 110 #define BMP3_PRESS (1) 111 #define BMP3_TEMP (1 << 1) 112 #define BMP3_ALL (0x03) 115 #define BMP3_CALIB_DATA_LEN (21) 116 #define BMP3_P_T_DATA_LEN (6) 121 #define BMP3_PRESS_EN_SEL (1 << 1) 122 #define BMP3_TEMP_EN_SEL (1 << 2) 123 #define BMP3_PRESS_OS_SEL (1 << 4) 126 #define BMP3_OP_MODE_MSK (0x30) 127 #define BMP3_OP_MODE_POS (0x04) 129 #define BMP3_PRESS_EN_MSK (0x01) 131 #define BMP3_TEMP_EN_MSK (0x02) 132 #define BMP3_TEMP_EN_POS (0x01) 134 #define BMP3_IIR_FILTER_MSK (0x0E) 135 #define BMP3_IIR_FILTER_POS (0x01) 137 #define BMP3_ODR_MSK (0x1F) 139 #define BMP3_PRESS_OS_MSK (0x07) 141 #define BMP3_TEMP_OS_MSK (0x38) 142 #define BMP3_TEMP_OS_POS (0x03) 144 #define BMP3_SET_BITS(reg_data, bitname, data) \ 145 ((reg_data & ~(bitname##_MSK)) | \ 146 ((data << bitname##_POS) & bitname##_MSK)) 149 #define BMP3_SET_BITS_POS_0(reg_data, bitname, data) \ 150 ((reg_data & ~(bitname##_MSK)) | \ 151 (data & bitname##_MSK)) 153 #define BMP3_GET_BITS(reg_data, bitname) ((reg_data & (bitname##_MSK)) >> \ 157 #define BMP3_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK)) 160 #define BMP3_POST_SLEEP_WAIT_TIME 5000 161 #define BMP3_POST_RESET_WAIT_TIME 2000 162 #define BMP3_POST_INIT_WAIT_TIME 40000 163 #define BMP3_TRIM_CRC_DATA_ADDR 0x30 164 #define BPM3_CMD_SOFT_RESET 0xB6 165 #define BMP3_ODR_ADDR 0x1D 166 #define BMP3_IIR_ADDR 0x1F 170 #define POWER_CNTL (0x0006) 172 #define ODR_FILTER (0x00F0) 174 #define INT_CTRL (0x0708) 176 #define ADV_SETT (0x1800) 289 virtual int init() = 0;
292 virtual uint8_t get_reg(uint8_t addr) = 0;
295 virtual int get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len) = 0;
298 virtual int set_reg(uint8_t value, uint8_t addr) = 0;
301 virtual data_s *get_data(uint8_t addr) = 0;
306 virtual uint32_t get_device_id()
const = 0;
309 class BMP388 :
public px4::ScheduledWorkItem
323 unsigned _measure_interval{0};
335 bool _collect_phase{
false};
342 uint32_t get_measurement_time(uint8_t osr_t, uint8_t osr_p);
345 bool get_calib_data();
346 bool validate_trimming_param();
347 bool set_sensor_settings();
348 bool set_op_mode(uint8_t op_mode);
350 bool get_sensor_data(uint8_t sensor_comp,
struct bmp3_data *comp_data);
358 typedef IBMP388 *(*BMP388_constructor)(uint8_t, uint32_t);
uint16_t par_t1
@ Trim Variables
#define BMP3_OVERSAMPLING_2X
#define BMP3_IIR_FILTER_DISABLE
perf_counter_t _comms_errors
Namespace encapsulating all device framework classes, functions and data.
High-resolution timer with callouts and timekeeping.
perf_counter_t _sample_perf
void init()
Activates/configures the hardware registers.
perf_counter_t _measure_perf
IBMP388 * bmp388_i2c_interface(uint8_t busnum, uint32_t device)
#define BMP3_OVERSAMPLING_16X
IBMP388 * bmp388_spi_interface(uint8_t busnum, uint32_t device)
Barometric pressure sensor driver interface.
Performance measuring tools.