38 #if BMP3_COMPENSATION == BMP3_DOUBLE_PRECISION_COMPENSATION
43 #elif BMP3_COMPENSATION == BMP3_SINGLE_PRECISION_COMPENSATION
48 #elif BMP3_COMPENSATION == BMP3_INTEGER_COMPENSATION
53 #error "BMP3: Unknown compensation type"
187 #if BMP3_COMPENSATION == BMP3_DOUBLE_PRECISION_COMPENSATION
199 temp_var = 0.00390625;
204 temp_var = 1073741824.0;
208 temp_var = 281474976710656.0;
212 temp_var = 1048576.0;
216 temp_var = 536870912.0;
220 temp_var = 4294967296.0;
224 temp_var = 137438953472.0;
245 temp_var = 281474976710656.0;
249 temp_var = 281474976710656.0;
253 temp_var = 36893488147419103232.0;
286 double partial_data1;
287 double partial_data2;
288 double partial_data3;
289 double partial_data4;
296 partial_out1 = bmp->
quant_calib.
par_p5 + partial_data1 + partial_data2 + partial_data3;
306 partial_data3 = partial_data1 * partial_data2;
308 comp_press = partial_out1 + partial_out2 + partial_data4;
322 double pow_output = 1;
325 pow_output = base * pow_output;
332 #elif BMP3_COMPENSATION == BMP3_SINGLE_PRECISION_COMPENSATION
344 temp_var = 0.00390625f;
349 temp_var = 1073741824.0f;
353 temp_var = 281474976710656.0f;
357 temp_var = 1048576.0f;
361 temp_var = 536870912.0f;
365 temp_var = 4294967296.0f;
369 temp_var = 137438953472.0f;
390 temp_var = 281474976710656.0f;
394 temp_var = 281474976710656.0f;
398 temp_var = 36893488147419103232.0f;
441 partial_out1 = bmp->
quant_calib.
par_p5 + partial_data1 + partial_data2 + partial_data3;
451 partial_data3 = partial_data1 * partial_data2;
453 comp_press = partial_out1 + partial_out2 + partial_data4;
467 float pow_output = 1;
470 pow_output = base * pow_output;
477 #elif BMP3_COMPENSATION == BMP3_INTEGER_COMPENSATION
519 partial_data3 = partial_data1 * partial_data1;
521 partial_data5 = ((
int64_t)(partial_data2 * 262144) + partial_data4);
522 partial_data6 = partial_data5 / 4294967296;
525 comp_temp = (
int64_t)((partial_data6 * 25) / 16384);
550 partial_data2 = partial_data1 / 64;
551 partial_data3 = (partial_data2 * bmp->
calib.
t_lin) / 256;
552 partial_data4 = (bmp->
calib.
par_p8 * partial_data3) / 32;
553 partial_data5 = (bmp->
calib.
par_p7 * partial_data1) * 16;
555 offset = (bmp->
calib.
par_p5 * 140737488355328) + partial_data4 + partial_data5 + partial_data6;
557 partial_data2 = (bmp->
calib.
par_p4 * partial_data3) / 32;
558 partial_data4 = (bmp->
calib.
par_p3 * partial_data1) * 4;
560 sensitivity = ((bmp->
calib.
par_p1 - 16384) * 70368744177664) + partial_data2 + partial_data4 + partial_data5;
562 partial_data1 = (sensitivity / 16777216) * bmp->
raw_pressure;
564 partial_data3 = partial_data2 + (65536 * bmp->
calib.
par_p9);
565 partial_data4 = (partial_data3 * bmp->
raw_pressure) / 8192;
566 partial_data5 = (partial_data4 * bmp->
raw_pressure) / 512;
568 partial_data2 = (bmp->
calib.
par_p11 * partial_data6) / 65536;
569 partial_data3 = (partial_data2 * bmp->
raw_pressure) / 128;
570 partial_data4 = (offset / 4) + partial_data1 + partial_data5 + partial_data3;
574 bmp->
pressure = ((float)comp_press) / 100.f;
enum Bmp3Status status
state machine status
struct bmp3_quantized_calib_data quant_calib
quantized calibration data
static void parse_sensor_data(struct Bmp3_I2c *bmp)
local function to extract raw data from i2c buffer and compute compensation with selected precision ...
#define BMP3_IIR_FILTER_COEFF_3
void bmp3_i2c_periodic(struct Bmp3_I2c *bmp)
Start new measurement if sensor ready.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
transaction successfully finished by I2C driver
#define BMP3_NO_OVERSAMPLING
static double bmp3_pow(double base, uint8_t power)
This internal API is used to calculate the power functionality for double precision floating point va...
Sensor driver for BMP3 sensor via I2C.
bool initialized
config done flag
float pressure
pressure in Pascal
#define BMP3_SENS_STATUS_REG_ADDR
uint32_t raw_pressure
uncompensated pressure
#define BMP3_CALIB_DATA_ADDR
uint32_t raw_temperature
uncompensated temperature
float temperature
temperature in deg Celcius
unsigned long long uint64_t
struct bmp3_reg_calib_data calib
calibration data
#define BMP3_OVERSAMPLING_8X
static const float offset[]
transaction set to done by user level
struct i2c_transaction i2c_trans
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define BMP3_PWR_CTRL_ADDR
void bmp3_i2c_init(struct Bmp3_I2c *bmp, struct i2c_periph *i2c_p, uint8_t addr)
init function
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
enum I2CTransactionStatus status
Transaction status.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
void bmp3_i2c_event(struct Bmp3_I2c *bmp)
static void parse_calib_data(struct Bmp3_I2c *bmp)
This internal API is used to parse the calibration data, compensates it and store it in device struct...
uint8_t slave_addr
Slave address.
#define BMP3_P_AND_T_HEADER_DATA_LEN
#define BMP3_CONCAT_BYTES(msb, lsb)
#define BMP3_CALIB_DATA_LEN
volatile bool data_available
data ready flag
static double compensate_temperature(struct Bmp3_I2c *bmp)
This internal API is used to compensate the raw temperature data and return the compensated temperatu...
static double compensate_pressure(struct Bmp3_I2c *bmp)
This internal API is used to compensate the raw pressure data and return the compensated pressure dat...
struct i2c_periph * i2c_p