From ec715dfebe052015d841536448469cb1c26dc6f2 Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Fri, 9 Feb 2007 20:04:54 +0000 Subject: [PATCH] *** empty log message *** --- conf/airframes/minimag1.xml | 2 -- conf/airframes/twinjet1.xml | 6 +++- conf/autopilot/tiny.makefile | 19 ++++++++--- sw/airborne/pprz_transport.h | 4 +-- sw/airborne/test_adcs.c | 63 ++++++++++++++++++++++++++++++++++++ sw/airborne/xbee.h | 6 ++-- 6 files changed, 87 insertions(+), 13 deletions(-) create mode 100644 sw/airborne/test_adcs.c diff --git a/conf/airframes/minimag1.xml b/conf/airframes/minimag1.xml index 18c2ffa752..3e335c5851 100644 --- a/conf/airframes/minimag1.xml +++ b/conf/airframes/minimag1.xml @@ -263,7 +263,5 @@ sim.CFLAGS += -DCONFIG=\"tiny.h\" -DAGR_CLIMB -DH_CTL_RATE_LOOP -DLOITER_TRIM -D sim.srcs += traffic_info.c # sim.srcs += bomb.c - - diff --git a/conf/airframes/twinjet1.xml b/conf/airframes/twinjet1.xml index cb720abd57..1ab5cc8606 100644 --- a/conf/airframes/twinjet1.xml +++ b/conf/airframes/twinjet1.xml @@ -87,6 +87,7 @@ +
@@ -107,6 +109,7 @@
+
@@ -203,7 +207,7 @@
- + diff --git a/conf/autopilot/tiny.makefile b/conf/autopilot/tiny.makefile index dcdb9fa52b..13f493e319 100644 --- a/conf/autopilot/tiny.makefile +++ b/conf/autopilot/tiny.makefile @@ -10,10 +10,6 @@ ap.TARGETDIR = autopilot LPC21ISP_BAUD = 38400 LPC21ISP_XTAL = 12000 - - - - # a test program to setup actuators setup_actuators.ARCHDIR = $(ARCHI) setup_actuators.ARCH = arm7tdmi @@ -31,4 +27,17 @@ tunnel.TARGET = tunnel tunnel.TARGETDIR = tunnel tunnel.CFLAGS += -DFBW -DCONFIG=\"tiny.h\" -DLED -DTIME_LED=1 -tunnel.srcs += $(SRC_ARCH)/uart_tunnel.c \ No newline at end of file +tunnel.srcs += $(SRC_ARCH)/uart_tunnel.c + + +# A test program to monitor the ADC values +test_adcs.ARCHDIR = $(ARCHI) +test_adcs.ARCH = arm7tdmi +test_adcs.TARGET = test_adcs +test_adcs.TARGETDIR = test_adcs + +test_adcs.CFLAGS += -DCONFIG=\"tiny_0_99.h\" -DLED -DTIME_LED=1 -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3 -DUSE_ADC_4 -DUSE_ADC_5 -DUSE_ADC_6 -DUSE_ADC_7 +test_adcs.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=XBeeTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DXBEE_UART=Uart0 -DDATALINK=XBEE -DUART0_BAUD=B9600 +test_adcs.srcs += downlink.c $(SRC_ARCH)/uart_hw.c xbee.c + +test_adcs.srcs += sys_time.c $(SRC_ARCH)/adc_hw.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c pprz_transport.c test_adcs.c diff --git a/sw/airborne/pprz_transport.h b/sw/airborne/pprz_transport.h index b1a27e5e68..feafcab38e 100644 --- a/sw/airborne/pprz_transport.h +++ b/sw/airborne/pprz_transport.h @@ -93,8 +93,8 @@ extern uint8_t ck_a, ck_b; #define PprzTransportPutArray(_put, _n, _x) { \ uint8_t i; \ PprzTransportPutUint8(_n); \ - for(i = 0; i < _n; i++) { \ - _put(&_x[i]); \ + for(_i = 0; _i < _n; _i++) { \ + _put(&_x[_i]); \ } \ } diff --git a/sw/airborne/test_adcs.c b/sw/airborne/test_adcs.c new file mode 100644 index 0000000000..f031791011 --- /dev/null +++ b/sw/airborne/test_adcs.c @@ -0,0 +1,63 @@ +/* + * Basic program periodically sending the values of the 8 ADCs + */ + + +#include "interrupt_hw.h" +#include "std.h" +#include "init_hw.h" +#include "sys_time.h" +#include "adc.h" +#include "messages.h" +#include "led.h" +#include "uart.h" +#include "downlink.h" + + +#define NB_ADC 8 +#define ADC_NB_SAMPLES 16 + +static struct adc_buf buf_adc[NB_ADC]; + +int main (int argc, char** argv) { + hw_init(); + sys_time_init(); + led_init(); + adc_init(); + + adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES); + adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES); + adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES); + adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES); + adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES); + adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES); + adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES); + adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES); + +#if NB_ADC != 8 +#error "8 ADCs expected !" +#endif + +#ifdef USE_UART0 + Uart0Init(); +#endif +#ifdef USE_UART1 + Uart1Init(); +#endif + + int_enable(); + + while(1) { + if (sys_time_periodic()) { + LED_TOGGLE(1); + uint16_t values[NB_ADC]; + uint8_t i; + for(i = 0; i < NB_ADC; i++) + values[i] = buf_adc[i].sum / ADC_NB_SAMPLES; + + uint8_t id = 42; + DOWNLINK_SEND_ADC(&id, NB_ADC, values); + } + } + return 0; +} diff --git a/sw/airborne/xbee.h b/sw/airborne/xbee.h index 849dcd7f13..8d2454dd82 100644 --- a/sw/airborne/xbee.h +++ b/sw/airborne/xbee.h @@ -97,10 +97,10 @@ void xbee_init( void ); #define XBeeTransportPutNamedUint8(_name, _byte) XBeeTransportPutUint8(_byte) #define XBeeTransportPutArray(_put, _n, _x) { \ - uint8_t i; \ + uint8_t _i; \ XBeeTransportPutUint8(_n); \ - for(i = 0; i < _n; i++) { \ - _put(&_x[i]); \ + for(_i = 0; _i < _n; _i++) { \ + _put(&_x[_i]); \ } \ }