Skip to content

Commit

Permalink
[modules] baro modules for real sensors only for ap target, not sim
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Oct 7, 2013
1 parent 49ab9ba commit bfe0072
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 42 deletions.
2 changes: 1 addition & 1 deletion conf/modules/baro_amsys.xml
Expand Up @@ -20,7 +20,7 @@
<periodic fun="baro_amsys_read_periodic()" freq="10."/>
<event fun="BaroAmsysEvent()"/>

<makefile>
<makefile target="ap">
<file name="baro_amsys.c"/>
</makefile>

Expand Down
2 changes: 1 addition & 1 deletion conf/modules/baro_ets.xml
Expand Up @@ -31,7 +31,7 @@
<periodic fun="baro_ets_read_periodic()" freq="10."/>
<event fun="BaroEtsEvent()"/>

<makefile>
<makefile target="ap">
<file name="baro_ets.c"/>
</makefile>

Expand Down
2 changes: 1 addition & 1 deletion conf/modules/baro_hca.xml
Expand Up @@ -13,7 +13,7 @@
<periodic fun="baro_hca_read_periodic()" freq="10."/>
<event fun="BaroHcaEvent()"/>

<makefile>
<makefile target="ap">
<file name="baro_hca.c"/>
</makefile>

Expand Down
20 changes: 0 additions & 20 deletions sw/airborne/modules/sensors/baro_amsys.c
Expand Up @@ -30,12 +30,6 @@
#include <math.h>
#include "generated/flight_plan.h" // for ground alt

#ifdef SITL
#include "subsystems/gps.h"
#include "subsystems/navigation/common_nav.h"
#include "math/pprz_isa.h"
#endif

//Messages
#include "mcu_periph/uart.h"
#include "messages.h"
Expand Down Expand Up @@ -128,27 +122,13 @@ void baro_amsys_init( void ) {

void baro_amsys_read_periodic( void ) {
// Initiate next read
#ifndef SITL
if (baro_amsys_i2c_trans.status == I2CTransDone){
#ifndef MEASURE_AMSYS_TEMPERATURE
i2c_receive(&BARO_AMSYS_I2C_DEV, &baro_amsys_i2c_trans, BARO_AMSYS_ADDR, 2);
#else
i2c_receive(&BARO_AMSYS_I2C_DEV, &baro_amsys_i2c_trans, BARO_AMSYS_ADDR, 4);
#endif
}
#else // SITL
/* fake an offset so sim works for under hmsl as well */
if (!baro_amsys_offset_init) {
baro_amsys_offset = BARO_AMSYS_OFFSET_MAX;
baro_amsys_offset_init = TRUE;
}
pBaroRaw = 0;
baro_amsys_altitude = gps.hmsl / 1000.0;
baro_amsys_p = pprz_isa_pressure_of_altitude(baro_amsys_altitude);
baro_amsys_adc = baro_amsys_p;
AbiSendMsgBARO_ABS(BARO_AMSYS_SENDER_ID, &baro_amsys_p);
baro_amsys_valid = TRUE;
#endif

#ifdef BARO_AMSYS_SYNC_SEND
DOWNLINK_SEND_AMSYS_BARO(DefaultChannel, DefaultDevice, &pBaroRaw, &baro_amsys_p, &baro_amsys_offset, &ref_alt_init, &baro_amsys_abs_altitude, &baro_amsys_altitude, &baro_amsys_temp);
Expand Down
4 changes: 0 additions & 4 deletions sw/airborne/modules/sensors/baro_bmp.h
Expand Up @@ -36,11 +36,7 @@
extern struct Bmp085 baro_bmp;

/// new measurement every 3rd baro_bmp_periodic
#ifndef SITL
#define BARO_BMP_DT (BARO_BMP_PERIODIC_PERIOD / 3)
#else
#define BARO_BMP_DT BARO_BMP_PERIODIC_PERIOID
#endif

extern bool_t baro_bmp_enabled;
extern float baro_bmp_r;
Expand Down
16 changes: 1 addition & 15 deletions sw/airborne/modules/sensors/baro_ets.c
Expand Up @@ -48,10 +48,6 @@

#include "subsystems/nav.h"

#ifdef SITL
#include "subsystems/gps.h"
#endif

#ifdef BARO_ETS_SYNC_SEND
#ifndef DOWNLINK_DEVICE
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
Expand Down Expand Up @@ -133,23 +129,13 @@ void baro_ets_init( void ) {

void baro_ets_read_periodic( void ) {
// Initiate next read
#ifndef SITL
if (!baro_ets_delay_done) {
if (SysTimeTimer(baro_ets_delay_time) < USEC_OF_SEC(BARO_ETS_START_DELAY)) return;
else baro_ets_delay_done = TRUE;
}
if (baro_ets_i2c_trans.status == I2CTransDone)
if (baro_ets_i2c_trans.status == I2CTransDone) {
i2c_receive(&BARO_ETS_I2C_DEV, &baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
#else // SITL
/* fake an offset so sim works as well */
if (!baro_ets_offset_init) {
baro_ets_offset = 12400;
baro_ets_offset_init = TRUE;
}
baro_ets_altitude = gps.hmsl / 1000.0;
baro_ets_adc = baro_ets_offset - ((baro_ets_altitude - ground_alt) / BARO_ETS_SCALE);
baro_ets_valid = TRUE;
#endif

#ifdef BARO_ETS_SYNC_SEND
DOWNLINK_SEND_BARO_ETS(DefaultChannel, DefaultDevice, &baro_ets_adc, &baro_ets_offset, &baro_ets_altitude);
Expand Down

0 comments on commit bfe0072

Please sign in to comment.