diff --git a/conf/airframes/booz2.xml b/conf/airframes/booz2.xml index 56dc0aca4d..08762a3013 100644 --- a/conf/airframes/booz2.xml +++ b/conf/airframes/booz2.xml @@ -86,24 +86,31 @@ -
+
- - - + + +
-
+
- + + + + + + + +
diff --git a/conf/autopilot/conf_booz2.makefile b/conf/autopilot/conf_booz2.makefile index 7142ccea79..252327694b 100644 --- a/conf/autopilot/conf_booz2.makefile +++ b/conf/autopilot/conf_booz2.makefile @@ -29,6 +29,7 @@ FLASH_MODE = IAP BOOZ=booz BOOZ_PRIV=booz_priv BOOZ_PRIV_ARCH=booz_priv/arm7 +BOOZ_PRIV_TEST=booz_priv/test BOOZ_ARCH=booz/arm7 # @@ -82,7 +83,7 @@ ap.ARCH = arm7tdmi ap.TARGET = ap ap.TARGETDIR = ap -#ap.CFLAGS += -DKILL_MOTORS +ap.CFLAGS += -DKILL_MOTORS ap.CFLAGS += -DCONFIG=\"booz2_board.h\" -I$(BOOZ_ARCH) -I$(BOOZ_PRIV) -I$(BOOZ_PRIV_ARCH) ap.srcs += $(BOOZ_PRIV)/booz2_main.c @@ -117,14 +118,16 @@ ap.CFLAGS += -DBOOZ2_ANALOG_BARO_LED=5 -DBOOZ2_ANALOG_BARO_PERIOD='SYS_TICS_OF_S ap.srcs += $(BOOZ_PRIV)/booz2_analog_baro.c ap.srcs += $(BOOZ_PRIV)/booz2_autopilot.c + ap.srcs += $(BOOZ_PRIV)/booz2_stabilization.c ap.srcs += $(BOOZ_PRIV)/booz2_stabilization_rate.c ap.srcs += $(BOOZ_PRIV)/booz2_stabilization_attitude.c ap.srcs += $(BOOZ_PRIV)/booz_supervision_int.c -ap.CFLAGS += -DALIGNER_LED=6 -ap.srcs += $(BOOZ_PRIV)/booz2_aligner.c -ap.srcs += $(BOOZ_PRIV)/booz2_att_cmpl_flt.c +ap.CFLAGS += -DFILTER_ALIGNER_LED=6 +ap.srcs += $(BOOZ_PRIV)/booz2_filter_aligner.c +ap.srcs += $(BOOZ_PRIV)/booz2_filter_attitude_cmpl_euler.c +ap.srcs += $(BOOZ_PRIV)/booz_trig_int.c # @@ -143,25 +146,53 @@ imu.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./500.))' imu.CFLAGS += -DLED imu.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c -imu.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 +imu.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -DUART1_VIC_SLOT=6 imu.srcs += $(SRC_ARCH)/uart_hw.c imu.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1 -imu.srcs += downlink.c pprz_transport.c $(BOOZ_PRIV)/imu_v3_telemetry.c +imu.srcs += downlink.c pprz_transport.c $(BOOZ_PRIV)/imu_v3_telemetry.c -imu.srcs += $(BOOZ_PRIV)/imu_v3_sensors.c $(BOOZ_PRIV_ARCH)/imu_v3_sensors_hw.c -imu.CFLAGS += -DADC -DUSE_AD0 -DUSE_AD0_1 -DUSE_AD0_2 -DUSE_AD0_3 -imu.srcs += $(SRC_ARCH)/adc_hw.c -imu.srcs += max1167.c $(SRC_ARCH)/max1167_hw.c -imu.srcs += micromag.c $(SRC_ARCH)/micromag_hw.c +imu.CFLAGS += -DIMU_SENSORS_SPI1_VIC_SLOT=7 +imu.srcs += $(BOOZ_PRIV)/imu_v3_sensors.c $(BOOZ_PRIV_ARCH)/imu_v3_sensors_hw.c +imu.CFLAGS += -DADC -DUSE_AD0 -DUSE_AD0_1 -DUSE_AD0_2 -DUSE_AD0_3 -DAD0_VIC_SLOT=2 +imu.srcs += $(SRC_ARCH)/adc_hw.c +imu.CFLAGS += -DMAX1167_EOC_VIC_SLOT=8 +imu.srcs += max1167.c $(SRC_ARCH)/max1167_hw.c +imu.CFLAGS += -DMICROMAG_DRDY_VIC_SLOT=9 +imu.srcs += micromag.c $(SRC_ARCH)/micromag_hw.c -imu.srcs += $(BOOZ_PRIV)/imu_v3_client_link.c $(BOOZ_PRIV_ARCH)/imu_v3_client_link_hw.c +imu.CFLAGS += -DIMU_CLIENT_LINK_SPI0_VIC_SLOT=3 +imu.srcs += $(BOOZ_PRIV)/imu_v3_client_link.c $(BOOZ_PRIV_ARCH)/imu_v3_client_link_hw.c +# +# IMU V3 MCU tests +# +# +# test micromag +# +imu_test_micromag.ARCHDIR = $(ARCHI) +imu_test_micromag.ARCH = arm7tdmi +imu_test_micromag.TARGET = imu_test_micromag +imu_test_micromag.TARGETDIR = imu_test_micromag +imu_test_micromag.CFLAGS += -DCONFIG=\"pprz_imu.h\" -I$(BOOZ) -I$(BOOZ_ARCH) -I$(BOOZ_PRIV) -I$(BOOZ_PRIV_ARCH) +imu_test_micromag.srcs += $(BOOZ_PRIV_TEST)/imu_v3_test_micromag.c +imu_test_micromag.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./500.))' +# -DTIME_LED=1 +imu_test_micromag.CFLAGS += -DLED +imu_test_micromag.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c +imu_test_micromag.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -DUART1_VIC_SLOT=6 +imu_test_micromag.srcs += $(SRC_ARCH)/uart_hw.c + +imu_test_micromag.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1 +imu_test_micromag.srcs += downlink.c pprz_transport.c + +imu_test_micromag.CFLAGS += -DMICROMAG_DRDY_VIC_SLOT=9 +imu_test_micromag.srcs += micromag.c $(SRC_ARCH)/micromag_hw.c diff --git a/conf/messages.xml b/conf/messages.xml index 10441b7fa6..6cf0b71a84 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -387,7 +387,12 @@ - + + + + + + @@ -913,18 +918,21 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -949,7 +957,7 @@ - + @@ -971,11 +979,60 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/radios/T6EXAP.xml b/conf/radios/T6EXAP.xml index 6550bfee21..adb04672d2 100644 --- a/conf/radios/T6EXAP.xml +++ b/conf/radios/T6EXAP.xml @@ -45,10 +45,10 @@ - - + + - - + + diff --git a/conf/telemetry/telemetry_booz2.xml b/conf/telemetry/telemetry_booz2.xml index 393556aba6..988dec956a 100644 --- a/conf/telemetry/telemetry_booz2.xml +++ b/conf/telemetry/telemetry_booz2.xml @@ -5,13 +5,21 @@ - - - - - - - + + + + + + + + + + + + + + + @@ -27,6 +35,7 @@ + diff --git a/sw/airborne/arm7/adc_hw.c b/sw/airborne/arm7/adc_hw.c index 3f353c4a24..64355ca7bc 100644 --- a/sw/airborne/arm7/adc_hw.c +++ b/sw/airborne/arm7/adc_hw.c @@ -1,9 +1,47 @@ +/* + * $Id$ + * + * Copyright (C) 2008 Pascal Brisset, Antoine Drouin + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + #include "adc.h" #include "LPC21xx.h" #include "armVIC.h" #include CONFIG + +#ifdef USE_AD0 +#ifndef AD0_VIC_SLOT +#define AD0_VIC_SLOT 2 +#endif +#endif + +#ifdef USE_AD1 +#ifndef AD1_VIC_SLOT +#define AD1_VIC_SLOT 4 +#endif +#endif + + /** First NB_ADC for bank 0, others for bank 2 */ static struct adc_buf* buffers[NB_ADC*2]; @@ -162,8 +200,8 @@ void adc_init( void ) { /* AD0 interrupt enabled */ VICIntEnable = VIC_BIT(VIC_AD0); /* AD0 interrupt as VIC2 */ - VICVectCntl2 = VIC_ENABLE | VIC_AD0; - VICVectAddr2 = (uint32_t)adcISR0; + _VIC_CNTL(AD0_VIC_SLOT) = VIC_ENABLE | VIC_AD0; + _VIC_ADDR(AD0_VIC_SLOT) = (uint32_t)adcISR0; #endif #ifdef USE_AD1 @@ -174,8 +212,8 @@ void adc_init( void ) { /* AD1 interrupt enabled */ VICIntEnable = VIC_BIT(VIC_AD1); /* AD1 interrupt as VIC2 */ - VICVectCntl4 = VIC_ENABLE | VIC_AD1; - VICVectAddr4 = (uint32_t)adcISR1; + _VIC_CNTL(AD1_VIC_SLOT) = VIC_ENABLE | VIC_AD1; + _VIC_ADDR(AD1_VIC_SLOT) = (uint32_t)adcISR1; #endif } diff --git a/sw/airborne/arm7/adc_hw.h b/sw/airborne/arm7/adc_hw.h index ede5818dd2..394246c0db 100644 --- a/sw/airborne/arm7/adc_hw.h +++ b/sw/airborne/arm7/adc_hw.h @@ -1,2 +1,31 @@ +/* + * $Id$ + * + * Copyright (C) 2008 Antoine Drouin + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef ADC_HW_H +#define ADC_HW_H + #define AdcBank0(x) (x) #define AdcBank1(x) (x+NB_ADC) + +#endif /* ADC_HW_H */ diff --git a/sw/airborne/arm7/armVIC.h b/sw/airborne/arm7/armVIC.h index 7d6dede0b2..5ae3f11766 100644 --- a/sw/airborne/arm7/armVIC.h +++ b/sw/airborne/arm7/armVIC.h @@ -14,6 +14,12 @@ #ifndef INC_ARM_VIC_H #define INC_ARM_VIC_H +#define __VIC_CNTL(idx) VICVectCntl##idx +#define __VIC_ADDR(idx) VICVectAddr##idx +#define _VIC_CNTL(idx) __VIC_CNTL(idx) +#define _VIC_ADDR(idx) __VIC_ADDR(idx) + + /****************************************************************************** * * MACRO Name: ISR_ENTRY() diff --git a/sw/airborne/arm7/booz_test_micromag.c b/sw/airborne/arm7/booz_test_micromag.c deleted file mode 100644 index 4701da790e..0000000000 --- a/sw/airborne/arm7/booz_test_micromag.c +++ /dev/null @@ -1,118 +0,0 @@ -#include "std.h" -#include "init_hw.h" -#include "interrupt_hw.h" -#include "sys_time.h" - -#include "uart.h" -#include "messages.h" -#include "downlink.h" - -#include "LPC21xx.h" -#include "6dof.h" -#include "micromag.h" -#include "spi_hw.h" - - -static inline void main_init(void); -static inline void main_periodic(void); -static inline void main_event(void); - -static void SPI1_ISR(void) __attribute__((naked)); -static void my_spi_init(void); - -int16_t mag_raw[AXIS_NB]; - -uint32_t t0, t1, diff; - -int main( void ) { - main_init(); - while (1) { - if (sys_time_periodic()) - main_periodic(); - main_event(); - } - return 0; -} - - -static inline void main_init(void) { - hw_init(); - sys_time_init(); - uart1_init_tx(); - - my_spi_init(); - micromag_init(); - - int_enable(); -} - - -static inline void main_periodic(void) { - // DOWNLINK_SEND_BOOT(&cpu_time_sec ); - switch (micromag_status) { - case MM_IDLE : - t0 = T0TC; - MmSendReq(); - break; - case MM_GOT_EOC: - MmReadRes(); - break; - } -} - - -static inline void main_event(void) { - if (micromag_status == MM_DATA_AVAILABLE) { - micromag_status = MM_IDLE; - mag_raw[AXIS_X] = micromag_values[0]; - mag_raw[AXIS_Y] = micromag_values[1]; - mag_raw[AXIS_Z] = micromag_values[2]; - DOWNLINK_SEND_IMU_MAG_RAW(&mag_raw[AXIS_X], &mag_raw[AXIS_Y], &mag_raw[AXIS_Z]); - t1 = T0TC; - diff = t1 - t0; - DOWNLINK_SEND_TIME(&diff); - } -} - - -/* SSPCR0 settings */ -#define SSP_DDS 0x07 << 0 /* data size : 8 bits */ -#define SSP_FRF 0x00 << 4 /* frame format : SPI */ -#define SSP_CPOL 0x00 << 6 /* clock polarity : data captured on first clock transition */ -#define SSP_CPHA 0x00 << 7 /* clock phase : SCK idles low */ -#define SSP_SCR 0x0F << 8 /* serial clock rate : divide by 16 */ - -/* SSPCR1 settings */ -#define SSP_LBM 0x00 << 0 /* loopback mode : disabled */ -#define SSP_SSE 0x00 << 1 /* SSP enable : disabled */ -#define SSP_MS 0x00 << 2 /* master slave mode : master */ -#define SSP_SOD 0x00 << 3 /* slave output disable : don't care when master */ - - -static void my_spi_init(void) { - - /* setup pins for SSP (SCK, MISO, MOSI) */ - PINSEL1 |= 2 << 2 | 2 << 4 | 2 << 6; - - /* setup SSP */ - SSPCR0 = SSP_DDS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR; - SSPCR1 = SSP_LBM | SSP_MS | SSP_SOD; - // SSPCPSR = 0x20; - SSPCPSR = 0x2; - - /* initialize interrupt vector */ - VICIntSelect &= ~VIC_BIT(VIC_SPI1); // SPI1 selected as IRQ - VICIntEnable = VIC_BIT(VIC_SPI1); // SPI1 interrupt enabled - VICVectCntl7 = VIC_ENABLE | VIC_SPI1; - VICVectAddr7 = (uint32_t)SPI1_ISR; // address of the ISR - -} - -static void SPI1_ISR(void) { - ISR_ENTRY(); - - MmOnSpiIt(); - - VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */ - ISR_EXIT(); -} diff --git a/sw/airborne/arm7/i2c_hw.c b/sw/airborne/arm7/i2c_hw.c index ede12c2ee0..cfb8cf49cd 100644 --- a/sw/airborne/arm7/i2c_hw.c +++ b/sw/airborne/arm7/i2c_hw.c @@ -1,3 +1,27 @@ +/* + * $Id$ + * + * Copyright (C) 2008 Pascal Brisset, Antoine Drouin + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + #include "i2c.h" @@ -17,15 +41,7 @@ #endif #ifndef I2C_VIC_SLOT -#define I2C_VIC_CNTL VICVectCntl9 -#define I2C_VIC_ADDR VICVectAddr9 -#else -#define __I2C_VIC_CNTL(idx) VICVectCntl##idx -#define __I2C_VIC_ADDR(idx) VICVectAddr##idx -#define _I2C_VIC_CNTL(idx) __I2C_VIC_CNTL(idx) -#define _I2C_VIC_ADDR(idx) __I2C_VIC_ADDR(idx) -#define I2C_VIC_CNTL _I2C_VIC_CNTL(I2C_VIC_SLOT) -#define I2C_VIC_ADDR _I2C_VIC_ADDR(I2C_VIC_SLOT) +#define I2C_VIC_SLOT 9 #endif void i2c0_ISR(void) __attribute__((naked)); @@ -46,10 +62,10 @@ void i2c_hw_init ( void ) { I2C0SCLH = I2C_SCLH; // initialize the interrupt vector - VICIntSelect &= ~VIC_BIT(VIC_I2C0); // I2C0 selected as IRQ - VICIntEnable = VIC_BIT(VIC_I2C0); // I2C0 interrupt enabled - I2C_VIC_CNTL = VIC_ENABLE | VIC_I2C0; - I2C_VIC_ADDR = (uint32_t)i2c0_ISR; // address of the ISR + VICIntSelect &= ~VIC_BIT(VIC_I2C0); // I2C0 selected as IRQ + VICIntEnable = VIC_BIT(VIC_I2C0); // I2C0 interrupt enabled + _VIC_CNTL(I2C_VIC_SLOT) = VIC_ENABLE | VIC_I2C0; + _VIC_ADDR(I2C_VIC_SLOT) = (uint32_t)i2c0_ISR; // address of the ISR } #define I2C_DATA_REG I2C0DAT diff --git a/sw/airborne/arm7/max1167_hw.c b/sw/airborne/arm7/max1167_hw.c index 8bd84a3b8c..b99641ded3 100644 --- a/sw/airborne/arm7/max1167_hw.c +++ b/sw/airborne/arm7/max1167_hw.c @@ -45,10 +45,10 @@ extern void max1167_hw_init( void ) { SetBit(EXTINT, MAX1167_EOC_EINT); /* initialize interrupt vector */ - VICIntSelect &= ~VIC_BIT( VIC_EINT0 ); // EXTINT0 selected as IRQ - VICIntEnable = VIC_BIT( VIC_EINT0 ); // EXTINT0 interrupt enabled - VICVectCntl8 = VIC_ENABLE | VIC_EINT0; - VICVectAddr8 = (uint32_t)EXTINT0_ISR; // address of the ISR + VICIntSelect &= ~VIC_BIT( VIC_EINT0 ); // EXTINT0 selected as IRQ + VICIntEnable = VIC_BIT( VIC_EINT0 ); // EXTINT0 interrupt enabled + _VIC_CNTL(MAX1167_EOC_VIC_SLOT) = VIC_ENABLE | VIC_EINT0; + _VIC_ADDR(MAX1167_EOC_VIC_SLOT) = (uint32_t)EXTINT0_ISR; // address of the ISR } @@ -81,7 +81,6 @@ void EXTINT0_ISR(void) { SpiSend(0); SpiClearRti(); SpiEnableRti(); - /* and it would be re enabled when we enter WAIT_EOC */ max1167_status = STA_MAX1167_READING_RES; SetBit(EXTINT, MAX1167_EOC_EINT); /* clear extint0 */ diff --git a/sw/airborne/arm7/micromag_hw.c b/sw/airborne/arm7/micromag_hw.c index a04539de2f..2e7c94ee54 100644 --- a/sw/airborne/arm7/micromag_hw.c +++ b/sw/airborne/arm7/micromag_hw.c @@ -37,10 +37,10 @@ void micromag_hw_init( void ) { SetBit(EXTINT,MM_DRDY_EINT); /* clear pending EINT */ /* initialize interrupt vector */ - VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT ); /* select EINT as IRQ source */ - VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT ); /* enable it */ - VICVectCntl9 = VIC_ENABLE | MM_DRDY_VIC_IT; - VICVectAddr9 = (uint32_t)EXTINT_ISR; // address of the ISR + VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT ); /* select EINT as IRQ source */ + VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT ); /* enable it */ + _VIC_CNTL(MICROMAG_DRDY_VIC_SLOT) = VIC_ENABLE | MM_DRDY_VIC_IT; + _VIC_ADDR(MICROMAG_DRDY_VIC_SLOT) = (uint32_t)EXTINT_ISR; // address of the ISR } @@ -51,8 +51,6 @@ void micromag_hw_init( void ) { void EXTINT_ISR(void) { ISR_ENTRY(); - // DOWNLINK_SEND_BOOZ_DEBUG_FOO(µmag_status); - micromag_status = MM_GOT_EOC; /* clear EINT */ SetBit(EXTINT,MM_DRDY_EINT); diff --git a/sw/airborne/arm7/micromag_hw.h b/sw/airborne/arm7/micromag_hw.h index c0f278189c..e28ab0033f 100644 --- a/sw/airborne/arm7/micromag_hw.h +++ b/sw/airborne/arm7/micromag_hw.h @@ -1,6 +1,8 @@ #ifndef MICROMAG_HW_H #define MICROMAG_HW_H +#include // for abs + #include "std.h" #include "LPC21xx.h" #include "interrupt_hw.h" @@ -30,19 +32,24 @@ extern volatile uint8_t micromag_cur_axe; } \ break; \ case MM_READING_RES: \ - micromag_values[micromag_cur_axe] = SSPDR << 8; \ - micromag_values[micromag_cur_axe] += SSPDR; \ - MmUnselect(); \ - SpiClearRti(); \ - SpiDisableRti(); \ - SpiDisable(); \ - micromag_cur_axe++; \ - if (micromag_cur_axe > 2) { \ - micromag_cur_axe = 0; \ - micromag_status = MM_DATA_AVAILABLE; \ + { \ + int16_t new_val; \ + new_val = SSPDR << 8; \ + new_val += SSPDR; \ + if (abs(new_val) < 2000) \ + micromag_values[micromag_cur_axe] = new_val; \ + MmUnselect(); \ + SpiClearRti(); \ + SpiDisableRti(); \ + SpiDisable(); \ + micromag_cur_axe++; \ + if (micromag_cur_axe > 2) { \ + micromag_cur_axe = 0; \ + micromag_status = MM_DATA_AVAILABLE; \ + } \ + else \ + micromag_status = MM_IDLE; \ } \ - else \ - micromag_status = MM_IDLE; \ break; \ } \ } @@ -72,4 +79,5 @@ extern volatile uint8_t micromag_cur_axe; } + #endif /* MICROMAG_HW_H */ diff --git a/sw/airborne/arm7/uart_hw.c b/sw/airborne/arm7/uart_hw.c index fdf8daa8a4..2aecd639d7 100644 --- a/sw/airborne/arm7/uart_hw.c +++ b/sw/airborne/arm7/uart_hw.c @@ -1,9 +1,37 @@ +/* + * $Id$ + * + * Copyright (C) 2008 Pascal Brisset, Antoine Drouin + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ #include "uart.h" #include "armVIC.h" #ifdef USE_UART0 +#ifndef UART0_VIC_SLOT +#define UART0_VIC_SLOT 5 +#endif + + void uart0_ISR(void) __attribute__((naked)); uint8_t uart0_rx_buffer[UART0_RX_BUFFER_SIZE]; @@ -39,10 +67,10 @@ void uart0_init_param( uint16_t baud, uint8_t mode, uint8_t fmode) { U0FCR = fmode; // initialize the interrupt vector - VICIntSelect &= ~VIC_BIT(VIC_UART0); // UART0 selected as IRQ - VICIntEnable = VIC_BIT(VIC_UART0); // UART0 interrupt enabled - VICVectCntl5 = VIC_ENABLE | VIC_UART0; - VICVectAddr5 = (uint32_t)uart0_ISR; // address of the ISR + VICIntSelect &= ~VIC_BIT(VIC_UART0); // UART0 selected as IRQ + VICIntEnable = VIC_BIT(VIC_UART0); // UART0 interrupt enabled + _VIC_CNTL(UART0_VIC_SLOT) = VIC_ENABLE | VIC_UART0; + _VIC_ADDR(UART0_VIC_SLOT) = (uint32_t)uart0_ISR; // address of the ISR // initialize the transmit data queue uart0_tx_extract_idx = 0; @@ -178,6 +206,10 @@ void uart0_ISR(void) #ifdef USE_UART1 +#ifndef UART1_VIC_SLOT +#define UART1_VIC_SLOT 6 +#endif + void uart1_ISR(void) __attribute__((naked)); uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE]; @@ -222,10 +254,10 @@ void uart1_init_param( uint16_t baud, uint8_t mode, uint8_t fmode) { U1FCR = fmode; // initialize the interrupt vector - VICIntSelect &= ~VIC_BIT(VIC_UART1); // UART1 selected as IRQ - VICIntEnable = VIC_BIT(VIC_UART1); // UART1 interrupt enabled - VICVectCntl6 = VIC_ENABLE | VIC_UART1; - VICVectAddr6 = (uint32_t)uart1_ISR; // address of the ISR + VICIntSelect &= ~VIC_BIT(VIC_UART1); // UART1 selected as IRQ + VICIntEnable = VIC_BIT(VIC_UART1); // UART1 interrupt enabled + _VIC_CNTL(UART1_VIC_SLOT) = VIC_ENABLE | VIC_UART1; + _VIC_ADDR(UART1_VIC_SLOT) = (uint32_t)uart1_ISR; // address of the ISR // initialize the transmit data queue uart1_tx_extract_idx = 0; diff --git a/sw/airborne/arm7/uart_hw.h b/sw/airborne/arm7/uart_hw.h index c1a74de7bb..fffed591d5 100644 --- a/sw/airborne/arm7/uart_hw.h +++ b/sw/airborne/arm7/uart_hw.h @@ -1,3 +1,27 @@ +/* + * $Id$ + * + * Copyright (C) 2008 Pascal Brisset, Antoine Drouin + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + #ifndef UART_HW_H #define UART_HW_H diff --git a/sw/airborne/micromag.c b/sw/airborne/micromag.c index 901daa5fd9..7fdd22c04b 100644 --- a/sw/airborne/micromag.c +++ b/sw/airborne/micromag.c @@ -12,3 +12,7 @@ void micromag_init( void ) { micromag_values[i] = 0; micromag_status = MM_IDLE; } + +void micromag_reset() { + micromag_status = MM_IDLE; +} diff --git a/sw/airborne/micromag.h b/sw/airborne/micromag.h index 25390c0df0..975c563559 100644 --- a/sw/airborne/micromag.h +++ b/sw/airborne/micromag.h @@ -8,6 +8,8 @@ extern void micromag_init( void ); extern void micromag_read( void ); +extern void micromag_reset( void); + #define MM_IDLE 0 #define MM_BUSY 1 #define MM_SENDING_REQ 2