38 lps->i2c_trans.slave_addr = addr;
42 lps->initialized =
false;
43 lps->data_available =
false;
51 lps->i2c_trans.buf[0] = reg;
52 lps->i2c_trans.buf[1] =
val;
53 lps->i2c_trans.len_r = 0;
54 lps->i2c_trans.len_w = 2;
61 switch (
lps->init_status) {
67 lps->initialized =
true;
92 lps->i2c_trans.len_r = 3;
93 lps->i2c_trans.len_w = 1;
98#define Int32FromBuf(buf, idx) (int32_t)(int8_t)buf[idx+2] << 16 | (uint16_t)buf[idx+1] << 8 | buf[idx];
103 return (
float)
press / 4096;
112 if (
lps->initialized) {
117 lps->data_available =
true;
121 switch(
lps->i2c_trans.status){
static bool i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
@ I2CTransTx
transmit only transaction
@ I2CTransTxRx
transmit and receive transaction
static void lps25h_set_default_config(struct Lps25hConfig *c)
float lps25h_readPressureMillibars(int32_t press)
#define Int32FromBuf(buf, idx)
static void lps25h_i2c_send_config(struct Lps25h_I2c *lps)
void lps25h_i2c_event(struct Lps25h_I2c *lps)
void lps25h_i2c_start_configure(struct Lps25h_I2c *lps)
void lps25h_i2c_init(struct Lps25h_I2c *lps, struct i2c_periph *i2c_p, uint8_t addr)
void lps25h_i2c_read(struct Lps25h_I2c *lps)
static void lps25h_i2c_tx_reg(struct Lps25h_I2c *lps, uint8_t reg, uint8_t val)
float pressureToAltMeters(float pressure_mbar, float altimeter_setting_mbar)
I2C interface for LPS25H barometer.
#define LPS25H_REG_OUT_XL
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.