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
31
32#include "baro_spa06.h"
33
34#include "modules/core/abi.h"
35#include "mcu_periph/sys_time.h"
36#include "math/pprz_isa.h"
37
38#ifndef SPA06_USE_SPI
39 #define SPA06_USE_SPI FALSE
40#endif
42PRINT_CONFIG_VAR(SPA06_DEV)
43
44
45#ifndef SPA06_SLAVE_ADDR
46 #define SPA06_SLAVE_ADDR SPA06_I2C_ADDR
47#endif
48
50#ifndef SPA06_SLAVE_IDX
51 #define SPA06_SLAVE_IDX SPI_SLAVE0
52#endif
53
54float baro_spa06_alt = 0;
56
59
68{
69#if SPA06_USE_SPI
71 baro_spa06.spi.p = &SPA06_DEV;
72 baro_spa06.spi.slave_idx = SPA06_SLAVE_IDX;
73#else
75 baro_spa06.i2c.p = (struct i2c_periph*)&SPA06_DEV;
76 baro_spa06.i2c.slave_addr = SPA06_SLAVE_ADDR;
77#endif
79}
80
86
95{
97
98 if (baro_spa06.data_available) {
99 uint32_t now_ts = get_sys_time_usec();
100 // send ABI message
101 AbiSendMsgBARO_ABS_RAW(BARO_SPA_SENDER_ID, now_ts, baro_spa06.pressure);
102 AbiSendMsgTEMPERATURE_RAW(BARO_SPA_SENDER_ID, now_ts, baro_spa06.temperature, TEMPERATURE_TYPE_BARO);
103 baro_spa06.data_available = false;
106 }
107}
Main include for ABI (AirBorneInterface).
#define TEMPERATURE_TYPE_BARO
barometer die
Definition abi_common.h:91
#define BARO_SPA_SENDER_ID
#define SPA06_USE_SPI
Definition baro_spa06.c:39
bool baro_spa06_alt_valid
true once the first valid sample has been processed
Definition baro_spa06.c:55
void baro_spa06_event(void)
Process finished bus transactions and publish new measurements.
Definition baro_spa06.c:94
float baro_spa06_alt
ISA pressure altitude of the last sample [m].
Definition baro_spa06.c:54
#define SPA06_SLAVE_ADDR
Default I2C slave address (SDO low); override with SPA06_I2C_ADDR_ALT for SDO high.
Definition baro_spa06.c:46
void baro_spa06_periodic(void)
Drive the sensor state machine (module periodic hook, 25Hz).
Definition baro_spa06.c:82
void baro_spa06_init(void)
Bind the driver to the configured bus.
Definition baro_spa06.c:67
struct spa06_t baro_spa06
The barometer driver instance.
Definition baro_spa06.c:58
#define SPA06_SLAVE_IDX
Default SPI slave select index, only used when SPA06_USE_SPI is TRUE.
Definition baro_spa06.c:51
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 float pprz_isa_altitude_of_pressure(float pressure)
Get absolute altitude from pressure (using simplified equation).
Definition pprz_isa.h:82
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
@ SPA06_SPI
Definition spa06.h:55
@ SPA06_I2C
Definition spa06.h:56
Driver instance state.
Definition spa06.h:110
Architecture independent timing functions.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.