Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
airspeed_ms45xx_i2c.c File Reference
#include "std.h"
#include "mcu_periph/i2c.h"
#include "modules/sensors/airspeed_ms45xx_i2c.h"
#include "filters/low_pass_filter.h"
#include "subsystems/abi.h"
#include "mcu_periph/uart.h"
#include "pprzlink/messages.h"
#include "subsystems/datalink/downlink.h"
#include "subsystems/datalink/telemetry.h"
+ Include dependency graph for airspeed_ms45xx_i2c.c:

Go to the source code of this file.

Macros

#define MS45XX_I2C_DEV   i2c2
 Default I2C device. More...
 
#define MS45XX_I2C_ADDR   0x50
 Sensor I2C slave address (existing defaults 0x50, 0x6C and 0x8C) More...
 
#define MS45XX_PRESSURE_OUTPUT_TYPE_InH2O   0
 MS45xx sensors pressure output type can be in PSI or InH2O, as defined in the datasheet if not defined to be MS45XX_PRESSURE_OUTPUT_TYPE_InH2O then PSI is used. More...
 
#define MS45XX_PRESSURE_RANGE   1
 MS45xx pressure range in PSI or InH2O The sensor is available in many ranges, the datasheet of your pressure sensor will tell which one and what this range represents. More...
 
#define MS45XX_PRESSURE_TYPE   0
 Pressure Type 0 = Differential, 1 = Gauge note there are theoretical more types than 2, e.g. More...
 
#define USE_AIRSPEED_LOWPASS_FILTER   TRUE
 Use low pass filter on pressure values. More...
 
#define MS45XX_OUTPUT_TYPE   0
 MS45xx output Type. More...
 
#define InH2O_TO_PA   249.08891
 Conversion factor from InH2O to Pa. More...
 
#define PSI_TO_PA   6894.75729
 Conversion factor from psi to Pa. More...
 
#define OutputPressureToPa   PSI_TO_PA
 
#define MS45XX_PRESSURE_SCALE   (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa)
 
#define MS45XX_PRESSURE_OFFSET   (1.25 * MS45XX_PRESSURE_RANGE * OutputPressureToPa)
 
#define MS45XX_SYNC_SEND   FALSE
 Send a AIRSPEED_MS45XX message with every new measurement. More...
 
#define MS45XX_AIRSPEED_SCALE   1.6327
 Quadratic scale factor for indicated airspeed. More...
 
#define MS45XX_LOWPASS_TAU   0.15
 Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq of 1/(2*pi*tau) ~= 1Hz. More...
 
#define AUTOSET_NB_MAX   20
 

Functions

static void ms45xx_downlink (struct transport_tx *trans, struct link_device *dev)
 
void ms45xx_i2c_init (void)
 
void ms45xx_i2c_periodic (void)
 
void ms45xx_i2c_event (void)
 

Variables

struct AirspeedMs45xx ms45xx
 
static struct i2c_transaction ms45xx_trans
 
static Butterworth2LowPass ms45xx_filter
 

Detailed Description

Airspeed sensor module using the MS45xxDO digital pressure sensor via I2C. Needs to be one of the versions with 14bit pressure and 11bit temperature.

Definition in file airspeed_ms45xx_i2c.c.

Macro Definition Documentation

◆ AUTOSET_NB_MAX

#define AUTOSET_NB_MAX   20

Definition at line 215 of file airspeed_ms45xx_i2c.c.

◆ InH2O_TO_PA

#define InH2O_TO_PA   249.08891

Conversion factor from InH2O to Pa.

Definition at line 101 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_AIRSPEED_SCALE

#define MS45XX_AIRSPEED_SCALE   1.6327

Quadratic scale factor for indicated airspeed.

airspeed = sqrt(2*p_diff/density) With p_diff in Pa and standard air density of 1.225 kg/m^3, default airspeed scale is 2/1.225

Definition at line 160 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_I2C_ADDR

#define MS45XX_I2C_ADDR   0x50

Sensor I2C slave address (existing defaults 0x50, 0x6C and 0x8C)

Definition at line 62 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_I2C_DEV

#define MS45XX_I2C_DEV   i2c2

Default I2C device.

Definition at line 56 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_LOWPASS_TAU

#define MS45XX_LOWPASS_TAU   0.15

Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq of 1/(2*pi*tau) ~= 1Hz.

Definition at line 167 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_OUTPUT_TYPE

#define MS45XX_OUTPUT_TYPE   0

MS45xx output Type.

0 = Output Type A with 10% to 90% 1 = Output Type B with 5% to 95%

Definition at line 97 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_OFFSET

#define MS45XX_PRESSURE_OFFSET   (1.25 * MS45XX_PRESSURE_RANGE * OutputPressureToPa)

Definition at line 127 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_OUTPUT_TYPE_InH2O

#define MS45XX_PRESSURE_OUTPUT_TYPE_InH2O   0

MS45xx sensors pressure output type can be in PSI or InH2O, as defined in the datasheet if not defined to be MS45XX_PRESSURE_OUTPUT_TYPE_InH2O then PSI is used.

Definition at line 69 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_RANGE

#define MS45XX_PRESSURE_RANGE   1

MS45xx pressure range in PSI or InH2O The sensor is available in many ranges, the datasheet of your pressure sensor will tell which one and what this range represents.

Definition at line 77 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_SCALE

#define MS45XX_PRESSURE_SCALE   (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa)

Definition at line 124 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_TYPE

#define MS45XX_PRESSURE_TYPE   0

Pressure Type 0 = Differential, 1 = Gauge note there are theoretical more types than 2, e.g.

Absolute not implemented

Definition at line 83 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_SYNC_SEND

#define MS45XX_SYNC_SEND   FALSE

Send a AIRSPEED_MS45XX message with every new measurement.

Mainly for debugging, use with caution, sends message at ~100Hz.

Definition at line 151 of file airspeed_ms45xx_i2c.c.

◆ OutputPressureToPa

#define OutputPressureToPa   PSI_TO_PA

Definition at line 109 of file airspeed_ms45xx_i2c.c.

◆ PSI_TO_PA

#define PSI_TO_PA   6894.75729

Conversion factor from psi to Pa.

Definition at line 104 of file airspeed_ms45xx_i2c.c.

◆ USE_AIRSPEED_LOWPASS_FILTER

#define USE_AIRSPEED_LOWPASS_FILTER   TRUE

Use low pass filter on pressure values.

Definition at line 89 of file airspeed_ms45xx_i2c.c.

Function Documentation

◆ ms45xx_downlink()

static void ms45xx_downlink ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 176 of file airspeed_ms45xx_i2c.c.

References AirspeedMs45xx::airspeed, dev, ms45xx, AirspeedMs45xx::pressure, and AirspeedMs45xx::temperature.

Referenced by ms45xx_i2c_event(), and ms45xx_i2c_init().

+ Here is the caller graph for this function:

◆ ms45xx_i2c_event()

◆ ms45xx_i2c_init()

◆ ms45xx_i2c_periodic()

void ms45xx_i2c_periodic ( void  )

Definition at line 207 of file airspeed_ms45xx_i2c.c.

References i2c_receive(), I2CTransDone, MS45XX_I2C_ADDR, MS45XX_I2C_DEV, ms45xx_trans, and i2c_transaction::status.

+ Here is the call graph for this function:

Variable Documentation

◆ ms45xx

struct AirspeedMs45xx ms45xx

Definition at line 170 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_downlink(), ms45xx_i2c_event(), and ms45xx_i2c_init().

◆ ms45xx_filter

Butterworth2LowPass ms45xx_filter
static

Definition at line 173 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_event(), and ms45xx_i2c_init().

◆ ms45xx_trans

struct i2c_transaction ms45xx_trans
static

Definition at line 171 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_event(), ms45xx_i2c_init(), and ms45xx_i2c_periodic().