38 #if PERIODIC_TELEMETRY
42 #ifndef USE_AIRSPEED_MS45XX
44 #define USE_AIRSPEED_MS45XX TRUE
49 #if USE_AIRSPEED_MS45XX
55 #ifndef MS45XX_I2C_DEV
56 #define MS45XX_I2C_DEV i2c2
60 #ifndef MS45XX_I2C_ADDR
61 #define MS45XX_I2C_ADDR 0x50
68 #ifndef MS45XX_PRESSURE_RANGE
69 #define MS45XX_PRESSURE_RANGE 1
76 #ifndef MS45XX_OUTPUT_TYPE
77 #define MS45XX_OUTPUT_TYPE 0
81 #define PSI_TO_PA 6894.75729
83 #if MS45XX_OUTPUT_TYPE == 0
94 #ifndef MS45XX_PRESSURE_SCALE
95 #define MS45XX_PRESSURE_SCALE (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * PSI_TO_PA)
97 #ifndef MS45XX_PRESSURE_OFFSET
98 #define MS45XX_PRESSURE_OFFSET (1.25 * MS45XX_PRESSURE_RANGE * PSI_TO_PA)
104 #ifndef MS45XX_PRESSURE_SCALE
105 #define MS45XX_PRESSURE_SCALE (2 * MS45XX_PRESSURE_RANGE / (0.9 * 16383) * PSI_TO_PA)
107 #ifndef MS45XX_PRESSURE_OFFSET
108 #define MS45XX_PRESSURE_OFFSET ((1.0 + 0.1 / 0.9) * MS45XX_PRESSURE_RANGE * PSI_TO_PA)
115 #ifndef MS45XX_SYNC_SEND
116 #define MS45XX_SYNC_SEND FALSE
124 #ifndef MS45XX_AIRSPEED_SCALE
125 #define MS45XX_AIRSPEED_SCALE 1.6327
131 #ifndef MS45XX_LOWPASS_TAU
132 #define MS45XX_LOWPASS_TAU 0.15
142 pprz_msg_send_AIRSPEED_MS45XX(trans, dev, AC_ID,
160 MS45XX_I2C_PERIODIC_PERIOD, 0);
162 #if PERIODIC_TELEMETRY
198 temp_raw = temp_raw >> 5;
212 #if USE_AIRSPEED_MS45XX
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
#define MS45XX_I2C_ADDR
Sensor I2C slave address (defaults 0x50, 0x6C and 0x8C)
Generic transmission transport header.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
transaction successfully finished by I2C driver
int16_t temperature
temperature in 0.1 deg Celcius
Periodic telemetry system header (includes downlink utility and generated code).
Simple first order low pass filter with bilinear transform.
void ms45xx_i2c_init(void)
Main include for ABI (AirBorneInterface).
struct AirspeedMs45xx ms45xx
float diff_pressure
differential pressure in Pascal
#define MS45XX_PRESSURE_OFFSET
bool_t sync_send
flag to enable sending every new measurement via telemetry
void ms45xx_i2c_event(void)
float airspeed
Airspeed in m/s estimated from differential pressure.
transaction set to done by user level
#define MS45XX_AIRSPEED_SCALE
Quadratic scale factor for airspeed.
static Butterworth2LowPass ms45xx_filter
float pressure_scale
scaling factor from raw measurement to Pascal
float airspeed_scale
quadratic scale factor to convert differential pressure to airspeed
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define MS45XX_SYNC_SEND
Send a AIRSPEED_MS45XX message with every new measurement.
#define DefaultPeriodic
Set default periodic telemetry.
float pressure_offset
offset in Pascal
I2C transaction structure.
enum I2CTransactionStatus status
Transaction status.
static const struct usb_device_descriptor dev
#define DefaultChannel
SITL.
API to get/set the generic vehicle states.
static struct i2c_transaction ms45xx_trans
Airspeed driver for the MS45xx via I2C.
static void stateSetAirspeed_f(float airspeed)
Set airspeed (float).
Common code for AP and FBW telemetry.
Second order low pass filter structure.
#define MS45XX_I2C_DEV
Default I2C device.
void ms45xx_i2c_periodic(void)
#define MS45XX_LOWPASS_TAU
Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq o...
bool_t i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
#define MS45XX_PRESSURE_SCALE
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
static void ms45xx_downlink(struct transport_tx *trans, struct link_device *dev)
Architecture independent I2C (Inter-Integrated Circuit Bus) API.