Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
baro_spa06.c
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
34#include "baro_spa06.h"
35
36#include "modules/core/abi.h"
37#include "math/pprz_isa.h"
38#ifdef SPA06_SYNC_SEND
39 #include "mcu_periph/uart.h"
40 #include "pprzlink/messages.h"
42#endif
43
44#if DOWNLINK && !defined(SPA06_SYNC_SEND)
46#endif
48
49#ifndef SPA06_USE_SPI
50 #define SPA06_USE_SPI FALSE
51#endif
54
55
56#ifndef SPA06_SLAVE_ADDR
57 #define SPA06_SLAVE_ADDR SPA06_I2C_ADDR
58#endif
59
61#ifndef SPA06_SLAVE_IDX
62 #define SPA06_SLAVE_IDX SPI_SLAVE0
63#endif
64
65float baro_spa06_alt = 0;
67static float baro_spa06_temp = 0;
68static float baro_spa06_press = 0;
69
72
73#if DOWNLINK && !defined(SPA06_SYNC_SEND)
88#endif
89
98{
99#if SPA06_USE_SPI
101 baro_spa06.spi.p = &SPA06_DEV;
102 baro_spa06.spi.slave_idx = SPA06_SLAVE_IDX;
103#else
105 baro_spa06.i2c.p = (struct i2c_periph*)&SPA06_DEV;
106 baro_spa06.i2c.slave_addr = SPA06_SLAVE_ADDR;
107#endif
109#if DOWNLINK && !defined(SPA06_SYNC_SEND)
111#endif
112}
113
119
Main include for ABI (AirBorneInterface).
#define BARO_SPA_SENDER_ID
#define SPA06_USE_SPI
Definition baro_spa06.c:50
bool baro_spa06_alt_valid
true once the first valid sample has been processed
Definition baro_spa06.c:66
void baro_spa06_event(void)
Process finished bus transactions and publish new measurements.
Definition baro_spa06.c:127
float baro_spa06_alt
ISA pressure altitude of the last sample [m].
Definition baro_spa06.c:65
#define SPA06_SLAVE_ADDR
Default I2C slave address (SDO low); override with SPA06_I2C_ADDR_ALT for SDO high.
Definition baro_spa06.c:57
static void send_baro_spa_data(struct transport_tx *trans, struct link_device *dev)
Periodic telemetry: report the latest barometer data.
Definition baro_spa06.c:80
static float baro_spa06_press
last compensated pressure [Pa]
Definition baro_spa06.c:68
void baro_spa06_periodic(void)
Drive the sensor state machine (module periodic hook, 25Hz)
Definition baro_spa06.c:115
void baro_spa06_init(void)
Bind the driver to the configured bus and register telemetry.
Definition baro_spa06.c:97
struct spa06_t baro_spa06
The barometer driver instance.
Definition baro_spa06.c:71
#define SPA06_SLAVE_IDX
Default SPI slave select index, only used when SPA06_USE_SPI is TRUE.
Definition baro_spa06.c:62
static float baro_spa06_temp
last sensor temperature [deg Celcius]
Definition baro_spa06.c:67
Module glue for the Goertek SPA06-003 / SPL06-001 barometer.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
static struct uart_periph * dev
static float pprz_isa_altitude_of_pressure(float pressure)
Get absolute altitude from pressure (using simplified equation).
Definition pprz_isa.h:82
static float p[2][2]
uint16_t up[LIGHT_NB]
Definition light_solar.c:48
uint16_t foo
Definition main_demo5.c:58
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Paparazzi atmospheric pressure conversion utilities.
void spa06_init(struct spa06_t *spa)
Initialize the spa06 sensor instance.
Definition spa06.c:71
void spa06_event(struct spa06_t *spa)
Should be called in the event thread.
Definition spa06.c:230
void spa06_periodic(struct spa06_t *spa)
Should be called periodically to request sensor readings.
Definition spa06.c:131
float pressure
pressure in Pascal
Definition spa06.h:123
volatile bool data_available
data ready flag
Definition spa06.h:118
float temperature
temperature in deg Celcius
Definition spa06.h:124
int32_t raw_pressure
uncompensated pressure
Definition spa06.h:121
enum spa06_bus_t bus
The communication bus used to connect the device SPI/I2C.
Definition spa06.h:125
int32_t raw_temperature
uncompensated temperature
Definition spa06.h:122
@ SPA06_SPI
Definition spa06.h:55
@ SPA06_I2C
Definition spa06.h:56
Driver instance state.
Definition spa06.h:110
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.