Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
spa06.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 OpenUAS
3 * Thanks to Florian Sansou florian.sansou@enac.fr for initial implementation
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
20 *
21 */
22
28#ifndef SPA06_H
29#define SPA06_H
30
31/* Header includes */
33#include "mcu_periph/i2c.h"
34#include "mcu_periph/spi.h"
35
42
52
58
65
83
136
138extern void spa06_init(struct spa06_t *spa);
140extern void spa06_periodic(struct spa06_t *spa);
142extern void spa06_event(struct spa06_t *spa);
143
144#endif /* SPA06_H */
I2C transaction structure.
Definition i2c.h:94
SPI peripheral structure.
Definition spi.h:171
SPI transaction structure.
Definition spi.h:144
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
uint16_t foo
Definition main_demo5.c:58
float pressure
pressure in Pascal
Definition spa06.h:123
uint8_t calib_idx
progress through the calibration chunks (spa06_get_calib/parse_calib_data)
Definition spa06.h:134
volatile bool data_available
data ready flag
Definition spa06.h:118
struct spi_transaction trans
Transaction used during configuration and measurements.
Definition spa06.h:47
uint8_t slave_addr
The I2C slave address on the bus.
Definition spa06.h:40
uint8_t init_error_cnt
Number of consecutive transaction failures.
Definition spa06.h:117
struct i2c_transaction trans
Transaction used during configuration and measurements.
Definition spa06.h:39
uint8_t tx_buf[50]
Transmit buffer (command byte + payload)
Definition spa06.h:49
int16_t c11
16 bit
Definition spa06.h:94
spa06_device_t
Device type, detected from the chip ID during initialization.
Definition spa06.h:60
@ SPA06_UNKNOWN
not (yet) detected
Definition spa06.h:61
@ SPA06
SPA06-003, has the extra c31/c40 calibration coefficients.
Definition spa06.h:62
@ SPL06
SPL06-001.
Definition spa06.h:63
float temperature
temperature in deg Celcius
Definition spa06.h:124
int16_t c20
16 bit
Definition spa06.h:95
int32_t raw_pressure
uncompensated pressure
Definition spa06.h:121
enum spa06_status_t status
state machine status
Definition spa06.h:111
void spa06_init(struct spa06_t *spa)
Initialize the driver instance, expects bus and i2c/spi members to be pre-filled.
Definition spa06.c:71
void spa06_event(struct spa06_t *spa)
Handle finished transactions and publish measurements; call from the event loop.
Definition spa06.c:230
uint8_t tmp_coef_srce
TMP_COEF_SRCE bit read from the sensor, mirrored into TMP_CFG bit 7.
Definition spa06.h:120
spa06_status_t
States of the non-blocking driver state machine.
Definition spa06.h:73
@ SPA06_STATUS_GET_CALIB
read the calibration coefficients (in chunks)
Definition spa06.h:78
@ SPA06_STATUS_READ_STATUS_REG
operational: poll until pressure and temperature are ready
Definition spa06.h:80
@ SPA06_STATUS_UNINIT
restart point: soft reset, then wait 40ms for the sensor to restart
Definition spa06.h:74
@ SPA06_STATUS_READ_DATA_REGS
operational: read the 6 result registers
Definition spa06.h:81
@ SPA06_STATUS_CONFIGURE
write the measurement configuration (register by register)
Definition spa06.h:79
@ SPA06_STATUS_IDLE
read the chip ID to detect the device type
Definition spa06.h:75
@ SPA06_STATUS_INIT_OK
wait for SENSOR_RDY and COEFFS_RDY
Definition spa06.h:76
@ SPA06_STATUS_GET_COEF_SRCE
read which temperature sensor the factory calibration used
Definition spa06.h:77
uint8_t config_idx
progress through the configuration writes (spa06_config)
Definition spa06.h:133
int16_t c40
12 bit, SPA06 only
Definition spa06.h:99
uint8_t slave_idx
Slave index used for Slave Select.
Definition spa06.h:46
struct spi_periph * p
Peripheral device for communication.
Definition spa06.h:45
int16_t c0
12 bit, temperature offset
Definition spa06.h:91
uint8_t rx_buf[50]
Receive buffer (dummy byte + response)
Definition spa06.h:50
bool reset
reset command sent, waiting for the sensor to restart
Definition spa06.h:115
int16_t c01
16 bit
Definition spa06.h:93
int32_t c10
20 bit
Definition spa06.h:101
int16_t c21
16 bit
Definition spa06.h:96
int16_t c1
12 bit, temperature gain
Definition spa06.h:92
struct spa06_reg_calib_data calib
calibration data
Definition spa06.h:119
int16_t c30
16 bit
Definition spa06.h:97
enum spa06_bus_t bus
The communication bus used to connect the device SPI/I2C.
Definition spa06.h:125
void spa06_periodic(struct spa06_t *spa)
Run the state machine, submits at most one bus transaction; call periodically.
Definition spa06.c:131
bool initialized
config done flag
Definition spa06.h:113
bool is_broken
sensor absent or persistently failing, retried after a backoff period
Definition spa06.h:114
volatile uint8_t * tx_buffer
points into the active bus transmit buffer
Definition spa06.h:131
uint32_t timer
times the 40ms post-reset wait and the broken-sensor retry backoff [us]
Definition spa06.h:116
int16_t c31
12 bit, SPA06 only
Definition spa06.h:98
int32_t raw_temperature
uncompensated temperature
Definition spa06.h:122
spa06_bus_t
Communication busses the spa06 driver can use.
Definition spa06.h:54
@ SPA06_SPI
Definition spa06.h:55
@ SPA06_I2C
Definition spa06.h:56
struct i2c_periph * p
Peripheral device for communication.
Definition spa06.h:38
int32_t c00
20 bit, pressure offset
Definition spa06.h:100
volatile uint8_t * rx_buffer
points into the active bus receive buffer (SPI dummy byte already skipped)
Definition spa06.h:130
enum spa06_device_t device
The device type detected.
Definition spa06.h:112
I2C bus configuration and transaction state.
Definition spa06.h:37
Factory calibration coefficients (register trim values)
Definition spa06.h:90
SPI bus configuration and transaction state.
Definition spa06.h:44
Driver instance state.
Definition spa06.h:110
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.