35#include "pprzlink/messages.h" 
   43#ifndef AIRSPEED_MS45XX_SEND_ABI 
   44#define AIRSPEED_MS45XX_SEND_ABI true 
   50#define MS45XX_I2C_DEV i2c2 
   55#ifndef MS45XX_I2C_ADDR 
   56#define MS45XX_I2C_ADDR 0x50 
   62#ifndef MS45XX_PRESSURE_OUTPUT_TYPE_InH2O 
   63#define MS45XX_PRESSURE_OUTPUT_TYPE_InH2O 0 
   70#ifndef MS45XX_PRESSURE_RANGE 
   71#define MS45XX_PRESSURE_RANGE 1 
   76#ifndef MS45XX_PRESSURE_TYPE 
   77#define MS45XX_PRESSURE_TYPE 0 
   82#ifndef USE_AIRSPEED_LOWPASS_FILTER 
   83#define USE_AIRSPEED_LOWPASS_FILTER TRUE 
   90#ifndef MS45XX_OUTPUT_TYPE 
   91#define MS45XX_OUTPUT_TYPE 0 
   95#define InH2O_TO_PA 249.08891 
   98#define PSI_TO_PA 6894.75729 
  100#if MS45XX_PRESSURE_OUTPUT_TYPE_InH2O 
  101#define OutputPressureToPa InH2O_TO_PA 
  103#define OutputPressureToPa PSI_TO_PA 
  106#if MS45XX_OUTPUT_TYPE == 0 
  117#ifndef MS45XX_PRESSURE_SCALE 
  118#define MS45XX_PRESSURE_SCALE (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa) 
  120#ifndef MS45XX_PRESSURE_OFFSET 
  121#define MS45XX_PRESSURE_OFFSET (16383 / 2) 
  127#ifndef MS45XX_PRESSURE_SCALE 
  128#define MS45XX_PRESSURE_SCALE (MS45XX_PRESSURE_RANGE/(0.9*16383)*OutputPressureToPa) 
  130#ifndef MS45XX_PRESSURE_OFFSET 
  131#define MS45XX_PRESSURE_OFFSET (0.05*16383) 
  147#ifdef MS45XX_AIRSPEED_SCALE 
  148PRINT_CONFIG_MSG(
"MS45XX changed air density. PS: Use MS45XX_PRESSURE_SCALE to calibrate the MS45XX.");
 
  151#define MS45XX_RHO_DIV_2 1.6327 
  157#ifndef MS45XX_LOWPASS_TAU 
  158#define MS45XX_LOWPASS_TAU 0.15 
  163#ifdef USE_AIRSPEED_LOWPASS_FILTER 
  208#ifdef USE_AIRSPEED_LOWPASS_FILTER 
  213#if PERIODIC_TELEMETRY 
 
  227#ifdef USE_AIRSPEED_LOWPASS_FILTER 
 
  242#define AUTOSET_NB_MAX 200 
  247  static float autoset_offset = 0.f;
 
  294#ifdef USE_AIRSPEED_LOWPASS_FILTER 
  302          autoset_offset += 
p_raw;
 
  306          autoset_offset = 0.f;
 
  314      #if AIRSPEED_MS45XX_SEND_ABI 
 
Main include for ABI (AirBorneInterface).
#define MS45XX_LOWPASS_TAU
Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq o...
#define MS45XX_RHO_DIV_2
Quadratic scale factor for indicated airspeed.
#define MS45XX_PRESSURE_RANGE
MS45xx pressure range in PSI or InH2O The sensor is available in many ranges, the datasheet of your p...
void ms45xx_i2c_event(void)
#define MS45XX_OUTPUT_TYPE
MS45xx output Type.
void ms45xx_i2c_periodic(void)
#define MS45XX_I2C_DEV
Default I2C device.
#define MS45XX_I2C_ADDR
Sensor I2C slave address (existing defaults 0x50, 0x6C and 0x8C)
void airspeed_ms45xx_i2c_change_tau(float new_tau)
struct AirspeedMs45xx ms45xx
static void ms45xx_downlink(struct transport_tx *trans, struct link_device *dev)
#define MS45XX_PRESSURE_TYPE
Pressure Type 0 = Differential, 1 = Gauge note there are theoretical more types than 2,...
#define MS45XX_PRESSURE_OFFSET
static struct i2c_transaction ms45xx_trans
static Butterworth2LowPass ms45xx_filter
#define MS45XX_PRESSURE_SCALE
void ms45xx_i2c_init(void)
Airspeed driver for the MS45xx pressure sensor via I2C.
float pressure_scale
Scaling factor from raw measurement to Pascal.
bool autoset_offset
Set offset value from current filtered value.
float pressure_offset
Offset in Pascal.
uint16_t raw_p
Raw pressure.
bool offset_set
Offset is set once.
bool pressure_type
Pressure type Differential of Gauge.
float pressure
(differential) pressure in Pascal
int16_t temperature
Temperature in 0.1 deg Celcius.
float lowpass_tau
Time constant for low pass filter.
float airspeed
Airspeed in m/s estimated from (differential) pressure.
Common code for AP and FBW telemetry.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
I2C transaction structure.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
Simple first order low pass filter with bilinear transform.
static float get_butterworth_2_low_pass(Butterworth2LowPass *filter)
Get current value of the second order Butterworth low pass filter.
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
Second order low pass filter structure.
static float sign(float x)
sign function
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
void preflight_error(struct preflight_result_t *result, const char *fmt,...)
Register a preflight error used inside the preflight checking functions.
void preflight_success(struct preflight_result_t *result, const char *fmt,...)
Register a preflight success used inside the preflight checking functions.
void preflight_check_register(struct preflight_check_t *check, preflight_check_f func)
Register a preflight check and add it to the linked list.
static const struct usb_device_descriptor dev
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.