51 bmp->data_available =
false;
52 bmp->initialized =
false;
66 bmp->spi.trans.slave_idx = bmp->spi.slave_idx;
67 bmp->spi.trans.output_length = 0;
68 bmp->spi.trans.input_length = 0;
69 bmp->spi.trans.before_cb = NULL;
70 bmp->spi.trans.after_cb = NULL;
71 bmp->spi.trans.input_buf = bmp->spi.rx_buf;
72 bmp->spi.trans.output_buf = bmp->spi.tx_buf;
76 bmp->rx_buffer = &bmp->spi.rx_buf[1];
77 bmp->tx_buffer = bmp->spi.tx_buf;
78 bmp->rx_length = &bmp->spi.trans.input_length;
83 bmp->i2c.trans.slave_addr = bmp->i2c.slave_addr;
86 bmp->rx_buffer = (
uint8_t *)bmp->i2c.trans.buf;
87 bmp->tx_buffer = (
uint8_t *)bmp->i2c.trans.buf;
88 bmp->rx_length = &bmp->i2c.trans.len_r;
286 int64_t t_fine = (int64_t)(var1 + var2);
291 bmp->
temperature = (((var1 + var2) / 5120.f) * 100);
307 var2 = (var1 * var1 * (double)bmp->
calib.
dig_p5) / 32768.0;
308 var2 = var2 + (var1 * (double)bmp->
calib.
dig_p5 * 2.0);
309 var2 = (var2 / 4.0) + ((
double)bmp->
calib.
dig_p4 * 65536.0);
310 var1 = (((double)bmp->
calib.
dig_p3 * var1 * (var1 / 524288.0)) + ((
double)bmp->
calib.
dig_p2 * var1)) / 524288.0;
311 var1 = (1 + (var1 / 32768.0)) * (double)bmp->
calib.
dig_p1;
313 p = (
p - (var2 / 4096.0)) * (6250.0 / var1);
366 bmp->spi.trans.output_length = 2;
367 bmp->spi.trans.input_length = 0;
373 i2c_transmit(bmp->i2c.p, &(bmp->i2c.trans), bmp->i2c.slave_addr, 2);
389 bmp->spi.trans.output_length = 2;
390 bmp->spi.trans.input_length = size+1;
396 i2c_transceive(bmp->i2c.p, &(bmp->i2c.trans), bmp->i2c.slave_addr, 1, size);
static bool bmp280_config(struct bmp280_t *bmp)
Configure the BMP280 device register by register.
void bmp280_periodic(struct bmp280_t *bmp)
Should be called periodically to request sensor readings.
static void bmp280_register_read(struct bmp280_t *bmp, uint8_t reg, uint16_t size)
Read a register.
void bmp280_init(struct bmp280_t *bmp)
Initialize the bmp280 sensor instance.
void bmp280_event(struct bmp280_t *bmp)
Should be called in the event thread.
static double compensate_pressure(struct bmp280_t *bmp)
This internal API is used to compensate the raw pressure data and return the compensated pressure dat...
static void bmp280_register_write(struct bmp280_t *bmp, uint8_t reg, uint8_t value)
Write a register with a value.
static void parse_sensor_data(struct bmp280_t *bmp, uint8_t *data)
local function to extract raw data from i2c buffer and compute compensation with selected precision
static void parse_calib_data(struct bmp280_t *bmp, uint8_t *data)
This internal API is used to parse the calibration data, compensates it and store it in device struct...
static double compensate_temperature(struct bmp280_t *bmp)
This internal API is used to compensate the raw temperature data and return the compensated temperatu...
Sensor driver for BMP280 sensor.
struct bmp280_reg_calib_data_t calib
calibration data
enum bmp280_status_t status
state machine status
volatile bool data_available
data ready flag
uint8_t config_idx
The current configuration index.
float temperature
temperature in deg Celcius
uint32_t raw_temperature
uncompensated temperature
@ BMP280_STATUS_READ_DATA_REGS
@ BMP280_STATUS_READ_STATUS_REG
@ BMP280_STATUS_GET_CALIB
@ BMP280_STATUS_CONFIGURE
enum bmp280_bus_t bus
The communication bus used to connect the device SPI/I2C.
enum bmp_device_t device
The device type detected.
float pressure
pressure in Pascal
bool initialized
config done flag
uint32_t raw_pressure
uncompensated pressure
#define BMP280_DATA_START_REG_ADDR
#define BMP280_IIR_FILTER_COEFF_16
#define BMP280_CTRL_MEAS_REG_ADDR
#define BMP280_CHIP_ID_REG_ADDR
#define BMP280_CALIB_LSB_DATA_ADDR
#define BMP280_CONFIG_REG_ADDR
#define BMP280_INACTIVITY_HALF_MS
#define BMP280_CALIB_DATA_LEN
#define BMP280_NVRAM_COPY_BIT
#define BMP280_P_T_DATA_LEN
#define BMP280_CONCAT_BYTES(msb, lsb)
#define BMP280_STATUS_REG_ADDR
#define BMP280_OVERSAMPLING_2X_T
#define BMP280_OVERSAMPLING_16X_P
#define BMP280_POWER_NORMAL_MODE
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
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelectUnselect
slave is selected before transaction and unselected after
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.