30 #include "pprzlink/messages.h"
36 #define AIRSPEED_AMSYS_ADDR 0xE8 // original F0
37 #ifndef AIRSPEED_AMSYS_SCALE
38 #define AIRSPEED_AMSYS_SCALE 1
40 #define AIRSPEED_AMSYS_OFFSET_MAX 29491
41 #define AIRSPEED_AMSYS_OFFSET_MIN 3277
42 #define AIRSPEED_AMSYS_OFFSET_NBSAMPLES_INIT 40
43 #define AIRSPEED_AMSYS_OFFSET_NBSAMPLES_AVRG 60
44 #define AIRSPEED_AMSYS_NBSAMPLES_AVRG 10
45 #ifndef AIRSPEED_AMSYS_MAXPRESURE
46 #define AIRSPEED_AMSYS_MAXPRESURE 2068 //003-2068, 001-1034 //Pascal
48 #ifndef AIRSPEED_AMSYS_FILTER
49 #define AIRSPEED_AMSYS_FILTER 0
51 #ifndef AIRSPEED_AMSYS_I2C_DEV
52 #define AIRSPEED_AMSYS_I2C_DEV i2c0
54 #ifdef MEASURE_AMSYS_TEMPERATURE
55 #define TEMPERATURE_AMSYS_OFFSET_MAX 29491
56 #define TEMPERATURE_AMSYS_OFFSET_MIN 3277
57 #define TEMPERATURE_AMSYS_MAX 85
58 #define TEMPERATURE_AMSYS_MIN -25
61 #ifndef USE_AIRSPEED_AMSYS
63 #define USE_AIRSPEED_AMSYS TRUE
94 airspeed_amsys_raw = 0;
96 airspeed_amsys_p = 0.0;
97 airspeed_amsys_offset = 0;
98 airspeed_amsys_offset_tmp = 0;
99 airspeed_amsys_i2c_done =
true;
100 airspeed_amsys_valid =
true;
101 airspeed_amsys_offset_init =
false;
113 #ifndef MEASURE_AMSYS_TEMPERATURE
120 #if USE_AIRSPEED_AMSYS
124 #elif !defined USE_NPS
130 #ifndef AIRSPEED_AMSYS_SYNC_SEND
138 &airspeed_amsys_raw, &airspeed_amsys_p,
139 &airspeed_amsys_tmp, &airspeed_amsys,
140 &airspeed_temperature);
147 airspeed_amsys_raw = 0;
149 #ifdef MEASURE_AMSYS_TEMPERATURE
151 const float temp_off_scale = (float)(TEMPERATURE_AMSYS_MAX - TEMPERATURE_AMSYS_MIN) /
152 (TEMPERATURE_AMSYS_OFFSET_MAX - TEMPERATURE_AMSYS_OFFSET_MIN);
154 airspeed_temperature = temp_off_scale * (tempAS_amsys_raw - TEMPERATURE_AMSYS_OFFSET_MIN) +
155 TEMPERATURE_AMSYS_MIN;
159 if (airspeed_amsys_raw == 0) {
160 airspeed_amsys_valid =
false;
162 airspeed_amsys_valid =
true;
166 if (airspeed_amsys_valid) {
182 if (!airspeed_amsys_offset_init) {
185 if (airspeed_amsys_cnt == 0) {
188 airspeed_amsys_offset_init =
true;
199 if (airspeed_amsys_p <= 0) {
200 airspeed_amsys_p = 0.000000001;
203 airspeed_amsys_tmp = sqrtf(2 * airspeed_amsys_p * airspeed_scale / 1.2041);
205 airspeed_amsys = airspeed_filter * airspeed_old +
213 #ifdef AIRSPEED_AMSYS_SYNC_SEND
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
float airspeed_temperature
#define AIRSPEED_AMSYS_ADDR
#define AIRSPEED_AMSYS_OFFSET_NBSAMPLES_INIT
volatile bool airspeed_amsys_i2c_done
#define AIRSPEED_AMSYS_OFFSET_MIN
struct i2c_transaction airspeed_amsys_i2c_trans
transaction set to done by user level
#define AIRSPEED_AMSYS_FILTER
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
I2C transaction structure.
enum I2CTransactionStatus status
Transaction status.
bool airspeed_amsys_valid
#define AIRSPEED_AMSYS_OFFSET_NBSAMPLES_AVRG
API to get/set the generic vehicle states.
uint16_t airspeed_amsys_raw
float airspeed_amsys_offset
uint16_t airspeed_amsys_cnt
void airspeed_amsys_read_event(void)
void airspeed_amsys_init(void)
static void stateSetAirspeed_f(float airspeed)
Set airspeed (float).
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
double airspeed_amsys_offset_tmp
Common code for AP and FBW telemetry.
#define AIRSPEED_AMSYS_I2C_DEV
#define AIRSPEED_AMSYS_OFFSET_MAX
bool airspeed_amsys_offset_init
void airspeed_amsys_downlink(void)
uint16_t tempAS_amsys_raw
void airspeed_amsys_read_periodic(void)
#define AIRSPEED_AMSYS_SCALE
#define AIRSPEED_AMSYS_MAXPRESURE
Architecture independent I2C (Inter-Integrated Circuit Bus) API.