mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 07:53:43 +08:00
made the VIC address configurable for most peripherals - added a default which matches previously hard coded
values
This commit is contained in:
@@ -86,24 +86,31 @@
|
||||
|
||||
</section>
|
||||
|
||||
<section name="BOOZ_STABILIZATION_RATE" prefix="BOOZ_STABILIZATION_RATE_">
|
||||
<section name="STABILIZATION_RATE" prefix="BOOZ_STABILIZATION_RATE_">
|
||||
|
||||
<define name="SP_MAX_P" value="10000"/>
|
||||
<define name="SP_MAX_Q" value="10000"/>
|
||||
<define name="SP_MAX_R" value=" 5000"/>
|
||||
|
||||
<define name="GAIN_P" value="-250"/>
|
||||
<define name="GAIN_Q" value="-250"/>
|
||||
<define name="GAIN_R" value="-100"/>
|
||||
<define name="GAIN_P" value="-400"/>
|
||||
<define name="GAIN_Q" value="-400"/>
|
||||
<define name="GAIN_R" value="-300"/>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<section name="BOOZ_STABILIZATION_ATTITUDE" prefix="BOOZ_STABILIZATION_ATTITUDE_">
|
||||
<section name="STABILIZATION_ATTITUDE" prefix="BOOZ_STABILIZATION_ATTITUDE_">
|
||||
|
||||
<define name="SP_MAX_PHI" value="4000"/>
|
||||
<define name="SP_MAX_THETA" value="4000"/>
|
||||
<define name="SP_MAX_R" value=" 5000"/>
|
||||
<define name="SP_MAX_R" value="5500"/>
|
||||
<define name="DEADBAND_R" value="250"/>
|
||||
|
||||
<define name="PHI_THETA_PGAIN" value="-4000"/>
|
||||
<define name="PHI_THETA_DGAIN" value="-2000"/>
|
||||
|
||||
<define name="PSI_PGAIN" value="-2000"/>
|
||||
<define name="PSI_DGAIN" value="-1000"/>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
+74
-17
@@ -387,7 +387,12 @@
|
||||
<field name="p" type="float" unit="pascal"/>
|
||||
</message>
|
||||
|
||||
|
||||
<message name="IMU_DEBUG" ID="211">
|
||||
<field name="max1167_status" type="uint8"/>
|
||||
<field name="micromag_status" type="uint8"/>
|
||||
<field name="imu_v3_sensors_micromag_timeout" type="uint8"/>
|
||||
<field name="imu_v3_sensors_micromag_nb_reset" type="uint8"/>
|
||||
</message>
|
||||
|
||||
<message name="IMU_TURNTABLE" ID="220">
|
||||
<field name="omega" type="float" unit="rad/s"/>
|
||||
@@ -913,18 +918,21 @@
|
||||
</message>
|
||||
|
||||
<message name="BOOZ2_FILTER" ID="134">
|
||||
<field name="gp" type="int32"/>
|
||||
<field name="gq" type="int32"/>
|
||||
<field name="gr" type="int32"/>
|
||||
<field name="err_gx" type="int32"/>
|
||||
<field name="err_gy" type="int32"/>
|
||||
<field name="err_gz" type="int32"/>
|
||||
<field name="err_hx" type="int32"/>
|
||||
<field name="err_hy" type="int32"/>
|
||||
<field name="err_hz" type="int32"/>
|
||||
<field name="bp" type="int32"/>
|
||||
<field name="bq" type="int32"/>
|
||||
<field name="br" type="int32"/>
|
||||
<field name="phi" type="int32"/>
|
||||
<field name="theta" type="int32"/>
|
||||
<field name="psi" type="int32"/>
|
||||
<field name="measure_phi" type="int32"/>
|
||||
<field name="measure_theta" type="int32"/>
|
||||
<field name="measure_psi" type="int32"/>
|
||||
<field name="corrected_phi" type="int32"/>
|
||||
<field name="corrected_theta" type="int32"/>
|
||||
<field name="corrected_psi" type="int32"/>
|
||||
<field name="correction_phi" type="int32"/>
|
||||
<field name="correction_theta" type="int32"/>
|
||||
<field name="correction_psi" type="int32"/>
|
||||
<field name="bp" type="int32"/>
|
||||
<field name="bq" type="int32"/>
|
||||
<field name="br" type="int32"/>
|
||||
</message>
|
||||
|
||||
<message name="BOOZ2_FILTER2" ID="135">
|
||||
@@ -949,7 +957,7 @@
|
||||
<field name="delta_t" type="int32"/>
|
||||
</message>
|
||||
|
||||
<message name="BOOZ2_ALIGNER" ID="137">
|
||||
<message name="BOOZ2_FILTER_ALIGNER" ID="137">
|
||||
<field name="lp_gp" type="int32"/>
|
||||
<field name="lp_gq" type="int32"/>
|
||||
<field name="lp_gr" type="int32"/>
|
||||
@@ -971,11 +979,60 @@
|
||||
<field name="qz" type="int32"/>
|
||||
</message>
|
||||
|
||||
<message name="VOR" ID="140">
|
||||
<field name="qdr" type="int32"/>
|
||||
<field name="nb_adc_overrun" type="uint32"/>
|
||||
<message name="BOOZ2_FILTER_COR" ID="139">
|
||||
<field name="mphi" type="int32"/>
|
||||
<field name="mtheta" type="int32"/>
|
||||
<field name="mpsi" type="int32"/>
|
||||
<field name="qi" type="int32"/>
|
||||
<field name="qx" type="int32"/>
|
||||
<field name="qy" type="int32"/>
|
||||
<field name="qz" type="int32"/>
|
||||
</message>
|
||||
|
||||
|
||||
|
||||
<message name="BOOZ2_STAB_ATTITUDE" ID="140">
|
||||
<field name="sp_phi" type="int32"/>
|
||||
<field name="sp_theta" type="int32"/>
|
||||
<field name="sp_psi" type="int32"/>
|
||||
</message>
|
||||
|
||||
<message name="BOOZ2_STAB_ATTITUDE_REF" ID="141">
|
||||
<field name="pd" type="int32"/>
|
||||
<field name="qd" type="int32"/>
|
||||
<field name="rd" type="int32"/>
|
||||
<field name="p" type="int32"/>
|
||||
<field name="q" type="int32"/>
|
||||
<field name="r" type="int32"/>
|
||||
<field name="qi" type="int32"/>
|
||||
<field name="qx" type="int32"/>
|
||||
<field name="qy" type="int32"/>
|
||||
<field name="qz" type="int32"/>
|
||||
</message>
|
||||
|
||||
|
||||
<message name="BOOZ2_STAB_ATTITUDE_REF_EULER" ID="142">
|
||||
<field name="pd" type="int32"/>
|
||||
<field name="qd" type="int32"/>
|
||||
<field name="rd" type="int32"/>
|
||||
<field name="p" type="int32"/>
|
||||
<field name="q" type="int32"/>
|
||||
<field name="r" type="int32"/>
|
||||
<field name="phi" type="int32"/>
|
||||
<field name="theta" type="int32"/>
|
||||
<field name="psi" type="int32"/>
|
||||
</message>
|
||||
|
||||
|
||||
|
||||
<message name="BOOZ2_CMD" ID="143">
|
||||
<field name="cmd_a" type="int32"/>
|
||||
<field name="cmd_e" type="int32"/>
|
||||
<field name="cmd_r" type="int32"/>
|
||||
<field name="cmd_t" type="int32"/>
|
||||
</message>
|
||||
|
||||
|
||||
</class>
|
||||
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@
|
||||
|
||||
<!DOCTYPE radio SYSTEM "radio.dtd">
|
||||
<radio name="Futaba T6EXAP" data_min="900" data_max="2100" sync_min ="5000" sync_max ="15000">
|
||||
<channel ctl="1" function="ROLL" max="1074" neutral="1520" min="1942" average="0"/>
|
||||
<channel ctl="2" function="PITCH" min="1109" neutral="1521" max="1938" average="0"/>
|
||||
<channel ctl="1" function="ROLL" max="1074" neutral="1526" min="1942" average="0"/>
|
||||
<channel ctl="2" function="PITCH" min="1109" neutral="1520" max="1938" average="0"/>
|
||||
<channel ctl="3" function="THROTTLE" min="1933" neutral="1933" max="1107" average="0"/>
|
||||
<channel ctl="4" function="YAW" min="1937" neutral="1524" max="1103" average="0"/>
|
||||
<channel ctl="5" function="GAIN1" min="1100" neutral="1500" max="3000" average="1"/>
|
||||
<channel ctl="6" function="MODE" min="1900" neutral="1500" max="1100" average="1"/>
|
||||
<channel ctl="5" function="GAIN1" min="1100" neutral="1500" max="3000" average="1"/>
|
||||
<channel ctl="6" function="MODE" min="1900" neutral="1500" max="1100" average="1"/>
|
||||
</radio>
|
||||
|
||||
@@ -5,13 +5,21 @@
|
||||
|
||||
<process name="Main">
|
||||
<mode name="default">
|
||||
<message name="ALIVE" period="5."/>
|
||||
<message name="DL_VALUE" period="1."/>
|
||||
<message name="BOOZ_STATUS" period="1."/>
|
||||
<message name="BOOZ2_RATE_LOOP" period=".05"/>
|
||||
<message name="BOOZ2_ALIGNER" period=".1"/>
|
||||
<message name="BOOZ2_FILTER_Q" period=".05"/>
|
||||
<!-- <message name="BOOZ2_ATT_LOOP" period=".05"/> -->
|
||||
<message name="DL_VALUE" period="1.1"/>
|
||||
<message name="BOOZ_STATUS" period="1.2"/>
|
||||
<!-- <message name="BOOZ2_RATE_LOOP" period=".1"/> -->
|
||||
<message name="BOOZ2_STAB_ATTITUDE" period=".05"/>
|
||||
<message name="BOOZ2_CMD" period=".05"/>
|
||||
<message name="BOOZ2_STAB_ATTITUDE_REF" period=".05"/>
|
||||
<!-- <message name="BOOZ2_ALIGNER" period=".1"/> -->
|
||||
<message name="BOOZ2_FILTER" period=".5"/>
|
||||
<!-- <message name="BOOZ2_FILTER_Q" period=".1"/> -->
|
||||
<message name="BOOZ2_GYRO" period=".5"/>
|
||||
<message name="BOOZ2_ACCEL" period=".5"/>
|
||||
<message name="BOOZ2_MAG" period=".5"/>
|
||||
<!-- <message name="BOOZ2_FILTER_COR" period=".05"/> -->
|
||||
<!-- <message name="BOOZ2_ATT_LOOP" period=".05"/> -->
|
||||
<message name="ALIVE" period="2.1"/>
|
||||
</mode>
|
||||
|
||||
<mode name="debug">
|
||||
@@ -27,6 +35,7 @@
|
||||
<message name="IMU_ACCEL_RAW" period=".1"/>
|
||||
<message name="IMU_GYRO_RAW" period=".1"/>
|
||||
<message name="IMU_MAG_RAW" period=".1"/>
|
||||
<message name="IMU_DEBUG" period=".1"/>
|
||||
</mode>
|
||||
|
||||
<mode name="raw_sensors">
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
+29
-13
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef MICROMAG_HW_H
|
||||
#define MICROMAG_HW_H
|
||||
|
||||
#include <stdlib.h> // 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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -12,3 +12,7 @@ void micromag_init( void ) {
|
||||
micromag_values[i] = 0;
|
||||
micromag_status = MM_IDLE;
|
||||
}
|
||||
|
||||
void micromag_reset() {
|
||||
micromag_status = MM_IDLE;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user