21 #define BMP280_MODE_SLEEP 0 22 #define BMP280_MODE_FORCED 1 23 #define BMP280_MODE_NORMAL 3 24 #define BMP280_MODE BMP280_MODE_NORMAL 26 #define BMP280_OVERSAMPLING_1 1 27 #define BMP280_OVERSAMPLING_2 2 28 #define BMP280_OVERSAMPLING_4 3 29 #define BMP280_OVERSAMPLING_8 4 30 #define BMP280_OVERSAMPLING_16 5 31 #define BMP280_OVERSAMPLING_P BMP280_OVERSAMPLING_16 32 #define BMP280_OVERSAMPLING_T BMP280_OVERSAMPLING_2 34 #define BMP280_FILTER_COEFFICIENT 2 36 #define BMP280_ID 0x58 38 #define BMP280_REG_CALIB 0x88 39 #define BMP280_REG_ID 0xD0 40 #define BMP280_REG_RESET 0xE0 41 #define BMP280_REG_STATUS 0xF3 42 #define BMP280_REG_CTRL_MEAS 0xF4 43 #define BMP280_REG_CONFIG 0xF5 44 #define BMP280_REG_DATA 0xF7 48 , _dev(
std::move(dev))
60 if (!sensor || !sensor->
_init()) {
89 _t1 = ((int16_t)buf[1] << 8) | buf[0];
90 _t2 = ((int16_t)buf[3] << 8) | buf[2];
91 _t3 = ((int16_t)buf[5] << 8) | buf[4];
92 _p1 = ((int16_t)buf[7] << 8) | buf[6];
93 _p2 = ((int16_t)buf[9] << 8) | buf[8];
94 _p3 = ((int16_t)buf[11] << 8) | buf[10];
95 _p4 = ((int16_t)buf[13] << 8) | buf[12];
96 _p5 = ((int16_t)buf[15] << 8) | buf[14];
97 _p6 = ((int16_t)buf[17] << 8) | buf[16];
98 _p7 = ((int16_t)buf[19] << 8) | buf[18];
99 _p8 = ((int16_t)buf[21] << 8) | buf[20];
100 _p9 = ((int16_t)buf[23] << 8) | buf[22];
154 int32_t var1, var2, t;
157 var1 = ((((temp_raw >> 3) - ((int32_t)_t1 << 1))) * ((int32_t)_t2)) >> 11;
158 var2 = (((((temp_raw >> 4) - ((int32_t)
_t1)) * ((temp_raw >> 4) - ((int32_t)
_t1))) >> 12) * ((int32_t)
_t3)) >> 14;
162 const float temp = ((float)t) / 100.0f;
173 int64_t var1, var2, p;
176 var1 = ((int64_t)
_t_fine) - 128000;
177 var2 = var1 * var1 * (int64_t)
_p6;
178 var2 = var2 + ((var1 * (int64_t)
_p5) << 17);
179 var2 = var2 + (((int64_t)
_p4) << 35);
180 var1 = ((var1 * var1 * (int64_t)
_p3) >> 8) + ((var1 * (int64_t)
_p2) << 12);
181 var1 = (((((int64_t)1) << 47) + var1)) * ((int64_t)
_p1) >> 33;
187 p = 1048576 - press_raw;
188 p = (((p << 31) - var2) * 3125) / var1;
189 var1 = (((int64_t)
_p9) * (p >> 13) * (p >> 13)) >> 25;
190 var2 = (((int64_t)
_p8) * p) >> 19;
191 p = ((p + var1 + var2) >> 8) + (((int64_t)
_p7) << 4);
194 const float press = (float)p / 256.0
f;
#define BMP280_OVERSAMPLING_P
#define BMP280_FILTER_COEFFICIENT
virtual PeriodicHandle register_periodic_callback(uint32_t period_usec, PeriodicCb)=0
#define BMP280_REG_CTRL_MEAS
void _copy_to_frontend(uint8_t instance, float pressure, float temperature)
uint8_t register_sensor(void)
static AP_Baro_Backend * probe(AP_Baro &baro, AP_HAL::OwnPtr< AP_HAL::Device > dev)
virtual AP_HAL::Semaphore * get_semaphore()=0
AP_Baro_BMP280(AP_Baro &baro, AP_HAL::OwnPtr< AP_HAL::Device > dev)
#define HAL_SEMAPHORE_BLOCK_FOREVER
virtual bool take(uint32_t timeout_ms) WARN_IF_UNUSED=0
AP_HAL::OwnPtr< AP_HAL::Device > _dev
void _update_temperature(int32_t)
#define BMP280_REG_CONFIG
virtual bool take_nonblocking() WARN_IF_UNUSED=0
static AP_HAL::OwnPtr< AP_HAL::Device > dev
virtual bool set_speed(Speed speed)=0
enum BusType bus_type(void) const
bool pressure_ok(float press)
#define BMP280_OVERSAMPLING_T
bool read_registers(uint8_t first_reg, uint8_t *recv, uint32_t recv_len)
#define FUNCTOR_BIND_MEMBER(func, rettype,...)
bool write_register(uint8_t reg, uint8_t val, bool checked=false)
void _update_pressure(int32_t)