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
512 int64_t partial_data4;
513 int64_t partial_data5;
514 int64_t partial_data6;
519 partial_data3 = partial_data1 * partial_data1;
520 partial_data4 = (int64_t)partial_data3 * bmp->
calib.
par_t3;
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);
539 int64_t partial_data1;
540 int64_t partial_data2;
541 int64_t partial_data3;
542 int64_t partial_data4;
543 int64_t partial_data5;
544 int64_t partial_data6;
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;
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...
void bmp3_i2c_event(struct Bmp3_I2c *bmp)
void bmp3_i2c_periodic(struct Bmp3_I2c *bmp)
Start new measurement if sensor ready.
void bmp3_i2c_init(struct Bmp3_I2c *bmp, struct i2c_periph *i2c_p, uint8_t addr)
init function
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...
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...
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 void parse_sensor_data(struct Bmp3_I2c *bmp)
local function to extract raw data from i2c buffer and compute compensation with selected precision
Sensor driver for BMP3 sensor via I2C.
float temperature
temperature in deg Celcius
struct bmp3_quantized_calib_data quant_calib
quantized calibration data
struct i2c_periph * i2c_p
bool initialized
config done flag
enum Bmp3Status status
state machine status
volatile bool data_available
data ready flag
struct i2c_transaction i2c_trans
float pressure
pressure in Pascal
struct bmp3_reg_calib_data calib
calibration data
uint32_t raw_temperature
uncompensated temperature
uint32_t raw_pressure
uncompensated pressure
#define BMP3_SENS_STATUS_REG_ADDR
#define BMP3_CALIB_DATA_LEN
#define BMP3_IIR_FILTER_COEFF_3
#define BMP3_CALIB_DATA_ADDR
#define BMP3_NO_OVERSAMPLING
#define BMP3_OVERSAMPLING_8X
#define BMP3_P_AND_T_HEADER_DATA_LEN
#define BMP3_PWR_CTRL_ADDR
#define BMP3_CONCAT_BYTES(msb, lsb)
static const float offset[]
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
uint8_t slave_addr
Slave address.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
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.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned long long uint64_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.