I2C transaction structure.
SPI peripheral structure.
SPI transaction structure.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
float pressure
pressure in Pascal
uint8_t calib_idx
progress through the calibration chunks (spa06_get_calib/parse_calib_data)
volatile bool data_available
data ready flag
struct spi_transaction trans
Transaction used during configuration and measurements.
uint8_t slave_addr
The I2C slave address on the bus.
uint8_t init_error_cnt
Number of consecutive transaction failures.
struct i2c_transaction trans
Transaction used during configuration and measurements.
uint8_t tx_buf[50]
Transmit buffer (command byte + payload)
spa06_device_t
Device type, detected from the chip ID during initialization.
@ SPA06_UNKNOWN
not (yet) detected
@ SPA06
SPA06-003, has the extra c31/c40 calibration coefficients.
float temperature
temperature in deg Celcius
int32_t raw_pressure
uncompensated pressure
enum spa06_status_t status
state machine status
void spa06_init(struct spa06_t *spa)
Initialize the driver instance, expects bus and i2c/spi members to be pre-filled.
void spa06_event(struct spa06_t *spa)
Handle finished transactions and publish measurements; call from the event loop.
uint8_t tmp_coef_srce
TMP_COEF_SRCE bit read from the sensor, mirrored into TMP_CFG bit 7.
spa06_status_t
States of the non-blocking driver state machine.
@ SPA06_STATUS_GET_CALIB
read the calibration coefficients (in chunks)
@ SPA06_STATUS_READ_STATUS_REG
operational: poll until pressure and temperature are ready
@ SPA06_STATUS_UNINIT
restart point: soft reset, then wait 40ms for the sensor to restart
@ SPA06_STATUS_READ_DATA_REGS
operational: read the 6 result registers
@ SPA06_STATUS_CONFIGURE
write the measurement configuration (register by register)
@ SPA06_STATUS_IDLE
read the chip ID to detect the device type
@ SPA06_STATUS_INIT_OK
wait for SENSOR_RDY and COEFFS_RDY
@ SPA06_STATUS_GET_COEF_SRCE
read which temperature sensor the factory calibration used
uint8_t config_idx
progress through the configuration writes (spa06_config)
int16_t c40
12 bit, SPA06 only
uint8_t slave_idx
Slave index used for Slave Select.
struct spi_periph * p
Peripheral device for communication.
int16_t c0
12 bit, temperature offset
uint8_t rx_buf[50]
Receive buffer (dummy byte + response)
bool reset
reset command sent, waiting for the sensor to restart
int16_t c1
12 bit, temperature gain
struct spa06_reg_calib_data calib
calibration data
enum spa06_bus_t bus
The communication bus used to connect the device SPI/I2C.
void spa06_periodic(struct spa06_t *spa)
Run the state machine, submits at most one bus transaction; call periodically.
bool initialized
config done flag
bool is_broken
sensor absent or persistently failing, retried after a backoff period
volatile uint8_t * tx_buffer
points into the active bus transmit buffer
uint32_t timer
times the 40ms post-reset wait and the broken-sensor retry backoff [us]
int16_t c31
12 bit, SPA06 only
int32_t raw_temperature
uncompensated temperature
spa06_bus_t
Communication busses the spa06 driver can use.
struct i2c_periph * p
Peripheral device for communication.
int32_t c00
20 bit, pressure offset
volatile uint8_t * rx_buffer
points into the active bus receive buffer (SPI dummy byte already skipped)
enum spa06_device_t device
The device type detected.
I2C bus configuration and transaction state.
Factory calibration coefficients (register trim values)
SPI bus configuration and transaction state.
Register definitions for the Goertek SPA06-003 / SPL06-001 barometer.
Architecture independent SPI (Serial Peripheral Interface) API.
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.