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

Module glue for the Goertek SPA06-003 / SPL06-001 barometer. More...

#include "baro_spa06.h"
#include "modules/core/abi.h"
#include "mcu_periph/sys_time.h"
#include "math/pprz_isa.h"
Include dependency graph for baro_spa06.c:

Go to the source code of this file.

Macros

#define SPA06_USE_SPI   FALSE
#define SPA06_SLAVE_ADDR   SPA06_I2C_ADDR
 Default I2C slave address (SDO low); override with SPA06_I2C_ADDR_ALT for SDO high.
#define SPA06_SLAVE_IDX   SPI_SLAVE0
 Default SPI slave select index, only used when SPA06_USE_SPI is TRUE.

Functions

void baro_spa06_init (void)
 Bind the driver to the configured bus.
void baro_spa06_periodic (void)
 Drive the sensor state machine (module periodic hook, 25Hz).
void baro_spa06_event (void)
 Process finished bus transactions and publish new measurements.

Variables

float baro_spa06_alt = 0
 ISA pressure altitude of the last sample [m].
bool baro_spa06_alt_valid = false
 true once the first valid sample has been processed
struct spa06_t baro_spa06
 The barometer driver instance.

Detailed Description

Module glue for the Goertek SPA06-003 / SPL06-001 barometer.

Wires the spa06 peripheral driver (see peripherals/spa06.c) into the module system: init/periodic/event hooks, and publishes each accepted measurement as ABI BARO_ABS + TEMPERATURE messages (BARO_SPA_SENDER_ID).

Definition in file baro_spa06.c.

Macro Definition Documentation

◆ SPA06_SLAVE_ADDR

#define SPA06_SLAVE_ADDR   SPA06_I2C_ADDR

Default I2C slave address (SDO low); override with SPA06_I2C_ADDR_ALT for SDO high.

Definition at line 46 of file baro_spa06.c.

Referenced by baro_spa06_init().

◆ SPA06_SLAVE_IDX

#define SPA06_SLAVE_IDX   SPI_SLAVE0

Default SPI slave select index, only used when SPA06_USE_SPI is TRUE.

Definition at line 51 of file baro_spa06.c.

Referenced by baro_spa06_init().

◆ SPA06_USE_SPI

#define SPA06_USE_SPI   FALSE

Definition at line 39 of file baro_spa06.c.

Function Documentation

◆ baro_spa06_event()

void baro_spa06_event ( void )

Process finished bus transactions and publish new measurements.

Process finished bus transactions and publish new measurements (module event hook).

When the driver flags a valid sample: sends ABI BARO_ABS [Pa] and TEMPERATURE [deg Celcius], updates the baro_spa06_alt globals (including the ISA pressure altitude) and clears data_available for the next sample.

Definition at line 94 of file baro_spa06.c.

References baro_spa06, baro_spa06_alt, baro_spa06_alt_valid, BARO_SPA_SENDER_ID, get_sys_time_usec(), pprz_isa_altitude_of_pressure(), spa06_event(), and TEMPERATURE_TYPE_BARO.

Here is the call graph for this function:

◆ baro_spa06_init()

void baro_spa06_init ( void )

Bind the driver to the configured bus.

Bind the driver to the configured bus and register telemetry (module init hook).

Bus selection is compile time: SPA06_USE_SPI picks SPI (SPA06_DEV + SPA06_SLAVE_IDX) or I2C (SPA06_DEV + SPA06_SLAVE_ADDR). The sensor itself is detected and configured asynchronously by the periodic/event pair.

Definition at line 67 of file baro_spa06.c.

References baro_spa06, SPA06_I2C, spa06_init(), SPA06_SLAVE_ADDR, SPA06_SLAVE_IDX, and SPA06_SPI.

Here is the call graph for this function:

◆ baro_spa06_periodic()

void baro_spa06_periodic ( void )

Drive the sensor state machine (module periodic hook, 25Hz).

Drive the sensor state machine (module periodic hook).

Definition at line 82 of file baro_spa06.c.

References baro_spa06, and spa06_periodic().

Here is the call graph for this function:

Variable Documentation

◆ baro_spa06

struct spa06_t baro_spa06

The barometer driver instance.

The barometer driver instance, exposed for debugging/telemetry.

Definition at line 58 of file baro_spa06.c.

Referenced by baro_spa06_event(), baro_spa06_init(), and baro_spa06_periodic().

◆ baro_spa06_alt

float baro_spa06_alt = 0

ISA pressure altitude of the last sample [m].

Definition at line 54 of file baro_spa06.c.

Referenced by baro_spa06_event().

◆ baro_spa06_alt_valid

bool baro_spa06_alt_valid = false

true once the first valid sample has been processed

Definition at line 55 of file baro_spa06.c.

Referenced by baro_spa06_event().