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;
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;
88 bmp->rx_length = &
bmp->i2c.trans.len_r;
108 switch (
bmp->status) {
110 bmp->data_available =
false;
111 bmp->initialized =
false;
130 bmp->initialized =
true;
162 switch (
bmp->status) {
183 bmp->initialized =
true;
199 bmp->data_available =
true;
217 if (!
bmp->initialized) {
283 double var1 = (((
double)
bmp->raw_temperature / 16384.0) - ((
double)
bmp->calib.dig_t1 / 1024.0)) * ((
double)
bmp->calib.dig_t2);
289 bmp->calib.t_fine = t_fine;
291 bmp->temperature = (((
var1 +
var2) / 5120.f) * 100);
293 return (
double)
bmp->temperature;
309 var2 = (
var2 / 4.0) + ((
double)
bmp->calib.dig_p4 * 65536.0);
331 switch(
bmp->config_idx) {
361 bmp->tx_buffer[1] = value;
365 bmp->tx_buffer[0] = (reg & 0x7F);
366 bmp->spi.trans.output_length = 2;
367 bmp->spi.trans.input_length = 0;
372 bmp->tx_buffer[0] = reg;
389 bmp->spi.trans.output_length = 2;
390 bmp->spi.trans.input_length = size+1;
391 bmp->tx_buffer[1] = 0;
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.
@ BMP280_STATUS_READ_DATA_REGS
@ BMP280_STATUS_READ_STATUS_REG
@ BMP280_STATUS_GET_CALIB
@ BMP280_STATUS_CONFIGURE
#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.