Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
dps310_i2c.h File Reference

Driver for the Infineon DPS310 barometer (I2C) More...

+ Include dependency graph for dps310_i2c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Dps310_I2c
 

Enumerations

enum  Dps310Status {
  DPS310_STATUS_UNINIT , DPS310_STATUS_GET_ID , DPS310_STATUS_TEMP_FIX , DPS310_STATUS_WAIT_RDY ,
  DPS310_STATUS_GET_COEF_SRCE , DPS310_STATUS_GET_CALIB , DPS310_STATUS_CONFIGURE_REGS , DPS310_STATUS_CONFIGURE_MEAS ,
  DPS310_STATUS_READ_DATA
}
 States of the non-blocking driver state machine. More...
 

Functions

void dps310_i2c_init (struct Dps310_I2c *dps, struct i2c_periph *i2c_p, uint8_t addr)
 Initialize the driver instance (no bus traffic yet)
 
void dps310_i2c_periodic (struct Dps310_I2c *dps)
 Run the driver state machine, submitting at most one I2C transaction.
 
void dps310_i2c_event (struct Dps310_I2c *dps)
 Consume finished I2C transactions and advance the state machine.
 

Detailed Description

Driver for the Infineon DPS310 barometer (I2C)

Definition in file dps310_i2c.h.


Data Structure Documentation

◆ Dps310_I2c

struct Dps310_I2c

Definition at line 51 of file dps310_i2c.h.

+ Collaboration diagram for Dps310_I2c:
Data Fields
struct dps310_reg_calib_data calib calibration data
volatile bool data_available data ready flag
struct i2c_periph * i2c_p I2C peripheral used for communication.
struct i2c_transaction i2c_trans I2C transaction (only one in flight at a time)
uint8_t init_error_cnt number of consecutive transaction failures
bool initialized config done flag
bool is_broken sensor not found or persistently failing, retried after a backoff period
float pressure pressure in Pascal
int32_t raw_pressure uncompensated pressure
int32_t raw_temperature uncompensated temperature
enum Dps310Status status state machine status
uint8_t temp_coef_srce TMP_COEF_SRCE bit read from the sensor, mirrored into TMP_CFG bit 7.
uint8_t temp_fix_step current step of the temperature errata fix sequence
float temperature temperature in deg Celsius
uint32_t timer broken-sensor retry backoff timer

Enumeration Type Documentation

◆ Dps310Status

States of the non-blocking driver state machine.

Traversed once in order during initialization, then the driver stays in DPS310_STATUS_READ_DATA. Any failure path leads back to DPS310_STATUS_UNINIT.

Enumerator
DPS310_STATUS_UNINIT 

restart point: reset driver state, then detect the sensor

DPS310_STATUS_GET_ID 

read the product/revision ID register

DPS310_STATUS_TEMP_FIX 

apply the 5-write temperature errata fix (genuine DPS310 only)

DPS310_STATUS_WAIT_RDY 

wait for SENSOR_RDY and COEF_RDY (~40ms after power-up)

DPS310_STATUS_GET_COEF_SRCE 

read which temperature sensor the factory calibration used

DPS310_STATUS_GET_CALIB 

read the 18 calibration coefficient bytes

DPS310_STATUS_CONFIGURE_REGS 

write PRS_CFG, TMP_CFG, MEAS_CFG (idle) and CFG_REG in one burst

DPS310_STATUS_CONFIGURE_MEAS 

enable continuous pressure + temperature measurements

DPS310_STATUS_READ_DATA 

operational: poll the 6 result registers

Definition at line 39 of file dps310_i2c.h.

Function Documentation

◆ dps310_i2c_event()

void dps310_i2c_event ( struct Dps310_I2c *  dps)
extern

Consume finished I2C transactions and advance the state machine.

Parameters
dpsThe dps310 instance

Should be called from the event loop. On success it parses the responses and publishes plausibility-checked measurements through data_available. On failure it counts consecutive errors, escalating from a simple retry to a full re-initialization (DPS310_MAX_ERROR_CNT) and, while uninitialized, to a timed backoff.

Definition at line 290 of file dps310_i2c.c.

References compensate_sensor(), DPS310_CHIP_ID, DPS310_COEF_SRCE_BIT_TMP_COEF_SRCE, DPS310_MAX_ERROR_CNT, DPS310_MEAS_CFG_COEF_RDY, DPS310_MEAS_CFG_SENSOR_RDY, DPS310_PRESSURE_MAX_PA, DPS310_PRESSURE_MIN_PA, DPS310_STATUS_CONFIGURE_MEAS, DPS310_STATUS_CONFIGURE_REGS, DPS310_STATUS_GET_CALIB, DPS310_STATUS_GET_COEF_SRCE, DPS310_STATUS_GET_ID, DPS310_STATUS_READ_DATA, DPS310_STATUS_TEMP_FIX, DPS310_STATUS_UNINIT, DPS310_STATUS_WAIT_RDY, DPS310_TEMP_FIX_SEQ_LEN, foo, get_sys_time_usec(), I2CTransDone, I2CTransFailed, I2CTransSuccess, parse_calib_data(), and parse_sensor_data().

Referenced by baro_dps310_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dps310_i2c_init()

void dps310_i2c_init ( struct Dps310_I2c *  dps,
struct i2c_periph *  i2c_p,
uint8_t  addr 
)
extern

Initialize the driver instance (no bus traffic yet)

Parameters
dpsThe dps310 instance
i2c_pI2C peripheral the sensor is connected to
addr8-bit I2C slave address (DPS310_I2C_ADDR or DPS310_I2C_ADDR_ALT)

Sensor detection and configuration happen asynchronously afterwards through dps310_i2c_periodic() and dps310_i2c_event().

Definition at line 174 of file dps310_i2c.c.

References DPS310_STATUS_UNINIT, foo, I2CTransDone, and i2c_periph::status.

Referenced by baro_dps310_init().

+ Here is the caller graph for this function:

◆ dps310_i2c_periodic()

void dps310_i2c_periodic ( struct Dps310_I2c *  dps)
extern

Run the driver state machine, submitting at most one I2C transaction.

Parameters
dpsThe dps310 instance

Should be called periodically. The call rate is decoupled from the sensor-internal 16 Hz measurement rate: polling faster only re-reads the latest sample. Does nothing while a transaction is still in flight. A persistently failing or absent sensor is retried after a DPS310_BROKEN_RETRY_US backoff instead of spamming the bus.

Definition at line 199 of file dps310_i2c.c.

References DPS310_BROKEN_RETRY_US, DPS310_CFG_REG_P_SHIFT, DPS310_CFG_REG_T_SHIFT, DPS310_MEAS_CTRL_CONT, DPS310_PRS_CFG_PM_PRC_16, DPS310_PRS_CFG_PM_RATE_16HZ, DPS310_REG_COEF, DPS310_REG_COEF_SRCE, DPS310_REG_ID, DPS310_REG_MEAS_CFG, DPS310_REG_PRS_CFG, DPS310_REG_PSR_B2, DPS310_STATUS_CONFIGURE_MEAS, DPS310_STATUS_CONFIGURE_REGS, DPS310_STATUS_GET_CALIB, DPS310_STATUS_GET_COEF_SRCE, DPS310_STATUS_GET_ID, DPS310_STATUS_READ_DATA, DPS310_STATUS_TEMP_FIX, DPS310_STATUS_UNINIT, DPS310_STATUS_WAIT_RDY, dps310_temp_fix_seq, DPS310_TMP_CFG_TMP_PRC_16, DPS310_TMP_CFG_TMP_RATE_16HZ, foo, get_sys_time_usec(), i2c_transceive(), i2c_transmit(), and I2CTransDone.

Referenced by baro_dps310_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: