diff --git a/conf/airframes/ENAC/quadrotor/booz2_g1.xml b/conf/airframes/ENAC/quadrotor/booz2_g1.xml index b1405b3931..b8acf7af5e 100644 --- a/conf/airframes/ENAC/quadrotor/booz2_g1.xml +++ b/conf/airframes/ENAC/quadrotor/booz2_g1.xml @@ -4,7 +4,9 @@ - + diff --git a/conf/modules/sonar_maxbotix_booz.xml b/conf/modules/sonar_maxbotix_booz.xml index ce23345d65..e28a1aa754 100644 --- a/conf/modules/sonar_maxbotix_booz.xml +++ b/conf/modules/sonar_maxbotix_booz.xml @@ -1,16 +1,27 @@ + +
- + +
- - - - - + + + + + + + +
diff --git a/sw/airborne/arch/lpc21/mcu_periph/adc_arch.h b/sw/airborne/arch/lpc21/mcu_periph/adc_arch.h index 947003f64b..6e5fe748c9 100644 --- a/sw/airborne/arch/lpc21/mcu_periph/adc_arch.h +++ b/sw/airborne/arch/lpc21/mcu_periph/adc_arch.h @@ -25,6 +25,8 @@ #ifndef ADC_HW_H #define ADC_HW_H +#include BOARD_CONFIG + #define AdcBank0(x) (x) #define AdcBank1(x) (x+NB_ADC) diff --git a/sw/airborne/modules/sonar/sonar_maxbotix_booz.c b/sw/airborne/modules/sonar/sonar_maxbotix.c similarity index 81% rename from sw/airborne/modules/sonar/sonar_maxbotix_booz.c rename to sw/airborne/modules/sonar/sonar_maxbotix.c index fad7db7e8d..c339212cea 100644 --- a/sw/airborne/modules/sonar/sonar_maxbotix_booz.c +++ b/sw/airborne/modules/sonar/sonar_maxbotix.c @@ -1,5 +1,4 @@ /* - * $Id: demo_module.c 3079 2009-03-11 16:55:42Z gautier $ * * Copyright (C) 2010 Gautier Hattenberger * @@ -22,22 +21,25 @@ * */ -#include "sonar_maxbotix_booz.h" -#include "booz2_analog.h" +#include "modules/sonar/sonar_maxbotix.h" +#include "mcu_periph/adc.h" uint16_t sonar_meas; bool_t sonar_data_available; +static struct adc_buf sonar_adc; + void maxbotix_init(void) { sonar_meas = 0; sonar_data_available = FALSE; + + adc_buf_channel(ADC_CHANNEL_SONAR, &sonar_adc, DEFAULT_AV_NB_SAMPLE); } /** Read ADC value to update sonar measurement */ void maxbotix_read(void) { - booz2_analog_extra_adc_read(); - sonar_meas = booz2_adc_1; + sonar_meas = sonar_adc.sum / sonar_adc.av_nb_sample; sonar_data_available = TRUE; } diff --git a/sw/airborne/modules/sonar/sonar_maxbotix_booz.h b/sw/airborne/modules/sonar/sonar_maxbotix.h similarity index 84% rename from sw/airborne/modules/sonar/sonar_maxbotix_booz.h rename to sw/airborne/modules/sonar/sonar_maxbotix.h index 596a8e5a75..b692f0889a 100644 --- a/sw/airborne/modules/sonar/sonar_maxbotix_booz.h +++ b/sw/airborne/modules/sonar/sonar_maxbotix.h @@ -1,5 +1,4 @@ /* - * $Id: demo_module.h 3079 2009-03-11 16:55:42Z gautier $ * * Copyright (C) 2010 Gautier Hattenberger * @@ -22,9 +21,9 @@ * */ -/** \file sonar_maxbotix_booz.h +/** \file sonar_maxbotix.h * - * simple driver to deal with one maxbotix sensor on booz AP + * simple driver to deal with one maxbotix sensor */ #ifndef SONAR_MAXBOTIX_BOOZ_H @@ -39,7 +38,7 @@ extern bool_t sonar_data_available; extern void maxbotix_init(void); extern void maxbotix_read(void); -#include "subsystems/ins.h" // needed because ins is not a module +//#include "subsystems/ins.h" // needed because ins is not a module #define SonarEvent(_handler) { \ if (sonar_data_available) { \ diff --git a/sw/airborne/subsystems/ins.c b/sw/airborne/subsystems/ins.c index cd098c51b5..0e8e560273 100644 --- a/sw/airborne/subsystems/ins.c +++ b/sw/airborne/subsystems/ins.c @@ -70,7 +70,7 @@ bool_t ins_hf_realign; int32_t ins_qfe; bool_t ins_baro_initialised; int32_t ins_baro_alt; -#ifdef BOOZ2_SONAR +#ifdef USE_SONAR bool_t ins_update_on_agl; int32_t ins_sonar_offset; #endif @@ -190,7 +190,7 @@ void ins_update_baro() { if (ins_vf_realign) { ins_vf_realign = FALSE; ins_qfe = baro.absolute; -#ifdef BOOZ2_SONAR +#ifdef USE_SONAR ins_sonar_offset = sonar_meas; #endif vff_realign(0.); @@ -267,13 +267,13 @@ void ins_update_gps(void) { } void ins_update_sonar() { -#if defined BOOZ2_SONAR && defined USE_VFF +#if defined USE_SONAR && defined USE_VFF static int32_t sonar_filtered = 0; sonar_filtered = (sonar_meas + 2*sonar_filtered) / 3; /* update baro_qfe assuming a flat ground */ - if (ins_update_on_agl && booz2_analog_baro_status == BOOZ2_ANALOG_BARO_RUNNING) { + if (ins_update_on_agl && baro.status == BS_RUNNING) { int32_t d_sonar = (((int32_t)sonar_filtered - ins_sonar_offset) * INS_SONAR_SENS_NUM) / INS_SONAR_SENS_DEN; - ins_qfe = (int32_t)booz2_analog_baro_value + (d_sonar * (INS_BARO_SENS_DEN))/INS_BARO_SENS_NUM; + ins_qfe = baro.absolute + (d_sonar * (INS_BARO_SENS_DEN))/INS_BARO_SENS_NUM; } #endif } diff --git a/sw/airborne/subsystems/ins.h b/sw/airborne/subsystems/ins.h index d2d374c121..6353bbb553 100644 --- a/sw/airborne/subsystems/ins.h +++ b/sw/airborne/subsystems/ins.h @@ -37,7 +37,7 @@ extern struct NedCoor_i ins_gps_speed_cm_s_ned; extern int32_t ins_baro_alt; extern int32_t ins_qfe; extern bool_t ins_baro_initialised; -#ifdef BOOZ2_SONAR +#ifdef USE_SONAR extern bool_t ins_update_on_agl; /* use sonar to update agl if available */ extern int32_t ins_sonar_offset; #endif