mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-02-06 02:52:42 +08:00
make i2c device configurable through parameter for ets modules
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
Airspeed ETS module (I2C)
|
||||
@param AIRSPEED_ETS_SCALE scale factor (default 1.8)
|
||||
@param AIRSPEED_ETS_OFFSET offset (default 0)
|
||||
@param AIRSPEED_ETS_I2C_DEV i2c device (default i2c0)
|
||||
-->
|
||||
|
||||
<module name="airspeed_ets" dir="sensors">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<!--
|
||||
Baro ETS module (I2C)
|
||||
@param BARO_ETS_I2C_DEV i2c device (default i2c0)
|
||||
-->
|
||||
|
||||
<module name="baro_ets" dir="sensors">
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<!--
|
||||
Baro SCP module (I2C)
|
||||
@param SCP_I2C_DEV i2c device (default i2c0)
|
||||
-->
|
||||
|
||||
<module name="baro_scp_i2c" dir="sensors">
|
||||
<header>
|
||||
<file name="baro_scp_i2c.h"/>
|
||||
|
||||
@@ -51,6 +51,10 @@
|
||||
#define AIRSPEED_ETS_OFFSET_NBSAMPLES_AVRG 60
|
||||
#define AIRSPEED_ETS_NBSAMPLES_AVRG 10
|
||||
|
||||
#ifndef AIRSPEED_ETS_I2C_DEV
|
||||
#define AIRSPEED_ETS_I2C_DEV i2c0
|
||||
#endif
|
||||
|
||||
// Global variables
|
||||
uint16_t airspeed_ets_raw;
|
||||
uint16_t airspeed_ets_offset;
|
||||
@@ -88,7 +92,7 @@ void airspeed_ets_init( void ) {
|
||||
void airspeed_ets_read_periodic( void ) {
|
||||
#ifndef SITL
|
||||
if (airspeed_ets_i2c_trans.status == I2CTransDone)
|
||||
I2CReceive(i2c0, airspeed_ets_i2c_trans, AIRSPEED_ETS_ADDR, 2);
|
||||
I2CReceive(AIRSPEED_ETS_I2C_DEV, airspeed_ets_i2c_trans, AIRSPEED_ETS_ADDR, 2);
|
||||
#else // SITL
|
||||
extern float sim_air_speed;
|
||||
EstimatorSetAirspeed(sim_air_speed);
|
||||
|
||||
@@ -54,6 +54,10 @@
|
||||
#define BARO_ETS_R 0.5
|
||||
#define BARO_ETS_SIGMA2 0.1
|
||||
|
||||
#ifndef BARO_ETS_I2C_DEV
|
||||
#define BARO_ETS_I2C_DEV i2c0
|
||||
#endif
|
||||
|
||||
// Global variables
|
||||
uint16_t baro_ets_adc;
|
||||
uint16_t baro_ets_offset;
|
||||
@@ -89,7 +93,7 @@ void baro_ets_read_periodic( void ) {
|
||||
// Initiate next read
|
||||
#ifndef SITL
|
||||
if (baro_ets_i2c_trans.status == I2CTransDone)
|
||||
I2CReceive(i2c0, baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
|
||||
I2CReceive(BARO_ETS_I2C_DEV, baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
|
||||
#else // SITL
|
||||
baro_ets_adc = 0;
|
||||
baro_ets_altitude = gps_alt / 100.0;
|
||||
|
||||
Reference in New Issue
Block a user