[baro] adapt baro_board module to the new interface

Some modules can be used directly, some needs some more changes or
adaptation
This commit is contained in:
Gautier Hattenberger
2012-08-22 15:46:38 +02:00
parent 70adb45cd7
commit a41ecf5116
10 changed files with 58 additions and 23 deletions
+3 -19
View File
@@ -2,30 +2,14 @@
<module name="baro_board" dir="sensors">
<doc>
<description>Temporary hack to use baro interface on fixedwing</description>
<description>Allow to use baro interface on fixedwing with external barometers</description>
</doc>
<header>
<file name="baro_board_module.h"/>
</header>
<init fun="baro_init()"/>
<periodic fun="baro_periodic()" freq="60."/>
<event fun="BaroEvent(baro_abs,baro_diff)"/>
<makefile target="ap">
<file name="baro_board.c" dir="boards/$(BOARD)"/>
<define name="USE_BARO_AS_ALTIMETER"/>
<raw>
ifeq ($(BOARD), navgo)
ap.CFLAGS += -DUSE_I2C1 -DUSE_ADS1114_1
ap.CFLAGS += -DADS1114_I2C_DEVICE=i2c1
ap.srcs += peripherals/ads1114.c
else ifeq ($(BOARD), umarim)
ap.CFLAGS += -DUSE_I2C1 -DUSE_ADS1114_1
ap.CFLAGS += -DADS1114_I2C_DEVICE=i2c1
ap.srcs += peripherals/ads1114.c
else ifeq ($(BOARD), lisa_l)
ap.CFLAGS += -DUSE_I2C2
endif
</raw>
<file name="baro_board_module.c"/>
<define name="USE_BAROMETER"/>
</makefile>
</module>
+7
View File
@@ -62,6 +62,13 @@
<message name="STATE_FILTER_STATUS" period="7."/>
<message name="DOWNLINK" period="5.7"/>
</mode>
<mode name="raw_sensors">
<message name="DL_VALUE" period="0.5"/>
<message name="ALIVE" period="2.1"/>
<message name="BARO_RAW" period="0.5"/>
<message name="IR_SENSORS" period="0.5"/>
<message name="IMU_GYRO_RAW" period="0.1"/>
</mode>
</process>
<process name="Fbw">
<mode name="default">
@@ -55,6 +55,8 @@ void baro_MS5534A_event_task( void );
void baro_MS5534A_event( void );
#define BaroMS5534AUpdate(_b) { if (baro_MS5534A_available) { _b = baro_MS5534A_pressure; baro_MS5534A_available = FALSE; } }
#endif // USE_BARO_MS5534A
#endif // BARO_MS5534A_H
+4 -2
View File
@@ -30,9 +30,9 @@
#define BARO_AMSYS_DT 0.05
// extern uint16_t baro_amsys_adc;
extern uint16_t baro_amsys_adc;
// extern float baro_amsys_offset;
// extern bool_t baro_amsys_valid;
extern bool_t baro_amsys_valid;
// extern bool_t baro_amsys_updated;
// extern bool_t baro_amsys_enabled;
extern float baro_amsys_altitude;
@@ -48,4 +48,6 @@ extern void baro_amsys_read_event( void );
#define BaroAmsysEvent() { if (baro_amsys_i2c_trans.status == I2CTransSuccess) baro_amsys_read_event(); }
#define BaroAmsysUpdate(_b) { if (baro_amsys_valid) { _b = baro_amsys_adc; baro_amsys_valid = FALSE; } }
#endif // BARO_AMSYS_H
+3
View File
@@ -74,6 +74,7 @@ float baro_bmp_sigma2;
// Global variables
uint8_t baro_bmp_status;
bool_t baro_bmp_valid;
uint32_t baro_bmp_pressure;
uint16_t baro_bmp_temperature;
int32_t baro_bmp_altitude, baro_bmp,baro_bmp_temp,baro_bmp_offset;
@@ -92,6 +93,7 @@ uint16_t baro_bmp_cnt;
void baro_bmp_init( void ) {
baro_bmp_status = BARO_BMP_UNINIT;
baro_bmp_valid = FALSE;
baro_bmp_r = BARO_BMP_R;
baro_bmp_sigma2 = BARO_BMP_SIGMA2;
baro_bmp_enabled = TRUE;
@@ -234,6 +236,7 @@ void baro_bmp_event( void ) {
if (baro_bmp_offset_init) {
baro_bmp_altitude = ground_alt + baro_bmp_temp;
// New value available
baro_bmp_valid = TRUE;
#if USE_BARO_BMP
#pragma message "USING BARO BMP"
EstimatorSetAlt(baro_bmp_altitude);
+3
View File
@@ -40,6 +40,7 @@ extern float baro_bmp_r;
extern float baro_bmp_sigma2;
extern uint8_t baro_bmp_status;
extern bool_t baro_bmp_valid;
extern uint32_t baro_bmp_pressure;
extern uint16_t baro_bmp_temperature;
extern int32_t baro_bmp_altitude;
@@ -50,4 +51,6 @@ void baro_bmp_init(void);
void baro_bmp_periodic(void);
void baro_bmp_event(void);
#define BaroBmpUpdate(_b) { if (baro_bmp_valid) { _b = baro_bmp_pressure; baro_bmp_valid = FALSE; } }
#endif
@@ -29,7 +29,35 @@
#include "subsystems/sensors/baro.h"
static inline void baro_abs(void) {}
static inline void baro_diff(void) {}
/** Absolute baro macro mapping.
* Select the baro module you want to use to feed the common baro interface
* in your airframe file when configuring baro_board module
* ex:
* for module baro_ets
* <define name="BARO_ABS_EVENT" value="BaroEtsUpdate"/>
*/
#ifndef BARO_ABS_EVENT
#define BARO_ABS_EVENT NoBaro
#endif
/** Differential baro macro mapping.
* TODO
*/
#ifndef BARO_DIFF_EVENT
#define BARO_DIFF_EVENT NoBaro
#endif
#define NoBaro(_b) {}
/** BaroEvent macro.
* Need to be maped to one the external baro running has a module
*/
#define BaroEvent(_b_abs_handler, _b_diff_handler) { \
BARO_ABS_EVENT(baro.absolute); \
BARO_DIFF_EVENT(baro.differential); \
_b_abs_handler(); \
_b_diff_handler(); \
}
#endif
+2
View File
@@ -60,4 +60,6 @@ extern void baro_ets_read_event( void );
#define BaroEtsEvent() { if (baro_ets_i2c_trans.status == I2CTransSuccess) baro_ets_read_event(); }
#define BaroEtsUpdate(_b) { if (baro_ets_valid) { _b = baro_ets_adc; baro_ets_valid = FALSE; } }
#endif // BARO_ETS_H
+2
View File
@@ -20,4 +20,6 @@ void baro_scp_init(void);
void baro_scp_periodic(void);
void baro_scp_event(void);
#define BaroScpUpdate(_b) { if (baro_scp_available) { _b = baro_scp_pressure; baro_scp_available = FALSE; } }
#endif
@@ -54,6 +54,8 @@ extern void pbn_read_event( void );
#define PbnEvent() { if (pbn_trans.status == I2CTransSuccess) pbn_read_event(); }
#define BaroPbnUpdate(_b) { if (data_valid) { _b = altitude_adc; data_valid = FALSE; } }
#define PERIODIC_SEND_PBN(_chan) DOWNLINK_SEND_PBN(DefaultChannel, DefaultDevice,&airspeed_adc,&altitude_adc,&pbn_airspeed,&pbn_altitude,&airspeed_offset,&altitude_offset);
#endif // PRESSURE_BOARD_NAVARRO_H