diff --git a/conf/Makefile.stm32 b/conf/Makefile.stm32
index f23312200d..fb7fe7ea20 100644
--- a/conf/Makefile.stm32
+++ b/conf/Makefile.stm32
@@ -99,12 +99,13 @@ LDSCRIPT = $($(TARGET).LDSCRIPT)
endif
endif
-UNAME = $(shell uname -s)
+#UNAME = $(shell uname -s)
+MULTILIB = $(shell if $(CC) --print-multi-lib | grep thumb2 > /dev/null ; then echo "yes"; else echo "no"; fi)
CFLAGS = -I. -I./$(ARCH) $(INCLUDES) -D__thumb2__ -Wall -msoft-float -O$(OPT)
CFLAGS += -Wl,gc-sections
CFLAGS += -mcpu=$(MCU) -mthumb -ansi
-ifeq ("$(UNAME)","Darwin")
+ifeq ("$(MULTILIB)","yes")
CFLAGS += -mfix-cortex-m3-ldrd
endif
CFLAGS += -std=gnu99
@@ -126,12 +127,12 @@ CFLAGS += -Wswitch-default
CFLAGS += $($(TARGET).CFLAGS)
AFLAGS = -ahls -mapcs-32
-ifeq ("$(UNAME)","Darwin")
+ifeq ("$(MULTILIB)","yes")
AFLAGS += -mcpu=$(MCU) -mthumb
endif
AFLAGS += -x assembler-with-cpp -Wa,-adhlns=$(OBJDIR)/$(<:.S=.lst),--g$(DEBUG)
-ifeq ("$(UNAME)","Darwin")
+ifeq ("$(MULTILIB)","yes")
LDFLAGS = -T$(LDSCRIPT) -nostartfiles -O$(OPT) --gc-sections -mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
else
LDFLAGS = -D__thumb2__ -T$(LDSCRIPT) -nostartfiles -L$(GCC_LIB_DIR) -O$(OPT) --gc-sections
@@ -148,7 +149,7 @@ ODFLAGS = -S
# Default target.
-all: printcommands sizebefore build sizeafter
+all: printcommands printmultilib sizebefore build sizeafter
printcommands:
@echo "Using CC = $(CC)"
@@ -158,6 +159,18 @@ printcommands:
@echo "Using NM = $(NM)"
@echo "Using SIZE = $(SIZE)"
@echo "Using OOCD = $(OOCD)"
+ @echo "GCC version:"
+ @$(CC) --version
+ @echo "OOCD version:"
+ @$(OOCD) --version
+
+ifeq ("$(MULTILIB)","yes")
+printmultilib:
+ @echo "*** Using multilib ***"
+else
+printmultilib:
+ @echo "*** NOT using multilib ***"
+endif
build: elf bin hex
# lss sym
diff --git a/conf/airframes/esden/lisa_m_pwm.xml b/conf/airframes/esden/lisa_m_pwm.xml
new file mode 100644
index 0000000000..0545cff7a6
--- /dev/null
+++ b/conf/airframes/esden/lisa_m_pwm.xml
@@ -0,0 +1,244 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/esden/lisa_pwm_aspirin.xml b/conf/airframes/esden/lisa_pwm_aspirin.xml
index a4641f0209..6b56c34a60 100644
--- a/conf/airframes/esden/lisa_pwm_aspirin.xml
+++ b/conf/airframes/esden/lisa_pwm_aspirin.xml
@@ -210,6 +210,8 @@
+
+
diff --git a/conf/autopilot/lisa_m_test_progs.makefile b/conf/autopilot/lisa_m_test_progs.makefile
new file mode 100644
index 0000000000..bc4448dfaa
--- /dev/null
+++ b/conf/autopilot/lisa_m_test_progs.makefile
@@ -0,0 +1,723 @@
+# Hey Emacs, this is a -*- makefile -*-
+#
+# $Id$
+# Copyright (C) 2010 The Paparazzi Team
+#
+# 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.
+#
+#
+
+
+
+
+################################################################################
+#
+#
+# Test program for the Lisa/M board
+#
+#
+#
+#
+# every "firmware" makefile should have a description of available targets
+# possible options for each of them, susbsystems and associated params for each of them
+#
+#
+#
+#
+################################################################################
+
+ARCH=stm32
+SRC_ARCH=arch/$(ARCH)
+SRC_LISA=lisa
+SRC_LISA_ARCH=$(SRC_LISA)/arch/$(ARCH)
+#SRC_ROTORCRAFT=rotorcraft
+SRC_BOARD=boards/$(BOARD)
+
+SRC_FIRMWARE=firmwares/rotorcraft
+SRC_SUBSYSTEMS=subsystems
+SRC_AIRBORNE=.
+
+#
+# default configuration expected from the board files
+#
+SYS_TIME_LED = 1
+# MODEM_PORT = UART2
+# MODEM_BAUD = B57600
+
+#
+# test leds
+#
+test_led.ARCHDIR = $(ARCH)
+test_led.CFLAGS += -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+test_led.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+test_led.srcs += $(SRC_AIRBORNE)/mcu.c \
+ $(SRC_ARCH)/mcu_arch.c \
+ $(SRC_LISA)/test_led.c \
+ $(SRC_ARCH)/stm32_exceptions.c \
+ $(SRC_ARCH)/stm32_vector_table.c
+test_led.CFLAGS += -DUSE_LED
+test_led.srcs += $(SRC_ARCH)/led_hw.c
+
+#
+# test uart
+#
+test_uart_lisam.ARCHDIR = $(ARCH)
+test_uart_lisam.CFLAGS = -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+test_uart_lisam.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+test_uart_lisam.srcs = $(SRC_AIRBORNE)/mcu.c \
+ $(SRC_ARCH)/mcu_arch.c \
+ $(SRC_LISA)/test_uart_lisam.c \
+ $(SRC_ARCH)/stm32_exceptions.c \
+ $(SRC_ARCH)/stm32_vector_table.c
+test_uart_lisam.CFLAGS += -DUSE_LED -DUSE_UART
+test_uart_lisam.srcs += $(SRC_ARCH)/led_hw.c
+test_uart_lisam.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+test_uart_lisam.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+test_uart_lisam.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+test_uart_lisam.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600
+test_uart_lisam.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
+test_uart_lisam.CFLAGS += -DUSE_UART3 -DUART3_BAUD=B57600
+test_uart_lisam.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+
+
+##
+## test servos
+##
+#
+#SRC_BOOZ_ARCH=$(SRC_BOOZ)/arch/$(ARCH)
+#
+#test_servos.ARCHDIR = $(ARCH)
+#test_servos.CFLAGS = -I$(SRC_FIRMWARE)/actuators/arch/$(ARCH) -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#test_servos.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_servos.LDFLAGS += -lm
+#test_servos.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_LISA)/test_servos.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_servos.CFLAGS += -DUSE_LED
+#test_servos.srcs += $(SRC_ARCH)/led_hw.c
+#test_servos.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_servos.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_servos.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_servos.srcs += $(SRC_FIRMWARE)/actuators/actuators_pwm.c $(SRC_FIRMWARE)/actuators/arch/$(ARCH)/actuators_pwm_arch.c
+#
+#
+##
+## test_telemetry : Sends ALIVE telemetry messages
+##
+## configuration
+## MODEM_PORT :
+## MODEM_BAUD :
+##
+#test_telemetry.ARCHDIR = $(ARCH)
+#test_telemetry.CFLAGS += -I$(SRC_LISA) -I$(SRC_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_telemetry.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_telemetry.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# test/test_telemetry.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_telemetry.CFLAGS += -DUSE_LED
+#test_telemetry.srcs += $(SRC_ARCH)/led_hw.c
+#test_telemetry.CFLAGS += -DUSE_SYS_TIME
+#test_telemetry.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_telemetry.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_telemetry.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#test_telemetry.CFLAGS += -DUSE_$(MODEM_PORT)
+#test_telemetry.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_telemetry.srcs += downlink.c pprz_transport.c
+#test_telemetry.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_telemetry.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#
+##
+## test_baro : reads barometers and sends values over telemetry
+##
+## configuration
+## SYS_TIME_LED
+## MODEM_PORT
+## MODEM_BAUD
+##
+#test_baro.ARCHDIR = $(ARCH)
+#test_baro.CFLAGS = -I$(SRC_LISA) -I$(SRC_ARCH) -I$(SRC_BOARD) -DPERIPHERALS_AUTO_INIT
+#test_baro.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_baro.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_BOARD)/test_baro.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_baro.CFLAGS += -DUSE_LED
+#test_baro.srcs += $(SRC_ARCH)/led_hw.c
+#test_baro.CFLAGS += -DUSE_SYS_TIME
+#test_baro.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_baro.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_baro.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#test_baro.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_baro.srcs += downlink.c pprz_transport.c
+#test_baro.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_baro.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#test_baro.srcs += $(SRC_BOARD)/baro_board.c
+#test_baro.CFLAGS += -DUSE_I2C2
+#test_baro.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#
+#
+##
+## test_rc_spektrum : sends RADIO_CONTROL messages on telemetry
+##
+## configuration
+## SYS_TIME_LED
+## MODEM_PORT
+## MODEM_BAUD
+## RADIO_CONTROL_LED
+## RADIO_CONROL_SPEKTRUM_PRIMARY_PORT
+##
+#test_rc_spektrum.ARCHDIR = $(ARCH)
+#
+#test_rc_spektrum.CFLAGS += -I$(SRC_ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_rc_spektrum.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_rc_spektrum.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_BOOZ_TEST)/booz2_test_radio_control.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_rc_spektrum.CFLAGS += -DUSE_LED
+#test_rc_spektrum.srcs += $(SRC_ARCH)/led_hw.c
+#test_rc_spektrum.CFLAGS += -DUSE_SYS_TIME
+#test_rc_spektrum.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_rc_spektrum.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_rc_spektrum.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#test_rc_spektrum.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_rc_spektrum.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#test_rc_spektrum.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_rc_spektrum.srcs += downlink.c pprz_transport.c
+#test_rc_spektrum.CFLAGS += -DRADIO_CONTROL
+#ifdef RADIO_CONTROL_LED
+#test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED)
+#endif
+#test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_BIND_IMPL_FUNC=radio_control_spektrum_try_bind
+#test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/spektrum.h\"
+#test_rc_spektrum.CFLAGS += -DRADIO_CONTROL_SPEKTRUM_PRIMARY_PORT=$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)
+#test_rc_spektrum.CFLAGS += -DOVERRIDE_$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)_IRQ_HANDLER -DUSE_TIM6_IRQ
+#test_rc_spektrum.srcs += $(SRC_SUBSYSTEMS)/radio_control.c \
+# subsystems/radio_control/spektrum.c \
+# $(SRC_ARCH)/subsystems/radio_control/spektrum_arch.c
+#
+#
+##
+## test_rc_ppm
+##
+## configuration
+## SYS_TIME_LED
+## MODEM_PORT
+## MODEM_BAUD
+## RADIO_CONTROL_LED
+##
+#test_rc_ppm.ARCHDIR = $(ARCH)
+#
+#test_rc_ppm.CFLAGS += -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -I$(SRC_BOARD)
+#test_rc_ppm.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_rc_ppm.CFLAGS += -DPERIPHERALS_AUTO_INIT
+#test_rc_ppm.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_BOOZ)/test/booz2_test_radio_control.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_rc_ppm.CFLAGS += -DUSE_LED
+#test_rc_ppm.srcs += $(SRC_ARCH)/led_hw.c
+#test_rc_ppm.CFLAGS += -DUSE_SYS_TIME
+#test_rc_ppm.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_rc_ppm.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_rc_ppm.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#test_rc_ppm.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_rc_ppm.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#test_rc_ppm.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_rc_ppm.srcs += downlink.c pprz_transport.c
+#test_rc_ppm.CFLAGS += -DRADIO_CONTROL
+#test_rc_ppm.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED)
+#test_rc_ppm.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/ppm.h\"
+#test_rc_ppm.CFLAGS += -DRADIO_CONTROL_TYPE_PPM
+#test_rc_ppm.srcs += $(SRC_SUBSYSTEMS)/radio_control.c \
+# $(SRC_SUBSYSTEMS)/radio_control/ppm.c \
+# $(SRC_ARCH)/subsystems/radio_control/ppm_arch.c
+#test_rc_ppm.CFLAGS += -DUSE_TIM2_IRQ
+#
+##
+## test_adc
+##
+## configuration
+## SYS_TIME_LED
+## MODEM_PORT
+## MODEM_BAUD
+##
+#test_adc.ARCHDIR = $(ARCH)
+#test_adc.CFLAGS = -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#test_adc.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#
+#test_adc.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_LISA)/test_adc.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_adc.CFLAGS += -DUSE_LED
+#test_adc.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_adc.CFLAGS += -DUSE_SYS_TIME
+#test_adc.CFLAGS +=-DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_adc.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_adc.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_adc.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_adc.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#test_adc.CFLAGS += -DDATALINK=PPRZ -DPPRZ_UART=$(MODEM_PORT)
+#
+#test_adc.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_adc.srcs += downlink.c pprz_transport.c
+#
+#test_adc.srcs += $(SRC_ARCH)/mcu_periph/adc_arch.c
+#test_adc.CFLAGS += -DUSE_AD1 -DUSE_AD1_1 -DUSE_AD1_2 -DUSE_AD1_3 -DUSE_AD1_4
+#test_adc.CFLAGS += -DUSE_ADC1_2_IRQ_HANDLER
+#
+##
+## test IMU b2
+##
+## configuration
+## SYS_TIME_LED
+## MODEM_PORT
+## MODEM_BAUD
+##
+#test_imu_b2.ARCHDIR = $(ARCH)
+#test_imu_b2.CFLAGS = -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_imu_b2.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_imu_b2.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_BOOZ_TEST)/booz_test_imu.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_imu_b2.CFLAGS += -DUSE_LED
+#test_imu_b2.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_imu_b2.CFLAGS += -DUSE_SYS_TIME
+#test_imu_b2.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_imu_b2.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_imu_b2.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_imu_b2.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_imu_b2.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_imu_b2.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
+#test_imu_b2.srcs += downlink.c pprz_transport.c
+#
+#test_imu_b2.srcs += math/pprz_trig_int.c
+#
+#test_imu_b2.CFLAGS += -DIMU_TYPE_H=\"subsystems/imu/imu_b2.h\"
+#test_imu_b2.CFLAGS += -DIMU_B2_MAG_TYPE=IMU_B2_MAG_MS2001 -DIMU_B2_VERSION_1_1
+#test_imu_b2.srcs += $(SRC_SUBSYSTEMS)/imu.c
+#test_imu_b2.CFLAGS += -DMAX_1168_DRDY_PORT=$(MAX_1168_DRDY_PORT)
+#test_imu_b2.CFLAGS += -DMAX_1168_DRDY_PORT_SOURCE=$(MAX_1168_DRDY_PORT_SOURCE)
+#test_imu_b2.CFLAGS += -DUSE_SPI2 -DUSE_DMA1_C4_IRQ -DUSE_EXTI2_IRQ -DUSE_SPI2_IRQ
+#test_imu_b2.srcs += $(SRC_SUBSYSTEMS)/imu/imu_b2.c $(SRC_ARCH)/subsystems/imu/imu_b2_arch.c
+#test_imu_b2.srcs += peripherals/max1168.c $(SRC_ARCH)/peripherals/max1168_arch.c
+#test_imu_b2.srcs += peripherals/ms2001.c $(SRC_ARCH)/peripherals/ms2001_arch.c
+#
+##
+## test IMU b2 1.2
+##
+## configuration
+## SYS_TIME_LED
+## MODEM_PORT
+## MODEM_BAUD
+##
+#test_imu_b2_2.ARCHDIR = $(ARCH)
+#test_imu_b2_2.CFLAGS = -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_imu_b2_2.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_imu_b2_2.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_BOOZ_TEST)/booz_test_imu.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_imu_b2_2.CFLAGS += -DUSE_LED
+#test_imu_b2_2.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_imu_b2_2.CFLAGS += -DUSE_SYS_TIME
+#test_imu_b2_2.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_imu_b2_2.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_imu_b2_2.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_imu_b2_2.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_imu_b2_2.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_imu_b2_2.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
+#test_imu_b2_2.srcs += downlink.c pprz_transport.c
+#
+#test_imu_b2_2.srcs += math/pprz_trig_int.c
+#
+#test_imu_b2_2.CFLAGS += -DIMU_TYPE_H=\"subsystems/imu/imu_b2.h\"
+#test_imu_b2_2.CFLAGS += -DIMU_B2_MAG_TYPE=IMU_B2_MAG_HMC5843 -DIMU_B2_VERSION_1_2
+#test_imu_b2_2.srcs += $(SRC_SUBSYSTEMS)/imu.c
+#test_imu_b2_2.CFLAGS += -DMAX_1168_DRDY_PORT=$(MAX_1168_DRDY_PORT)
+#test_imu_b2_2.CFLAGS += -DMAX_1168_DRDY_PORT_SOURCE=$(MAX_1168_DRDY_PORT_SOURCE)
+#test_imu_b2_2.CFLAGS += -DUSE_SPI2 -DUSE_DMA1_C4_IRQ -DUSE_EXTI2_IRQ -DUSE_SPI2_IRQ
+#test_imu_b2_2.srcs += $(SRC_SUBSYSTEMS)/imu/imu_b2.c $(SRC_ARCH)/subsystems/imu/imu_b2_arch.c
+#test_imu_b2_2.srcs += peripherals/max1168.c $(SRC_ARCH)/peripherals/max1168_arch.c
+#test_imu_b2_2.CFLAGS += -DUSE_I2C2
+#test_imu_b2_2.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#test_imu_b2_2.srcs += peripherals/hmc5843.c $(SRC_ARCH)/peripherals/hmc5843_arch.c
+#test_imu_b2_2.CFLAGS += -DUSE_EXTI9_5_IRQ # Mag Int on PB5
+#
+#
+##
+## test IMU aspirin
+##
+#test_imu_aspirin.ARCHDIR = $(ARCH)
+#test_imu_aspirin.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_imu_aspirin.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_imu_aspirin.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_BOOZ_TEST)/booz_test_imu.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_imu_aspirin.CFLAGS += -DUSE_LED
+#test_imu_aspirin.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_imu_aspirin.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
+#test_imu_aspirin.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_imu_aspirin.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_imu_aspirin.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
+#test_imu_aspirin.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_imu_aspirin.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
+#test_imu_aspirin.srcs += downlink.c pprz_transport.c
+#
+#test_imu_aspirin.srcs += math/pprz_trig_int.c
+#
+#test_imu_aspirin.CFLAGS += -DIMU_TYPE_H=\"imu/imu_aspirin.h\" -DIMU_OVERRIDE_CHANNELS
+#test_imu_aspirin.srcs += $(SRC_SUBSYSTEMS)/imu.c \
+# $(SRC_SUBSYSTEMS)/imu/imu_aspirin.c \
+# $(SRC_ARCH)/subsystems/imu/imu_aspirin_arch.c
+#test_imu_aspirin.srcs += peripherals/hmc5843.c $(SRC_ARCH)/peripherals/hmc5843_arch.c
+#
+#test_imu_aspirin.CFLAGS += -DUSE_I2C2
+#test_imu_aspirin.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#test_imu_aspirin.CFLAGS += -DUSE_EXTI15_10_IRQ # Gyro Int on PC14
+#test_imu_aspirin.CFLAGS += -DUSE_EXTI9_5_IRQ # Mag Int on PB5
+#test_imu_aspirin.CFLAGS += -DUSE_EXTI2_IRQ # Accel Int on PD2
+#test_imu_aspirin.CFLAGS += -DUSE_DMA1_C4_IRQ # SPI2 Rx DMA
+#
+#
+#
+#
+#
+#
+#
+#
+#
+##
+## test hmc5843
+##
+#test_hmc5843.ARCHDIR = $(ARCH)
+#test_hmc5843.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -Ibooz -DPERIPHERALS_AUTO_INIT
+#test_hmc5843.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_hmc5843.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# lisa/test/lisa_test_hmc5843.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_hmc5843.CFLAGS += -DUSE_LED
+#test_hmc5843.srcs += $(SRC_ARCH)/led_hw.c
+#test_hmc5843.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_hmc5843.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_hmc5843.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_hmc5843.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_hmc5843.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_hmc5843.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_hmc5843.srcs += downlink.c pprz_transport.c
+#
+#test_hmc5843.CFLAGS += -DUSE_I2C2
+#test_hmc5843.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#test_hmc5843.CFLAGS += -DIMU_OVERRIDE_CHANNELS
+#test_hmc5843.CFLAGS += -DUSE_EXTI9_5_IRQ # Mag Int on PB5
+#
+#
+##
+## test ITG3200
+##
+#test_itg3200.ARCHDIR = $(ARCH)
+#test_itg3200.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_itg3200.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_itg3200.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# lisa/test/lisa_test_itg3200.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_itg3200.CFLAGS += -DUSE_LED
+#test_itg3200.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_itg3200.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_itg3200.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_itg3200.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_itg3200.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_itg3200.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_itg3200.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_itg3200.srcs += downlink.c pprz_transport.c
+#
+#test_itg3200.CFLAGS += -DUSE_I2C2
+#test_itg3200.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#test_itg3200.CFLAGS += -DUSE_EXTI15_10_IRQ # Gyro Int on PC14
+#
+#
+##
+## test adxl345 with DMA
+##
+#test_adxl345.ARCHDIR = $(ARCH)
+#test_adxl345.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+#test_adxl345.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_adxl345.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# lisa/test/lisa_test_adxl345_dma.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_adxl345.CFLAGS += -DUSE_LED
+#test_adxl345.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_adxl345.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
+#test_adxl345.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+#test_adxl345.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_adxl345.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
+#test_adxl345.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_adxl345.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
+#test_adxl345.srcs += downlink.c pprz_transport.c
+#
+#test_adxl345.CFLAGS += -DUSE_EXTI2_IRQ # Accel Int on PD2
+#test_adxl345.CFLAGS += -DUSE_DMA1_C4_IRQ # SPI2 Rx DMA
+#
+#
+#
+##
+## simple test of mikrokopter motor controllers
+##
+#test_esc_mkk_simple.ARCHDIR = $(ARCH)
+#test_esc_mkk_simple.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#test_esc_mkk_simple.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_esc_mkk_simple.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# test/test_esc_mkk_simple.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_esc_mkk_simple.CFLAGS += -DUSE_LED
+#test_esc_mkk_simple.srcs += $(SRC_ARCH)/led_hw.c
+#test_esc_mkk_simple.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_esc_mkk_simple.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_esc_mkk_simple.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#test_esc_mkk_simple.CFLAGS += -DUSE_I2C2
+#test_esc_mkk_simple.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#test_esc_mkk_simple.CFLAGS += -DACTUATORS_MKK_DEV=i2c2
+#
+#
+##
+## simple test of asctec v1 motor controllers
+##
+#test_esc_asctecv1_simple.ARCHDIR = $(ARCH)
+#test_esc_asctecv1_simple.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#test_esc_asctecv1_simple.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_esc_asctecv1_simple.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# test/test_esc_asctecv1_simple.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_esc_asctecv1_simple.CFLAGS += -DUSE_LED
+#test_esc_asctecv1_simple.srcs += $(SRC_ARCH)/led_hw.c
+#test_esc_asctecv1_simple.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
+#test_esc_asctecv1_simple.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_esc_asctecv1_simple.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#test_esc_asctecv1_simple.CFLAGS += -DUSE_I2C1
+#test_esc_asctecv1_simple.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#
+#
+##
+## test actuators mkk
+##
+#test_actuators_mkk.ARCHDIR = $(ARCH)
+#test_actuators_mkk.CFLAGS = -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -DPERIPHERALS_AUTO_INIT
+#test_actuators_mkk.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_actuators_mkk.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# test/test_actuators.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_actuators_mkk.CFLAGS += -DUSE_LED
+#test_actuators_mkk.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_actuators_mkk.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
+#test_actuators_mkk.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_actuators_mkk.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_actuators_mkk.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
+#test_actuators_mkk.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_actuators_mkk.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
+#test_actuators_mkk.srcs += downlink.c pprz_transport.c
+#
+#test_actuators_mkk.srcs += $(SRC_BOOZ)/booz2_commands.c
+#test_actuators_mkk.srcs += $(SRC_FIRMWARE)/actuators/actuators_mkk.c
+#test_actuators_mkk.CFLAGS += -DACTUATORS_MKK_DEVICE=i2c1
+#test_actuators_mkk.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
+#test_actuators_mkk.CFLAGS += -DUSE_I2C1
+#test_actuators_mkk.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#
+##
+## test actuators asctecv1
+##
+#test_actuators_asctecv1.ARCHDIR = $(ARCH)
+#test_actuators_asctecv1.CFLAGS = -I$(SRC_LISA) -I$(ARCH) -I$(SRC_BOOZ) -DPERIPHERALS_AUTO_INIT
+#test_actuators_asctecv1.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_actuators_asctecv1.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# test/test_actuators.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#
+#test_actuators_asctecv1.CFLAGS += -DUSE_LED
+#test_actuators_asctecv1.srcs += $(SRC_ARCH)/led_hw.c
+#
+#test_actuators_asctecv1.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
+#test_actuators_asctecv1.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_actuators_asctecv1.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_actuators_asctecv1.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
+#test_actuators_asctecv1.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_actuators_asctecv1.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
+#test_actuators_asctecv1.srcs += downlink.c pprz_transport.c
+#
+#test_actuators_asctecv1.srcs += $(SRC_BOOZ)/booz2_commands.c
+#test_actuators_asctecv1.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
+#test_actuators_asctecv1.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
+#test_actuators_asctecv1.CFLAGS += -DUSE_I2C1
+#test_actuators_asctecv1.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+#
+#
+##
+## test bmp085
+##
+#test_bmp085.ARCHDIR = $(ARCH)
+#test_bmp085.CFLAGS = -I$(SRC_FIRMWARE) -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#test_bmp085.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_bmp085.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# lisa/test/lisa_test_bmp085.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_bmp085.CFLAGS += -DUSE_LED
+#test_bmp085.srcs += $(SRC_ARCH)/led_hw.c
+#test_bmp085.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_bmp085.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_bmp085.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_bmp085.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_bmp085.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_bmp085.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_bmp085.srcs += downlink.c pprz_transport.c
+#
+#test_bmp085.CFLAGS += -DUSE_I2C2
+#test_bmp085.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c
+##test_bmp085.CFLAGS += -DIMU_OVERRIDE_CHANNELS
+##test_bmp085.CFLAGS += -DUSE_EXTI9_5_IRQ # Mag Int on PB5
+#
+#
+#
+##
+## Test manual : a simple test with rc and servos - I want to fly lisa/M
+##
+#test_manual.ARCHDIR = $(ARCH)
+#test_manual.CFLAGS = -I$(SRC_FIRMWARE) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#test_manual.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#test_manual.srcs = $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# test/test_manual.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#test_manual.CFLAGS += -DUSE_LED
+#test_manual.srcs += $(SRC_ARCH)/led_hw.c
+#test_manual.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#test_manual.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#test_manual.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+#
+#test_manual.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+#test_manual.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
+#
+#test_manual.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=$(MODEM_PORT)
+#test_manual.srcs += downlink.c pprz_transport.c
+#
+#test_manual.srcs += $(SRC_BOOZ)/booz2_commands.c
+#
+#test_manual.CFLAGS += -I$(SRC_FIRMWARE)/actuators/arch/$(ARCH)
+##test_manual.srcs += $(SRC_FIRMWARE)/actuators/actuators_pwm.c
+#test_manual.srcs += $(SRC_FIRMWARE)/actuators/arch/$(ARCH)/actuators_pwm_arch.c
+#test_manual.srcs += $(SRC_FIRMWARE)/actuators/actuators_heli.c
+#
+#
+#test_manual.CFLAGS += -I$(SRC_BOOZ) -I$(SRC_BOOZ)/arch/$(ARCH)
+#test_manual.CFLAGS += -DRADIO_CONTROL
+#ifdef RADIO_CONTROL_LED
+#test_manual.CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED)
+#endif
+#test_manual.CFLAGS += -DRADIO_CONTROL_BIND_IMPL_FUNC=radio_control_spektrum_try_bind
+#test_manual.CFLAGS += -DRADIO_CONTROL_TYPE_H=\"subsystems/radio_control/spektrum.h\"
+#test_manual.CFLAGS += -DRADIO_CONTROL_SPEKTRUM_PRIMARY_PORT=$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)
+#test_manual.CFLAGS += -DOVERRIDE_$(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT)_IRQ_HANDLER -DUSE_TIM6_IRQ
+#test_manual.srcs += $(SRC_SUBSYSTEMS)/radio_control.c \
+# subsystems/radio_control/spektrum.c \
+# $(SRC_ARCH)/subsystems/radio_control/spektrum_arch.c
+#
+#
+#
+##
+## tunnel
+##
+#tunnel.ARCHDIR = $(ARCH)
+#tunnel.CFLAGS += -I$(SRC_LISA) -I$(ARCH) -DPERIPHERALS_AUTO_INIT
+#tunnel.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+#tunnel.srcs += $(SRC_AIRBORNE)/mcu.c \
+# $(SRC_ARCH)/mcu_arch.c \
+# $(SRC_LISA)/tunnel_hw.c \
+# $(SRC_ARCH)/stm32_exceptions.c \
+# $(SRC_ARCH)/stm32_vector_table.c
+#tunnel.CFLAGS += -DUSE_LED
+#tunnel.srcs += $(SRC_ARCH)/led_hw.c
+#tunnel.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+#tunnel.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+#tunnel.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
diff --git a/conf/autopilot/lisa_m_test_progs.xml b/conf/autopilot/lisa_m_test_progs.xml
new file mode 100644
index 0000000000..5a7712caed
--- /dev/null
+++ b/conf/autopilot/lisa_m_test_progs.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
diff --git a/conf/autopilot/subsystems/rotorcraft/ahrs_cmpl.makefile b/conf/autopilot/subsystems/rotorcraft/ahrs_cmpl.makefile
index 9171256a81..9482514737 100644
--- a/conf/autopilot/subsystems/rotorcraft/ahrs_cmpl.makefile
+++ b/conf/autopilot/subsystems/rotorcraft/ahrs_cmpl.makefile
@@ -2,7 +2,11 @@
# Fixed point complementary filter using euler angles for attitude estimation
#
+ifdef AHRS_ALIGNER_LED
ap.CFLAGS += -DUSE_AHRS_CMPL -DAHRS_ALIGNER_LED=$(AHRS_ALIGNER_LED) -DAHRS_FIXED_POINT
+else
+ap.CFLAGS += -DUSE_AHRS_CMPL -DAHRS_FIXED_POINT
+endif
ap.srcs += $(SRC_SUBSYSTEMS)/ahrs.c
ap.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_aligner.c
ap.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_int_cmpl_euler.c
diff --git a/conf/boards/lisa_m_1.0.makefile b/conf/boards/lisa_m_1.0.makefile
index 78de8610ed..0a05903f17 100644
--- a/conf/boards/lisa_m_1.0.makefile
+++ b/conf/boards/lisa_m_1.0.makefile
@@ -27,7 +27,7 @@ endif
#
#
-SYS_TIME_LED = 2
+SYS_TIME_LED = 1
RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT = UART3
RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT = UART5
diff --git a/conf/modules/ins_arduimu.xml b/conf/modules/ins_arduimu.xml
index a4bc6325b3..ecbd865263 100644
--- a/conf/modules/ins_arduimu.xml
+++ b/conf/modules/ins_arduimu.xml
@@ -11,8 +11,8 @@
-
+
+
+
diff --git a/sw/airborne/arch/lpc21/LPC2148-ROM-bl.ld b/sw/airborne/arch/lpc21/LPC2148-ROM-bl.ld
index 08391aed14..625af790cd 100644
--- a/sw/airborne/arch/lpc21/LPC2148-ROM-bl.ld
+++ b/sw/airborne/arch/lpc21/LPC2148-ROM-bl.ld
@@ -41,6 +41,18 @@ SECTIONS
} > ROM
*****/
+. = ALIGN (4);
+
+.ARM.exidx :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+
+ } >ROM
+
+
+
. = ALIGN(4);
/* .ctors .dtors are used for c++ constructors/destructors */
diff --git a/sw/airborne/arch/lpc21/mcu_periph/i2c_arch.c b/sw/airborne/arch/lpc21/mcu_periph/i2c_arch.c
index 378337c50b..f8f02fc83e 100644
--- a/sw/airborne/arch/lpc21/mcu_periph/i2c_arch.c
+++ b/sw/airborne/arch/lpc21/mcu_periph/i2c_arch.c
@@ -28,7 +28,6 @@
#include "interrupt_hw.h"
#include BOARD_CONFIG
-
///////////////////
// I2C Automaton //
///////////////////
@@ -56,22 +55,18 @@ __attribute__ ((always_inline)) static inline void I2cEndOfTransaction(struct i2
}
}
-__attribute__ ((always_inline)) static inline void I2cFinished(struct i2c_periph* p, struct i2c_transaction* t) {
+__attribute__ ((always_inline)) static inline void I2cSendStop(struct i2c_periph* p, struct i2c_transaction* t) {
+ ((i2cRegs_t *)(p->reg_addr))->conset = _BV(STO);
// transaction finished with success
t->status = I2CTransSuccess;
I2cEndOfTransaction(p);
}
-__attribute__ ((always_inline)) static inline void I2cSendStop(struct i2c_periph* p, struct i2c_transaction* t) {
- ((i2cRegs_t *)(p->reg_addr))->conset = _BV(STO);
- I2cFinished(p,t);
-}
-
__attribute__ ((always_inline)) static inline void I2cFail(struct i2c_periph* p, struct i2c_transaction* t) {
((i2cRegs_t *)(p->reg_addr))->conset = _BV(STO);
+ // transaction failed
t->status = I2CTransFailed;
- p->status = I2CFailed;
- // FIXME I2C should be reseted here
+ // FIXME I2C should be reseted here ?
I2cEndOfTransaction(p);
}
@@ -119,35 +114,7 @@ __attribute__ ((always_inline)) static inline void I2cAutomaton(int32_t state, s
}
else {
/* error , we should have got NACK */
- I2cSendStop(p,trans);
- }
- break;
- case I2C_MR_SLA_ACK: /* At least one char */
- /* Wait and reply with ACK or NACK */
- I2cReceive(p->reg_addr,p->idx_buf < trans->len_r - 1);
- break;
- case I2C_MR_SLA_NACK:
- case I2C_MT_SLA_NACK:
- I2cSendStart(p);
- break;
- case I2C_MT_SLA_ACK:
- case I2C_MT_DATA_ACK:
- if (p->idx_buf < trans->len_w) {
- I2cSendByte(p->reg_addr,trans->buf[p->idx_buf]);
- p->idx_buf++;
- } else {
- if (trans->type == I2CTransTxRx) {
- trans->type = I2CTransRx; /* FIXME should not change type */
- p->idx_buf = 0;
- trans->slave_addr |= 1;
- I2cSendStart(p);
- } else {
- if (trans->stop_after_transmit) {
- I2cSendStop(p,trans);
- } else {
- I2cFinished(p,trans);
- }
- }
+ I2cFail(p,trans);
}
break;
case I2C_MR_DATA_NACK:
@@ -156,9 +123,33 @@ __attribute__ ((always_inline)) static inline void I2cAutomaton(int32_t state, s
}
I2cSendStop(p,trans);
break;
+ case I2C_MR_SLA_ACK: /* At least one char */
+ /* Wait and reply with ACK or NACK */
+ I2cReceive(p->reg_addr,p->idx_buf < trans->len_r - 1);
+ break;
+ case I2C_MR_SLA_NACK:
+ case I2C_MT_SLA_NACK:
+ /* Slave is not responding, transaction is failed */
+ I2cFail(p,trans);
+ break;
+ case I2C_MT_SLA_ACK:
+ case I2C_MT_DATA_ACK:
+ if (p->idx_buf < trans->len_w) {
+ I2cSendByte(p->reg_addr,trans->buf[p->idx_buf]);
+ p->idx_buf++;
+ } else {
+ if (trans->type == I2CTransTxRx) {
+ //trans->type = I2CTransRx; /* FIXME should not change type */
+ p->idx_buf = 0;
+ trans->slave_addr |= 1;
+ I2cSendStart(p);
+ } else {
+ I2cSendStop(p,trans);
+ }
+ }
+ break;
default:
- I2cSendStop(p,trans);
- //I2cFail(p,trans);
+ I2cFail(p,trans);
/* FIXME log error */
break;
}
diff --git a/sw/airborne/arch/sim/modules/ins/ins_arduimu.c b/sw/airborne/arch/sim/modules/ins/ins_arduimu.c
new file mode 100644
index 0000000000..05d1f1c9c0
--- /dev/null
+++ b/sw/airborne/arch/sim/modules/ins/ins_arduimu.c
@@ -0,0 +1,49 @@
+/** ArduIMU simulation. OCaml binding.
+ * Sim provides IR sensor reading and airspeed
+ */
+
+
+#include
+#include "generated/airframe.h"
+
+#include
+
+#include "estimator.h"
+
+// Prevent undefined reference (from estimator.c)
+#include "subsystems/sensors/infrared.h"
+struct Infrared infrared;
+
+// Arduimu empty implementation
+#include "modules/ins/ins_arduimu.h"
+
+float ArduIMU_data[NB_DATA];
+
+float ins_roll_neutral;
+float ins_pitch_neutral;
+
+//mixer
+float pitch_of_throttle_gain;
+float throttle_slew;
+
+void ArduIMU_init( void ) {}
+void ArduIMU_periodic( void ) {}
+void ArduIMU_periodicGPS( void ) {}
+void IMU_Daten_verarbeiten( void ) {}
+
+// Updates from Ocaml sim
+float sim_air_speed;
+
+value set_ir_and_airspeed(
+ value roll __attribute__ ((unused)),
+ value front __attribute__ ((unused)),
+ value top __attribute__ ((unused)),
+ value air_speed
+ ) {
+ // Feed directly the estimator
+ estimator_phi = atan2(Int_val(roll), Int_val(top)) - ins_roll_neutral;
+ estimator_theta = atan2(Int_val(front), Int_val(top)) - ins_pitch_neutral;
+ sim_air_speed = Double_val(air_speed);
+ return Val_unit;
+}
+
diff --git a/sw/airborne/arch/sim/sim_ap.c b/sw/airborne/arch/sim/sim_ap.c
index 9a8d211881..f344d8f74f 100644
--- a/sw/airborne/arch/sim/sim_ap.c
+++ b/sw/airborne/arch/sim/sim_ap.c
@@ -117,3 +117,9 @@ value set_datalink_message(value s) {
dl_parse_msg();
return Val_unit;
}
+
+/** Required by electrical */
+void adc_buf_channel(void* a __attribute__ ((unused)),
+ void* b __attribute__ ((unused)),
+ void* c __attribute__ ((unused))) {
+}
diff --git a/sw/airborne/arch/sim/sim_ir.c b/sw/airborne/arch/sim/sim_ir.c
index 1ec7884faf..deb6a6b59d 100644
--- a/sw/airborne/arch/sim/sim_ir.c
+++ b/sw/airborne/arch/sim/sim_ir.c
@@ -16,23 +16,19 @@ float sim_air_speed;
void ir_gain_calib(void) {
}
-value set_ir(value roll __attribute__ ((unused)),
- value front __attribute__ ((unused)),
- value top __attribute__ ((unused)),
- value air_speed
- ) {
+value set_ir_and_airspeed(
+ value roll __attribute__ ((unused)),
+ value front __attribute__ ((unused)),
+ value top __attribute__ ((unused)),
+ value air_speed
+ ) {
// INFRARED_TELEMETRY : Stupid hack to use with modules
-#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
+//#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
infrared.roll = Int_val(roll);
infrared.pitch = Int_val(front);
infrared.top = Int_val(top);
-#endif
+//#endif
sim_air_speed = Double_val(air_speed);
return Val_unit;
}
-/** Required by infrared.c:ir_init() */
-void adc_buf_channel(void* a __attribute__ ((unused)),
- void* b __attribute__ ((unused)),
- void* c __attribute__ ((unused))) {
-}
diff --git a/sw/airborne/arch/stm32/led_hw.h b/sw/airborne/arch/stm32/led_hw.h
index 133e070dd7..397781939f 100644
--- a/sw/airborne/arch/stm32/led_hw.h
+++ b/sw/airborne/arch/stm32/led_hw.h
@@ -42,10 +42,12 @@
#define _LED_GPIO_CLK(i) i
#define _LED_GPIO(i) i
#define _LED_GPIO_PIN(i) i
+#define _LED_AFIO_REMAP(i) i
#define LED_GPIO_CLK(i) _LED_GPIO_CLK(LED_ ## i ## _GPIO_CLK)
#define LED_GPIO(i) _LED_GPIO(LED_ ## i ## _GPIO)
#define LED_GPIO_PIN(i) _LED_GPIO_PIN(LED_ ## i ## _GPIO_PIN)
+#define LED_AFIO_REMAP(i) _LED_AFIO_REMAP(LED_ ## i ## _AFIO_REMAP)
/* set pin as output */
#define LED_INIT(i) { \
@@ -55,10 +57,11 @@
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; \
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \
GPIO_Init(LED_GPIO(i), &GPIO_InitStructure); \
+ LED_AFIO_REMAP(i); \
}
-#define LED_ON(i) { LED_GPIO(i)->BRR = LED_GPIO_PIN(i);}
-#define LED_OFF(i) {LED_GPIO(i)->BSRR = LED_GPIO_PIN(i);}
+#define LED_ON(i) {LED_GPIO(i)->BSRR = LED_GPIO_PIN(i);}
+#define LED_OFF(i) { LED_GPIO(i)->BRR = LED_GPIO_PIN(i);}
#define LED_TOGGLE(i) { LED_GPIO(i)->ODR ^= LED_GPIO_PIN(i);}
#define LED_PERIODIC() {}
diff --git a/sw/airborne/arch/stm32/mcu_arch.c b/sw/airborne/arch/stm32/mcu_arch.c
index eb6760b1c6..3c8a01fd10 100644
--- a/sw/airborne/arch/stm32/mcu_arch.c
+++ b/sw/airborne/arch/stm32/mcu_arch.c
@@ -36,6 +36,7 @@
void mcu_arch_init(void) {
#ifdef HSE_TYPE_EXT_CLK
+#warning Using external clock
/* Setup the microcontroller system.
* Initialize the Embedded Flash Interface,
* initialize the PLL and update the SystemFrequency variable.
@@ -43,7 +44,7 @@ void mcu_arch_init(void) {
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE with external clock ( HSE_Bypass ) */
- RCC_HSEConfig( RCC_HSE_Bypass );
+ RCC_HSEConfig( STM32_RCC_MODE );
/* Wait till HSE is ready */
ErrorStatus HSEStartUpStatus = RCC_WaitForHSEStartUp();
if (HSEStartUpStatus != SUCCESS) {
@@ -62,7 +63,7 @@ void mcu_arch_init(void) {
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* PLLCLK = 8MHz * 9 = 72 MHz */
- RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
+ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, STM32_PLL_MULT);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
@@ -73,6 +74,7 @@ void mcu_arch_init(void) {
while(RCC_GetSYSCLKSource() != 0x08) {}
}
#else /* HSE_TYPE_EXT_CLK */
+#warning Using normal system clock setup
SystemInit();
#endif /* HSE_TYPE_EXT_CLK */
/* Set the Vector Table base location at 0x08000000 */
diff --git a/sw/airborne/arch/stm32/mcu_periph/can_arch.c b/sw/airborne/arch/stm32/mcu_periph/can_arch.c
index 2af91534c1..002e0968cf 100644
--- a/sw/airborne/arch/stm32/mcu_periph/can_arch.c
+++ b/sw/airborne/arch/stm32/mcu_periph/can_arch.c
@@ -25,6 +25,7 @@
#include
#include
+#include "mcu_periph/can_arch.h"
#include "mcu_periph/can.h"
#include
diff --git a/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c b/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c
index da000029e0..195970cc20 100644
--- a/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c
+++ b/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c
@@ -7,9 +7,418 @@
static void start_transaction(struct i2c_periph* p);
+static inline void end_of_transaction(struct i2c_periph *p);
+static inline void i2c_hard_reset(struct i2c_periph *p);
+static inline void i2c_reset_init(struct i2c_periph *p);
+
+#define I2C_BUSY 0x20
+
+#ifdef DEBUG_I2C
+#define SPURIOUS_INTERRUPT(_status, _event) { while(1); }
+#define OUT_OF_SYNC_STATE_MACHINE(_status, _event) { while(1); }
+#else
+#define SPURIOUS_INTERRUPT(_status, _event) {}
+#define OUT_OF_SYNC_STATE_MACHINE(_status, _event) {}
+#endif
+
+#ifdef USE_I2C1
+static I2C_InitTypeDef I2C1_InitStruct = {
+ .I2C_Mode = I2C_Mode_I2C,
+ .I2C_DutyCycle = I2C_DutyCycle_2,
+ .I2C_OwnAddress1 = 0x00,
+ .I2C_Ack = I2C_Ack_Enable,
+ .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
+ .I2C_ClockSpeed = 200000
+};
+#endif
+
+#ifdef USE_I2C2
+static I2C_InitTypeDef I2C2_InitStruct = {
+ .I2C_Mode = I2C_Mode_I2C,
+ .I2C_DutyCycle = I2C_DutyCycle_2,
+ .I2C_OwnAddress1 = 0x00,
+ .I2C_Ack = I2C_Ack_Enable,
+ .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
+ .I2C_ClockSpeed = 300000
+};
+#endif
+
+static inline void i2c_delay(void)
+{
+ for (__IO int j = 0; j < 50; j++);
+}
+
+static inline void i2c_apply_config(struct i2c_periph *p)
+{
+ I2C_Init(p->reg_addr, p->init_struct);
+}
+
+static inline void end_of_transaction(struct i2c_periph *p)
+{
+ p->trans_extract_idx++;
+ if (p->trans_extract_idx >= I2C_TRANSACTION_QUEUE_LEN)
+ p->trans_extract_idx = 0;
+ /* if we have no more transaction to process, stop here */
+ if (p->trans_extract_idx == p->trans_insert_idx)
+ p->status = I2CIdle;
+ /* if not, start next transaction */
+ else
+ start_transaction(p);
+}
+
+static inline void abort_and_reset(struct i2c_periph *p) {
+ struct i2c_transaction* trans = p->trans[p->trans_extract_idx];
+ trans->status = I2CTransFailed;
+ I2C_ITConfig(p->reg_addr, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR, DISABLE);
+ i2c_hard_reset(p);
+ I2C_ITConfig(p->reg_addr, I2C_IT_ERR, ENABLE);
+ end_of_transaction(p);
+}
+
+#ifdef USE_I2C2
+static inline void on_status_start_requested(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_addr_wr_sent(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_sending_byte(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_stop_requested(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_addr_rd_sent(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_reading_byte(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_reading_last_byte(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+static inline void on_status_restart_requested(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event);
+
+/*
+ * Start Requested
+ *
+ */
+static inline void on_status_start_requested(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ if (event & I2C_FLAG_SB) {
+ if(trans->type == I2CTransRx) {
+ I2C_Send7bitAddress(periph->reg_addr, trans->slave_addr, I2C_Direction_Receiver);
+ periph->status = I2CAddrRdSent;
+ }
+ else {
+ I2C_Send7bitAddress(periph->reg_addr, trans->slave_addr, I2C_Direction_Transmitter);
+ periph->status = I2CAddrWrSent;
+ }
+ }
+ else
+ SPURIOUS_INTERRUPT(I2CStartRequested, event);
+}
+
+/*
+ * Addr WR sent
+ *
+ */
+static inline void on_status_addr_wr_sent(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ if ((event & I2C_FLAG_ADDR) && (event & I2C_FLAG_TRA)) {
+ I2C_SendData(periph->reg_addr, trans->buf[0]);
+ if (trans->len_w > 1) {
+ I2C_SendData(periph->reg_addr, trans->buf[1]);
+ periph->idx_buf = 2;
+ I2C_ITConfig(periph->reg_addr, I2C_IT_BUF, ENABLE);
+ periph->status = I2CSendingByte;
+ }
+ else {
+ periph->idx_buf = 1;
+ if (trans->type == I2CTransTx) {
+ I2C_GenerateSTOP(periph->reg_addr, ENABLE);
+ periph->status = I2CStopRequested;
+ }
+ else {
+ I2C_GenerateSTART(periph->reg_addr, ENABLE);
+ periph->status = I2CRestartRequested;
+ }
+ }
+ }
+ else
+ SPURIOUS_INTERRUPT(I2CAddrWrSent, event);
+}
+
+/*
+ * Sending Byte
+ *
+ */
+static inline void on_status_sending_byte(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ I2C_TypeDef *regs = (I2C_TypeDef *) periph->reg_addr;
+ if (event & I2C_FLAG_TXE) {
+ if (periph->idx_buf < trans->len_w) {
+ I2C_SendData(periph->reg_addr, trans->buf[periph->idx_buf]);
+ periph->idx_buf++;
+ }
+ else {
+ I2C_ITConfig(periph->reg_addr, I2C_IT_BUF, DISABLE);
+ if (trans->type == I2CTransTx) {
+ I2C_GenerateSTOP(periph->reg_addr, ENABLE);
+ /* Make sure that the STOP bit is cleared by Hardware */
+ static __IO uint8_t counter = 0;
+ while ((regs->CR1 & 0x200) == 0x200) {
+ counter++;
+ if (counter > 100) break;
+ }
+ periph->status = I2CStopRequested;
+ }
+ else {
+ I2C_GenerateSTART(periph->reg_addr, ENABLE);
+ periph->status = I2CRestartRequested;
+ }
+ }
+ }
+ else
+ SPURIOUS_INTERRUPT(I2CSendingByte, event);
+}
+
+/*
+ * Stop Requested
+ *
+ */
+static inline void on_status_stop_requested(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ /* bummer.... */
+ if (event & I2C_FLAG_RXNE) {
+ uint8_t read_byte = I2C_ReceiveData(periph->reg_addr);
+ if (periph->idx_buf < trans->len_r) {
+ trans->buf[periph->idx_buf] = read_byte;
+ }
+ }
+ I2C_ITConfig(periph->reg_addr, I2C_IT_EVT|I2C_IT_BUF, DISABLE); // should only need to disable evt, buf already disabled
+ trans->status = I2CTransSuccess;
+ end_of_transaction(periph);
+}
+
+/*
+ * Addr RD sent
+ *
+ */
+static inline void on_status_addr_rd_sent(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ I2C_TypeDef *regs = (I2C_TypeDef *) periph->reg_addr;
+
+ if ((event & I2C_FLAG_ADDR) && !(event & I2C_FLAG_TRA)) {
+ periph->idx_buf = 0;
+ if(trans->len_r == 1) { // If we're going to read only one byte
+ I2C_AcknowledgeConfig(periph->reg_addr, DISABLE); // make sure it's gonna be nacked
+ I2C_GenerateSTOP(periph->reg_addr, ENABLE); // and followed by a stop
+ /* Make sure that the STOP bit is cleared by Hardware */
+ static __IO uint8_t counter = 0;
+ while ((regs->CR1 & 0x200) == 0x200) {
+ counter++;
+ if (counter > 100) break;
+ }
+ periph->status = I2CReadingLastByte; // and remember we did
+ }
+ else {
+ I2C_AcknowledgeConfig(periph->reg_addr, ENABLE); // if it's more than one byte, ack it
+ I2C_ITConfig(periph->reg_addr, I2C_IT_BUF, ENABLE);
+ periph->status = I2CReadingByte; // and remember we did
+ }
+ }
+ else
+ SPURIOUS_INTERRUPT(I2CAddrRdSent, event);
+}
-static inline void i2c2_hard_reset(void);
+/*
+ * Reading byte
+ *
+ */
+static inline void on_status_reading_byte(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ I2C_TypeDef *regs = (I2C_TypeDef *) periph->reg_addr;
+ if (event & I2C_FLAG_RXNE) {
+ uint8_t read_byte = I2C_ReceiveData(periph->reg_addr);
+ if (periph->idx_buf < trans->len_r) {
+ trans->buf[periph->idx_buf] = read_byte;
+ periph->idx_buf++;
+ if (periph->idx_buf >= trans->len_r-1) { // We're reading our last byte
+ I2C_AcknowledgeConfig(periph->reg_addr, DISABLE); // give them a nack once it's done
+ I2C_GenerateSTOP(periph->reg_addr, ENABLE); // and follow with a stop
+ /* Make sure that the STOP bit is cleared by Hardware */
+ static __IO uint8_t counter = 0;
+ while ((regs->CR1 & 0x200) == 0x200) {
+ counter++;
+ if (counter > 100) break;
+ }
+ periph->status = I2CStopRequested; // remember we already trigered the stop
+ }
+ } // else { something very wrong has happened }
+ }
+ else
+ SPURIOUS_INTERRUPT(I2CReadingByte, event);
+}
+
+/*
+ * Reading last byte
+ *
+ */
+static inline void on_status_reading_last_byte(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ if (event & I2C_FLAG_BTF) {
+ uint8_t read_byte = I2C_ReceiveData(periph->reg_addr);
+ trans->buf[periph->idx_buf] = read_byte;
+ I2C_GenerateSTOP(periph->reg_addr, ENABLE);
+ periph->status = I2CStopRequested;
+ }
+ else if (event & I2C_FLAG_RXNE) { // should really be BTF ?
+ uint8_t read_byte = I2C_ReceiveData(periph->reg_addr);
+ trans->buf[periph->idx_buf] = read_byte;
+ periph->status = I2CStopRequested;
+ }
+ else
+ SPURIOUS_INTERRUPT(I2CReadingLastByte, event);
+}
+
+/*
+ * Restart requested
+ *
+ */
+static inline void on_status_restart_requested(struct i2c_periph *periph, struct i2c_transaction* trans, uint32_t event) {
+ if (event & I2C_FLAG_SB) {
+ I2C_Send7bitAddress(periph->reg_addr, trans->slave_addr, I2C_Direction_Receiver);
+ periph->status = I2CAddrRdSent;
+ }
+}
+
+
+
+static inline void i2c_event(struct i2c_periph *p, uint32_t event)
+{
+ struct i2c_transaction* trans = p->trans[p->trans_extract_idx];
+ switch (p->status) {
+ case I2CStartRequested:
+ on_status_start_requested(p, trans, event);
+ break;
+ case I2CAddrWrSent:
+ on_status_addr_wr_sent(p, trans, event);
+ break;
+ case I2CSendingByte:
+ on_status_sending_byte(p, trans, event);
+ break;
+ case I2CStopRequested:
+ on_status_stop_requested(p, trans, event);
+ break;
+ case I2CAddrRdSent:
+ on_status_addr_rd_sent(p, trans, event);
+ break;
+ case I2CReadingByte:
+ on_status_reading_byte(p, trans, event);
+ break;
+ case I2CReadingLastByte:
+ on_status_reading_last_byte(p, trans, event);
+ break;
+ case I2CRestartRequested:
+ on_status_restart_requested(p, trans, event);
+ break;
+ default:
+ OUT_OF_SYNC_STATE_MACHINE(p->status, event);
+ break;
+ }
+}
+
+static inline void i2c_error(struct i2c_periph *p)
+{
+ p->errors->er_irq_cnt;
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_AF)) { /* Acknowledge failure */
+ p->errors->ack_fail_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_AF);
+ }
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_BERR)) { /* Misplaced Start or Stop condition */
+ p->errors->miss_start_stop_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_BERR);
+ }
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_ARLO)) { /* Arbitration lost */
+ p->errors->arb_lost_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_ARLO);
+ // I2C_AcknowledgeConfig(I2C2, DISABLE);
+ // uint8_t dummy __attribute__ ((unused)) = I2C_ReceiveData(I2C2);
+ // I2C_GenerateSTOP(I2C2, ENABLE);
+ }
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_OVR)) { /* Overrun/Underrun */
+ p->errors->over_under_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_OVR);
+ }
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_PECERR)) { /* PEC Error in reception */
+ p->errors->pec_recep_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_PECERR);
+ }
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_TIMEOUT)) { /* Timeout or Tlow error */
+ p->errors->timeout_tlow_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_TIMEOUT);
+ }
+ if (I2C_GetITStatus(p->reg_addr, I2C_IT_SMBALERT)) { /* SMBus alert */
+ p->errors->smbus_alert_cnt++;
+ I2C_ClearITPendingBit(p->reg_addr, I2C_IT_SMBALERT);
+ }
+
+ abort_and_reset(p);
+}
+
+
+static inline void i2c_hard_reset(struct i2c_periph *p)
+{
+ I2C_TypeDef *regs = (I2C_TypeDef *) p->reg_addr;
+
+ I2C_DeInit(p->reg_addr);
+
+ GPIO_InitTypeDef GPIO_InitStructure;
+ GPIO_InitStructure.GPIO_Pin = p->scl_pin | p->sda_pin;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
+ GPIO_SetBits(GPIOB, p->scl_pin | p->sda_pin);
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ while(GPIO_ReadInputDataBit(GPIOB, p->sda_pin) == Bit_RESET) {
+ // Raise SCL, wait until SCL is high (in case of clock stretching)
+ GPIO_SetBits(GPIOB, p->scl_pin);
+ while (GPIO_ReadInputDataBit(GPIOB, p->scl_pin) == Bit_RESET);
+ i2c_delay();
+
+ // Lower SCL, wait
+ GPIO_ResetBits(GPIOB, p->scl_pin);
+ i2c_delay();
+
+ // Raise SCL, wait
+ GPIO_SetBits(GPIOB, p->scl_pin);
+ i2c_delay();
+ }
+
+ // Generate a start condition followed by a stop condition
+ GPIO_SetBits(GPIOB, p->scl_pin);
+ i2c_delay();
+ GPIO_ResetBits(GPIOB, p->sda_pin);
+ i2c_delay();
+ GPIO_ResetBits(GPIOB, p->sda_pin);
+ i2c_delay();
+
+ // Raise both SCL and SDA and wait for SCL high (in case of clock stretching)
+ GPIO_SetBits(GPIOB, p->scl_pin | p->sda_pin);
+ while (GPIO_ReadInputDataBit(GPIOB, p->scl_pin) == Bit_RESET);
+
+ // Wait for SDA to be high
+ while (GPIO_ReadInputDataBit(GPIOB, p->sda_pin) != Bit_SET);
+
+ // SCL and SDA should be high at this point, bus should be free
+ // Return the GPIO pins to the alternate function
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ I2C_DeInit(p->reg_addr);
+
+ i2c_apply_config(p);
+
+ if (regs->SR2 & I2C_BUSY) {
+ // Reset the I2C block
+ I2C_SoftwareResetCmd(p->reg_addr, ENABLE);
+ I2C_SoftwareResetCmd(p->reg_addr, DISABLE);
+ }
+}
+
+static inline void i2c_reset_init(struct i2c_periph *p)
+{
+ // Reset bus and configure GPIO pins
+ i2c_hard_reset(p);
+
+ // enable peripheral
+ I2C_Cmd(p->reg_addr, ENABLE);
+
+ // enable error interrupts
+ I2C_ITConfig(p->reg_addr, I2C_IT_ERR, ENABLE);
+}
+#endif
#ifdef USE_I2C1
@@ -17,29 +426,6 @@ struct i2c_errors i2c1_errors;
#include "my_debug_servo.h"
-#define I2C1_APPLY_CONFIG() { \
- I2C_InitTypeDef I2C_InitStructure; \
- I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; \
- I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; \
- I2C_InitStructure.I2C_OwnAddress1 = 0x00; \
- I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; \
- I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; \
- I2C_InitStructure.I2C_ClockSpeed = 200000; \
- I2C_Init(I2C1, &I2C_InitStructure); \
- }
-
-#define I2C1_END_OF_TRANSACTION() { \
- i2c1.trans_extract_idx++; \
- if (i2c1.trans_extract_idx>=I2C_TRANSACTION_QUEUE_LEN) \
- i2c1.trans_extract_idx = 0; \
- /* if we have no more transaction to process, stop here */ \
- if (i2c1.trans_extract_idx == i2c1.trans_insert_idx) \
- i2c1.status = I2CIdle; \
- /* if not, start next transaction */ \
- else \
- start_transaction(&i2c1); \
- }
-
#define I2C1_ABORT_AND_RESET() { \
struct i2c_transaction* trans2 = i2c1.trans[i2c1.trans_extract_idx]; \
trans2->status = I2CTransFailed; \
@@ -47,9 +433,9 @@ struct i2c_errors i2c1_errors;
I2C_Cmd(I2C1, DISABLE); \
I2C_DeInit(I2C1); \
I2C_Cmd(I2C1, ENABLE); \
- I2C1_APPLY_CONFIG(); \
+ i2c_apply_config(&i2c1); \
I2C_ITConfig(I2C1, I2C_IT_ERR, ENABLE); \
- I2C1_END_OF_TRANSACTION(); \
+ end_of_transaction(&i2c1); \
}
//
@@ -65,6 +451,10 @@ struct i2c_errors i2c1_errors;
void i2c1_hw_init(void) {
i2c1.reg_addr = I2C1;
+ i2c1.init_struct = &I2C1_InitStruct;
+ i2c1.scl_pin = GPIO_Pin_6;
+ i2c1.sda_pin = GPIO_Pin_7;
+ i2c1.errors = &i2c1_errors;
/* zeros error counter */
ZEROS_ERR_COUNTER(i2c1_errors);
@@ -107,7 +497,7 @@ void i2c1_hw_init(void) {
/* I2C Peripheral Enable */
I2C_Cmd(I2C1, ENABLE);
/* Apply I2C configuration after enabling it */
- I2C1_APPLY_CONFIG();
+ i2c_apply_config(&i2c1);
/* Enable I2C1 error interrupts */
I2C_ITConfig(I2C1, I2C_IT_ERR, ENABLE);
@@ -145,7 +535,6 @@ void i2c1_ev_irq_handler(void) {
/* Test on I2C1 EV8 and clear it */
case I2C_EVENT_MASTER_BYTE_TRANSMITTING: /* Without BTF, EV8 */
- // DEBUG_S5_TOGGLE();
if(i2c1.idx_buf < trans->len_w) {
I2C_SendData(I2C1, trans->buf[i2c1.idx_buf]);
i2c1.idx_buf++;
@@ -158,7 +547,6 @@ void i2c1_ev_irq_handler(void) {
break;
case I2C_EVENT_MASTER_BYTE_TRANSMITTED: /* With BTF EV8-2 */
- // DEBUG_S6_TOGGLE();
if(i2c1.idx_buf < trans->len_w) {
I2C_SendData(I2C1, trans->buf[i2c1.idx_buf]);
i2c1.idx_buf++;
@@ -166,7 +554,7 @@ void i2c1_ev_irq_handler(void) {
else {
trans->status = I2CTransSuccess;
I2C_ITConfig(I2C1, I2C_IT_EVT, DISABLE);
- I2C1_END_OF_TRANSACTION();
+ end_of_transaction(&i2c1);
}
// while (I2C_GetFlagStatus(I2C1, I2C_FLAG_MSL));
break;
@@ -175,7 +563,6 @@ void i2c1_ev_irq_handler(void) {
i2c1_errors.unexpected_event_cnt++;
i2c1_errors.last_unexpected_event = event;
// spurious Interrupt
- // DEBUG_S2_TOGGLE();
// I have already had I2C_EVENT_SLAVE_STOP_DETECTED ( 0x10 )
// let's clear that by restarting I2C
// if (event == I2C_EVENT_SLAVE_STOP_DETECTED) {
@@ -244,24 +631,13 @@ struct i2c_errors i2c2_errors;
#include "my_debug_servo.h"
-#define I2C2_APPLY_CONFIG() { \
- \
- I2C_InitTypeDef I2C_InitStructure= { \
- .I2C_Mode = I2C_Mode_I2C, \
- .I2C_DutyCycle = I2C_DutyCycle_2, \
- .I2C_OwnAddress1 = 0x00, \
- .I2C_Ack = I2C_Ack_Enable, \
- .I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit, \
- .I2C_ClockSpeed = 300000 \
- }; \
- I2C_Init(I2C2, &I2C_InitStructure); \
- \
- }
-
-
void i2c2_hw_init(void) {
i2c2.reg_addr = I2C2;
+ i2c2.init_struct = &I2C2_InitStruct;
+ i2c2.scl_pin = GPIO_Pin_10;
+ i2c2.sda_pin = GPIO_Pin_11;
+ i2c2.errors = &i2c2_errors;
/* zeros error counter */
ZEROS_ERR_COUNTER(i2c2_errors);
@@ -292,466 +668,21 @@ void i2c2_hw_init(void) {
/* Enable GPIOB clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
- /* Configure I2C2 pins: SCL and SDA -----------------------------------------*/
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
- i2c2_hard_reset();
-
- /* I2C Peripheral Enable ----------------------------------------------------*/
- I2C_Cmd(I2C2, ENABLE);
-
- /* Apply I2C configuration after enabling it */
- I2C2_APPLY_CONFIG();
-
-
- /* Enable I2C2 error interrupts ---------------------------------------------*/
- I2C_ITConfig(I2C2, I2C_IT_ERR, ENABLE);
-
- // DEBUG_SERVO1_INIT();
- // DEBUG_SERVO2_INIT();
+ // Reset and initialize I2C HW
+ i2c_reset_init(&i2c2);
}
-static inline void on_status_start_requested(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_addr_wr_sent(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_sending_byte(struct i2c_transaction* trans, uint32_t event);
-//static inline void on_status_sending_last_byte(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_stop_requested(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_addr_rd_sent(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_reading_byte(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_reading_last_byte(struct i2c_transaction* trans, uint32_t event);
-static inline void on_status_restart_requested(struct i2c_transaction* trans, uint32_t event);
-
-#ifdef DEBUG_I2C
-#define SPURIOUS_INTERRUPT(_status, _event) { while(1); }
-#define OUT_OF_SYNC_STATE_MACHINE(_status, _event) { while(1); }
-#else
-#define SPURIOUS_INTERRUPT(_status, _event) {}
-#define OUT_OF_SYNC_STATE_MACHINE(_status, _event) {}
-#endif
-
-
-#define I2C2_END_OF_TRANSACTION() { \
- i2c2.trans_extract_idx++; \
- if (i2c2.trans_extract_idx>=I2C_TRANSACTION_QUEUE_LEN) \
- i2c2.trans_extract_idx = 0; \
- /* if we have no more transaction to process, stop here */ \
- if (i2c2.trans_extract_idx == i2c2.trans_insert_idx) \
- i2c2.status = I2CIdle; \
- /* if not, start next transaction */ \
- else \
- start_transaction(&i2c2); \
- }
-
-#define I2C_BUSY 0x20
-static inline void i2c2_hard_reset(void)
-{
- I2C_DeInit(I2C2);
-
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
- GPIO_SetBits(GPIOB, GPIO_Pin_10 | GPIO_Pin_11);
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
- while(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) == Bit_RESET) {
- // Raise SCL, wait until SCL is high (in case of clock stretching)
- GPIO_SetBits(GPIOB, GPIO_Pin_10);
- while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_10) == Bit_RESET);
- for (__IO int j = 0; j < 50; j++);
-
- // Lower SCL, wait
- GPIO_ResetBits(GPIOB, GPIO_Pin_10);
- for (__IO int j = 0; j < 50; j++);
-
- // Raise SCL, wait
- GPIO_SetBits(GPIOB, GPIO_Pin_10);
- for (__IO int j = 0; j < 50; j++);
- }
-
- // Generate a start condition followed by a stop condition
- GPIO_SetBits(GPIOB, GPIO_Pin_10);
- for (__IO int j = 0; j < 50; j++);
- GPIO_ResetBits(GPIOB, GPIO_Pin_11);
- for (__IO int j = 0; j < 50; j++);
- GPIO_ResetBits(GPIOB, GPIO_Pin_11);
- for (__IO int j = 0; j < 50; j++);
-
- // Raise both SCL and SDA and wait for SCL high (in case of clock stretching)
- GPIO_SetBits(GPIOB, GPIO_Pin_10 | GPIO_Pin_11);
- while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_10) == Bit_RESET);
-
- // Wait for SDA to be high
- while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11) != Bit_SET);
-
- // SCL and SDA should be high at this point, bus should be free
- // Return the GPIO pins to the alternate function
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
- I2C_DeInit(I2C2);
-
- I2C2_APPLY_CONFIG();
-
- if (I2C2->SR2 & I2C_BUSY) {
- // Reset the I2C block
- I2C_SoftwareResetCmd(I2C2, ENABLE);
- I2C_SoftwareResetCmd(I2C2, DISABLE);
- }
-}
-
-#define I2C2_ABORT_AND_RESET() { \
- struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx]; \
- trans->status = I2CTransFailed; \
- I2C_ITConfig(I2C2, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR, DISABLE); \
- i2c2_hard_reset(); \
- I2C_ITConfig(I2C2, I2C_IT_ERR, ENABLE); \
- I2C2_END_OF_TRANSACTION(); \
- }
-
-
-
-/*
- * Start Requested
- *
- */
-static inline void on_status_start_requested(struct i2c_transaction* trans, uint32_t event) {
- if (event & I2C_FLAG_SB) {
- if(trans->type == I2CTransRx) {
- I2C_Send7bitAddress(I2C2, trans->slave_addr, I2C_Direction_Receiver);
- i2c2.status = I2CAddrRdSent;
- }
- else {
- I2C_Send7bitAddress(I2C2, trans->slave_addr, I2C_Direction_Transmitter);
- i2c2.status = I2CAddrWrSent;
- }
- }
- else
- SPURIOUS_INTERRUPT(I2CStartRequested, event);
-}
-
-/*
- * Addr WR sent
- *
- */
-static inline void on_status_addr_wr_sent(struct i2c_transaction* trans, uint32_t event) {
- if ((event & I2C_FLAG_ADDR) && (event & I2C_FLAG_TRA)) {
- I2C_SendData(I2C2, trans->buf[0]);
- if (trans->len_w > 1) {
- I2C_SendData(I2C2, trans->buf[1]);
- i2c2.idx_buf = 2;
- I2C_ITConfig(I2C2, I2C_IT_BUF, ENABLE);
- i2c2.status = I2CSendingByte;
- }
- else {
- i2c2.idx_buf = 1;
- if (trans->type == I2CTransTx) {
- I2C_GenerateSTOP(I2C2, ENABLE);
- i2c2.status = I2CStopRequested;
- }
- else {
- I2C_GenerateSTART(I2C2, ENABLE);
- i2c2.status = I2CRestartRequested;
- }
- }
- }
- else
- SPURIOUS_INTERRUPT(I2CAddrWrSent, event);
-}
-
-/*
- * Sending Byte
- *
- */
-static inline void on_status_sending_byte(struct i2c_transaction* trans, uint32_t event) {
- if (event & I2C_FLAG_TXE) {
- if (i2c2.idx_buf < trans->len_w) {
- I2C_SendData(I2C2, trans->buf[i2c2.idx_buf]);
- i2c2.idx_buf++;
- }
- else {
- I2C_ITConfig(I2C2, I2C_IT_BUF, DISABLE);
- if (trans->type == I2CTransTx) {
- I2C_GenerateSTOP(I2C2, ENABLE);
- /* Make sure that the STOP bit is cleared by Hardware */
- static __IO uint8_t counter = 0;
- while ((I2C2->CR1&0x200) == 0x200) {
- counter++;
- if (counter > 100) break;
- }
- i2c2.status = I2CStopRequested;
- }
- else {
- I2C_GenerateSTART(I2C2, ENABLE);
- i2c2.status = I2CRestartRequested;
- }
- }
- }
- else
- SPURIOUS_INTERRUPT(I2CSendingByte, event);
-}
-
-#if 0
-/*
- * Sending last byte
- *
- */
-static inline void on_status_sending_last_byte(struct i2c_transaction* trans, uint32_t event) {
- if (event & I2C_FLAG_TXE) { // should really be BTF as we're supposed to have disabled buf it already
- struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
- if (trans->type == I2CTransTx) {
- I2C_GenerateSTOP(I2C2, ENABLE);
- i2c2.status = I2CStopRequested;
- }
- else {
- I2C_GenerateSTART(I2C2, ENABLE);
- i2c2.status = I2CRestartRequested;
- }
- // I2C_ITConfig(I2C2, I2C_IT_BUF, DISABLE);
- }
- else
- SPURIOUS_INTERRUPT(I2CSendingLastByte, event);
-}
-#endif
-
-
-/*
- * Stop Requested
- *
- */
-static inline void on_status_stop_requested(struct i2c_transaction* trans, uint32_t event) {
- /* bummer.... */
- if (event & I2C_FLAG_RXNE) {
- uint8_t read_byte = I2C_ReceiveData(I2C2);
- if (i2c2.idx_buf < trans->len_r) {
- trans->buf[i2c2.idx_buf] = read_byte;
- }
- }
- I2C_ITConfig(I2C2, I2C_IT_EVT|I2C_IT_BUF, DISABLE); // should only need to disable evt, buf already disabled
- trans->status = I2CTransSuccess;
- I2C2_END_OF_TRANSACTION();
-}
-
-/*
- * Addr RD sent
- *
- */
-static inline void on_status_addr_rd_sent(struct i2c_transaction* trans, uint32_t event) {
- if ((event & I2C_FLAG_ADDR) && !(event & I2C_FLAG_TRA)) {
- i2c2.idx_buf = 0;
- if(trans->len_r == 1) { // If we're going to read only one byte
- I2C_AcknowledgeConfig(I2C2, DISABLE); // make sure it's gonna be nacked
- I2C_GenerateSTOP(I2C2, ENABLE); // and followed by a stop
- /* Make sure that the STOP bit is cleared by Hardware */
- static __IO uint8_t counter = 0;
- while ((I2C2->CR1&0x200) == 0x200) {
- counter++;
- if (counter > 100) break;
- }
- i2c2.status = I2CReadingLastByte; // and remember we did
- }
- else {
- I2C_AcknowledgeConfig(I2C2, ENABLE); // if it's more than one byte, ack it
- I2C_ITConfig(I2C2, I2C_IT_BUF, ENABLE);
- i2c2.status = I2CReadingByte; // and remember we did
- }
- }
- else
- SPURIOUS_INTERRUPT(I2CAddrRdSent, event);
-}
-
-
-/*
- * Reading byte
- *
- */
-static inline void on_status_reading_byte(struct i2c_transaction* trans, uint32_t event) {
- if (event & I2C_FLAG_RXNE) {
- uint8_t read_byte = I2C_ReceiveData(I2C2);
- if (i2c2.idx_buf < trans->len_r) {
- trans->buf[i2c2.idx_buf] = read_byte;
- i2c2.idx_buf++;
- if (i2c2.idx_buf >= trans->len_r-1) { // We're reading our last byte
- I2C_AcknowledgeConfig(I2C2, DISABLE); // give them a nack once it's done
- I2C_GenerateSTOP(I2C2, ENABLE); // and follow with a stop
- /* Make sure that the STOP bit is cleared by Hardware */
- static __IO uint8_t counter = 0;
- while ((I2C2->CR1&0x200) == 0x200) {
- counter++;
- if (counter > 100) break;
- }
- i2c2.status = I2CStopRequested; // remember we already trigered the stop
- }
- } // else { something very wrong has happened }
- }
- else
- SPURIOUS_INTERRUPT(I2CReadingByte, event);
-}
-
-/*
- * Reading last byte
- *
- */
-static inline void on_status_reading_last_byte(struct i2c_transaction* trans, uint32_t event) {
- if (event & I2C_FLAG_BTF) {
- uint8_t read_byte = I2C_ReceiveData(I2C2);
- trans->buf[i2c2.idx_buf] = read_byte;
- I2C_GenerateSTOP(I2C2, ENABLE);
- i2c2.status = I2CStopRequested;
- }
- else if (event & I2C_FLAG_RXNE) { // should really be BTF ?
- uint8_t read_byte = I2C_ReceiveData(I2C2);
- trans->buf[i2c2.idx_buf] = read_byte;
- i2c2.status = I2CStopRequested;
- }
- else
- SPURIOUS_INTERRUPT(I2CReadingLastByte, event);
-}
-
-/*
- * Restart requested
- *
- */
-static inline void on_status_restart_requested(struct i2c_transaction* trans, uint32_t event) {
- // DEBUG_S6_ON();
- if (event & I2C_FLAG_SB) {
- // DEBUG_S2_ON();
- I2C_Send7bitAddress(I2C2, trans->slave_addr, I2C_Direction_Receiver);
- i2c2.status = I2CAddrRdSent;
- // DEBUG_S2_OFF();
- }
-
- if (event & I2C_FLAG_BTF) {
- // DEBUG_S5_ON();
- // DEBUG_S5_OFF();
- }
-
- if (event & I2C_FLAG_TXE) {
- // DEBUG_S3_ON();
- // DEBUG_S3_OFF();
- }
-
- // if (event & I2C_FLAG_TXE) {
- // DEBUG_S2_ON();
- // DEBUG_S2_OFF();
- // }
-
-
- // else if (event & I2C_FLAG_TXE) {
- // i2c2.status = I2CReadingByte;
- // }
- // else
- // SPURIOUS_INTERRUPT(I2CRestartRequested, event);
- // DEBUG_S6_OFF();
-}
-
void i2c2_ev_irq_handler(void) {
- // DEBUG_S4_ON();
uint32_t event = I2C_GetLastEvent(I2C2);
- struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
- //#if 0
- // if (i2c2_errors.irq_cnt < 16) {
- // i2c2_errors.event_chain[i2c2_errors.irq_cnt] = event;
- // i2c2_errors.status_chain[i2c2_errors.irq_cnt] = i2c2.status;
- // i2c2_errors.irq_cnt++;
- // } else { while (1);}
- //#endif
- switch (i2c2.status) {
- case I2CStartRequested:
- on_status_start_requested(trans, event);
- break;
- case I2CAddrWrSent:
- on_status_addr_wr_sent(trans, event);
- break;
- case I2CSendingByte:
- // DEBUG_S4_ON();
- on_status_sending_byte(trans, event);
- // DEBUG_S4_OFF();
- break;
-#if 0
- case I2CSendingLastByte:
- // DEBUG_S5_ON();
- on_status_sending_last_byte(trans, event);
- // DEBUG_S5_OFF();
- break;
-#endif
- case I2CStopRequested:
- // DEBUG_S1_ON();
- on_status_stop_requested(trans, event);
- // DEBUG_S1_OFF();
- break;
- case I2CAddrRdSent:
- on_status_addr_rd_sent(trans, event);
- break;
- case I2CReadingByte:
- // DEBUG_S2_ON();
- on_status_reading_byte(trans, event);
- // DEBUG_S2_OFF();
- break;
- case I2CReadingLastByte:
- // DEBUG_S5_ON();
- on_status_reading_last_byte(trans, event);
- // DEBUG_S5_OFF();
- break;
- case I2CRestartRequested:
- // DEBUG_S5_ON();
- on_status_restart_requested(trans, event);
- // DEBUG_S5_OFF();
- break;
- default:
- OUT_OF_SYNC_STATE_MACHINE(i2c2.status, event);
- break;
- }
- // DEBUG_S4_OFF();
+ i2c_event(&i2c2, event);
}
-
void i2c2_er_irq_handler(void) {
- // DEBUG_S5_ON();
- i2c2_errors.er_irq_cnt;
- if (I2C_GetITStatus(I2C2, I2C_IT_AF)) { /* Acknowledge failure */
- i2c2_errors.ack_fail_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_AF);
- }
- if (I2C_GetITStatus(I2C2, I2C_IT_BERR)) { /* Misplaced Start or Stop condition */
- i2c2_errors.miss_start_stop_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_BERR);
- }
- if (I2C_GetITStatus(I2C2, I2C_IT_ARLO)) { /* Arbitration lost */
- i2c2_errors.arb_lost_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_ARLO);
- // I2C_AcknowledgeConfig(I2C2, DISABLE);
- // uint8_t dummy __attribute__ ((unused)) = I2C_ReceiveData(I2C2);
- // I2C_GenerateSTOP(I2C2, ENABLE);
- }
- if (I2C_GetITStatus(I2C2, I2C_IT_OVR)) { /* Overrun/Underrun */
- i2c2_errors.over_under_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_OVR);
- }
- if (I2C_GetITStatus(I2C2, I2C_IT_PECERR)) { /* PEC Error in reception */
- i2c2_errors.pec_recep_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_PECERR);
- }
- if (I2C_GetITStatus(I2C2, I2C_IT_TIMEOUT)) { /* Timeout or Tlow error */
- i2c2_errors.timeout_tlow_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_TIMEOUT);
- }
- if (I2C_GetITStatus(I2C2, I2C_IT_SMBALERT)) { /* SMBus alert */
- i2c2_errors.smbus_alert_cnt++;
- I2C_ClearITPendingBit(I2C2, I2C_IT_SMBALERT);
- }
-
- I2C2_ABORT_AND_RESET();
-
- // DEBUG_S5_OFF();
+ i2c_error(&i2c2);
}
diff --git a/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c b/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c
index 91b609b63d..583b90c089 100644
--- a/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c
+++ b/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c
@@ -85,7 +85,10 @@ typedef struct SpektrumStateStruct SpektrumStateType;
SpektrumStateType PrimarySpektrumState = {1,0,0,0,0,0,0,0,0};
#ifdef RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT
+#warning "Using secondary spektrum receiver."
SpektrumStateType SecondarySpektrumState = {1,0,0,0,0,0,0,0,0};
+#else
+#warning "NOT using secondary spektrum receiver."
#endif
int16_t SpektrumBuf[SPEKTRUM_CHANNELS_PER_FRAME*MAX_SPEKTRUM_FRAMES];
diff --git a/sw/airborne/boards/lisa_l_1.0.h b/sw/airborne/boards/lisa_l_1.0.h
index 8724588595..0a157060a0 100644
--- a/sw/airborne/boards/lisa_l_1.0.h
+++ b/sw/airborne/boards/lisa_l_1.0.h
@@ -1,11 +1,14 @@
#ifndef CONFIG_LISA_V1_0_H
#define CONFIG_LISA_V1_0_H
+#define BOARD_LISA_L
#define AHB_CLK 72000000
/* Lisa uses an external clock instead of a crystal */
#define HSE_TYPE_EXT_CLK
+#define STM32_RCC_MODE RCC_HSE_Bypass
+#define STM32_PLL_MULT RCC_PLLMul_9
/* Onboard LEDs */
#define LED_1_BANK
diff --git a/sw/airborne/boards/lisa_m/baro_board.c b/sw/airborne/boards/lisa_m/baro_board.c
new file mode 100644
index 0000000000..11829b5acf
--- /dev/null
+++ b/sw/airborne/boards/lisa_m/baro_board.c
@@ -0,0 +1,122 @@
+
+#include "subsystems/sensors/baro.h"
+
+struct Baro baro;
+struct BaroBoard baro_board;
+struct i2c_transaction baro_trans;
+
+
+static inline void baro_board_write_to_register(uint8_t baro_addr, uint8_t reg_addr, uint8_t val_msb, uint8_t val_lsb);
+static inline void baro_board_read_from_register(uint8_t baro_addr, uint8_t reg_addr);
+static inline void baro_board_set_current_register(uint8_t baro_addr, uint8_t reg_addr);
+static inline void baro_board_read_from_current_register(uint8_t baro_addr);
+
+// absolute
+#define BARO_ABS_ADDR 0x90
+// differential
+#define BARO_DIFF_ADDR 0x92
+
+void baro_init(void) {
+ baro.status = BS_UNINITIALIZED;
+ baro.absolute = 0;
+ baro.differential = 0;
+ baro_board.status = LBS_UNINITIALIZED;
+}
+
+
+void baro_periodic(void) {
+ // check i2c_done
+ if (!i2c_idle(&i2c2)) return;
+ switch (baro_board.status) {
+ case LBS_UNINITIALIZED:
+ baro_board_send_reset();
+ baro_board.status = LBS_RESETED;
+ break;
+ case LBS_RESETED:
+ baro_board_send_config_abs();
+ baro_board.status = LBS_INITIALIZING_ABS;
+ break;
+ case LBS_INITIALIZING_ABS:
+ baro_board_set_current_register(BARO_ABS_ADDR, 0x00);
+ baro_board.status = LBS_INITIALIZING_ABS_1;
+ break;
+ case LBS_INITIALIZING_ABS_1:
+ baro_board_send_config_diff();
+ baro_board.status = LBS_INITIALIZING_DIFF;
+ break;
+ case LBS_INITIALIZING_DIFF:
+ baro_board_set_current_register(BARO_DIFF_ADDR, 0x00);
+ baro_board.status = LBS_INITIALIZING_DIFF_1;
+ // baro_board.status = LBS_UNINITIALIZED;
+ break;
+ case LBS_INITIALIZING_DIFF_1:
+ baro.status = BS_RUNNING;
+ case LBS_READ_DIFF:
+ baro_board_read_from_current_register(BARO_ABS_ADDR);
+ baro_board.status = LBS_READING_ABS;
+ break;
+ case LBS_READ_ABS:
+ baro_board_read_from_current_register(BARO_DIFF_ADDR);
+ baro_board.status = LBS_READING_DIFF;
+ break;
+ default:
+ break;
+ }
+
+}
+
+
+void baro_board_send_config_abs(void) {
+ baro_board_write_to_register(BARO_ABS_ADDR, 0x01, 0x86, 0x83);
+}
+
+void baro_board_send_config_diff(void) {
+ baro_board_write_to_register(BARO_DIFF_ADDR, 0x01, 0x84, 0x83);
+}
+
+void baro_board_send_reset(void) {
+ baro_trans.type = I2CTransTx;
+ baro_trans.slave_addr = 0x00;
+ baro_trans.len_w = 1;
+ baro_trans.buf[0] = 0x06;
+ i2c_submit(&i2c2,&baro_trans);
+}
+
+static inline void baro_board_write_to_register(uint8_t baro_addr, uint8_t reg_addr, uint8_t val_msb, uint8_t val_lsb) {
+ baro_trans.type = I2CTransTx;
+ baro_trans.slave_addr = baro_addr;
+ baro_trans.len_w = 3;
+ baro_trans.buf[0] = reg_addr;
+ baro_trans.buf[1] = val_msb;
+ baro_trans.buf[2] = val_lsb;
+ i2c_submit(&i2c2,&baro_trans);
+}
+
+static inline void baro_board_read_from_register(uint8_t baro_addr, uint8_t reg_addr) {
+ baro_trans.type = I2CTransTxRx;
+ baro_trans.slave_addr = baro_addr;
+ baro_trans.len_w = 1;
+ baro_trans.len_r = 2;
+ baro_trans.buf[0] = reg_addr;
+ i2c_submit(&i2c2,&baro_trans);
+ // i2c2.buf[0] = reg_addr;
+ // i2c2_transceive(baro_addr, 1, 2, &baro_board.i2c_done);
+}
+
+static inline void baro_board_set_current_register(uint8_t baro_addr, uint8_t reg_addr) {
+ baro_trans.type = I2CTransTx;
+ baro_trans.slave_addr = baro_addr;
+ baro_trans.len_w = 1;
+ baro_trans.buf[0] = reg_addr;
+ i2c_submit(&i2c2,&baro_trans);
+ // i2c2.buf[0] = reg_addr;
+ // i2c2_transmit(baro_addr, 1, &baro_board.i2c_done);
+}
+
+static inline void baro_board_read_from_current_register(uint8_t baro_addr) {
+ baro_trans.type = I2CTransRx;
+ baro_trans.slave_addr = baro_addr;
+ baro_trans.len_r = 2;
+ i2c_submit(&i2c2,&baro_trans);
+ // i2c2_receive(baro_addr, 2, &baro_board.i2c_done);
+}
diff --git a/sw/airborne/boards/lisa_m/baro_board.h b/sw/airborne/boards/lisa_m/baro_board.h
new file mode 100644
index 0000000000..e2d61a79db
--- /dev/null
+++ b/sw/airborne/boards/lisa_m/baro_board.h
@@ -0,0 +1,62 @@
+
+/*
+ * board specific fonctions for the lisa_m board
+ *
+ */
+
+#ifndef BOARDS_LISA_L_BARO_H
+#define BOARDS_LISA_L_BARO_H
+
+#include "std.h"
+#include "mcu_periph/i2c.h"
+
+enum LisaBaroStatus {
+ LBS_UNINITIALIZED,
+ LBS_RESETED,
+ LBS_INITIALIZING_ABS,
+ LBS_INITIALIZING_ABS_1,
+ LBS_INITIALIZING_DIFF,
+ LBS_INITIALIZING_DIFF_1,
+ LBS_IDLE,
+ LBS_READING_ABS,
+ LBS_READ_ABS,
+ LBS_READING_DIFF,
+ LBS_READ_DIFF
+};
+
+struct BaroBoard {
+ enum LisaBaroStatus status;
+};
+
+extern struct BaroBoard baro_board;
+extern struct i2c_transaction baro_trans;
+
+extern void baro_board_send_reset(void);
+extern void baro_board_send_config_abs(void);
+extern void baro_board_send_config_diff(void);
+
+#define BaroEvent(_b_abs_handler, _b_diff_handler) { \
+ if (baro_board.status == LBS_READING_ABS && \
+ baro_trans.status != I2CTransPending) { \
+ baro_board.status = LBS_READ_ABS; \
+ if (baro_trans.status == I2CTransSuccess) { \
+ int16_t tmp = baro_trans.buf[0]<<8 | baro_trans.buf[1]; \
+ baro.absolute = tmp; \
+ _b_abs_handler(); \
+ } \
+ } \
+ else if (baro_board.status == LBS_READING_DIFF && \
+ baro_trans.status != I2CTransPending) { \
+ baro_board.status = LBS_READ_DIFF; \
+ if (baro_trans.status == I2CTransSuccess) { \
+ int16_t tmp = baro_trans.buf[0]<<8 | baro_trans.buf[1]; \
+ baro.differential = tmp; \
+ _b_diff_handler(); \
+ } \
+ } \
+ }
+
+
+
+
+#endif /* BOARDS_LISA_L_BARO_H */
diff --git a/sw/airborne/boards/lisa_m_1.0.h b/sw/airborne/boards/lisa_m_1.0.h
index e87613b155..a0941c8737 100644
--- a/sw/airborne/boards/lisa_m_1.0.h
+++ b/sw/airborne/boards/lisa_m_1.0.h
@@ -1,19 +1,22 @@
#ifndef CONFIG_LISA_M_1_0_H
#define CONFIG_LISA_M_1_0_H
+#define BOARD_LISA_M
#define AHB_CLK 72000000
/* Onboard LEDs */
#define LED_1_BANK
#define LED_1_GPIO GPIOB
-#define LED_1_GPIO_CLK RCC_APB2Periph_GPIOB
+#define LED_1_GPIO_CLK RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO
#define LED_1_GPIO_PIN GPIO_Pin_4
+#define LED_1_AFIO_REMAP GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE)
#define LED_2_BANK
#define LED_2_GPIO GPIOC
#define LED_2_GPIO_CLK RCC_APB2Periph_GPIOC
#define LED_2_GPIO_PIN GPIO_Pin_13
+#define LED_2_AFIO_REMAP ((void)0)
/* configuration for aspirin - and more generaly IMUs */
#define IMU_ACC_DRDY_RCC_GPIO RCC_APB2Periph_GPIOB
@@ -23,5 +26,10 @@
#define ADC_CHANNEL_VSUPPLY 4
#define DefaultVoltageOfAdc(adc) (0.01787109375*adc)
+#define BOARD_HAS_BARO
+
+#define HSE_TYPE_EXT_CLK
+#define STM32_RCC_MODE RCC_HSE_ON
+#define STM32_PLL_MULT RCC_PLLMul_6
#endif /* CONFIG_LISA_M_1_0_H */
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c b/sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c
index 90bb98f8f9..07602f1430 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c
+++ b/sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c
@@ -43,7 +43,6 @@ void actuators_init(void) {
actuators_mkk.trans[i].type = I2CTransTx;
actuators_mkk.trans[i].len_w = 1;
actuators_mkk.trans[i].slave_addr = actuators_addr[i];
- actuators_mkk.trans[i].stop_after_transmit = TRUE;
actuators_mkk.trans[i].status = I2CTransSuccess;
}
diff --git a/sw/airborne/firmwares/rotorcraft/autopilot.c b/sw/airborne/firmwares/rotorcraft/autopilot.c
index c3026d4a4b..405bde903e 100644
--- a/sw/airborne/firmwares/rotorcraft/autopilot.c
+++ b/sw/airborne/firmwares/rotorcraft/autopilot.c
@@ -65,7 +65,9 @@ void autopilot_init(void) {
autopilot_flight_time = 0;
autopilot_rc = TRUE;
autopilot_power_switch = FALSE;
+#ifdef POWER_SWITCH_LED
LED_ON(POWER_SWITCH_LED); // POWER OFF
+#endif
}
diff --git a/sw/airborne/firmwares/rotorcraft/autopilot.h b/sw/airborne/firmwares/rotorcraft/autopilot.h
index 10defb26d0..9c611a7316 100644
--- a/sw/airborne/firmwares/rotorcraft/autopilot.h
+++ b/sw/airborne/firmwares/rotorcraft/autopilot.h
@@ -95,11 +95,17 @@ extern uint16_t autopilot_flight_time;
else autopilot_motors_on = TRUE; \
}
+#ifdef POWER_SWITCH_LED
#define autopilot_SetPowerSwitch(_v) { \
autopilot_power_switch = _v; \
if (_v) { LED_OFF(POWER_SWITCH_LED); } \
else { LED_ON(POWER_SWITCH_LED); } \
}
+#else
+#define autopilot_SetPowerSwitch(_v) { \
+ autopilot_power_switch = _v; \
+ }
+#endif
#ifndef TRESHOLD_GROUND_DETECT
#define TRESHOLD_GROUND_DETECT ACCEL_BFP_OF_REAL(15.)
diff --git a/sw/airborne/lisa/test_led.c b/sw/airborne/lisa/test_led.c
index 0052006f56..f3d5d1269d 100644
--- a/sw/airborne/lisa/test_led.c
+++ b/sw/airborne/lisa/test_led.c
@@ -29,12 +29,62 @@
#include "led.h"
void Delay(__IO uint32_t nCount);
+void led_on(int i);
+void led_off(int i);
+#ifdef BOARD_LISA_L
#define LED_PROGRAM_SIZE 26
const int LED_PROG_ON[LED_PROGRAM_SIZE] = { 3, 5, 7, 1, -1, -1, -1, -1, 2, 4, 6, 0, 3, 5, 7, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
const int LED_PROG_OFF[LED_PROGRAM_SIZE] = {-1, -1, -1, -1, 3, 5, 7, 1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 5, 7, 1, 2, 4, 6, 0, -1, -1 };
+#endif
+#ifdef BOARD_LISA_M
+#define LED_PROGRAM_SIZE 10
+
+const int LED_PROG_ON[LED_PROGRAM_SIZE] = { 1, 2, -1, -1, -1, 2, 1, -1, -1, -1 };
+const int LED_PROG_OFF[LED_PROGRAM_SIZE] = { -1, -1, 1, 2, -1, -1, -1, 2, 1, -1 };
+#endif
+
+void led_on(int i) {
+#ifdef BOARD_LISA_L
+ LED_ON(i);
+#endif
+
+#ifdef BOARD_LISA_M
+ switch (i) {
+ case 1:
+ LED_ON(1);
+ break;
+ case 2:
+ LED_ON(2);
+ break;
+ default:
+ /* ignore as we only have 2 led's for now on lisa/m */
+ break;
+ }
+#endif
+}
+
+void led_off(int i) {
+#ifdef BOARD_LISA_L
+ LED_OFF(i);
+#endif
+
+#ifdef BOARD_LISA_M
+ switch (i) {
+ case 1:
+ LED_OFF(1);
+ break;
+ case 2:
+ LED_OFF(2);
+ break;
+ default:
+ /* ignore as we only have 2 led's for now on lisa/m */
+ break;
+ }
+#endif
+}
int main(void) {
int i = 0;
@@ -43,11 +93,11 @@ int main(void) {
for (i=0; i< LED_PROGRAM_SIZE; i++)
{
if (LED_PROG_ON[i] >= 0)
- LED_ON(LED_PROG_ON[i]);
+ led_on(LED_PROG_ON[i]);
LED_PERIODIC();
Delay(2000000);
if (LED_PROG_OFF[i] >= 0)
- LED_OFF(LED_PROG_OFF[i]);
+ led_off(LED_PROG_OFF[i]);
}
};
return 0;
diff --git a/sw/airborne/lisa/test_uart_lisam.c b/sw/airborne/lisa/test_uart_lisam.c
new file mode 100644
index 0000000000..4e898b0793
--- /dev/null
+++ b/sw/airborne/lisa/test_uart_lisam.c
@@ -0,0 +1,90 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2009 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
+#include
+
+#include
+#include
+
+#include BOARD_CONFIG
+#include "mcu.h"
+#include "mcu_periph/uart.h"
+#include "sys_time.h"
+
+static inline void main_init( void );
+static inline void main_periodic( void );
+
+int main(void) {
+
+ main_init();
+
+ while (1) {
+ if (sys_time_periodic())
+ main_periodic();
+ }
+ return 0;
+}
+
+static inline void main_init( void ) {
+ mcu_init();
+ sys_time_init();
+}
+
+static inline void main_periodic( void ) {
+ char ch;
+
+ Uart1Transmit('a');
+ Uart2Transmit('b');
+ Uart3Transmit('c');
+
+ LED_OFF(1);
+ LED_OFF(2);
+
+ if (Uart1ChAvailable()) {
+ ch = Uart1Getch();
+ if (ch == 'a') {
+ LED_ON(1);
+ } else {
+ LED_ON(2);
+ }
+ }
+
+ if (Uart2ChAvailable()) {
+ ch = Uart2Getch();
+ if (ch == 'b') {
+ LED_ON(1);
+ } else {
+ LED_ON(2);
+ }
+ }
+
+ if (Uart3ChAvailable()) {
+ ch = Uart3Getch();
+ if (ch == 'c') {
+ LED_ON(1);
+ } else {
+ LED_ON(2);
+ }
+ }
+}
diff --git a/sw/airborne/mcu_periph/i2c.h b/sw/airborne/mcu_periph/i2c.h
index 43753823ce..93bd0f77ba 100644
--- a/sw/airborne/mcu_periph/i2c.h
+++ b/sw/airborne/mcu_periph/i2c.h
@@ -43,7 +43,6 @@ struct i2c_transaction {
uint8_t slave_addr;
uint16_t len_r;
uint8_t len_w;
- bool_t stop_after_transmit;
volatile uint8_t buf[I2C_BUF_LEN];
volatile enum I2CTransactionStatus status;
};
@@ -61,6 +60,10 @@ struct i2c_periph {
volatile enum I2CStatus status;
volatile uint8_t idx_buf;
void* reg_addr;
+ void *init_struct;
+ uint16_t scl_pin;
+ uint16_t sda_pin;
+ struct i2c_errors *errors;
};
@@ -132,40 +135,28 @@ extern bool_t i2c_idle(struct i2c_periph* p);
extern bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t);
#define I2CReceive(_p, _t, _s_addr, _len) { \
- _t.type = I2CTransRx; \
- _t.slave_addr = _s_addr; \
- _t.len_r = _len; \
- _t.len_w = 0; \
- _t.stop_after_transmit = TRUE; \
- i2c_submit(&(_p),&(_t)); \
- }
+ _t.type = I2CTransRx; \
+ _t.slave_addr = _s_addr; \
+ _t.len_r = _len; \
+ _t.len_w = 0; \
+ i2c_submit(&(_p),&(_t)); \
+}
#define I2CTransmit(_p, _t, _s_addr, _len) { \
- _t.type = I2CTransTx; \
- _t.slave_addr = _s_addr; \
- _t.len_r = 0; \
- _t.len_w = _len; \
- _t.stop_after_transmit = TRUE; \
- i2c_submit(&(_p),&(_t)); \
- }
+ _t.type = I2CTransTx; \
+ _t.slave_addr = _s_addr; \
+ _t.len_r = 0; \
+ _t.len_w = _len; \
+ i2c_submit(&(_p),&(_t)); \
+}
-#define I2CTransmitNoStop(_p, _t, _s_addr, _len) { \
- _t.type = I2CTransTx; \
- _t.slave_addr = _s_addr; \
- _t.len_r = 0; \
- _t.len_w = _len; \
- _t.stop_after_transmit = FALSE; \
- i2c_submit(&(_p),&(_t)); \
- }
-
-#define I2CTransceive(_p, _t, _s_addr, _len_w, _len_r) { \
- _t.type = I2CTransTxRx; \
- _t.slave_addr = _s_addr; \
- _t.len_r = _len_r; \
- _t.len_w = _len_w; \
- _t.stop_after_transmit = TRUE; \
- i2c_submit(&(_p),&(_t)); \
- }
+#define I2CTransceive(_p, _t, _s_addr, _len_w, _len_r) { \
+ _t.type = I2CTransTxRx; \
+ _t.slave_addr = _s_addr; \
+ _t.len_r = _len_r; \
+ _t.len_w = _len_w; \
+ i2c_submit(&(_p),&(_t)); \
+}
#endif /* I2C_H */
diff --git a/sw/airborne/peripherals/ami601.c b/sw/airborne/peripherals/ami601.c
index 81b1e512a2..1f7f3d4c76 100644
--- a/sw/airborne/peripherals/ami601.c
+++ b/sw/airborne/peripherals/ami601.c
@@ -17,7 +17,6 @@ void ami601_init( void ) {
}
ami601_i2c_trans.status = I2CTransSuccess;
ami601_i2c_trans.slave_addr = AMI601_SLAVE_ADDR;
- ami601_i2c_trans.stop_after_transmit = TRUE;
ami601_nb_err = 0;
ami601_status = AMI601_IDLE;
@@ -26,7 +25,7 @@ void ami601_init( void ) {
void ami601_read( void ) {
if (ami601_status != AMI601_IDLE) {
ami601_nb_err++;
- ami601_status == AMI601_IDLE;
+ ami601_status = AMI601_IDLE;
}
else {
ami601_status = AMI601_SENDING_REQ;
diff --git a/sw/airborne/peripherals/hmc5843.c b/sw/airborne/peripherals/hmc5843.c
index 71050c442c..f02c148312 100644
--- a/sw/airborne/peripherals/hmc5843.c
+++ b/sw/airborne/peripherals/hmc5843.c
@@ -11,7 +11,6 @@ void hmc5843_init(void)
{
hmc5843.i2c_trans.status = I2CTransSuccess;
hmc5843.i2c_trans.slave_addr = HMC5843_ADDR;
- hmc5843.i2c_trans.stop_after_transmit = TRUE;
hmc5843_arch_init();
}
diff --git a/sw/airborne/test/test_esc_mkk_simple.c b/sw/airborne/test/test_esc_mkk_simple.c
index 232890665a..983f19564b 100644
--- a/sw/airborne/test/test_esc_mkk_simple.c
+++ b/sw/airborne/test/test_esc_mkk_simple.c
@@ -59,7 +59,6 @@ static inline void main_periodic_task( void ) {
trans.buf[0] = 0x04;
trans.len_w = 1;
trans.slave_addr = 0x58;
- trans.stop_after_transmit = TRUE;
i2c_submit(&ACTUATORS_MKK_DEV,&trans);
LED_PERIODIC();
diff --git a/sw/simulator/hitl.ml b/sw/simulator/hitl.ml
index c7f3d98c60..cde61c4e41 100644
--- a/sw/simulator/hitl.ml
+++ b/sw/simulator/hitl.ml
@@ -87,7 +87,7 @@ module Make (A:Data.MISSION) (FM: FlightModel.SIG) = struct
"GSpeed", scale gps.gspeed 1e2;
"Heading", scale (deg_of_rad gps.course) 1e5]
- let infrared = fun ir_left ir_front ir_top _air_speed ->
+ let infrared_and_airspeed = fun ir_left ir_front ir_top _air_speed ->
try
DatalinkPprz.message_send "hitl" "HITL_INFRARED"
["ac_id",Pprz.Int !my_id;
diff --git a/sw/simulator/sim.ml b/sw/simulator/sim.ml
index 06fb54418f..d19f4ae9a5 100644
--- a/sw/simulator/sim.ml
+++ b/sw/simulator/sim.ml
@@ -61,7 +61,7 @@ module type AIRCRAFT =
val commands : pprz_t array -> unit
(** Called once at init *)
- val infrared : float -> float -> float -> float -> unit
+ val infrared_and_airspeed : float -> float -> float -> float -> unit
(** [infrared ir_left ir_front ir_top air_speed] Called on timer *)
val gps : Gps.state -> unit
@@ -207,7 +207,7 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct
let ir_left = sin phi_sensor *. !infrared_contrast
and ir_front = sin theta_sensor *. !infrared_contrast
and ir_top = cos phi_sensor *. cos theta_sensor *. !infrared_contrast in
- Aircraft.infrared ir_left ir_front ir_top (FlightModel.get_air_speed !state)
+ Aircraft.infrared_and_airspeed ir_left ir_front ir_top (FlightModel.get_air_speed !state)
and gps_task = fun () ->
let (x,y,z) = FlightModel.get_xyz !state in
diff --git a/sw/simulator/sim.mli b/sw/simulator/sim.mli
index b05db95d39..810e2217e2 100644
--- a/sw/simulator/sim.mli
+++ b/sw/simulator/sim.mli
@@ -9,7 +9,7 @@ module type AIRCRAFT =
val init : int -> GPack.box -> unit
val boot : Stdlib.value -> unit
val commands : Stdlib.pprz_t array -> unit
- val infrared : float -> float -> float -> float -> unit
+ val infrared_and_airspeed : float -> float -> float -> float -> unit
val gps : Gps.state -> unit
end
diff --git a/sw/simulator/sitl.ml b/sw/simulator/sitl.ml
index 5b63c2ea5a..d239cb6d41 100644
--- a/sw/simulator/sitl.ml
+++ b/sw/simulator/sitl.ml
@@ -189,10 +189,10 @@ module Make (A:Data.MISSION) (FM: FlightModel.SIG) = struct
(* Functions called by the simulator *)
let commands = fun s -> rcommands := s
- external set_ir : int -> int -> int -> float -> unit = "set_ir"
- let infrared = fun ir_left ir_front ir_top air_speed ->
+ external set_ir_and_airspeed : int -> int -> int -> float -> unit = "set_ir_and_airspeed"
+ let infrared_and_airspeed = fun ir_left ir_front ir_top air_speed ->
(** ADC neutral is not taken into account in the soft sim (c.f. sim_ir.c)*)
- set_ir (truncate ir_left) (truncate ir_front) (truncate ir_top) air_speed
+ set_ir_and_airspeed (truncate ir_left) (truncate ir_front) (truncate ir_top) air_speed
external use_gps_pos: int -> int -> int -> float -> float -> float -> float -> float -> bool -> float -> float -> unit = "sim_use_gps_pos_bytecode" "sim_use_gps_pos"
let gps = fun gps ->