diff --git a/.gitignore b/.gitignore
index 56f5b760ba..5ea8fce35a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
# ignore html dir for github pages
-/doc/html
+/doc/generated
*.so
*.[oa]
diff --git a/.gitmodules b/.gitmodules
index 6ea3549f82..c75a096d03 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,6 @@
[submodule "sw/ext/libopencm3"]
path = sw/ext/libopencm3
- url = git://libopencm3.git.sourceforge.net/gitroot/libopencm3/libopencm3
-[submodule "sw/ext/stm32loader"]
- path = sw/ext/stm32loader
- url = https://github.com/jsnyder/stm32loader.git
+ url = https://github.com/libopencm3/libopencm3.git
[submodule "sw/ext/luftboot"]
path = sw/ext/luftboot
url = https://github.com/paparazzi/luftboot.git
diff --git a/Doxyfile b/Doxyfile
index c768dff65d..e0b045a019 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -51,7 +51,7 @@ PROJECT_LOGO = data/pictures/penguin_icon.png
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY = doc/html
+OUTPUT_DIRECTORY = doc/generated
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
@@ -828,7 +828,7 @@ GENERATE_HTML = YES
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
-HTML_OUTPUT = docs
+HTML_OUTPUT =
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
diff --git a/Makefile b/Makefile
index 7ee5a26a1b..ff963faecf 100644
--- a/Makefile
+++ b/Makefile
@@ -210,10 +210,6 @@ upload_ms ms.upload: ms
#####
#####
-doxygen:
- mkdir -p dox
- doxygen Doxyfile
-
run_sitl :
$(PAPARAZZI_HOME)/var/$(AIRCRAFT)/sim/simsitl
@@ -282,4 +278,4 @@ run_tests:
test: all replace_current_conf_xml run_tests restore_conf_xml
-.PHONY: all print_build_version clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible doxygen run_sitl install uninstall test replace_current_conf_xml run_tests restore_conf_xml
+.PHONY: all print_build_version clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible run_sitl install uninstall test replace_current_conf_xml run_tests restore_conf_xml
diff --git a/conf/Makefile.stm32 b/conf/Makefile.stm32
index 9cdaa60ab6..f82913db43 100644
--- a/conf/Makefile.stm32
+++ b/conf/Makefile.stm32
@@ -51,7 +51,7 @@ ifneq ($(BOARD_SERIAL),)
OOCD_OPTIONS = -c "ft2232_serial $(BOARD_SERIAL)"
endif
-LOADER= $(PAPARAZZI_SRC)/sw/ext/stm32loader/stm32loader.py
+LOADER ?= $(PAPARAZZI_SRC)/sw/tools/stm32loader/stm32loader.py
ifndef $(TARGET).OOCD_INTERFACE
OOCD_INTERFACE = lisa-l
@@ -130,7 +130,7 @@ AFLAGS += -mcpu=$(MCU) -mthumb
endif
AFLAGS += -x assembler-with-cpp -Wa,-adhlns=$(OBJDIR)/$(<:.S=.lst),--g$(DEBUG)
-LDFLAGS = -L../ext/libopencm3/lib/stm32/f1
+LDFLAGS = -L../ext/libopencm3/lib
ifeq ("$(MULTILIB)","yes")
LDFLAGS += -T$(LDSCRIPT) -nostartfiles -O$(OPT) -mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
else
diff --git a/conf/airframes/CDW/DualBoardApFbw.xml b/conf/airframes/CDW/DualBoardApFbw.xml
new file mode 100644
index 0000000000..bd93c11697
--- /dev/null
+++ b/conf/airframes/CDW/DualBoardApFbw.xml
@@ -0,0 +1,308 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/CDW/LisaAspirin2.xml b/conf/airframes/CDW/LisaAspirin2.xml
deleted file mode 100644
index 6817edb260..0000000000
--- a/conf/airframes/CDW/LisaAspirin2.xml
+++ /dev/null
@@ -1,248 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/airframes/CDW/classix.xml b/conf/airframes/CDW/classix.xml
new file mode 100644
index 0000000000..8f73aacd32
--- /dev/null
+++ b/conf/airframes/CDW/classix.xml
@@ -0,0 +1,260 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/CDW/debug_i2c.xml b/conf/airframes/CDW/debug_i2c.xml
deleted file mode 100644
index 9bdd852c30..0000000000
--- a/conf/airframes/CDW/debug_i2c.xml
+++ /dev/null
@@ -1,276 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/airframes/CDW/ChimuJTinyFwSpi.xml b/conf/airframes/CDW/test/ChimuJTinyFwSpi.xml
similarity index 90%
rename from conf/airframes/CDW/ChimuJTinyFwSpi.xml
rename to conf/airframes/CDW/test/ChimuJTinyFwSpi.xml
index e3b8d1529e..a5d4bd9c1e 100644
--- a/conf/airframes/CDW/ChimuJTinyFwSpi.xml
+++ b/conf/airframes/CDW/test/ChimuJTinyFwSpi.xml
@@ -1,5 +1,6 @@
+
@@ -81,15 +82,12 @@
-
-
-
-
+
@@ -100,7 +98,7 @@
-
+
@@ -108,21 +106,21 @@
-
+
-
-
-
+
+
+
-
+
-
-
+
+
diff --git a/conf/airframes/CDW/ChimuLisaFw.xml b/conf/airframes/CDW/test/ChimuLisaFw.xml
similarity index 100%
rename from conf/airframes/CDW/ChimuLisaFw.xml
rename to conf/airframes/CDW/test/ChimuLisaFw.xml
diff --git a/conf/airframes/CDW/ChimuTinyFw.xml b/conf/airframes/CDW/test/ChimuTinyFw.xml
similarity index 94%
rename from conf/airframes/CDW/ChimuTinyFw.xml
rename to conf/airframes/CDW/test/ChimuTinyFw.xml
index 099a016e70..54d2b8b0e7 100644
--- a/conf/airframes/CDW/ChimuTinyFw.xml
+++ b/conf/airframes/CDW/test/ChimuTinyFw.xml
@@ -1,13 +1,14 @@
+
-
-
-
-
-
+
+
+
+
+
@@ -109,7 +110,7 @@
-
+
diff --git a/conf/airframes/CDW/yapa3_aspirin2.xml b/conf/airframes/CDW/test/yapa3_aspirin2.xml
similarity index 99%
rename from conf/airframes/CDW/yapa3_aspirin2.xml
rename to conf/airframes/CDW/test/yapa3_aspirin2.xml
index 152832dd54..a9fe19f48d 100644
--- a/conf/airframes/CDW/yapa3_aspirin2.xml
+++ b/conf/airframes/CDW/test/yapa3_aspirin2.xml
@@ -222,7 +222,7 @@
-
+
diff --git a/conf/airframes/CDW/debug_i2c_lpc.xml b/conf/airframes/CDW/tiny2_chimu_spi_pt.xml
similarity index 55%
rename from conf/airframes/CDW/debug_i2c_lpc.xml
rename to conf/airframes/CDW/tiny2_chimu_spi_pt.xml
index 01233bd41d..22778dc457 100644
--- a/conf/airframes/CDW/debug_i2c_lpc.xml
+++ b/conf/airframes/CDW/tiny2_chimu_spi_pt.xml
@@ -1,95 +1,86 @@
-
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
+
-
+
+
+
-
-
-
-
-
-
+
-
-
-
+
-
-
-
+
@@ -102,7 +93,7 @@
-
+
@@ -113,7 +104,7 @@
-
+
@@ -121,23 +112,21 @@
-
+
-
+
-
-
+
+
-
-
-
-
+
+
@@ -168,33 +157,44 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
-
+
-
-
-
-
+
+
+
+
diff --git a/conf/airframes/CDW/yapa_xsens.xml b/conf/airframes/CDW/yapa_xsens.xml
index 2604ef5156..49e5880351 100644
--- a/conf/airframes/CDW/yapa_xsens.xml
+++ b/conf/airframes/CDW/yapa_xsens.xml
@@ -43,7 +43,7 @@
-
+
@@ -207,7 +207,7 @@
-
+
diff --git a/conf/airframes/ENAC/fixed-wing/eternity1.xml b/conf/airframes/ENAC/fixed-wing/eternity1.xml
new file mode 100644
index 0000000000..6a9595967d
--- /dev/null
+++ b/conf/airframes/ENAC/fixed-wing/eternity1.xml
@@ -0,0 +1,195 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/ENAC/fixed-wing/firestorm.xml b/conf/airframes/ENAC/fixed-wing/firestorm.xml
index 4c8cc21882..584e3fb3a9 100644
--- a/conf/airframes/ENAC/fixed-wing/firestorm.xml
+++ b/conf/airframes/ENAC/fixed-wing/firestorm.xml
@@ -9,7 +9,6 @@
-
@@ -36,7 +35,9 @@
-
+
+
+
@@ -125,6 +126,7 @@
diff --git a/conf/airframes/ENAC/fixed-wing/funjet2.xml b/conf/airframes/ENAC/fixed-wing/funjet2.xml
new file mode 100644
index 0000000000..bd474733af
--- /dev/null
+++ b/conf/airframes/ENAC/fixed-wing/funjet2.xml
@@ -0,0 +1,227 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/ENAC/fixed-wing/merlin.xml b/conf/airframes/ENAC/fixed-wing/merlin.xml
new file mode 100644
index 0000000000..11d9c086df
--- /dev/null
+++ b/conf/airframes/ENAC/fixed-wing/merlin.xml
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/ENAC/fixed-wing/mythe.xml b/conf/airframes/ENAC/fixed-wing/mythe.xml
new file mode 100644
index 0000000000..9424bb2846
--- /dev/null
+++ b/conf/airframes/ENAC/fixed-wing/mythe.xml
@@ -0,0 +1,265 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/ENAC/fixed-wing/twinjet2.xml b/conf/airframes/ENAC/fixed-wing/twinjet2.xml
new file mode 100644
index 0000000000..342dc35415
--- /dev/null
+++ b/conf/airframes/ENAC/fixed-wing/twinjet2.xml
@@ -0,0 +1,219 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/ENAC/fixed-wing/weasel.xml b/conf/airframes/ENAC/fixed-wing/weasel.xml
index 25c8678dff..8f6946c8f3 100644
--- a/conf/airframes/ENAC/fixed-wing/weasel.xml
+++ b/conf/airframes/ENAC/fixed-wing/weasel.xml
@@ -6,11 +6,10 @@
LEA 5H GPS
-->
-
+
-
-
+
@@ -18,7 +17,9 @@
+
+
@@ -49,7 +50,6 @@
-
@@ -122,6 +122,7 @@
@@ -133,7 +134,6 @@
-
diff --git a/conf/airframes/ENAC/quadrotor/blender.xml b/conf/airframes/ENAC/quadrotor/blender.xml
index 209b6518e6..55cbf4c8a5 100644
--- a/conf/airframes/ENAC/quadrotor/blender.xml
+++ b/conf/airframes/ENAC/quadrotor/blender.xml
@@ -1,12 +1,11 @@
+
+
-
-
-
-
-
-
+
+
+
@@ -30,21 +29,40 @@
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -54,24 +72,13 @@
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
+
-
-
-
-
+
diff --git a/conf/airframes/ENAC/quadrotor/booz2_g1.xml b/conf/airframes/ENAC/quadrotor/booz2_g1.xml
index 743a71c620..d1450b4f65 100644
--- a/conf/airframes/ENAC/quadrotor/booz2_g1.xml
+++ b/conf/airframes/ENAC/quadrotor/booz2_g1.xml
@@ -1,11 +1,8 @@
-
-
-
-
-
+
+
@@ -27,28 +24,30 @@
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
@@ -58,12 +57,19 @@
-
-
-
-
+
+
+
+
+
+
+
+
@@ -158,8 +164,8 @@
@@ -208,24 +214,19 @@
-
+
-
-
-
-
+
diff --git a/conf/airframes/TestHardware/LisaL_v1.1_aspirin_v1.5_rc.xml b/conf/airframes/TestHardware/LisaL_v1.1_aspirin_v1.5_rc.xml
index 3aed8ead28..557d03acb9 100644
--- a/conf/airframes/TestHardware/LisaL_v1.1_aspirin_v1.5_rc.xml
+++ b/conf/airframes/TestHardware/LisaL_v1.1_aspirin_v1.5_rc.xml
@@ -24,6 +24,7 @@
+
@@ -70,11 +71,16 @@
-->
-
-
-
-
-
+
+
+
+
+
+
+
@@ -84,17 +90,10 @@
-
-
-
-
-
-
-
-
+
+
+
+
@@ -103,6 +102,14 @@
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml b/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml
index 38bee2483a..f72a7f9295 100644
--- a/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml
+++ b/conf/airframes/TestHardware/LisaL_v1.1_b2_v1.2_rc.xml
@@ -23,6 +23,7 @@
+
@@ -70,11 +71,16 @@
-->
-
-
-
-
-
+
+
+
+
+
+
+
@@ -84,19 +90,10 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -105,6 +102,14 @@
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/airframe.dtd b/conf/airframes/airframe.dtd
index 9a1e5c36b6..5950084218 100644
--- a/conf/airframes/airframe.dtd
+++ b/conf/airframes/airframe.dtd
@@ -1,21 +1,18 @@
-
+
-
-
-
-
-
+
+
@@ -54,7 +51,6 @@ driver CDATA #IMPLIED>
-
-
-
-
-
-
-
@@ -87,6 +72,9 @@ value CDATA #REQUIRED
command CDATA #IMPLIED
servo CDATA #IMPLIED>
+
+
diff --git a/conf/airframes/esden/calib/asp21-026.xml b/conf/airframes/esden/calib/asp21-026.xml
new file mode 100644
index 0000000000..10144752af
--- /dev/null
+++ b/conf/airframes/esden/calib/asp21-026.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/esden/hexy_ll11a2pwm.xml b/conf/airframes/esden/hexy_ll11a2pwm.xml
index 69ba7a1173..6ae1d2b368 100644
--- a/conf/airframes/esden/hexy_ll11a2pwm.xml
+++ b/conf/airframes/esden/hexy_ll11a2pwm.xml
@@ -11,13 +11,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -28,50 +28,33 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
@@ -229,26 +212,32 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/esden/hexy_lm2a2pwm.xml b/conf/airframes/esden/hexy_lm2a2pwm.xml
new file mode 100644
index 0000000000..6fea357f2b
--- /dev/null
+++ b/conf/airframes/esden/hexy_lm2a2pwm.xml
@@ -0,0 +1,233 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/esden/quady_ll11a2pwm.xml b/conf/airframes/esden/quady_ll11a2pwm.xml
index 2fe252327e..368bdb9a9e 100644
--- a/conf/airframes/esden/quady_ll11a2pwm.xml
+++ b/conf/airframes/esden/quady_ll11a2pwm.xml
@@ -11,11 +11,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -26,48 +26,31 @@
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
@@ -229,22 +212,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -255,7 +243,6 @@
-
diff --git a/conf/airframes/esden/quady_lm1a1pwm.xml b/conf/airframes/esden/quady_lm1a1pwm.xml
index a5dbd1736d..3ce579cf50 100644
--- a/conf/airframes/esden/quady_lm1a1pwm.xml
+++ b/conf/airframes/esden/quady_lm1a1pwm.xml
@@ -11,11 +11,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -26,48 +26,31 @@
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
@@ -190,21 +173,27 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
diff --git a/conf/airframes/esden/quady_lm2a2pwm.xml b/conf/airframes/esden/quady_lm2a2pwm.xml
index 579c5550e7..14d64fdc9e 100644
--- a/conf/airframes/esden/quady_lm2a2pwm.xml
+++ b/conf/airframes/esden/quady_lm2a2pwm.xml
@@ -11,11 +11,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -26,48 +26,31 @@
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
@@ -186,25 +169,35 @@
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
diff --git a/conf/airframes/examples/booz2.xml b/conf/airframes/examples/booz2.xml
index 553fc34a9d..f9986df8b8 100644
--- a/conf/airframes/examples/booz2.xml
+++ b/conf/airframes/examples/booz2.xml
@@ -1,10 +1,17 @@
+
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -14,17 +21,10 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/examples/h_hex.xml b/conf/airframes/examples/h_hex.xml
index 04fcaf4edd..0afc6f9d0a 100644
--- a/conf/airframes/examples/h_hex.xml
+++ b/conf/airframes/examples/h_hex.xml
@@ -1,13 +1,20 @@
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -17,17 +24,10 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -172,6 +182,7 @@
+
@@ -200,8 +211,8 @@
-
-
+
diff --git a/conf/airframes/examples/lisa_asctec.xml b/conf/airframes/examples/lisa_asctec.xml
index fce3a2180d..0d38e840c1 100644
--- a/conf/airframes/examples/lisa_asctec.xml
+++ b/conf/airframes/examples/lisa_asctec.xml
@@ -1,12 +1,14 @@
+
+
-
-
-
-
-
+
+
+
+
+
@@ -22,13 +24,10 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -183,6 +190,7 @@
+
@@ -192,6 +200,7 @@
+
@@ -219,8 +228,8 @@
-
-
+
diff --git a/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml b/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml
index 64fa05cb6e..4942450dab 100644
--- a/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml
+++ b/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml
@@ -25,7 +25,8 @@
-
+
+
@@ -38,11 +39,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -52,18 +53,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum_geo_mag.xml b/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum_geo_mag.xml
old mode 100755
new mode 100644
index c89a281729..dcc9a9c309
--- a/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum_geo_mag.xml
+++ b/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum_geo_mag.xml
@@ -25,7 +25,8 @@
-
+
+
@@ -43,11 +44,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -62,13 +63,10 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/examples/quadrotor_lisa_m_mkk.xml b/conf/airframes/examples/quadrotor_lisa_m_mkk.xml
index 9a01431aa4..42fcb6b0d0 100644
--- a/conf/airframes/examples/quadrotor_lisa_m_mkk.xml
+++ b/conf/airframes/examples/quadrotor_lisa_m_mkk.xml
@@ -20,6 +20,7 @@
+
@@ -28,6 +29,19 @@
+
+
+
+
+
+
+
+
+
@@ -35,18 +49,10 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/examples/separate_fbw_ap.xml b/conf/airframes/examples/separate_fbw_ap.xml
new file mode 100644
index 0000000000..352e060f7c
--- /dev/null
+++ b/conf/airframes/examples/separate_fbw_ap.xml
@@ -0,0 +1,317 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/airframes/examples/setup_lisam2.xml b/conf/airframes/examples/setup_lisam2.xml
index 640c0e72e5..0d228f0fd9 100644
--- a/conf/airframes/examples/setup_lisam2.xml
+++ b/conf/airframes/examples/setup_lisam2.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/conf/airframes/obsolete/twinjet1.xml b/conf/airframes/obsolete/twinjet1.xml
index 9442d1e4c1..0c39819c0d 100644
--- a/conf/airframes/obsolete/twinjet1.xml
+++ b/conf/airframes/obsolete/twinjet1.xml
@@ -186,7 +186,7 @@ fbw.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLI
fbw.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c $(SRC_ARCH)/mcu_periph/uart_arch.c
fbw.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK -DUSE_SPI -DSPI_SLAVE
-fbw.srcs += inter_mcu.c link_mcu.c spi.c $(SRC_ARCH)/spi_hw.c
+fbw.srcs += inter_mcu.c link_mcu_spi.c spi.c $(SRC_ARCH)/spi_hw.c
fbw.CFLAGS += -DADC -DUSE_AD0
fbw.srcs += $(SRC_ARCH)/adc_hw.c
@@ -202,7 +202,7 @@ ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLIN
ap.srcs += subsystems/datalink/downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c subsystems/datalink/pprz_transport.c
ap.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK -DUSE_SPI -DSPI_MASTER -DUSE_SPI_SLAVE0
-ap.srcs += inter_mcu.c link_mcu.c spi.c $(SRC_ARCH)/spi_hw.c
+ap.srcs += inter_mcu.c link_mcu_spi.c spi.c $(SRC_ARCH)/spi_hw.c
ap.CFLAGS += -DUSE_GPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400
ap.srcs += gps_ubx.c gps.c latlong.c
diff --git a/conf/airframes/obsolete/twinstar6.xml b/conf/airframes/obsolete/twinstar6.xml
index 347f357bd1..4bbc84a9f5 100644
--- a/conf/airframes/obsolete/twinstar6.xml
+++ b/conf/airframes/obsolete/twinstar6.xml
@@ -195,7 +195,7 @@ fbw.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLI
fbw.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c $(SRC_ARCH)/mcu_periph/uart_arch.c
fbw.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK -DUSE_SPI -DSPI_SLAVE
-fbw.srcs += inter_mcu.c link_mcu.c spi.c $(SRC_ARCH)/spi_hw.c
+fbw.srcs += inter_mcu.c link_mcu_spi.c spi.c $(SRC_ARCH)/spi_hw.c
fbw.CFLAGS += -DADC -DUSE_AD0
fbw.srcs += $(SRC_ARCH)/adc_hw.c
@@ -208,7 +208,7 @@ ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLIN
ap.srcs += subsystems/datalink/downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c subsystems/navigation/traffic_info.c subsystems/datalink/pprz_transport.c
ap.CFLAGS += -DINTER_MCU -DMCU_SPI_LINK -DUSE_SPI -DSPI_MASTER
-ap.srcs += inter_mcu.c link_mcu.c spi.c $(SRC_ARCH)/spi_hw.c
+ap.srcs += inter_mcu.c link_mcu_spi.c spi.c $(SRC_ARCH)/spi_hw.c
ap.CFLAGS += -DUSE_GPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400
ap.srcs += gps_ubx.c gps.c latlong.c
diff --git a/conf/boards/classix.makefile b/conf/boards/classix.makefile
index efdfbdc3bc..c4dd62e1dc 100644
--- a/conf/boards/classix.makefile
+++ b/conf/boards/classix.makefile
@@ -55,5 +55,13 @@ ifndef SYS_TIME_LED
SYS_TIME_LED = none
endif
+#
+# you can use different actuators by adding a configure option to your firmware section
+# e.g. with )
diff --git a/conf/firmwares/subsystems/fixedwing/attitude_infrared.makefile b/conf/firmwares/subsystems/fixedwing/attitude_infrared.makefile
deleted file mode 100644
index 34a12e0fa7..0000000000
--- a/conf/firmwares/subsystems/fixedwing/attitude_infrared.makefile
+++ /dev/null
@@ -1 +0,0 @@
-$(error Attitude estimation via infrared has been implemented as an AHRS subsystem now. Please replace with and add the module in your airframe file.)
diff --git a/conf/firmwares/subsystems/fixedwing/attitude_infrared_i2c.makefile b/conf/firmwares/subsystems/fixedwing/attitude_infrared_i2c.makefile
deleted file mode 100644
index af75bb8d7c..0000000000
--- a/conf/firmwares/subsystems/fixedwing/attitude_infrared_i2c.makefile
+++ /dev/null
@@ -1 +0,0 @@
-$(error Attitude estimation via infrared has been implemented as an AHRS subsystem now. Please replace with and add the module in your airframe file.)
diff --git a/conf/firmwares/subsystems/fixedwing/autopilot.makefile b/conf/firmwares/subsystems/fixedwing/autopilot.makefile
index c3db971434..6c762740da 100644
--- a/conf/firmwares/subsystems/fixedwing/autopilot.makefile
+++ b/conf/firmwares/subsystems/fixedwing/autopilot.makefile
@@ -152,7 +152,8 @@ endif
fbw_CFLAGS += -DFBW
fbw_srcs += $(SRC_FIRMWARE)/main_fbw.c
fbw_srcs += subsystems/electrical.c
-fbw_srcs += $(SRC_FIXEDWING)/commands.c
+fbw_srcs += subsystems/commands.c
+fbw_srcs += subsystems/actuators.c
fbw_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
######################################################################
@@ -162,6 +163,7 @@ fbw_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
ap_CFLAGS += -DAP
ap_srcs += $(SRC_FIRMWARE)/main_ap.c
+ap_srcs += $(SRC_FIRMWARE)/autopilot.c
ap_srcs += $(SRC_FIRMWARE)/ap_downlink.c
ap_srcs += state.c
@@ -239,15 +241,16 @@ jsbsim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c
#
ifeq ($(BOARD),classix)
- fbw.CFLAGS += -DMCU_SPI_LINK -DUSE_SPI -DSPI_SLAVE
- fbw.srcs += $(SRC_FIXEDWING)/link_mcu.c mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_arch.c
- ap_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
- ap.CFLAGS += -DMCU_SPI_LINK -DUSE_SPI -DSPI_MASTER -DUSE_SPI_SLAVE0
- ap.srcs += $(SRC_FIXEDWING)/link_mcu.c mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_arch.c
+ include $(CFG_FIXEDWING)/intermcu_spi.makefile
else
# Single MCU's run both
- ap.CFLAGS += $(fbw_CFLAGS)
- ap.srcs += $(fbw_srcs)
+ ifeq ($(SEPARATE_FBW),)
+ ap.CFLAGS += $(fbw_CFLAGS)
+ ap.srcs += $(fbw_srcs)
+ else
+ # avoid fbw_telemetry_mode error
+ ap_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
+ endif
endif
#
diff --git a/conf/firmwares/subsystems/fixedwing/control_energyadaptive.makefile b/conf/firmwares/subsystems/fixedwing/control_energyadaptive.makefile
new file mode 100644
index 0000000000..7b4f6dc790
--- /dev/null
+++ b/conf/firmwares/subsystems/fixedwing/control_energyadaptive.makefile
@@ -0,0 +1,8 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# Standard fixed wing control loops
+
+
+$(TARGET).srcs += $(SRC_FIRMWARE)/stabilization/stabilization_adaptive.c $(SRC_FIRMWARE)/guidance/energy_ctrl.c
+
+$(TARGET).CFLAGS += -DCTRL_TYPE_H=\"firmwares/fixedwing/guidance/energy_ctrl.h\"
diff --git a/conf/firmwares/subsystems/fixedwing/gps_ublox_lea4p.makefile b/conf/firmwares/subsystems/fixedwing/gps_ublox_lea4p.makefile
deleted file mode 100644
index da4d84a19d..0000000000
--- a/conf/firmwares/subsystems/fixedwing/gps_ublox_lea4p.makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# UBlox LEA 4P
-
-$(error The gps_ublox_lea4p subsystem has been renamed, please replace with in your airframe file.)
diff --git a/conf/firmwares/subsystems/fixedwing/gps_ublox_lea5h.makefile b/conf/firmwares/subsystems/fixedwing/gps_ublox_lea5h.makefile
deleted file mode 100644
index 59e9799be5..0000000000
--- a/conf/firmwares/subsystems/fixedwing/gps_ublox_lea5h.makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-# UBlox LEA 5H
-
-$(error The gps_ublox_lea5h subsystem has been renamed, please replace with in your airframe file.)
-
diff --git a/conf/firmwares/subsystems/fixedwing/imu_booz.makefile b/conf/firmwares/subsystems/fixedwing/imu_booz.makefile
deleted file mode 100644
index 8efad96332..0000000000
--- a/conf/firmwares/subsystems/fixedwing/imu_booz.makefile
+++ /dev/null
@@ -1 +0,0 @@
-$(error The imu_booz subsystem has been removed, please replace with e.g. or "b2_v1.0", "b2_v1.1", "b2_v1.2" as appropriate.)
diff --git a/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile b/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile
new file mode 100644
index 0000000000..aad941720c
--- /dev/null
+++ b/conf/firmwares/subsystems/fixedwing/intermcu_spi.makefile
@@ -0,0 +1,11 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# InterMCU type SPI
+
+
+fbw.CFLAGS += -DMCU_SPI_LINK -DUSE_SPI -DSPI_SLAVE
+fbw.srcs += $(SRC_FIXEDWING)/link_mcu_spi.c mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_arch.c
+ap_srcs += $(SRC_FIRMWARE)/fbw_downlink.c
+ap.CFLAGS += -DMCU_SPI_LINK -DUSE_SPI -DSPI_MASTER -DUSE_SPI_SLAVE0
+ap.srcs += $(SRC_FIXEDWING)/link_mcu_spi.c mcu_periph/spi.c $(SRC_ARCH)/mcu_periph/spi_arch.c
+SEPARATE_FBW = 1
diff --git a/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile b/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile
new file mode 100644
index 0000000000..da9ec6967d
--- /dev/null
+++ b/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile
@@ -0,0 +1,29 @@
+# Hey Emacs, this is a -*- makefile -*-
+
+# InterMCU type UART
+
+
+ifeq ($(TARGET),fbw)
+ ifeq ($(INTERMCU_PORT),none)
+ INTERMCU_PORT_NR = 2
+ endif
+ fbw.CFLAGS += -DINTERMCU_LINK=Uart$(INTERMCU_PORT_NR) -DUSE_UART$(INTERMCU_PORT_NR) -DUART$(INTERMCU_PORT_NR)_BAUD=B57600
+else
+ ifeq ($(INTERMCU_PORT),none)
+ INTERMCU_PORT_NR = 5
+ endif
+ ap.CFLAGS += -DINTERMCU_LINK=Uart$(INTERMCU_PORT_NR) -DUSE_UART$(INTERMCU_PORT_NR) -DUART$(INTERMCU_PORT_NR)_BAUD=B57600
+endif
+
+ifneq ($(TARGET),sim)
+$(TARGET).CFLAGS += -DINTER_MCU -DMCU_UART_LINK
+$(TARGET).srcs += ./link_mcu_usart.c
+endif
+
+
+
+#############################
+# CAN:
+# fbw.srcs += ./link_mcu_can.c ./mcu_periph/can.c ./arch/stm32/mcu_periph/can_arch.c
+# fbw.CFLAGS += -DINTER_MCU -DMCU_CAN_LINK
+# $(TARGET).CFLAGS += -DCAN_SJW_TQ=CAN_SJW_1tq -DCAN_BS1_TQ=CAN_BS1_3tq -DCAN_BS2_TQ=CAN_BS2_4tq -DCAN_PRESCALER=12 -DUSE_CAN -DUSE_CAN1 -DUSE_USB_LP_CAN1_RX0_IRQ -DCAN_ERR_RESUME=DISABLE
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_asctec_v2.makefile b/conf/firmwares/subsystems/rotorcraft/actuators_asctec_v2.makefile
deleted file mode 100644
index eaa8e486c8..0000000000
--- a/conf/firmwares/subsystems/rotorcraft/actuators_asctec_v2.makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# asctec controllers v2
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-
-ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-ap.CFLAGS += -DACTUATORS_ASCTEC_V2_PROTOCOL
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
-
-ifeq ($(ARCH), lpc21)
-ap.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c0
-ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=150 -DI2C0_SCLH=150 -DI2C0_VIC_SLOT=11
-endif
-
-ifeq ($(ARCH), stm32)
-ap.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
-ap.CFLAGS += -DUSE_I2C1
-endif
-
-# Simulator
-nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
-nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_ASCTEC_DEVICE=i2c0
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_dummy.makefile b/conf/firmwares/subsystems/rotorcraft/actuators_dummy.makefile
deleted file mode 100644
index 5c6b93839a..0000000000
--- a/conf/firmwares/subsystems/rotorcraft/actuators_dummy.makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# empty dummy actuators for testing
-#
-
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_dummy.c
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_heli.makefile b/conf/firmwares/subsystems/rotorcraft/actuators_heli.makefile
deleted file mode 100644
index e27dc150c5..0000000000
--- a/conf/firmwares/subsystems/rotorcraft/actuators_heli.makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_heli.c
-ap.srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_pwm_supervision.makefile b/conf/firmwares/subsystems/rotorcraft/actuators_pwm_supervision.makefile
deleted file mode 100644
index 04cae36bbd..0000000000
--- a/conf/firmwares/subsystems/rotorcraft/actuators_pwm_supervision.makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-
-ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_pwm_supervision.c
-ap.srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
-
-# Simulator
-nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_pwm_supervision.c
-nps.srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_skiron.makefile b/conf/firmwares/subsystems/rotorcraft/actuators_skiron.makefile
deleted file mode 100644
index 6365fbbfbb..0000000000
--- a/conf/firmwares/subsystems/rotorcraft/actuators_skiron.makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Skiron Actuators
-#
-# enable the subsystem for your firmware:
-#
-# ...
-#
-#
-#
-# ...
-#
-#
-#
-# required xml configuration:
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-
-# set default i2c timing if not already configured
-ifeq ($(SKIRON_I2C_SCL_TIME), )
-SKIRON_I2C_SCL_TIME=150
-endif
-
-ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_skiron.c
-
-ifeq ($(ARCH), lpc21)
-ap.CFLAGS += -DACTUATORS_SKIRON_DEVICE=i2c0
-ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(SKIRON_I2C_SCL_TIME) -DI2C0_SCLH=$(SKIRON_I2C_SCL_TIME) -DI2C0_VIC_SLOT=10
-endif
-
-# Simulator
-nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_skiron.c
-nps.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(SKIRON_I2C_SCL_TIME) -DI2C0_SCLH=$(SKIRON_I2C_SCL_TIME) -DI2C0_VIC_SLOT=10 -DACTUATORS_MKK_DEVICE=i2c0
-
diff --git a/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile b/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile
index ccf7d83b07..22b8ee11e6 100644
--- a/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile
+++ b/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile
@@ -82,7 +82,8 @@ nps.srcs += $(SRC_FIRMWARE)/telemetry.c \
subsystems/datalink/downlink.c \
$(SRC_ARCH)/ivy_transport.c
-nps.srcs += $(SRC_FIRMWARE)/commands.c
+nps.srcs += subsystems/actuators.c
+nps.srcs += subsystems/commands.c
nps.srcs += $(SRC_FIRMWARE)/datalink.c
diff --git a/conf/firmwares/subsystems/shared/actuators_4015.makefile b/conf/firmwares/subsystems/shared/actuators_4015.makefile
index 6451c757b0..2ae0e976a8 100644
--- a/conf/firmwares/subsystems/shared/actuators_4015.makefile
+++ b/conf/firmwares/subsystems/shared/actuators_4015.makefile
@@ -1,4 +1,4 @@
# for Tiny v1.1
-$(TARGET).CFLAGS += -DACTUATORS=\"servos_4015_MAT_hw.h\" -DSERVOS_4015_MAT
-$(TARGET).srcs += $(SRC_ARCH)/servos_4015_MAT_hw.c actuators.c
+$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_4015_MAT
+$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/servos_4015_MAT_hw.c
diff --git a/conf/firmwares/subsystems/shared/actuators_4017.makefile b/conf/firmwares/subsystems/shared/actuators_4017.makefile
index 471e3c3433..db89c10474 100644
--- a/conf/firmwares/subsystems/shared/actuators_4017.makefile
+++ b/conf/firmwares/subsystems/shared/actuators_4017.makefile
@@ -1,4 +1,4 @@
# for Tiny v2 or Twog v1
-$(TARGET).CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017
-$(TARGET).srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c
+$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_4017
+$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/servos_4017_hw.c
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_asctec.makefile b/conf/firmwares/subsystems/shared/actuators_asctec.makefile
similarity index 71%
rename from conf/firmwares/subsystems/rotorcraft/actuators_asctec.makefile
rename to conf/firmwares/subsystems/shared/actuators_asctec.makefile
index d1d1c1137d..189d90efb7 100644
--- a/conf/firmwares/subsystems/rotorcraft/actuators_asctec.makefile
+++ b/conf/firmwares/subsystems/shared/actuators_asctec.makefile
@@ -1,5 +1,6 @@
# asctec controllers
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
+$(TARGET).CFLAGS += -DACTUATORS
+ap.srcs += subsystems/actuators/actuators_asctec.c
ifeq ($(ARCH), lpc21)
ap.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c0
@@ -13,6 +14,6 @@ endif
# Simulator
-nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_asctec.c
+nps.srcs += subsystems/actuators/actuators_asctec.c
nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_ASCTEC_DEVICE=i2c0
diff --git a/conf/firmwares/subsystems/shared/actuators_asctec_v2.makefile b/conf/firmwares/subsystems/shared/actuators_asctec_v2.makefile
new file mode 100644
index 0000000000..1133841086
--- /dev/null
+++ b/conf/firmwares/subsystems/shared/actuators_asctec_v2.makefile
@@ -0,0 +1,25 @@
+# asctec controllers v2
+#
+# required xml configuration:
+#
+# servo section with driver="Asctec"
+# command_laws section to map motor_mixing commands to servos
+#
+
+$(TARGET).CFLAGS += -DACTUATORS
+ap.CFLAGS += -DACTUATORS_ASCTEC_V2_PROTOCOL
+ap.srcs += subsystems/actuators/actuators_asctec.c
+
+ifeq ($(ARCH), lpc21)
+ap.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c0
+ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=150 -DI2C0_SCLH=150 -DI2C0_VIC_SLOT=11
+endif
+
+ifeq ($(ARCH), stm32)
+ap.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
+ap.CFLAGS += -DUSE_I2C1
+endif
+
+# Simulator
+nps.srcs += subsystems/actuators/actuators_asctec.c
+nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_ASCTEC_DEVICE=i2c0
diff --git a/conf/firmwares/subsystems/shared/actuators_direct.makefile b/conf/firmwares/subsystems/shared/actuators_direct.makefile
deleted file mode 100644
index 019bb6fac2..0000000000
--- a/conf/firmwares/subsystems/shared/actuators_direct.makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-$(TARGET).CFLAGS += -DACTUATORS=\"subsystems/actuators/actuators_pwm.h\" -DSERVOS_DIRECT
-$(TARGET).srcs += subsystems/actuators/actuators_pwm.c actuators.c
-$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
diff --git a/conf/firmwares/subsystems/shared/actuators_dummy.makefile b/conf/firmwares/subsystems/shared/actuators_dummy.makefile
new file mode 100644
index 0000000000..b91bfa8834
--- /dev/null
+++ b/conf/firmwares/subsystems/shared/actuators_dummy.makefile
@@ -0,0 +1 @@
+# for classix and AP only boards
diff --git a/conf/firmwares/subsystems/rotorcraft/actuators_mkk.makefile b/conf/firmwares/subsystems/shared/actuators_mkk.makefile
similarity index 56%
rename from conf/firmwares/subsystems/rotorcraft/actuators_mkk.makefile
rename to conf/firmwares/subsystems/shared/actuators_mkk.makefile
index 440c947fd8..a9c290a0d2 100644
--- a/conf/firmwares/subsystems/rotorcraft/actuators_mkk.makefile
+++ b/conf/firmwares/subsystems/shared/actuators_mkk.makefile
@@ -17,24 +17,12 @@
#
#
#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
-#
+# servo section with driver="Mkk"
+# command_laws section to map motor_mixing commands to servos
#
-ap.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-ap.srcs += $(SRC_FIRMWARE)/actuators/actuators_mkk.c
+$(TARGET).CFLAGS += -DACTUATORS
+ap.srcs += subsystems/actuators/actuators_mkk.c
ifeq ($(ARCH), lpc21)
@@ -52,6 +40,5 @@ ap.CFLAGS += -DUSE_I2C1
endif
# Simulator
-nps.srcs += $(SRC_FIRMWARE)/actuators/supervision.c
-nps.srcs += $(SRC_FIRMWARE)/actuators/actuators_mkk.c
+nps.srcs += subsystems/actuators/actuators_mkk.c
nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_MKK_DEVICE=i2c0
diff --git a/conf/firmwares/subsystems/shared/actuators_ppm.makefile b/conf/firmwares/subsystems/shared/actuators_ppm.makefile
index 99171e4448..8509ec1de1 100644
--- a/conf/firmwares/subsystems/shared/actuators_ppm.makefile
+++ b/conf/firmwares/subsystems/shared/actuators_ppm.makefile
@@ -5,6 +5,6 @@
# The PPM is output on the SERV_CLK pin. The PPM frame rate, pulse width, and number of channels
# can be adjusted in the "servos_ppm_hw.h" file to suit your particular receiver.
-$(TARGET).CFLAGS += -DACTUATORS=\"servos_ppm_hw.h\" -DSERVOS_PPM_MAT
-$(TARGET).srcs += $(SRC_ARCH)/servos_ppm_hw.c actuators.c
+$(TARGET).CFLAGS += -DACTUATORS -DSERVOS_PPM_MAT
+$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/servos_ppm_hw.c
diff --git a/conf/firmwares/subsystems/shared/actuators_pwm.makefile b/conf/firmwares/subsystems/shared/actuators_pwm.makefile
new file mode 100644
index 0000000000..c476520918
--- /dev/null
+++ b/conf/firmwares/subsystems/shared/actuators_pwm.makefile
@@ -0,0 +1,4 @@
+
+
+$(TARGET).CFLAGS += -DACTUATORS
+$(TARGET).srcs += $(SRC_ARCH)/subsystems/actuators/actuators_pwm_arch.c
diff --git a/conf/firmwares/subsystems/shared/actuators_skiron.makefile b/conf/firmwares/subsystems/shared/actuators_skiron.makefile
new file mode 100644
index 0000000000..86375c977d
--- /dev/null
+++ b/conf/firmwares/subsystems/shared/actuators_skiron.makefile
@@ -0,0 +1,36 @@
+#
+# Skiron Actuators
+#
+# enable the subsystem for your firmware:
+#
+# ...
+#
+#
+#
+# ...
+#
+#
+#
+# required xml configuration:
+#
+# servo section with driver="Skiron"
+# command_laws section to map motor_mixing commands to servos
+#
+
+# set default i2c timing if not already configured
+ifeq ($(SKIRON_I2C_SCL_TIME), )
+SKIRON_I2C_SCL_TIME=150
+endif
+
+$(TARGET).CFLAGS += -DACTUATORS
+ap.srcs += subsystems/actuators/actuators_skiron.c
+
+ifeq ($(ARCH), lpc21)
+ap.CFLAGS += -DACTUATORS_SKIRON_DEVICE=i2c0
+ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(SKIRON_I2C_SCL_TIME) -DI2C0_SCLH=$(SKIRON_I2C_SCL_TIME) -DI2C0_VIC_SLOT=10
+endif
+
+# Simulator
+nps.srcs += subsystems/actuators/actuators_skiron.c
+nps.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(SKIRON_I2C_SCL_TIME) -DI2C0_SCLH=$(SKIRON_I2C_SCL_TIME) -DI2C0_VIC_SLOT=10 -DACTUATORS_SKIRON_DEVICE=i2c0
+
diff --git a/conf/firmwares/subsystems/shared/motor_mixing.makefile b/conf/firmwares/subsystems/shared/motor_mixing.makefile
new file mode 100644
index 0000000000..c621595cb8
--- /dev/null
+++ b/conf/firmwares/subsystems/shared/motor_mixing.makefile
@@ -0,0 +1,19 @@
+# Motor Mixing
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+
+$(TARGET).CFLAGS += -DUSE_MOTOR_MIXING
+$(TARGET).srcs += subsystems/actuators/motor_mixing.c
+
diff --git a/conf/joystick/xbox_booz_cam.xml b/conf/joystick/xbox_rotorcraft_cam.xml
similarity index 80%
rename from conf/joystick/xbox_booz_cam.xml
rename to conf/joystick/xbox_rotorcraft_cam.xml
index 5eecdc472e..5e14acba4d 100644
--- a/conf/joystick/xbox_booz_cam.xml
+++ b/conf/joystick/xbox_rotorcraft_cam.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/conf/messages.xml b/conf/messages.xml
index 3322b460b5..1b2412b967 100644
--- a/conf/messages.xml
+++ b/conf/messages.xml
@@ -77,7 +77,7 @@
-
+
@@ -727,7 +727,7 @@
-
+
@@ -737,7 +737,7 @@
-
+
@@ -1394,8 +1394,8 @@
-
-
+
+
@@ -1803,7 +1803,7 @@
-
+
@@ -2177,7 +2177,7 @@
-
+
diff --git a/conf/modules/baro_ets.xml b/conf/modules/baro_ets.xml
index b283978cb2..a202bde455 100644
--- a/conf/modules/baro_ets.xml
+++ b/conf/modules/baro_ets.xml
@@ -9,6 +9,8 @@
Baro ETS module (I2C)
+
+
diff --git a/conf/modules/booz_cam.xml b/conf/modules/booz_cam.xml
deleted file mode 100644
index 48d9baaa98..0000000000
--- a/conf/modules/booz_cam.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- Camera control for BOOZ board
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/modules/booz_drop.xml b/conf/modules/booz_drop.xml
deleted file mode 100644
index 2b3355bb72..0000000000
--- a/conf/modules/booz_drop.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
- Drop control for BOOZ board
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/modules/booz_pwm.xml b/conf/modules/booz_pwm.xml
deleted file mode 100644
index 422c7f0301..0000000000
--- a/conf/modules/booz_pwm.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
- Allow to use PWM output on booz boards, PWM0 is activated by default (PWM5 on lpc21 output)
-
-
-
-
-
-
-
-
-
diff --git a/conf/modules/cam_point.xml b/conf/modules/cam_point.xml
index 0d6775465b..8a84132269 100644
--- a/conf/modules/cam_point.xml
+++ b/conf/modules/cam_point.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/conf/modules/digital_cam.xml b/conf/modules/digital_cam.xml
index c84947f986..4bef1874e4 100644
--- a/conf/modules/digital_cam.xml
+++ b/conf/modules/digital_cam.xml
@@ -4,15 +4,6 @@
// Use (parts of) the following section in airframe file to change
-
-
# ap.CFLAGS += -DGPS_TRIGGERED_FUNCTION="dc_shoot_on_gps"
# ap.CFLAGS += -DDC_GPS_TRIGGER_START=1
# ap.CFLAGS += -DDC_GPS_TRIGGER_STOP=3
@@ -24,6 +15,12 @@
Digital camera control (trigger using led)
+
+
+
+
+
+
diff --git a/conf/modules/geo_mag.xml b/conf/modules/geo_mag.xml
old mode 100755
new mode 100644
diff --git a/conf/modules/led_safety_status.xml b/conf/modules/led_safety_status.xml
new file mode 100644
index 0000000000..6f416755bc
--- /dev/null
+++ b/conf/modules/led_safety_status.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ LED module that blinks in different patterns in different safety situations
+
+
+
+
+
+
+
+
diff --git a/conf/modules/rotorcraft_cam.xml b/conf/modules/rotorcraft_cam.xml
new file mode 100644
index 0000000000..05142e146d
--- /dev/null
+++ b/conf/modules/rotorcraft_cam.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Camera control for rotorcraft.
+ The camera is controled by the heading of the vehicle for pan and can be controlled by a servo for tilt if defined.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/modules/servo_switch.xml b/conf/modules/servo_switch.xml
index 175747143c..d5e9b99a0e 100644
--- a/conf/modules/servo_switch.xml
+++ b/conf/modules/servo_switch.xml
@@ -5,7 +5,7 @@
Servo switch
-
+
@@ -19,8 +19,10 @@
-
+
+
+ The servo will not exceed the min and max positions defined in the servo section
-->
diff --git a/conf/radios/ezuhf.xml b/conf/radios/ezuhf.xml
index 3be98d59f7..cb17af9357 100644
--- a/conf/radios/ezuhf.xml
+++ b/conf/radios/ezuhf.xml
@@ -6,7 +6,7 @@
-
diff --git a/conf/settings/control/ctl_energy.xml b/conf/settings/control/ctl_energy.xml
index 4c2e865c52..f5cfc27a55 100644
--- a/conf/settings/control/ctl_energy.xml
+++ b/conf/settings/control/ctl_energy.xml
@@ -27,8 +27,8 @@
-
-
+
+
@@ -46,13 +46,17 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/settings/modules/booz_cam.xml b/conf/settings/modules/rotorcraft_cam.xml
similarity index 54%
rename from conf/settings/modules/booz_cam.xml
rename to conf/settings/modules/rotorcraft_cam.xml
index 4b7c08e05d..17ae9b50b4 100644
--- a/conf/settings/modules/booz_cam.xml
+++ b/conf/settings/modules/rotorcraft_cam.xml
@@ -2,7 +2,7 @@
-
+
@@ -10,12 +10,12 @@
-
-
+
+
-
+
diff --git a/conf/settings/modules/servo_switch.xml b/conf/settings/modules/servo_switch.xml
index fe29a120c9..687f0c7bb5 100644
--- a/conf/settings/modules/servo_switch.xml
+++ b/conf/settings/modules/servo_switch.xml
@@ -4,8 +4,8 @@
-
-
+
+
diff --git a/conf/telemetry/default_rotorcraft.xml b/conf/telemetry/default_rotorcraft.xml
index c55ee17611..2376ac8749 100644
--- a/conf/telemetry/default_rotorcraft.xml
+++ b/conf/telemetry/default_rotorcraft.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/conf/tests_conf.xml b/conf/tests_conf.xml
index 6803587eb8..bf8a59b424 100644
--- a/conf/tests_conf.xml
+++ b/conf/tests_conf.xml
@@ -165,6 +165,47 @@
settings=" settings/test_fixedwing_actuators.xml"
gui_color="blue"
/>
+
+
+
+
+
reg_addr))->fcr = UART_FIFO_8;
}
-void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) {
+void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud, bool_t hw_flow_control __attribute__ ((unused))) {
uart_disable_interrupts(p);
uart_set_baudrate(p, baud);
uart_enable_interrupts(p);
diff --git a/sw/airborne/arch/lpc21/modules/core/booz_pwm_arch.c b/sw/airborne/arch/lpc21/modules/core/booz_pwm_arch.c
deleted file mode 100644
index 45579d7992..0000000000
--- a/sw/airborne/arch/lpc21/modules/core/booz_pwm_arch.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * $Id: $
- *
- * Copyright (C) 2011 ENAC
- *
- * 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 "modules/core/booz_pwm_arch.h"
-
-#define PWM_PERIOD CPU_TICKS_OF_USEC(20000)
-#define PWM_DUTY CPU_TICKS_OF_USEC(1500)
-
-void booz_pwm_init_arch( void ) {
-
- /* start PWM5 */
- /* select P0.21 as PWM5 */
- PWM0_PINSEL |= PWM0_PINSEL_VAL << PWM0_PINSEL_BIT;
- /* select pwm period */
- PWMMR0 = PWM_PERIOD;
- /* select pwm value to 50% at init (1500 us) */
- PWMMR5 = PWM_DUTY;
- /* commit values */
- PWMLER = PWMLER_LATCH0 | PWMLER_LATCH5;
- /* prescle timer to match TIMER 0 (15MHz) */
- PWMPR = T0_PCLK_DIV - 1;
- /* enable counter and pwm mode */
- PWMTCR = PWMTCR_COUNTER_ENABLE | PWMTCR_PWM_ENABLE;
- /* enable PWM5 */
- PWMPCR = PWMPCR_ENA5;
-
-#ifdef USE_PWM1
- /* start PWM2 */
- PWM1_PINSEL |= PWM1_PINSEL_VAL << PWM1_PINSEL_BIT;
- /* select pwm value to 50% at init (1500 us) */
- PWMMR2 = PWM_DUTY;
- /* commit values */
- PWMLER = PWMLER_LATCH2;
- /* enable PWM2 */
- PWMPCR |= PWMPCR_ENA2;
-#endif
-
-
-}
diff --git a/sw/airborne/arch/lpc21/servos_csc.h b/sw/airborne/arch/lpc21/servos_csc.h
deleted file mode 100644
index b7d8acb6b3..0000000000
--- a/sw/airborne/arch/lpc21/servos_csc.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef SERVOS_CSC_H
-#define SERVOS_CSC_H
-
-#include "LPC21xx.h"
-#include "generated/airframe.h"
-#include "actuators.h"
-#include "mcu_periph/sys_time.h"
-
-#define SERVOS_TICS_OF_USEC(s) CPU_TICKS_OF_USEC(s)
-#define ChopServo(x,a,b) Chop(x, a, b)
-#define SERVO_COUNT 4
-
-#define Actuator(i) actuators[i]
-
-static inline void ActuatorsCommit(void)
-{
-
-}
-
-#endif /* SERVOS_CSC_H */
diff --git a/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.c b/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.c
index 2dfd68cdc8..23f49dc6f8 100644
--- a/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.c
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.c
@@ -1,6 +1,29 @@
+/*
+ * Copyright (C) 2010-2012 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.
+ */
+
+#include "subsystems/actuators/actuators_pwm_arch.h"
+#include "subsystems/actuators/actuators_pwm.h"
#include "std.h"
-#include "actuators.h"
-#include "actuators_pwm_arch.h"
+#include BOARD_CONFIG
+#include "generated/airframe.h"
/* 40 Hz */
#ifndef SERVOS_PERIOD
@@ -28,7 +51,7 @@ const uint8_t pwm_latch_value = 0
#endif
;
-void actuators_init ( void ) {
+void actuators_pwm_arch_init ( void ) {
/* configure pins for PWM */
#if defined PWM_SERVO_0
diff --git a/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.h b/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.h
index 0032b075dc..e54d87a41e 100644
--- a/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.h
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/actuators_pwm_arch.h
@@ -1,22 +1,30 @@
+/*
+ * 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.
+ */
+
#ifndef ACTUATORS_PWM_ARCH_H
#define ACTUATORS_PWM_ARCH_H
#include "LPC21xx.h"
#include "mcu_periph/sys_time.h"
-#define SERVOS_TICS_OF_USEC(s) CPU_TICKS_OF_USEC(s)
-#define ChopServo(x,a,b) Chop(x, a, b)
-
-#define SERVO_REG_0 PWMMR5
-#define SERVO_REG_1 PWMMR3
-#define SERVO_REG_2 PWMMR1
-#define SERVO_REG_3 PWMMR6
-#define SERVO_REG_4 PWMMR4
-#define SERVO_REG_5 PWMMR2
-
-#define COMMAND_(i) SERVO_REG_ ## i
-#define Actuator(i) COMMAND_(i)
-
/*
wiring on classix PWM connector
@@ -30,35 +38,54 @@ PWM6 PWM2 SSEL0 EINT2 P0.7
*/
-#define PWM_PINSEL_MASK_VAL 3
+#define SERVOS_TICS_OF_USEC(s) CPU_TICKS_OF_USEC(s)
-#define PWM_SERVO_0_PINSEL PINSEL1
-#define PWM_SERVO_0_PINSEL_VAL 1
-#define PWM_SERVO_0_PINSEL_BIT 10
-#define PWM_SERVO_0_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_0_PINSEL_BIT)
-#define PWM_SERVO_0_ENA PWMPCR_ENA5
-#define PWM_SERVO_0_LATCH PWMLER_LATCH5
+/* default definition of servo (from classix order) */
+#ifndef SERVO_REG_0
+#define SERVO_REG_0 PWMMR5
+#endif
+#ifndef SERVO_REG_1
+#define SERVO_REG_1 PWMMR3
+#endif
+#ifndef SERVO_REG_2
+#define SERVO_REG_2 PWMMR1
+#endif
+#ifndef SERVO_REG_3
+#define SERVO_REG_3 PWMMR6
+#endif
+#ifndef SERVO_REG_4
+#define SERVO_REG_4 PWMMR4
+#endif
+#ifndef SERVO_REG_5
+#define SERVO_REG_5 PWMMR2
+#endif
+
+#define COMMAND_(i) SERVO_REG_ ## i
+/** Actuator set macro */
+#define ActuatorPwmSet(_i, _v) { COMMAND_(_i) = SERVOS_TICS_OF_USEC(_v); }
+
+#define PWM_PINSEL_MASK_VAL 3
#define PWM_SERVO_1_PINSEL PINSEL0
#define PWM_SERVO_1_PINSEL_VAL 2
-#define PWM_SERVO_1_PINSEL_BIT 2
+#define PWM_SERVO_1_PINSEL_BIT 0
#define PWM_SERVO_1_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_1_PINSEL_BIT)
-#define PWM_SERVO_1_ENA PWMPCR_ENA3
-#define PWM_SERVO_1_LATCH PWMLER_LATCH3
+#define PWM_SERVO_1_ENA PWMPCR_ENA1
+#define PWM_SERVO_1_LATCH PWMLER_LATCH1
#define PWM_SERVO_2_PINSEL PINSEL0
#define PWM_SERVO_2_PINSEL_VAL 2
-#define PWM_SERVO_2_PINSEL_BIT 0
+#define PWM_SERVO_2_PINSEL_BIT 14
#define PWM_SERVO_2_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_2_PINSEL_BIT)
-#define PWM_SERVO_2_ENA PWMPCR_ENA1
-#define PWM_SERVO_2_LATCH PWMLER_LATCH1
+#define PWM_SERVO_2_ENA PWMPCR_ENA2
+#define PWM_SERVO_2_LATCH PWMLER_LATCH2
#define PWM_SERVO_3_PINSEL PINSEL0
#define PWM_SERVO_3_PINSEL_VAL 2
-#define PWM_SERVO_3_PINSEL_BIT 18
+#define PWM_SERVO_3_PINSEL_BIT 2
#define PWM_SERVO_3_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_3_PINSEL_BIT)
-#define PWM_SERVO_3_ENA PWMPCR_ENA6
-#define PWM_SERVO_3_LATCH PWMLER_LATCH6
+#define PWM_SERVO_3_ENA PWMPCR_ENA3
+#define PWM_SERVO_3_LATCH PWMLER_LATCH3
#define PWM_SERVO_4_PINSEL PINSEL0
#define PWM_SERVO_4_PINSEL_VAL 2
@@ -67,16 +94,24 @@ PWM6 PWM2 SSEL0 EINT2 P0.7
#define PWM_SERVO_4_ENA PWMPCR_ENA4
#define PWM_SERVO_4_LATCH PWMLER_LATCH4
-#define PWM_SERVO_5_PINSEL PINSEL0
-#define PWM_SERVO_5_PINSEL_VAL 2
-#define PWM_SERVO_5_PINSEL_BIT 14
+#define PWM_SERVO_5_PINSEL PINSEL1
+#define PWM_SERVO_5_PINSEL_VAL 1
+#define PWM_SERVO_5_PINSEL_BIT 10
#define PWM_SERVO_5_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_5_PINSEL_BIT)
-#define PWM_SERVO_5_ENA PWMPCR_ENA2
-#define PWM_SERVO_5_LATCH PWMLER_LATCH2
+#define PWM_SERVO_5_ENA PWMPCR_ENA5
+#define PWM_SERVO_5_LATCH PWMLER_LATCH5
+
+#define PWM_SERVO_6_PINSEL PINSEL0
+#define PWM_SERVO_6_PINSEL_VAL 2
+#define PWM_SERVO_6_PINSEL_BIT 18
+#define PWM_SERVO_6_PINSEL_MASK ~(PWM_PINSEL_MASK_VAL << PWM_SERVO_6_PINSEL_BIT)
+#define PWM_SERVO_6_ENA PWMPCR_ENA6
+#define PWM_SERVO_6_LATCH PWMLER_LATCH6
extern const uint8_t pwm_latch_value;
-#define ActuatorsCommit() { \
+/** Actuator commit macro */
+#define ActuatorsPwmCommit() { \
PWMLER = pwm_latch_value; \
}
diff --git a/sw/airborne/arch/lpc21/servos_4015_MAT_hw.c b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_MAT_hw.c
similarity index 96%
rename from sw/airborne/arch/lpc21/servos_4015_MAT_hw.c
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_MAT_hw.c
index cf254ffc59..5c777f8235 100644
--- a/sw/airborne/arch/lpc21/servos_4015_MAT_hw.c
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_MAT_hw.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* Copyright (C) 2006 Antoine Drouin
*
* This file is part of paparazzi.
@@ -27,7 +25,7 @@
*/
-#include "actuators.h"
+#include "subsystems/actuators.h"
#include "paparazzi.h"
#include "generated/airframe.h"
@@ -36,7 +34,7 @@ uint32_t servos_delay = SERVO_REFRESH_TICS;
#define START_TIMEOUT 0xFFFF;
-void actuators_init ( void ) {
+void actuators_4015_init ( void ) {
/* select clock pin as MAT0.1 output */
IO0DIR |= _BV(SERVO_CLOCK_PIN);
SERVO_CLOCK_PINSEL |= SERVO_CLOCK_PINSEL_VAL << SERVO_CLOCK_PINSEL_BIT;
diff --git a/sw/airborne/arch/lpc21/servos_4015_MAT_hw.h b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_MAT_hw.h
similarity index 91%
rename from sw/airborne/arch/lpc21/servos_4015_MAT_hw.h
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_MAT_hw.h
index d157e86bda..9e69bb07d5 100644
--- a/sw/airborne/arch/lpc21/servos_4015_MAT_hw.h
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_MAT_hw.h
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* Copyright (C) 2006 Antoine Drouin
*
* This file is part of paparazzi.
@@ -42,9 +40,11 @@
#define _4015_NB_CHANNELS 8
extern uint16_t servos_values[_4015_NB_CHANNELS];
-#define Actuator(i) servos_values[i]
+#define Actuator4015Set(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
-#define ActuatorsCommit() {}
+extern void actuators_4015_init(void);
+#define Actuators4015Commit() {}
+#define Actuators4015Init() actuators_4015_init()
extern uint8_t servos_4015_idx;
extern uint32_t servos_delay;
diff --git a/sw/airborne/arch/lpc21/servos_4015_hw.c b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw.c
similarity index 77%
rename from sw/airborne/arch/lpc21/servos_4015_hw.c
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw.c
index 60eeb6af5e..836d37829a 100644
--- a/sw/airborne/arch/lpc21/servos_4015_hw.c
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw.c
@@ -1,4 +1,25 @@
-#include "actuators.h"
+/*
+ * Copyright (C) 2006 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 "subsystems/actuators.h"
#include "armVIC.h"
#include "generated/airframe.h"
@@ -19,7 +40,7 @@ uint16_t servos_values[_4015_NB_CHANNELS];
#define PWMIR_MRI_SERV1 PWMIR_MR2I
-void actuators_init ( void ) {
+void actuators_4015_init ( void ) {
/* PWM selected as IRQ */
VICIntSelect &= ~VIC_BIT(VIC_PWM);
/* PWM interrupt enabled */
diff --git a/sw/airborne/arch/lpc21/servos_4015_hw.h b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw.h
similarity index 79%
rename from sw/airborne/arch/lpc21/servos_4015_hw.h
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw.h
index 60fe1593a0..cf5574ae39 100644
--- a/sw/airborne/arch/lpc21/servos_4015_hw.h
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw.h
@@ -35,9 +35,11 @@
#define _4015_NB_CHANNELS 8
extern uint16_t servos_values[_4015_NB_CHANNELS];
-#define Actuator(i) servos_values[i]
+#define Actuator4015Set(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
-#define ActuatorsCommit() {}
+extern void actuators_4015_init(void);
+#define Actuators4015Commit() {}
+#define Actuators4015Init() actuators_4015_init()
void PWM_ISR ( void ) __attribute__((naked));
diff --git a/sw/airborne/arch/lpc21/servos_4015_hw_new.c b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw_new.c
similarity index 82%
rename from sw/airborne/arch/lpc21/servos_4015_hw_new.c
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw_new.c
index 8a31b359b5..fdbc695682 100644
--- a/sw/airborne/arch/lpc21/servos_4015_hw_new.c
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4015_hw_new.c
@@ -1,4 +1,25 @@
-#include "actuators.h"
+/*
+ * Copyright (C) 2006 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 "subsystems/actuators.h"
#include "armVIC.h"
#include "generated/airframe.h"
@@ -19,7 +40,7 @@ uint16_t servos_values[_4015_NB_CHANNELS];
#define PWMIR_MRI_SERV1 PWMIR_MR2I
-void actuators_init ( void ) {
+void actuators_4015_init ( void ) {
/* PWM selected as IRQ */
VICIntSelect &= ~VIC_BIT(VIC_PWM);
/* PWM interrupt enabled */
diff --git a/sw/airborne/arch/lpc21/servos_4017_hw.c b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4017_hw.c
similarity index 64%
rename from sw/airborne/arch/lpc21/servos_4017_hw.c
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4017_hw.c
index 72022c414e..20a7d63b16 100644
--- a/sw/airborne/arch/lpc21/servos_4017_hw.c
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4017_hw.c
@@ -1,4 +1,25 @@
-#include "actuators.h"
+/*
+ * Copyright (C) 2006 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 "subsystems/actuators.h"
#include "paparazzi.h"
#include "generated/airframe.h"
@@ -7,7 +28,7 @@ uint8_t servos_4017_idx;
#define START_TIMEOUT 0xFFFF;
-void actuators_init ( void ) {
+void actuators_4017_init ( void ) {
/* select clock pin as MAT0.1 output */
IO0DIR |= _BV(SERVO_CLOCK_PIN);
SERVO_CLOCK_PINSEL |= SERVO_CLOCK_PINSEL_VAL << SERVO_CLOCK_PINSEL_BIT;
diff --git a/sw/airborne/arch/lpc21/servos_4017_hw.h b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4017_hw.h
similarity index 69%
rename from sw/airborne/arch/lpc21/servos_4017_hw.h
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_4017_hw.h
index 9f2989c791..e131ad18e5 100644
--- a/sw/airborne/arch/lpc21/servos_4017_hw.h
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_4017_hw.h
@@ -1,3 +1,25 @@
+/*
+ * Copyright (C) 2012 ENAC
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
#ifndef SERVOS_4017_HW_H
#define SERVOS_4017_HW_H
@@ -19,9 +41,11 @@
#endif
extern uint16_t servos_values[_4017_NB_CHANNELS];
-#define Actuator(i) servos_values[i]
+#define Actuator4017Set(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
-#define ActuatorsCommit() {}
+extern void actuators_4017_init(void);
+#define Actuators4017Commit() {}
+#define Actuators4017Init() actuators_4017_init()
extern uint8_t servos_4017_idx;
diff --git a/sw/airborne/arch/lpc21/servos_ppm_hw.c b/sw/airborne/arch/lpc21/subsystems/actuators/servos_ppm_hw.c
similarity index 96%
rename from sw/airborne/arch/lpc21/servos_ppm_hw.c
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_ppm_hw.c
index 6162f48f9f..5a5271e504 100644
--- a/sw/airborne/arch/lpc21/servos_ppm_hw.c
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_ppm_hw.c
@@ -26,7 +26,7 @@
* \ for a R/C receiver which has a microcontroller to drive the servos
* \(not a 4015 or 4017 decade counter chip).
*/
-#include "actuators.h"
+#include "subsystems/actuators.h"
#include "paparazzi.h"
#include "generated/airframe.h"
@@ -36,7 +36,7 @@ uint32_t servos_delay = SERVO_REFRESH_TICS;
#define START_TIMEOUT 0xFFFF;
-void actuators_init ( void ) {
+void actuators_ppm_init ( void ) {
/* select ppm output pin as MAT0.1 output */
SERVO_CLOCK_PINSEL |= SERVO_CLOCK_PINSEL_VAL << SERVO_CLOCK_PINSEL_BIT;
diff --git a/sw/airborne/arch/lpc21/servos_ppm_hw.h b/sw/airborne/arch/lpc21/subsystems/actuators/servos_ppm_hw.h
similarity index 93%
rename from sw/airborne/arch/lpc21/servos_ppm_hw.h
rename to sw/airborne/arch/lpc21/subsystems/actuators/servos_ppm_hw.h
index eb40c18d25..2396622395 100644
--- a/sw/airborne/arch/lpc21/servos_ppm_hw.h
+++ b/sw/airborne/arch/lpc21/subsystems/actuators/servos_ppm_hw.h
@@ -40,9 +40,11 @@
#define _PPM_NB_CHANNELS 8
extern uint16_t servos_values[_PPM_NB_CHANNELS];
-#define Actuator(i) servos_values[i]
+#define ActuatorPpmSet(_i, _v) { servos_values[_i] = SERVOS_TICS_OF_USEC(_v); }
-#define ActuatorsCommit() {}
+extern void actuators_ppm_init(void);
+#define ActuatorsPpmCommit() {}
+#define ActuatorsPpmInit() actuators_ppm_init()
extern uint8_t servos_PPM_idx;
extern uint32_t servos_delay;
extern uint8_t ppm_pulse; /* 1=start of pulse, 0=end of pulse */
diff --git a/sw/airborne/arch/omap/mcu_periph/uart_arch.c b/sw/airborne/arch/omap/mcu_periph/uart_arch.c
index ff5f49445e..ebbce01fa4 100644
--- a/sw/airborne/arch/omap/mcu_periph/uart_arch.c
+++ b/sw/airborne/arch/omap/mcu_periph/uart_arch.c
@@ -32,7 +32,7 @@
#include "fms/fms_serial_port.h"
-void uart_periph_set_baudrate(struct uart_periph* p, uint16_t baud) {
+void uart_periph_set_baudrate(struct uart_periph* p, uint16_t baud, bool_t hw_flow_control __attribute__ ((unused))) {
struct FmsSerialPort* fmssp;
// close serial port if already open
if (p->reg_addr != NULL) {
diff --git a/sw/airborne/arch/sim/jsbsim_hw.h b/sw/airborne/arch/sim/jsbsim_hw.h
index fa32784663..27406b89a6 100644
--- a/sw/airborne/arch/sim/jsbsim_hw.h
+++ b/sw/airborne/arch/sim/jsbsim_hw.h
@@ -40,7 +40,7 @@
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
#include "firmwares/fixedwing/guidance/guidance_v.h"
#include "subsystems/sensors/infrared.h"
-#include "commands.h"
+#include "subsystems/commands.h"
#include "firmwares/fixedwing/main_ap.h"
#include "ap_downlink.h"
#include "sim_uart.h"
diff --git a/sw/airborne/arch/sim/sim_ap.c b/sw/airborne/arch/sim/sim_ap.c
index 7eaffac836..4a9a2ec3c4 100644
--- a/sw/airborne/arch/sim/sim_ap.c
+++ b/sw/airborne/arch/sim/sim_ap.c
@@ -18,7 +18,7 @@
#include "subsystems/nav.h"
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
#include "firmwares/fixedwing/guidance/guidance_v.h"
-#include "commands.h"
+#include "subsystems/commands.h"
#include "firmwares/fixedwing/main_ap.h"
#include "ap_downlink.h"
#include "sim_uart.h"
diff --git a/sw/airborne/arch/sim/sim_gps.c b/sw/airborne/arch/sim/sim_gps.c
index 4c8d0cfa93..75ded9ea8b 100644
--- a/sw/airborne/arch/sim/sim_gps.c
+++ b/sw/airborne/arch/sim/sim_gps.c
@@ -7,7 +7,6 @@
/** From airborne/autopilot/ */
#include "generated/airframe.h"
#include "generated/flight_plan.h"
-#include "autopilot.h"
#include "subsystems/gps.h"
#include "math/pprz_geodetic_float.h"
#include "math/pprz_geodetic_int.h"
diff --git a/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.c b/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.c
index cb0f4faf31..ad6b754f91 100644
--- a/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.c
+++ b/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.c
@@ -23,12 +23,9 @@
* dummy servos handling for sim
*/
-#include "subsystems/actuators/actuators_pwm.h"
+#include "subsystems/actuators/actuators_pwm_arch.h"
void actuators_pwm_arch_init(void) {
}
-void actuators_pwm_commit(void) {
-
-}
diff --git a/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.h b/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.h
index 1c2f9ea167..02c159b6b0 100644
--- a/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.h
+++ b/sw/airborne/arch/sim/subsystems/actuators/actuators_pwm_arch.h
@@ -26,17 +26,11 @@
#ifndef ACTUATORS_PWM_ARCH_H
#define ACTUATORS_PWM_ARCH_H
-#define ACTUATORS_PWM_NB 8
+#define SERVOS_TICS_OF_USEC(_v) (_v)
-/* Needs to be included after ACTUATORS_PWM_NB is defined!
- * Otherwise ACTUATORS_PWM_NB is not declared in actuators_pwm.h
- */
-#include "subsystems/actuators/actuators_pwm.h"
+#define ActuatorPwmSet(_i, _v) {}
+#define ActuatorsPwmCommit() {}
extern void actuators_pwm_arch_init(void);
-extern void actuators_pwm_commit(void);
-
-#define SERVOS_TICS_OF_USEC(_v) (_v)
-#define ActuatorsCommit() {}
#endif /* ACTUATORS_PWM_ARCH_H */
diff --git a/sw/airborne/modules/drop/booz_drop.h b/sw/airborne/arch/sim/subsystems/actuators/servos_4015_MAT_hw.h
similarity index 69%
rename from sw/airborne/modules/drop/booz_drop.h
rename to sw/airborne/arch/sim/subsystems/actuators/servos_4015_MAT_hw.h
index c1b0182305..f3e00e1822 100644
--- a/sw/airborne/modules/drop/booz_drop.h
+++ b/sw/airborne/arch/sim/subsystems/actuators/servos_4015_MAT_hw.h
@@ -1,7 +1,5 @@
/*
- * $Id: $
- *
- * Copyright (C) 2009 Flixr
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -19,20 +17,17 @@
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
+ *
*/
+#ifndef SERVOS_4015_HW_H
+#define SERVOS_4015_HW_H
-#ifndef BOOZ_DROP_H
-#define BOOZ_DROP_H
+#define SERVOS_TICS_OF_USEC(_v) (_v)
-#include "std.h"
+#define Actuator4015Set(_i, _v) {}
+#define Actuators4015Init() {}
+#define Actuators4015Commit() {}
-extern bool_t booz_drop_ball;
+#endif
-extern void booz_drop_init(void);
-extern void booz_drop_periodic(void);
-
-#define NavDropNow() ({ booz_drop_ball = TRUE; FALSE; })
-#define NavDropClose() ({ booz_drop_ball = FALSE; FALSE; })
-
-#endif /* BOOZ_DROP_H */
diff --git a/sw/airborne/firmwares/rotorcraft/actuators.h b/sw/airborne/arch/sim/subsystems/actuators/servos_4017_hw.h
similarity index 73%
rename from sw/airborne/firmwares/rotorcraft/actuators.h
rename to sw/airborne/arch/sim/subsystems/actuators/servos_4017_hw.h
index e8d0c056d1..fad3ed1c7f 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators.h
+++ b/sw/airborne/arch/sim/subsystems/actuators/servos_4017_hw.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2012 The Paparazzi Team
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -17,20 +17,18 @@
* 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.
+ *
*/
-/** @file actuators.h
- * Generic Actuators API.
- */
+#ifndef SERVOS_4017_HW_H
+#define SERVOS_4017_HW_H
-#ifndef ACTUATORS_H
-#define ACTUATORS_H
+#define SERVOS_TICS_OF_USEC(_v) (_v)
-//#include ACTUATORS
+#define Actuator4017Set(_i, _v) {}
+#define Actuators4017Init() {}
+#define Actuators4017Commit() {}
-#include "std.h"
+#endif
-extern void actuators_init(void);
-extern void actuators_set(bool_t motors_on);
-#endif /* ACTUATORS_H */
diff --git a/sw/airborne/firmwares/rotorcraft/commands.c b/sw/airborne/arch/sim/subsystems/actuators/servos_ppm_hw.h
similarity index 76%
rename from sw/airborne/firmwares/rotorcraft/commands.c
rename to sw/airborne/arch/sim/subsystems/actuators/servos_ppm_hw.h
index a07e5fe486..63f8d5eeda 100644
--- a/sw/airborne/firmwares/rotorcraft/commands.c
+++ b/sw/airborne/arch/sim/subsystems/actuators/servos_ppm_hw.h
@@ -1,6 +1,5 @@
-/* $Id$
- *
- * (c) 2009 Antoine Drouin
+/*
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -18,9 +17,18 @@
* 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 "firmwares/rotorcraft/commands.h"
+#ifndef SERVOS_PPM_HW_H
+#define SERVOS_PPM_HW_H
+
+#define SERVOS_TICS_OF_USEC(_v) (_v)
+
+#define ActuatorPpmSet(_i, _v) {}
+#define ActuatorsPpmInit() {}
+#define ActuatorsPpmCommit() {}
+
+#endif
+
-int32_t commands[COMMANDS_NB];
-const int32_t commands_failsafe[COMMANDS_NB] = COMMANDS_FAILSAFE;
diff --git a/sw/airborne/arch/stm32/mcu_periph/adc_arch.c b/sw/airborne/arch/stm32/mcu_periph/adc_arch.c
index 147fe0da47..84bcf37315 100644
--- a/sw/airborne/arch/stm32/mcu_periph/adc_arch.c
+++ b/sw/airborne/arch/stm32/mcu_periph/adc_arch.c
@@ -96,7 +96,7 @@
void adc1_2_isr(void);
-uint8_t adc_new_data_trigger;
+volatile uint8_t adc_new_data_trigger;
/* Static functions */
@@ -312,80 +312,62 @@ static inline void adc_init_single(uint32_t adc,
}
/* Configure ADC */
- //adc_reset(adc);
- /* XXX: This register fiddeling code should be moved to libopencm3! */
+ /* Explicitly setting most registers, reset/default values are correct for most */
+
/* Set CR1 register. */
- {
- uint32_t tmpreg = ADC_CR1(adc);
- /* Clear DUALMOD and SCAN. */
- tmpreg &= ~(ADC_CR1_DUALMOD_MASK | ADC_CR1_SCAN);
-
- /* Set correct DUALMOD and SCAN. */
- tmpreg |= ADC_CR1_DUALMOD_IND | ADC_CR1_SCAN;
-
- ADC_CR1(adc) = tmpreg;
- }
+ /* Clear AWDEN */
+ adc_disable_analog_watchdog_regular(adc);
+ /* Clear JAWDEN */
+ adc_disable_analog_watchdog_injected(adc);
+ /* Clear DISCEN */
+ adc_disable_discontinuous_mode_regular(adc);
+ /* Clear JDISCEN */
+ adc_disable_discontinuous_mode_injected(adc);
+ /* Clear JAUTO */
+ adc_disable_automatic_injected_group_conversion(adc);
+ /* Set SCAN */
+ adc_enable_scan_mode(adc);
+ /* Enable ADC JEOC interrupt (Set JEOCIE) */
+ adc_enable_eoc_interrupt_injected(adc);
+ /* Clear AWDIE */
+ adc_disable_awd_interrupt(adc);
+ /* Clear EOCIE */
+ adc_disable_eoc_interrupt(adc);
/* Set CR2 register. */
- {
- uint32_t tmpreg = ADC_CR2(adc);
- /* Clear CONT, ALIGN and EXTSEL. */
- tmpreg &= ~(ADC_CR2_CONT | ADC_CR2_ALIGN | ADC_CR2_EXTSEL_MASK);
-
- /* Set correct CONT, ALIGN and EXTSEL. */
- tmpreg |= ADC_CR2_EXTSEL_SWSTART;
-
- ADC_CR2(adc) = tmpreg;
- }
-
- /* Set SQR1 register. */
- {
- uint32_t tmpreg = ADC_SQR1(adc);
-
- /* Clear regular channel sequence length. */
- tmpreg &= ~(0xF); //~(ADC_SQR1_L_MSK);
-
- /* Set regular channel sequence length. */
- tmpreg |= 0;
-
- ADC_SQR1(adc) = tmpreg;
- }
-
- /* Set JSQR1 injected sequence length. */
- {
- uint32_t tmpreg = ADC_JSQR(adc);
-
- /* Clear injected channel sequence length. */
- tmpreg &= ~(0x2 << 20); //~(ADC_JSQR_JL_MSK);
-
- /* Set injected channel sequence length. */
- tmpreg |= (num_channels << ADC_JSQR_JL_LSB);
-
- ADC_JSQR(adc) = tmpreg;
- }
+ /* Clear TSVREFE */
+ adc_disable_temperature_sensor(adc);
+ /* Clear EXTTRIG */
+ adc_disable_external_trigger_regular(adc);
+ /* Clear ALIGN */
+ adc_set_right_aligned(adc);
+ /* Clear DMA */
+ adc_disable_dma(adc);
+ /* Clear CONT */
+ adc_set_single_conversion_mode(adc);
rank = 0;
if (chan1) {
- adc_set_conversion_time(adc, adc_channel_map[0], ADC_SMPR1_SMP_41DOT5CYC);
- channels[rank] = adc_channel_map[0];
+ adc_set_sample_time(adc, adc_channel_map[0], ADC_SMPR1_SMP_41DOT5CYC);
+ channels[rank] = adc_channel_map[0];
rank++;
}
if (chan2) {
- adc_set_conversion_time(adc, adc_channel_map[1], ADC_SMPR1_SMP_41DOT5CYC);
- channels[rank] = adc_channel_map[1];
+ adc_set_sample_time(adc, adc_channel_map[1], ADC_SMPR1_SMP_41DOT5CYC);
+ channels[rank] = adc_channel_map[1];
rank++;
}
if (chan3) {
- adc_set_conversion_time(adc, adc_channel_map[2], ADC_SMPR1_SMP_41DOT5CYC);
- channels[rank] = adc_channel_map[2];
+ adc_set_sample_time(adc, adc_channel_map[2], ADC_SMPR1_SMP_41DOT5CYC);
+ channels[rank] = adc_channel_map[2];
rank++;
}
if (chan4) {
- adc_set_conversion_time(adc, adc_channel_map[3], ADC_SMPR1_SMP_41DOT5CYC);
- channels[rank] = adc_channel_map[3];
+ adc_set_sample_time(adc, adc_channel_map[3], ADC_SMPR1_SMP_41DOT5CYC);
+ channels[rank] = adc_channel_map[3];
}
adc_set_injected_sequence(adc, num_channels, channels);
@@ -398,15 +380,11 @@ static inline void adc_init_single(uint32_t adc,
adc_enable_external_trigger_injected(adc, ADC_CR2_JEXTSEL_TIM2_TRGO);
#endif
- /* Enable ADC JEOC interrupt */
- adc_enable_jeoc_interrupt(adc);
-
/* Enable ADC */
- adc_on(adc);
+ adc_power_on(adc);
/* Enable ADC reset calibaration register */
adc_reset_calibration(adc);
-
/* Check the end of ADC reset calibration */
while ((ADC_CR2(adc) & ADC_CR2_RSTCAL) != 0);
/* Start ADC calibaration */
diff --git a/sw/airborne/arch/stm32/mcu_periph/uart_arch.c b/sw/airborne/arch/stm32/mcu_periph/uart_arch.c
index 130601e581..75eddfd531 100644
--- a/sw/airborne/arch/stm32/mcu_periph/uart_arch.c
+++ b/sw/airborne/arch/stm32/mcu_periph/uart_arch.c
@@ -29,15 +29,22 @@
#include
#include "std.h"
-void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) {
+void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud, bool_t hw_flow_control) {
/* Configure USART */
usart_set_baudrate((u32)p->reg_addr, baud);
usart_set_databits((u32)p->reg_addr, 8);
usart_set_stopbits((u32)p->reg_addr, USART_STOPBITS_1);
usart_set_parity((u32)p->reg_addr, USART_PARITY_NONE);
- usart_set_flow_control((u32)p->reg_addr, USART_FLOWCONTROL_NONE);
usart_set_mode((u32)p->reg_addr, USART_MODE_TX_RX);
+
+ if (hw_flow_control) {
+ usart_set_flow_control((u32)p->reg_addr, USART_FLOWCONTROL_RTS_CTS);
+ }
+ else {
+ usart_set_flow_control((u32)p->reg_addr, USART_FLOWCONTROL_NONE);
+ }
+
/* Enable USART1 Receive interrupts */
USART_CR1((u32)p->reg_addr) |= USART_CR1_RXNEIE;
@@ -126,8 +133,19 @@ void uart1_init( void ) {
gpio_set_mode(GPIO_BANK_USART1_RX, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_FLOAT, GPIO_USART1_RX);
- /* Configure USART */
- uart_periph_set_baudrate(&uart1, UART1_BAUD);
+#if UART1_HW_FLOW_CONTROL
+#warning "USING UART1 FLOW CONTROL. Make sure to pull down CTS if you are not connecting any flow-control-capable hardware."
+ gpio_set_mode(GPIO_BANK_USART1_RTS, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART1_RTS);
+ gpio_set_mode(GPIO_BANK_USART1_CTS, GPIO_MODE_INPUT,
+ GPIO_CNF_INPUT_FLOAT, GPIO_USART1_CTS);
+
+ /* Configure USART1, enable hardware flow control*/
+ uart_periph_set_baudrate(&uart1, UART1_BAUD, TRUE);
+#else
+ /* Configure USART1, no flow control */
+ uart_periph_set_baudrate(&uart1, UART1_BAUD, FALSE);
+#endif
}
void usart1_isr(void) { usart_isr(&uart1); }
@@ -155,7 +173,7 @@ void uart2_init( void ) {
GPIO_CNF_INPUT_FLOAT, GPIO_USART2_RX);
/* Configure USART */
- uart_periph_set_baudrate(&uart2, UART2_BAUD);
+ uart_periph_set_baudrate(&uart2, UART2_BAUD, FALSE);
}
void usart2_isr(void) { usart_isr(&uart2); }
@@ -185,7 +203,7 @@ void uart3_init( void ) {
GPIO_CNF_INPUT_FLOAT, GPIO_USART3_PR_RX);
/* Configure USART */
- uart_periph_set_baudrate(&uart3, UART3_BAUD);
+ uart_periph_set_baudrate(&uart3, UART3_BAUD, FALSE);
}
void usart3_isr(void) { usart_isr(&uart3); }
@@ -214,7 +232,7 @@ void uart5_init( void ) {
GPIO_CNF_INPUT_FLOAT, GPIO_UART5_RX);
/* Configure USART */
- uart_periph_set_baudrate(&uart5, UART5_BAUD);
+ uart_periph_set_baudrate(&uart5, UART5_BAUD, FALSE);
}
void uart5_isr(void) { usart_isr(&uart5); }
diff --git a/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.c b/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.c
index 0af66ccff6..c8c8b0b1e2 100644
--- a/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.c
+++ b/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.c
@@ -23,13 +23,15 @@
* STM32 PWM servos handling.
*/
-#include "actuators.h"
#include "subsystems/actuators/actuators_pwm_arch.h"
+#include "subsystems/actuators/actuators_pwm.h"
#include
#include
#include
+int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
+
#define PCLK 72000000
#define ONE_MHZ_CLK 1000000
#ifndef SERVO_HZ
diff --git a/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.h b/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.h
index c2f0e4227e..e81fd46c41 100644
--- a/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.h
+++ b/sw/airborne/arch/stm32/subsystems/actuators/actuators_pwm_arch.h
@@ -38,15 +38,13 @@
#define ACTUATORS_PWM_NB 6
#endif
-/* Needs to be included after ACTUATORS_PWM_NB is defined!
- * Otherwise ACTUATORS_PWM_NB is not declared in actuators_pwm.h
- */
-#include "subsystems/actuators/actuators_pwm.h"
+extern int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
-extern void actuators_pwm_arch_init(void);
extern void actuators_pwm_commit(void);
#define SERVOS_TICS_OF_USEC(_v) (_v)
-#define ActuatorsCommit actuators_pwm_commit
+
+#define ActuatorPwmSet(_i, _v) { actuators_pwm_values[_i] = _v; }
+#define ActuatorsPwmCommit actuators_pwm_commit
#endif /* ACTUATORS_PWM_ARCH_H */
diff --git a/sw/airborne/boards/booz_1.0.h b/sw/airborne/boards/booz_1.0.h
index 0c110c2f7d..350d870054 100644
--- a/sw/airborne/boards/booz_1.0.h
+++ b/sw/airborne/boards/booz_1.0.h
@@ -163,26 +163,24 @@
#define MS2100_DRDY_EINT 3
#define MS2100_DRDY_VIC_IT VIC_EINT3
-/* PWM5 on CAM connector */
-/* P0.21 */
-#define PWM0_PINSEL PINSEL1
-#define PWM0_PINSEL_VAL 0x01
-#define PWM0_PINSEL_BIT 10
-/* PWM2 on SPI connector */
-/* P0.7 */
-#define PWM1_PINSEL PINSEL0
-#define PWM1_PINSEL_VAL 0x02
-#define PWM1_PINSEL_BIT 14
+/* Servo definition for actruators_pwm driver */
+
+/* BOOZ PWM0 = PWM_SERVO_5 (driver) = PWM5 (lpc)
+ * on CAM connector */
+#if USE_PWM0
+#define PWM_SERVO_5 1
+#define SERVO_REG_0 PWMMR5
+#endif
+
+/* BOOZ PWM1 = PWM_SERVO_2 (driver) = PWM2 (lpc)
+ * on SPI connector */
+#if USE_PWM1
+#define PWM_SERVO_2 1
+#define SERVO_REG_1 PWMMR2
+#endif
#define BOARD_HAS_BARO 1
-/*
- * Modem
- */
-//#define MODEM_DEVICE Uart1
-//#define MODEM_UART_FLAG
-
-
#endif /* CONFIG_BOOZ2_V1_0_H */
diff --git a/sw/airborne/boards/classix_1.0.h b/sw/airborne/boards/classix_1.0.h
index fd21440500..ee7d102c04 100644
--- a/sw/airborne/boards/classix_1.0.h
+++ b/sw/airborne/boards/classix_1.0.h
@@ -46,7 +46,13 @@
#define PPM_CCR_CRI TCCR_CR2_I
#define PPM_CR T0CR2
-/* SERVOS : 4017 on FBW_RC0 connector */
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
+#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
+#define ActuatorsDefaultInit() ActuatorsPwmInit()
+#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
+
+/* SERVOS : 4017 on FBW_RC0 connector (ppm driver) */
/* MAT0.1 on P0.5 */
#define SERVO_CLOCK_PIN 5
diff --git a/sw/airborne/boards/lisa_l_1.0.h b/sw/airborne/boards/lisa_l_1.0.h
index 0bfed3a280..b324f421f8 100644
--- a/sw/airborne/boards/lisa_l_1.0.h
+++ b/sw/airborne/boards/lisa_l_1.0.h
@@ -21,6 +21,12 @@
#define IMU_ACC_DRDY_GPIO GPIOD
#define IMU_ACC_DRDY_GPIO_PORTSOURCE GPIO_PortSourceGPIOD
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
+#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
+#define ActuatorsDefaultInit() ActuatorsPwmInit()
+#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
+
/* PA0 - ADC0 */
/* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
diff --git a/sw/airborne/boards/lisa_m_1.0.h b/sw/airborne/boards/lisa_m_1.0.h
index add01752b1..b48dc45b0a 100644
--- a/sw/airborne/boards/lisa_m_1.0.h
+++ b/sw/airborne/boards/lisa_m_1.0.h
@@ -59,6 +59,12 @@
#define IMU_ACC_DRDY_GPIO_PORTSOURCE GPIO_PortSourceGPIOB
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
+#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
+#define ActuatorsDefaultInit() ActuatorsPwmInit()
+#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
+
#define DefaultVoltageOfAdc(adc) (0.00485*adc)
diff --git a/sw/airborne/boards/lisa_m_2.0.h b/sw/airborne/boards/lisa_m_2.0.h
index 2d411960cd..a43720622d 100644
--- a/sw/airborne/boards/lisa_m_2.0.h
+++ b/sw/airborne/boards/lisa_m_2.0.h
@@ -95,6 +95,12 @@
#define IMU_ACC_DRDY_GPIO_PORTSOURCE GPIO_PortSourceGPIOB
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
+#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
+#define ActuatorsDefaultInit() ActuatorsPwmInit()
+#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
+
#define DefaultVoltageOfAdc(adc) (0.0045*adc)
diff --git a/sw/airborne/boards/navgo_1.0.h b/sw/airborne/boards/navgo_1.0.h
index 95d7f17914..015b51d428 100644
--- a/sw/airborne/boards/navgo_1.0.h
+++ b/sw/airborne/boards/navgo_1.0.h
@@ -54,7 +54,7 @@
/* ADC */
-/* not compatible with PWM0 */
+/* not compatible with PWM1 */
#define ADC_0 AdcBank1(6)
#ifdef USE_ADC_0
#ifndef USE_AD1
@@ -91,18 +91,19 @@
#define SPI1_DRDY_EINT 0
#define SPI1_DRDY_VIC_IT VIC_EINT0
-/* PWM0 (internal PWM2) */
-/* P0.7 */
-#define PWM0_PINSEL PINSEL0
-#define PWM0_PINSEL_VAL 0x02
-#define PWM0_PINSEL_BIT 14
+/* Servo definition for actruators_pwm driver */
-/* PWM1 (internal PWM5) */
-/* not compatible with ADC_0 */
-/* P0.21 */
-#define PWM1_PINSEL PINSEL1
-#define PWM1_PINSEL_VAL 0x01
-#define PWM1_PINSEL_BIT 10
+/* NAVGO PWM0 = PWM_SERVO_2 (driver) = PWM2 (lpc) */
+#if USE_PWM0
+#define PWM_SERVO_2 1
+#define SERVO_REG_0 PWMMR2
+#endif
+
+/* NAVGO PWM1 = PWM_SERVO_5 (driver) = PWM5 (lpc) */
+#if USE_PWM1
+#define PWM_SERVO_5 1
+#define SERVO_REG_1 PWMMR5
+#endif
#define BOARD_HAS_BARO 1
diff --git a/sw/airborne/boards/tiny_0.99.h b/sw/airborne/boards/tiny_0.99.h
index b6915b33eb..6aed88d605 100644
--- a/sw/airborne/boards/tiny_0.99.h
+++ b/sw/airborne/boards/tiny_0.99.h
@@ -35,6 +35,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 19
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4015.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4015Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4015Init()
+#define ActuatorsDefaultCommit() Actuators4015Commit()
+
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
diff --git a/sw/airborne/boards/tiny_1.1.h b/sw/airborne/boards/tiny_1.1.h
index d76d4aa61e..a589957443 100644
--- a/sw/airborne/boards/tiny_1.1.h
+++ b/sw/airborne/boards/tiny_1.1.h
@@ -46,6 +46,12 @@
#define POWER_SWITCH_LED 3
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4015.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4015Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4015Init()
+#define ActuatorsDefaultCommit() Actuators4015Commit()
+
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
diff --git a/sw/airborne/boards/tiny_2.0.h b/sw/airborne/boards/tiny_2.0.h
index ac512c8ea9..f828e60a83 100644
--- a/sw/airborne/boards/tiny_2.0.h
+++ b/sw/airborne/boards/tiny_2.0.h
@@ -49,6 +49,12 @@
#define POWER_SWITCH_LED 4
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4017Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4017Init()
+#define ActuatorsDefaultCommit() Actuators4017Commit()
+
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
diff --git a/sw/airborne/boards/tiny_2.1.h b/sw/airborne/boards/tiny_2.1.h
index 572f2b6cf0..bef470ba3a 100644
--- a/sw/airborne/boards/tiny_2.1.h
+++ b/sw/airborne/boards/tiny_2.1.h
@@ -86,6 +86,12 @@
#define Set_GPS_RESET_Pin_LOW() LED_ON(GPS_RESET)
#define Open_GPS_RESET_Pin() ClearBit(LED_DIR(GPS_RESET), LED_PIN(GPS_RESET))
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4017Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4017Init()
+#define ActuatorsDefaultCommit() Actuators4017Commit()
+
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
diff --git a/sw/airborne/boards/tiny_sim.h b/sw/airborne/boards/tiny_sim.h
index c3cb2f3b91..229028bfe3 100644
--- a/sw/airborne/boards/tiny_sim.h
+++ b/sw/airborne/boards/tiny_sim.h
@@ -29,6 +29,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 19
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4017Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4017Init()
+#define ActuatorsDefaultCommit() Actuators4017Commit()
+
/* p0.21 aka PWM5 */
#define SERV0_CLOCK_PIN 21
#define SERV0_CLOCK_PINSEL PINSEL1
diff --git a/sw/airborne/boards/umarim_1.0.h b/sw/airborne/boards/umarim_1.0.h
index f17d5df75d..c69e27da97 100644
--- a/sw/airborne/boards/umarim_1.0.h
+++ b/sw/airborne/boards/umarim_1.0.h
@@ -30,6 +30,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 24
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4017Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4017Init()
+#define ActuatorsDefaultCommit() Actuators4017Commit()
+
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
diff --git a/sw/airborne/boards/umarim_lite_2.0.h b/sw/airborne/boards/umarim_lite_2.0.h
index 2690f73c0c..6f023e5548 100644
--- a/sw/airborne/boards/umarim_lite_2.0.h
+++ b/sw/airborne/boards/umarim_lite_2.0.h
@@ -30,6 +30,12 @@
#define LED_2_BANK 1
#define LED_2_PIN 24
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_4017.h"
+#define ActuatorDefaultSet(_x,_y) Actuator4017Set(_x,_y)
+#define ActuatorsDefaultInit() Actuators4017Init()
+#define ActuatorsDefaultCommit() Actuators4017Commit()
+
/* P0.5 aka MAT0.1 */
#define SERVO_CLOCK_PIN 5
#define SERVO_CLOCK_PINSEL PINSEL0
diff --git a/sw/airborne/boards/yapa_2.0.h b/sw/airborne/boards/yapa_2.0.h
new file mode 100644
index 0000000000..9fc0a0163c
--- /dev/null
+++ b/sw/airborne/boards/yapa_2.0.h
@@ -0,0 +1,6 @@
+#include "boards/tiny_2.1.h"
+
+
+// ADC / 1023 * 3.3V * (10k + 1k5) / 1k5
+#undef DefaultVoltageOfAdc
+#define DefaultVoltageOfAdc(adc) (0.0247311828*adc)
diff --git a/sw/airborne/firmwares/beth/main_stm32.c b/sw/airborne/firmwares/beth/main_stm32.c
index af702db5ee..a1e1b7c8c8 100644
--- a/sw/airborne/firmwares/beth/main_stm32.c
+++ b/sw/airborne/firmwares/beth/main_stm32.c
@@ -28,7 +28,7 @@
#include "mcu_periph/can.h"
#include "mcu_periph/sys_time.h"
#include "subsystems/datalink/downlink.h"
-#include "firmwares/rotorcraft/commands.h"
+#include "subsystems/commands.h"
#include "firmwares/rotorcraft/actuators.h"
//#include "booz/booz_radio_control.h"
#include "subsystems/imu.h"
diff --git a/sw/airborne/arch/lpc21/modules/core/booz_pwm_arch.h b/sw/airborne/firmwares/fixedwing/autopilot.c
similarity index 57%
rename from sw/airborne/arch/lpc21/modules/core/booz_pwm_arch.h
rename to sw/airborne/firmwares/fixedwing/autopilot.c
index 567b5793fa..347cc80dbf 100644
--- a/sw/airborne/arch/lpc21/modules/core/booz_pwm_arch.h
+++ b/sw/airborne/firmwares/fixedwing/autopilot.c
@@ -1,7 +1,5 @@
/*
- * $Id: $
- *
- * Copyright (C) 2011 ENAC
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -22,25 +20,41 @@
*
*/
-#ifndef BOOZ_PWM_ARCH_H
-#define BOOZ_PWM_ARCH_H
+/** \file autopilot.c
+ * \brief Autopilot inititalization
+ *
+ */
-#include "std.h"
-#include "mcu_periph/sys_time.h"
+#include "firmwares/fixedwing/autopilot.h"
-extern void booz_pwm_init_arch(void);
+uint8_t pprz_mode;
+bool_t kill_throttle;
-// Default PWM is PWM0
-#define BoozSetPwmValue(_v) BoozSetPwm0Value(_v)
+bool_t launch;
+
+/** flight time in seconds. */
+uint16_t autopilot_flight_time;
+
+uint8_t lateral_mode;
+
+uint16_t vsupply;
+float energy;
+
+bool_t gps_lost;
+
+bool_t power_switch;
+
+void autopilot_init(void) {
+ pprz_mode = PPRZ_MODE_AUTO2;
+ kill_throttle = FALSE;
+ launch = FALSE;
+ autopilot_flight_time = 0;
+
+ lateral_mode = LATERAL_MODE_MANUAL;
+
+ gps_lost = FALSE;
+
+ power_switch = FALSE;
-#define BoozSetPwm0Value(_v) { \
- PWMMR5 = CPU_TICKS_OF_USEC(_v); \
- PWMLER = PWMLER_LATCH5; \
}
-#define BoozSetPwm1Value(_v) { \
- PWMMR2 = CPU_TICKS_OF_USEC(_v); \
- PWMLER = PWMLER_LATCH2; \
-}
-
-#endif /* BOOZ_PWM_ARCH_H */
diff --git a/sw/airborne/firmwares/fixedwing/autopilot.h b/sw/airborne/firmwares/fixedwing/autopilot.h
index bd8f20c1dd..65c9b3495b 100644
--- a/sw/airborne/firmwares/fixedwing/autopilot.h
+++ b/sw/airborne/firmwares/fixedwing/autopilot.h
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
*
* This file is part of paparazzi.
@@ -32,14 +30,23 @@
#include
#include "std.h"
+#include "paparazzi.h"
#include "mcu_periph/sys_time.h"
+#include "generated/airframe.h"
+
+/** Autopilot inititalization.
+ */
+extern void autopilot_init(void);
+
+/** Threshold for RC mode detection.
+ */
#define THRESHOLD_MANUAL_PPRZ (MIN_PPRZ / 2)
-
#define THRESHOLD1 THRESHOLD_MANUAL_PPRZ
#define THRESHOLD2 (MAX_PPRZ/2)
-
+/** AP modes.
+ */
#define PPRZ_MODE_MANUAL 0
#define PPRZ_MODE_AUTO1 1
#define PPRZ_MODE_AUTO2 2
@@ -57,6 +64,10 @@ extern bool_t kill_throttle;
/** flight time in seconds. */
extern uint16_t autopilot_flight_time;
+#define autopilot_ResetFlightTimeAndLaunch(_) { \
+ autopilot_flight_time = 0; launch = FALSE; \
+}
+
// FIXME, move to control
#define LATERAL_MODE_MANUAL 0
@@ -71,7 +82,14 @@ extern uint8_t lateral_mode;
#define THROTTLE_THRESHOLD_TAKEOFF (pprz_t)(MAX_PPRZ * 0.9)
-extern uint8_t vsupply;
+/** Supply voltage in deciVolt.
+ * This the ap copy of the measurement from fbw
+ */
+extern uint16_t vsupply;
+
+/** Fuel consumption (mAh)
+ * TODO: move to electrical subsystem
+ */
extern float energy;
extern bool_t launch;
@@ -85,6 +103,9 @@ extern bool_t gps_lost;
(_mode != new_mode ? _mode = new_mode, TRUE : FALSE); \
})
+
+/** Power switch control.
+ */
extern bool_t power_switch;
#ifdef POWER_SWITCH_LED
@@ -96,9 +117,6 @@ extern bool_t power_switch;
#define autopilot_SetPowerSwitch(_x) { power_switch = _x; }
#endif // POWER_SWITCH_LED
-#define autopilot_ResetFlightTimeAndLaunch(_) { \
- autopilot_flight_time = 0; launch = FALSE; \
-}
/* CONTROL_RATE will be removed in the next release
* please use CONTROL_FREQUENCY instead
diff --git a/sw/airborne/firmwares/fixedwing/fbw_downlink.h b/sw/airborne/firmwares/fixedwing/fbw_downlink.h
index 38609e9082..19947da37e 100644
--- a/sw/airborne/firmwares/fixedwing/fbw_downlink.h
+++ b/sw/airborne/firmwares/fixedwing/fbw_downlink.h
@@ -39,8 +39,8 @@
#include "messages.h"
#include "generated/periodic_telemetry.h"
#include "generated/airframe.h"
-#include "commands.h"
-#include "actuators.h"
+#include "subsystems/commands.h"
+#include "subsystems/actuators.h"
#include "mcu_periph/uart.h"
#include "firmwares/fixedwing/main_fbw.h"
@@ -78,7 +78,7 @@
#endif // RADIO_CONTROL
#ifdef ACTUATORS
-#define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, SERVOS_NB, actuators)
+#define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, ACTUATORS_NB, actuators)
#else
#define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
#endif
diff --git a/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.c b/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.c
index b3b68b6375..1373c0954b 100644
--- a/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.c
+++ b/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Pascal Brisset, Antoine Drouin, Michel Gorraz
+ * Copyright (C) 2012 TUDelft, Tobias Muench
*
* This file is part of paparazzi.
*
@@ -20,34 +20,45 @@
*/
/**
- * @file firmwares/fixedwing/guidance/guidance_v.c
- * Vertical control using total energy control for fixed wing vehicles.
+ * @file firmwares/fixedwing/guidance/energy_ctrl.c
+ * Total Energy (speed + height) control for fixed wing vehicles.
+ *
+ * Energy:
+ * @f{eqnarray*}{
+ * E &=& mgh + \frac{1}{2}mV^2 \\
+ * \frac{\dot{E}}{V} &=& \left(\gamma + \frac{\dot{V}}{g}\right) W
+ * @f}
+ *
+ * Equilibrium:
+ * @f[
+ * \frac{\dot{V}}{g} = \frac{\mbox{Thrust}}{W} - \frac{\mbox{Drag}}{W} - \sin(\gamma)
+ * @f]
+ * with:
+ * @f[
+ * \frac{\mbox{Drag}}{\mbox{Weight}} = \left(\frac{C_l}{C_d}\right)^{-1}
+ * @f]
+ *
+ * - glide angle: @f$\dot{V}=0, T=0 \rightarrow \gamma = \frac{C_d}{C_l}@f$
+ * - level flight: @f$\dot{V}=0, \gamma=0 \rightarrow \frac{W}{T} = \frac{C_l}{C_d}@f$
+ *
+ * Strategy:
+ * - thrust = path + acceleration[g] (total energy)
+ * - pitch = path - acceleration[g] (energy balance)
+ *
+ * Pseudo-Control Unit = dimensionless acceleration [g]
+ *
+ * - pitch <-> pseudocontrol: sin(Theta) steers Vdot in [g]
+ * - throttle <-> pseudocontrol: motor characteristic as function of V x throttle steeds VDot
+ *
+ * @dot
+ * digraph total_energy_control {
+ * node [shape=record];
+ * b [label="attitude loop" URL="\ref attitude_loop"];
+ * c [label="climb loop" URL="\ref v_ctl_climb_loop"];
+ * b -> c [ arrowhead="open", style="dashed" ];
+ * }
+ * @enddot
*
-
-
- =================================================
- Energy:
- ------
- E = mgh + 1/2mV^2
- Edot / V = (gamma + Vdot/g) * W
-
- equilibrium
-
- Vdot / g = Thrust/W - Drag/W - sin(gamma)
- with: Drag/Weight = (Cl/Cd)^-1
-
- -glide angle: Vdot = 0, T=0 ==> gamma = Cd/Cl
- -level flight: Vdot = 0, gamma=0 ==> W/T = Cl/Cd
- =================================================
-
- Strategy: thrust = path + acceleration[g] (total energy)
- pitch = path - acceleration[g] (energy balance)
-
- Pseudo-Control Unit = dimensionless acceleration [g]
-
- - pitch <-> pseudocontrol: sin(Theta) steers Vdot in [g]
- - throttle <-> pseudocontrol: motor characteristic as function of V x throttle steeds VDot
-
*/
#pragma message "CAUTION! Using TOTAL ENERGY CONTROLLER: Experimental!"
@@ -67,8 +78,6 @@ uint8_t v_ctl_mode = V_CTL_MODE_MANUAL;
uint8_t v_ctl_climb_mode = V_CTL_CLIMB_MODE_AUTO_THROTTLE;
uint8_t v_ctl_auto_throttle_submode = V_CTL_CLIMB_MODE_AUTO_THROTTLE;
float v_ctl_auto_throttle_sum_err = 0;
-float v_ctl_auto_airspeed_controlled = 0;
-float v_ctl_auto_groundspeed_setpoint = 0;
#ifdef LOITER_TRIM
#error "Energy Controller can not accep Loiter Trim"
@@ -85,9 +94,7 @@ float v_ctl_altitude_pgain;
float v_ctl_airspeed_pgain;
float v_ctl_altitude_error; ///< in meters, (setpoint - alt) -> positive = too low
-float v_ctl_auto_airspeed_setpoint; ///< in meters per second
-
-float v_ctl_max_climb = 2;
+float v_ctl_max_climb;
float v_ctl_max_acceleration = 0.5;
/* inner loop */
@@ -114,6 +121,19 @@ float v_ctl_energy_total_igain;
float v_ctl_energy_diff_pgain;
float v_ctl_energy_diff_igain;
+float v_ctl_auto_airspeed_setpoint; ///< in meters per second
+float v_ctl_auto_airspeed_setpoint_slew;
+#ifndef AIRSPEED_SETPOINT_SLEW
+#define AIRSPEED_SETPOINT_SLEW 1
+#endif
+float v_ctl_auto_airspeed_controlled;
+#ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
+float v_ctl_auto_groundspeed_setpoint; ///< in meters per second
+float v_ctl_auto_groundspeed_pgain;
+float v_ctl_auto_groundspeed_igain;
+float v_ctl_auto_groundspeed_sum_err;
+#define V_CTL_AUTO_GROUNDSPEED_MAX_SUM_ERR 100
+#endif
pprz_t v_ctl_throttle_setpoint;
pprz_t v_ctl_throttle_slewed;
@@ -170,16 +190,65 @@ void v_ctl_init( void ) {
/* outer loop */
v_ctl_altitude_setpoint = 0.;
+
+#ifdef V_CTL_ALTITUDE_PGAIN
v_ctl_altitude_pgain = V_CTL_ALTITUDE_PGAIN;
+#endif
+#ifdef V_CTL_AIRSPEED_PGAIN
+ v_ctl_airspeed_pgain = V_CTL_AIRSPEED_PGAIN;
+#endif
+
v_ctl_auto_airspeed_setpoint = NOMINAL_AIRSPEED;
+ v_ctl_auto_airspeed_setpoint_slew = v_ctl_auto_airspeed_setpoint;
+
/* inner loops */
v_ctl_climb_setpoint = 0.;
/* "auto throttle" inner loop parameters */
v_ctl_auto_throttle_nominal_cruise_throttle = V_CTL_AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE;
+
+#ifdef V_CTL_AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT
v_ctl_auto_throttle_climb_throttle_increment = V_CTL_AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT;
v_ctl_auto_throttle_pitch_of_vz_pgain = V_CTL_AUTO_THROTTLE_PITCH_OF_VZ_PGAIN;
+#endif
+
+#ifdef V_CTL_AUTO_THROTTLE_OF_AIRSPEED_PGAIN
+ v_ctl_auto_throttle_of_airspeed_pgain = V_CTL_AUTO_THROTTLE_OF_AIRSPEED_PGAIN;
+ v_ctl_auto_throttle_of_airspeed_igain = V_CTL_AUTO_THROTTLE_OF_AIRSPEED_IGAIN;
+#endif
+
+#ifdef V_CTL_AUTO_PITCH_OF_AIRSPEED_PGAIN
+ v_ctl_auto_pitch_of_airspeed_pgain = V_CTL_AUTO_PITCH_OF_AIRSPEED_PGAIN;
+ v_ctl_auto_pitch_of_airspeed_igain = V_CTL_AUTO_PITCH_OF_AIRSPEED_IGAIN;
+ v_ctl_auto_pitch_of_airspeed_dgain = V_CTL_AUTO_PITCH_OF_AIRSPEED_DGAIN;
+#endif
+
+
+#ifdef V_CTL_ENERGY_TOT_PGAIN
+ v_ctl_energy_total_pgain = V_CTL_ENERGY_TOT_PGAIN;
+ v_ctl_energy_total_igain = V_CTL_ENERGY_TOT_IGAIN;
+ v_ctl_energy_diff_pgain = V_CTL_ENERGY_DIFF_PGAIN;
+ v_ctl_energy_diff_igain = V_CTL_ENERGY_DIFF_IGAIN;
+#endif
+
+#ifdef V_CTL_ALTITUDE_MAX_CLIMB
+ v_ctl_max_climb = V_CTL_ALTITUDE_MAX_CLIMB;
+#else
+ v_ctl_max_climb = 2;
+#warning "V_CTL_ALTITUDE_MAX_CLIMB not defined - default is 2m/s"
+#endif
+
+#ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
+ v_ctl_auto_groundspeed_setpoint = V_CTL_AUTO_GROUNDSPEED_SETPOINT;
+ v_ctl_auto_groundspeed_pgain = V_CTL_AUTO_GROUNDSPEED_PGAIN;
+ v_ctl_auto_groundspeed_igain = V_CTL_AUTO_GROUNDSPEED_IGAIN;
+ v_ctl_auto_groundspeed_sum_err = 0.;
+#endif
+
+#ifndef STALL_AIRSPEED
+#define STALL_AIRSPEED NOMINAL_AIRSPEED
+#endif
v_ctl_throttle_setpoint = 0;
}
@@ -192,7 +261,7 @@ void v_ctl_init( void ) {
void v_ctl_altitude_loop( void )
{
// Imput Checks
- if (v_ctl_auto_airspeed_setpoint <= 0.0f) v_ctl_auto_airspeed_setpoint = NOMINAL_AIRSPEED;
+ if (v_ctl_auto_airspeed_setpoint <= STALL_AIRSPEED * 1.23) v_ctl_auto_airspeed_setpoint = STALL_AIRSPEED * 1.23;
// Altitude Controller
v_ctl_altitude_error = v_ctl_altitude_setpoint - stateGetPositionUtm_f()->alt;
@@ -228,8 +297,32 @@ static float low_pass_vdot(float v)
void v_ctl_climb_loop( void )
{
+#ifdef AIRSPEED_SETPOINT_SLEW
+ // airspeed_setpoint ratelimiter:
+ float airspeed_incr = v_ctl_auto_airspeed_setpoint - v_ctl_auto_airspeed_setpoint_slew; // FIXME
+ BoundAbs(airspeed_incr, AIRSPEED_SETPOINT_SLEW * NOMINAL_AIRSPEED);
+ v_ctl_auto_airspeed_setpoint_slew += airspeed_incr;
+#endif
+
+#ifdef V_CTL_AUTO_GROUNDSPEED_SETPOINT
+ // Ground speed control loop (input: groundspeed error, output: airspeed controlled)
+ float err_groundspeed = (v_ctl_auto_groundspeed_setpoint - (*stateGetHorizontalSpeedNorm_f()));
+ v_ctl_auto_groundspeed_sum_err += err_groundspeed;
+ BoundAbs(v_ctl_auto_groundspeed_sum_err, V_CTL_AUTO_GROUNDSPEED_MAX_SUM_ERR);
+ v_ctl_auto_airspeed_controlled = (err_groundspeed + v_ctl_auto_groundspeed_sum_err * v_ctl_auto_groundspeed_igain) * v_ctl_auto_groundspeed_pgain;
+
+ // Do not allow controlled airspeed below the setpoint
+ if (v_ctl_auto_airspeed_controlled < v_ctl_auto_airspeed_setpoint) {
+ v_ctl_auto_airspeed_controlled = v_ctl_auto_airspeed_setpoint;
+ // reset integrator of ground speed loop
+ v_ctl_auto_groundspeed_sum_err = v_ctl_auto_airspeed_controlled/(v_ctl_auto_groundspeed_pgain*v_ctl_auto_groundspeed_igain);
+ }
+#else
+ v_ctl_auto_airspeed_controlled = v_ctl_auto_airspeed_setpoint_slew;
+#endif
+
// Airspeed outerloop: positive means we need to accelerate
- float speed_error = v_ctl_auto_airspeed_setpoint - (*stateGetAirspeed_f());
+ float speed_error = v_ctl_auto_airspeed_controlled - (*stateGetAirspeed_f());
// Speed Controller to PseudoControl: gain 1 -> 5m/s error = 0.5g acceleration
v_ctl_desired_acceleration = speed_error * v_ctl_airspeed_pgain / 9.81f;
@@ -260,10 +353,9 @@ void v_ctl_climb_loop( void )
if (launch && (v_ctl_mode >= V_CTL_MODE_AUTO_CLIMB))
{
v_ctl_auto_throttle_nominal_cruise_throttle +=
- v_ctl_auto_throttle_of_airspeed_igain * speed_error * dt
- + en_tot_err * v_ctl_energy_total_igain * dt;
- if (v_ctl_auto_throttle_nominal_cruise_throttle < 0.0f) v_ctl_auto_throttle_nominal_cruise_throttle = 0.0f;
- else if (v_ctl_auto_throttle_nominal_cruise_throttle > 1.0f) v_ctl_auto_throttle_nominal_cruise_throttle = 1.0f;
+ v_ctl_auto_throttle_of_airspeed_igain * speed_error * dt
+ + en_tot_err * v_ctl_energy_total_igain * dt;
+ Bound(v_ctl_auto_throttle_nominal_cruise_throttle,0.0f,1.0f);
}
// Total Controller
@@ -287,13 +379,14 @@ void v_ctl_climb_loop( void )
Bound(v_ctl_auto_throttle_nominal_cruise_pitch,H_CTL_PITCH_MIN_SETPOINT, H_CTL_PITCH_MAX_SETPOINT);
}
float v_ctl_pitch_of_vz =
- + (v_ctl_climb_setpoint /*+ d_err * v_ctl_auto_throttle_pitch_of_vz_dgain*/) * v_ctl_auto_throttle_pitch_of_vz_pgain
- - v_ctl_auto_pitch_of_airspeed_pgain * speed_error
+ + (v_ctl_climb_setpoint /*+ d_err * v_ctl_auto_throttle_pitch_of_vz_dgain*/) * v_ctl_auto_throttle_pitch_of_vz_pgain
+ - v_ctl_auto_pitch_of_airspeed_pgain * speed_error
+ v_ctl_auto_pitch_of_airspeed_dgain * vdot
+ v_ctl_energy_diff_pgain * en_dis_err
+ v_ctl_auto_throttle_nominal_cruise_pitch;
- v_ctl_pitch_setpoint = v_ctl_pitch_of_vz;
+ nav_pitch = v_ctl_pitch_of_vz;
+ Bound(nav_pitch,H_CTL_PITCH_MIN_SETPOINT,H_CTL_PITCH_MAX_SETPOINT)
ac_char_update(controlled_throttle, v_ctl_pitch_of_vz, v_ctl_climb_setpoint, v_ctl_desired_acceleration);
diff --git a/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.h b/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.h
index c3bb8b49a6..18bb371888 100644
--- a/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.h
+++ b/sw/airborne/firmwares/fixedwing/guidance/energy_ctrl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 TUDelft
+ * Copyright (C) 2012 TUDelft, Tobias Muench
*
* This file is part of paparazzi.
*
@@ -62,6 +62,10 @@ extern float v_ctl_energy_total_igain;
extern float v_ctl_energy_diff_pgain;
extern float v_ctl_energy_diff_igain;
+extern float v_ctl_auto_groundspeed_pgain;
+extern float v_ctl_auto_groundspeed_igain;
+extern float v_ctl_auto_groundspeed_sum_err;
+
/////////////////////////////////////////////////
// Automatically found airplane characteristics
diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c
index aa174d3363..6dfedc62ad 100644
--- a/sw/airborne/firmwares/fixedwing/main_ap.c
+++ b/sw/airborne/firmwares/fixedwing/main_ap.c
@@ -38,7 +38,7 @@
#include "mcu.h"
#include "mcu_periph/sys_time.h"
-#include "link_mcu.h"
+#include "link_mcu_spi.h"
// Sensors
#if USE_GPS
@@ -105,45 +105,20 @@ static inline void on_baro_abs_event( void );
static inline void on_baro_dif_event( void );
#endif
-bool_t power_switch;
-
// what version is this ????
static const uint16_t version = 1;
-uint8_t pprz_mode = PPRZ_MODE_AUTO2;
-uint8_t lateral_mode = LATERAL_MODE_MANUAL;
-
static uint8_t mcu1_status;
#if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
static uint8_t mcu1_ppm_cpt;
#endif
-bool_t kill_throttle = FALSE;
-
-bool_t launch = FALSE;
-
-/* flight time in seconds */
-uint16_t autopilot_flight_time = 0;
-
-
-/** Supply voltage in deciVolt.
- * This the ap copy of the measurement from fbw
- */
-uint8_t vsupply;
-
/** Supply current in milliAmpere.
* This the ap copy of the measurement from fbw
*/
static int32_t current; // milliAmpere
-/** Fuel consumption (mAh)
- * TODO: move to electrical subsystem
- */
-float energy;
-
-bool_t gps_lost = FALSE;
-
tid_t modules_tid; ///< id for modules_periodic_task() timer
tid_t telemetry_tid; ///< id for telemetry_periodic() timer
@@ -188,7 +163,7 @@ void init_ap( void ) {
stateInit();
/************* Links initialization ***************/
-#if defined MCU_SPI_LINK
+#if defined MCU_SPI_LINK || defined MCU_UART_LINK
link_mcu_init();
#endif
#if USE_AUDIO_TELEMETRY
@@ -196,6 +171,7 @@ void init_ap( void ) {
#endif
/************ Internal status ***************/
+ autopilot_init();
h_ctl_init();
v_ctl_init();
nav_init();
@@ -226,8 +202,6 @@ void init_ap( void ) {
IO0SET = _BV(AEROCOMM_DATA_PIN);
#endif
- power_switch = FALSE;
-
/************ Multi-uavs status ***************/
#ifdef TRAFFIC_INFO
@@ -533,7 +507,7 @@ void attitude_loop( void ) {
ap_state->commands[COMMAND_PITCH] = h_ctl_elevator_setpoint;
-#if defined MCU_SPI_LINK
+#if defined MCU_SPI_LINK || defined MCU_UART_LINK
link_mcu_send();
#elif defined INTER_MCU && defined SINGLE_MCU
/**Directly set the flag indicating to FBW that shared buffer is available*/
@@ -639,7 +613,7 @@ void event_task_ap( void ) {
DatalinkEvent();
-#ifdef MCU_SPI_LINK
+#if defined MCU_SPI_LINK || defined MCU_UART_LINK
link_mcu_event_task();
#endif
diff --git a/sw/airborne/firmwares/fixedwing/main_fbw.c b/sw/airborne/firmwares/fixedwing/main_fbw.c
index 0c7b22060a..31b5b9812e 100644
--- a/sw/airborne/firmwares/fixedwing/main_fbw.c
+++ b/sw/airborne/firmwares/fixedwing/main_fbw.c
@@ -36,8 +36,8 @@
#include "firmwares/fixedwing/main_fbw.h"
#include "mcu.h"
#include "mcu_periph/sys_time.h"
-#include "commands.h"
-#include "firmwares/fixedwing/actuators.h"
+#include "subsystems/commands.h"
+#include "subsystems/actuators.h"
#include "subsystems/electrical.h"
#include "subsystems/radio_control.h"
#include "firmwares/fixedwing/autopilot.h"
@@ -46,7 +46,11 @@
#include "mcu_periph/i2c.h"
#ifdef MCU_SPI_LINK
-#include "link_mcu.h"
+#include "link_mcu_spi.h"
+#endif
+
+#ifdef MCU_UART_LINK
+#include "link_mcu_usart.h"
#endif
uint8_t fbw_mode;
@@ -54,6 +58,20 @@ uint8_t fbw_mode;
#include "inter_mcu.h"
+/** Trim commands for roll and pitch/
+ */
+#ifndef COMMAND_ROLL_TRIM
+#define COMMAND_ROLL_TRIM 0
+#endif
+
+#ifndef COMMAND_PITCH_TRIM
+#define COMMAND_PITCH_TRIM 0
+#endif
+
+pprz_t command_roll_trim;
+pprz_t command_pitch_trim;
+
+
volatile uint8_t fbw_new_actuators = 0;
tid_t fbw_periodic_tid; ///< id for periodic_task_fbw() timer
@@ -86,6 +104,10 @@ void init_fbw( void ) {
fbw_mode = FBW_MODE_FAILSAFE;
+ command_roll_trim = COMMAND_ROLL_TRIM;
+ command_pitch_trim = COMMAND_PITCH_TRIM;
+
+
/**** start timers for periodic functions *****/
fbw_periodic_tid = sys_time_register_timer((1./60.), NULL);
electrical_tid = sys_time_register_timer(0.1, NULL);
@@ -125,7 +147,7 @@ void event_task_fbw( void) {
i2c_event();
#ifdef INTER_MCU
-#ifdef MCU_SPI_LINK
+#if defined MCU_SPI_LINK | defined MCU_UART_LINK
link_mcu_event_task();
#endif /* MCU_SPI_LINK */
@@ -135,9 +157,11 @@ void event_task_fbw( void) {
inter_mcu_event_task();
command_roll_trim = ap_state->command_roll_trim;
command_pitch_trim = ap_state->command_pitch_trim;
+#ifndef OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP
if (ap_ok && fbw_mode == FBW_MODE_FAILSAFE) {
fbw_mode = FBW_MODE_AUTO;
}
+#endif
if (fbw_mode == FBW_MODE_AUTO) {
SetCommands(ap_state->commands);
}
@@ -154,6 +178,17 @@ void event_task_fbw( void) {
#endif /**Else the buffer is filled even if the last receive was not correct */
}
+#if OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_AP_CAN_FORCE_FAILSAFE
+#warning DANGER DANGER DANGER DANGER: Outback Challenge Rule FORCE-CRASH-RULE: DANGER DANGER: AP is now capable to FORCE your FBW in failsafe mode EVEN IF RC IS NOT LOST: Consider the consequences.
+
+ int crash = 0;
+ if (commands[COMMAND_FORCECRASH] >= 8000)
+ {
+ set_failsafe_mode();
+ crash = 1;
+ }
+
+#endif
#ifdef ACTUATORS
if (fbw_new_actuators > 0)
{
@@ -170,6 +205,13 @@ void event_task_fbw( void) {
SetActuatorsFromCommands(trimmed_commands);
fbw_new_actuators = 0;
+ #if OUTBACK_CHALLENGE_VERY_DANGEROUS_RULE_AP_CAN_FORCE_FAILSAFE
+ if (crash == 1)
+ {
+ for (;;) {}
+ }
+ #endif
+
}
#endif
@@ -192,7 +234,12 @@ void periodic_task_fbw( void ) {
#ifdef RADIO_CONTROL
radio_control_periodic_task();
if (fbw_mode == FBW_MODE_MANUAL && radio_control.status == RC_REALLY_LOST) {
+#ifdef OUTBACK_CHALLENGE_DANGEROUS_RULE_RC_LOST_NO_AP
+#warning WARNING DANGER: OUTBACK_CHALLENGE RULE RC_LOST_NO_AP defined. If you loose RC you will NOT go to automatically go to AUTO2 Anymore!!
+set_failsafe_mode();
+#else
fbw_mode = FBW_MODE_AUTO;
+#endif
}
#endif
@@ -204,6 +251,11 @@ void periodic_task_fbw( void ) {
}
#endif
+#ifdef MCU_UART_LINK
+ inter_mcu_fill_fbw_state();
+ link_mcu_periodic_task();
+#endif
+
#ifdef DOWNLINK
fbw_downlink_periodic_task();
#endif
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_pwm_supervision.c b/sw/airborne/firmwares/rotorcraft/actuators/actuators_pwm_supervision.c
deleted file mode 100644
index 8350a36de3..0000000000
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_pwm_supervision.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010-2012 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.
- */
-
-/** @file actuators_pwm_supervision.h
- * PWM actuators with supervision.
- */
-
-#include "generated/airframe.h"
-
-/* warn if SUPERVISION_STOP_MOTOR is not defined in the airframe file */
-#ifndef SUPERVISION_STOP_MOTOR
-#warning "STOP_MOTOR is not defined in the SUPERVISION section, are you sure you want to use the default of 0?"
-#endif
-
-#include "firmwares/rotorcraft/actuators/supervision.h"
-#include "firmwares/rotorcraft/commands.h"
-#include "subsystems/radio_control.h"
-
-#include "firmwares/rotorcraft/actuators.h"
-#include "subsystems/actuators/actuators_pwm.h"
-
-
-/** actuator PWM values in usec. */
-int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
-
-void actuators_init(void)
-{
- supervision_init();
- actuators_pwm_arch_init();
-}
-
-void actuators_set(bool_t motors_on)
-{
- /* set normal control surface actuators, i.e. servos */
- SetActuatorsFromCommands(commands);
-
- /* run supervision for actuators (motor controllers) that need mixing */
- supervision_run(motors_on, FALSE, commands);
-
- for (int i = 0; i < SUPERVISION_NB_MOTOR; i++) {
- actuators_pwm_values[i] = supervision.commands[i];
- }
- ActuatorsCommit();
-}
-
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/supervision.c b/sw/airborne/firmwares/rotorcraft/actuators/supervision.c
deleted file mode 100644
index 6a020617ec..0000000000
--- a/sw/airborne/firmwares/rotorcraft/actuators/supervision.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2008-2012 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.
- */
-
-/** @file supervision.c
- * Supervision.
- * Handles the mapping of roll/pitch/yaw commands
- * to actual motor commands.
- */
-
-#include "firmwares/rotorcraft/actuators/supervision.h"
-#include "paparazzi.h"
-
-//#include
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-
-#ifndef SUPERVISION_STOP_MOTOR
-#define SUPERVISION_STOP_MOTOR 0
-#endif
-
-#ifndef SUPERVISION_MIN_MOTOR_STARTUP
-#define SUPERVISION_MIN_MOTOR_STARTUP SUPERVISION_MIN_MOTOR
-#endif
-
-#if defined (SUPERVISION_MAX_NEGATIVE_MOTOR_STEP) || defined (SUPERVISION_MAX_POSITIVE_MOTOR_STEP)
-#define SUPERVISION_USE_MAX_MOTOR_STEP_BINDING
-
-#ifndef SUPERVISION_MAX_NEGATIVE_MOTOR_STEP
-#define SUPERVISION_MAX_NEGATIVE_MOTOR_STEP INT32_MIN
-#endif
-/*
-#ifndef SUPERVISION_MAX_POSITIVE_MOTOR_STEP
-#define SUPERVISION_MAX_POSITIVE_MOTOR_STEP INT32_MAX
-#endif
-*/
-#endif
-
-static const int32_t roll_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_ROLL_COEF;
-static const int32_t pitch_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_PITCH_COEF;
-static const int32_t yaw_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_YAW_COEF;
-static const int32_t thrust_coef[SUPERVISION_NB_MOTOR] = SUPERVISION_THRUST_COEF;
-
-struct Supervision supervision;
-
-void supervision_init(void) {
- uint8_t i;
- for (i=0; i i * max_counter / (SUPERVISION_NB_MOTOR + SUPERVISION_STARTUP_DELAY)) {
- if (counter > SUPERVISION_NB_MOTOR * max_counter / (SUPERVISION_NB_MOTOR + SUPERVISION_STARTUP_DELAY)) {
- supervision.commands[i] = SUPERVISION_MIN_MOTOR_STARTUP + (SUPERVISION_MIN_MOTOR - SUPERVISION_MIN_MOTOR_STARTUP) * counter / max_counter;
- } else {
- supervision.commands[i] = SUPERVISION_MIN_MOTOR_STARTUP;
- }
- } else {
- supervision.commands[i] = 0;
- }
-#else
- if (counter < i * max_counter / SUPERVISION_NB_MOTOR) {
- supervision.commands[i] = SUPERVISION_MIN_MOTOR_STARTUP;
- }
-#endif
- }
-}
-
-void supervision_run(bool_t motors_on, bool_t override_on, int32_t in_cmd[] ) {
- uint8_t i;
- if (motors_on) {
- int32_t min_cmd = INT32_MAX;
- int32_t max_cmd = INT32_MIN;
- /* do the mixing in float to avoid overflows, implicitly casted back to int32_t */
- for (i=0; i max_cmd)
- max_cmd = supervision.commands[i];
- }
- if (min_cmd < SUPERVISION_MIN_MOTOR && max_cmd > SUPERVISION_MAX_MOTOR)
- supervision.nb_failure++;
- if (min_cmd < SUPERVISION_MIN_MOTOR)
- offset_commands(-(min_cmd - SUPERVISION_MIN_MOTOR));
- if (max_cmd > SUPERVISION_MAX_MOTOR)
- offset_commands(-(max_cmd - SUPERVISION_MAX_MOTOR));
-
- /* For testing motor failure */
- if (motors_on && override_on) {
- for (i = 0; i < SUPERVISION_NB_MOTOR; i++) {
- if (supervision.override_enabled[i])
- supervision.commands[i] = supervision.override_value[i];
- }
- }
- bound_commands();
- bound_commands_step();
- }
- else {
- for (i=0; i
- *
- * This file is part of paparazzi.
- *
- * paparazzi is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * paparazzi is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with paparazzi; see the file COPYING. If not, write to
- * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef COMMANDS_H
-#define COMMANDS_H
-
-#include "paparazzi.h"
-#include "generated/airframe.h"
-
-extern int32_t commands[COMMANDS_NB];
-extern const int32_t commands_failsafe[COMMANDS_NB];
-
-#ifndef ROTORCRAFT_COMMANDS_YAW_ALWAYS_ENABLED
-#define SetCommands(_in_cmd, _in_flight, _motors_on) { \
- commands[COMMAND_PITCH] = _in_cmd[COMMAND_PITCH]; \
- commands[COMMAND_ROLL] = _in_cmd[COMMAND_ROLL]; \
- commands[COMMAND_YAW] = (_in_flight) ? _in_cmd[COMMAND_YAW] : 0; \
- commands[COMMAND_THRUST] = (_motors_on) ? _in_cmd[COMMAND_THRUST] : 0; \
- }
-#else
-#define SetCommands(_in_cmd, _in_flight, _motors_on) { \
- commands[COMMAND_PITCH] = _in_cmd[COMMAND_PITCH]; \
- commands[COMMAND_ROLL] = _in_cmd[COMMAND_ROLL]; \
- commands[COMMAND_YAW] = _in_cmd[COMMAND_YAW]; \
- commands[COMMAND_THRUST] = (_motors_on) ? _in_cmd[COMMAND_THRUST] : 0; \
- }
-#endif
-
-#endif /* COMMANDS_H */
diff --git a/sw/airborne/firmwares/rotorcraft/guidance/guidance_v.h b/sw/airborne/firmwares/rotorcraft/guidance/guidance_v.h
index 28b887eb9b..56c2437215 100644
--- a/sw/airborne/firmwares/rotorcraft/guidance/guidance_v.h
+++ b/sw/airborne/firmwares/rotorcraft/guidance/guidance_v.h
@@ -32,17 +32,6 @@
#include "generated/airframe.h"
#include "firmwares/rotorcraft/guidance/guidance_v_ref.h"
-/** Supervision default bounds
- * In case Asctec controllers are used without supervision
- * Used in control and adaptation filter
- * */
-#ifndef SUPERVISION_MIN_MOTOR
-#define SUPERVISION_MIN_MOTOR 1
-#endif
-#ifndef SUPERVISION_MAX_MOTOR
-#define SUPERVISION_MAX_MOTOR 200
-#endif
-
#include "firmwares/rotorcraft/guidance/guidance_v_adpt.h"
#define GUIDANCE_V_MODE_KILL 0
diff --git a/sw/airborne/firmwares/rotorcraft/main.c b/sw/airborne/firmwares/rotorcraft/main.c
index 9d7e2a37c4..3218dec115 100644
--- a/sw/airborne/firmwares/rotorcraft/main.c
+++ b/sw/airborne/firmwares/rotorcraft/main.c
@@ -35,8 +35,11 @@
#include "subsystems/settings.h"
#include "subsystems/datalink/xbee.h"
-#include "firmwares/rotorcraft/commands.h"
-#include "firmwares/rotorcraft/actuators.h"
+#include "subsystems/commands.h"
+#include "subsystems/actuators.h"
+#if USE_MOTOR_MIXING
+#include "subsystems/actuators/motor_mixing.h"
+#endif
#include "subsystems/imu.h"
#include "subsystems/gps.h"
@@ -100,6 +103,10 @@ STATIC_INLINE void main_init( void ) {
stateInit();
actuators_init();
+#if USE_MOTOR_MIXING
+ motor_mixing_init();
+#endif
+
radio_control_init();
#if DATALINK == XBEE
@@ -160,7 +167,8 @@ STATIC_INLINE void main_periodic( void ) {
/* run control loops */
autopilot_periodic();
/* set actuators */
- actuators_set(autopilot_motors_on);
+ //actuators_set(autopilot_motors_on);
+ SetActuatorsFromCommands(commands);
modules_periodic_task();
diff --git a/sw/airborne/firmwares/rotorcraft/telemetry.h b/sw/airborne/firmwares/rotorcraft/telemetry.h
index 92cb440a01..9e92c56234 100644
--- a/sw/airborne/firmwares/rotorcraft/telemetry.h
+++ b/sw/airborne/firmwares/rotorcraft/telemetry.h
@@ -40,7 +40,7 @@
#include "firmwares/rotorcraft/autopilot.h"
#include "firmwares/rotorcraft/guidance.h"
-#include "firmwares/rotorcraft/actuators.h"
+#include "subsystems/actuators.h"
#include "mcu_periph/sys_time.h"
#include "subsystems/electrical.h"
@@ -136,6 +136,12 @@
#define PERIODIC_SEND_PPM(_trans, _dev) {}
#endif
+#ifdef ACTUATORS
+#define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, ACTUATORS_NB, actuators)
+#else
+#define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
+#endif
+
#define PERIODIC_SEND_IMU_GYRO_SCALED(_trans, _dev) { \
DOWNLINK_SEND_IMU_GYRO_SCALED(_trans, _dev, \
&imu.gyro.p, \
@@ -731,9 +737,9 @@
}
#if USE_CAM
-#define PERIODIC_SEND_BOOZ2_CAM(_trans, _dev) DOWNLINK_SEND_BOOZ2_CAM(_trans, _dev,&booz_cam_tilt,&booz_cam_pan);
+#define PERIODIC_SEND_ROTORCRAFT_CAM(_trans, _dev) DOWNLINK_SEND_ROTORCRAFT_CAM(_trans, _dev,&rotorcraft_cam_tilt,&rotorcraft_cam_pan);
#else
-#define PERIODIC_SEND_BOOZ2_CAM(_trans, _dev) {}
+#define PERIODIC_SEND_ROTORCRAFT_CAM(_trans, _dev) {}
#endif
#define PERIODIC_SEND_ROTORCRAFT_TUNE_HOVER(_trans, _dev) { \
diff --git a/sw/airborne/firmwares/setup/setup_actuators.c b/sw/airborne/firmwares/setup/setup_actuators.c
index 875e9dc2fb..d55e6815ce 100644
--- a/sw/airborne/firmwares/setup/setup_actuators.c
+++ b/sw/airborne/firmwares/setup/setup_actuators.c
@@ -4,8 +4,7 @@
#include "mcu.h"
#include "mcu_periph/sys_time.h"
#include "led.h"
-#include "firmwares/fixedwing/actuators.h"
-//#include "actuators.h"
+#include "subsystems/actuators.h"
#include "firmwares/fixedwing/main_fbw.h"
@@ -30,8 +29,8 @@ void dl_parse_msg( void ) {
uint8_t servo_no = DL_SET_ACTUATOR_no(dl_buffer);
uint16_t servo_value = DL_SET_ACTUATOR_value(dl_buffer);
LED_TOGGLE(2);
- if (servo_no < SERVOS_NB)
- SetServo(servo_no, servo_value);
+ if (servo_no < ACTUATORS_NB)
+ //SetServo(servo_no, servo_value);
}
#ifdef DlSetting
else if (msg_id == DL_SETTING && DL_SETTING_ac_id(dl_buffer) == AC_ID) {
@@ -40,7 +39,7 @@ void dl_parse_msg( void ) {
DlSetting(i, val);
LED_TOGGLE(2);
for (int j=0 ; j<8 ; j++) {
- SetServo(j,actuators[j]);
+ //SetServo(j,actuators[j]);
}
DOWNLINK_SEND_DL_VALUE(DefaultChannel, DefaultDevice, &i, &val);
} else if (msg_id == DL_GET_SETTING && DL_GET_SETTING_ac_id(dl_buffer) == AC_ID) {
@@ -58,8 +57,8 @@ void init_fbw( void ) {
actuators_init();
uint8_t i;
- for(i = 0; i < SERVOS_NB; i++) {
- SetServo(i, 1500);
+ for(i = 0; i < ACTUATORS_NB; i++) {
+ //SetServo(i, 1500);
}
// SetServo(SERVO_GAZ, SERVO_GAZ_MIN);
@@ -83,7 +82,7 @@ void periodic_task_fbw(void) {
/* SetServo(SERVO_THROTTLE, servo_value); */
RunOnceEvery(300, DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM));
- RunOnceEvery(300, DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, SERVOS_NB, actuators ));
+ RunOnceEvery(300, DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, ACTUATORS_NB, actuators ));
}
void event_task_fbw(void) {
diff --git a/sw/airborne/inter_mcu.c b/sw/airborne/inter_mcu.c
index bc8217ce5f..4ede605ef9 100644
--- a/sw/airborne/inter_mcu.c
+++ b/sw/airborne/inter_mcu.c
@@ -30,7 +30,7 @@ static struct ap_state _ap_state;
struct fbw_state* fbw_state = &_fbw_state;
struct ap_state* ap_state = &_ap_state;
#else /* SINGLE_MCU */
-#include "link_mcu.h"
+#include "link_mcu_spi.h"
struct fbw_state* fbw_state = &link_mcu_from_fbw_msg.payload.from_fbw;
struct ap_state* ap_state = &link_mcu_from_ap_msg.payload.from_ap;
#endif /* ! SINGLE_MCU */
diff --git a/sw/airborne/inter_mcu.h b/sw/airborne/inter_mcu.h
index 9361dfe0fd..e7d0847f6f 100644
--- a/sw/airborne/inter_mcu.h
+++ b/sw/airborne/inter_mcu.h
@@ -58,8 +58,8 @@ struct fbw_state {
#endif
uint8_t status;
uint8_t nb_err;
- uint8_t vsupply; /* 1e-1 V */
- int32_t current; /* milliAmps */
+ uint16_t vsupply; ///< 1e-1 V
+ int32_t current; ///< milliAmps
};
struct ap_state {
diff --git a/sw/airborne/link_mcu.c b/sw/airborne/link_mcu_spi.c
similarity index 99%
rename from sw/airborne/link_mcu.c
rename to sw/airborne/link_mcu_spi.c
index ae3122f758..2e66490068 100644
--- a/sw/airborne/link_mcu.c
+++ b/sw/airborne/link_mcu_spi.c
@@ -22,7 +22,7 @@
*
*/
-#include "link_mcu.h"
+#include "link_mcu_spi.h"
#include "mcu_periph/spi.h"
struct link_mcu_msg link_mcu_from_ap_msg;
diff --git a/sw/airborne/link_mcu.h b/sw/airborne/link_mcu_spi.h
similarity index 100%
rename from sw/airborne/link_mcu.h
rename to sw/airborne/link_mcu_spi.h
diff --git a/sw/airborne/link_mcu_usart.c b/sw/airborne/link_mcu_usart.c
new file mode 100644
index 0000000000..ebbf2201ae
--- /dev/null
+++ b/sw/airborne/link_mcu_usart.c
@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) 2010-2012 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.
+ *
+ */
+
+#include "link_mcu_usart.h"
+#include "mcu_periph/uart.h"
+#include "led.h"
+
+#include "subsystems/commands.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// LINK
+
+#define __InterMcuLink(dev, _x) dev##_x
+#define _InterMcuLink(dev, _x) __InterMcuLink(dev, _x)
+#define InterMcuLink(_x) _InterMcuLink(INTERMCU_LINK, _x)
+
+#define InterMcuBuffer() InterMcuLink(ChAvailable())
+
+#define InterMcuUartSend1(c) InterMcuLink(Transmit(c))
+#define InterMcuUartSetBaudrate(_a) InterMcuLink(SetBaudrate(_a))
+#define InterMcuUartRunning InterMcuLink(TxRunning)
+#define InterMcuUartSendMessage InterMcuLink(SendMessage)
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// PROTOCOL
+
+#define INTERMCU_SYNC1 0xB5
+#define INTERMCU_SYNC2 0x62
+
+#define InterMcuInitCheksum() { intermcu_data.send_ck_a = intermcu_data.send_ck_b = 0; }
+#define UpdateChecksum(c) { intermcu_data.send_ck_a += c; intermcu_data.send_ck_b += intermcu_data.send_ck_a; }
+#define InterMcuTrailer() { InterMcuUartSend1(intermcu_data.send_ck_a); InterMcuUartSend1(intermcu_data.send_ck_b); InterMcuUartSendMessage(); }
+
+#define InterMcuSend1(c) { uint8_t i8=c; InterMcuUartSend1(i8); UpdateChecksum(i8); }
+#define InterMcuSend2(c) { uint16_t i16=c; InterMcuSend1(i16&0xff); InterMcuSend1(i16 >> 8); }
+#define InterMcuSend1ByAddr(x) { InterMcuSend1(*x); }
+#define InterMcuSend2ByAddr(x) { InterMcuSend1(*x); InterMcuSend1(*(x+1)); }
+#define InterMcuSend4ByAddr(x) { InterMcuSend1(*x); InterMcuSend1(*(x+1)); InterMcuSend1(*(x+2)); InterMcuSend1(*(x+3)); }
+
+#define InterMcuHeader(nav_id, msg_id, len) { \
+ InterMcuUartSend1(INTERMCU_SYNC1); \
+ InterMcuUartSend1(INTERMCU_SYNC2); \
+ InterMcuInitCheksum(); \
+ InterMcuSend1(nav_id); \
+ InterMcuSend1(msg_id); \
+ InterMcuSend2(len); \
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// MESSAGES
+
+// class
+#define MSG_INTERMCU_ID 100
+
+
+#define MSG_INTERMCU_COMMAND_ID 0x05
+#define MSG_INTERMCU_COMMAND_LENGTH (2*(COMMANDS_NB))
+#define MSG_INTERMCU_COMMAND(_intermcu_payload, nr) (uint16_t)(*((uint8_t*)_intermcu_payload+0)|*((uint8_t*)_intermcu_payload+1+(2*(nr)))<<8)
+
+#define InterMcuSend_INTERMCU_COMMAND(cmd) { \
+ InterMcuHeader(MSG_INTERMCU_ID, MSG_INTERMCU_COMMAND_ID, MSG_INTERMCU_COMMAND_LENGTH);\
+ for (int i=0;i INTERMCU_MAX_PAYLOAD) {
+ goto error;
+ }
+ intermcu_data.msg_idx = 0;
+ intermcu_data.status++;
+ break;
+ case GOT_LEN2:
+ intermcu_data.msg_buf[intermcu_data.msg_idx] = c;
+ intermcu_data.msg_idx++;
+ if (intermcu_data.msg_idx >= intermcu_data.len) {
+ intermcu_data.status++;
+ }
+ break;
+ case GOT_PAYLOAD:
+ if (c != intermcu_data.ck_a) {
+ goto error;
+ }
+ intermcu_data.status++;
+ break;
+ case GOT_CHECKSUM1:
+ if (c != intermcu_data.ck_b) {
+ goto error;
+ }
+ intermcu_data.msg_available = TRUE;
+ goto restart;
+ break;
+ default:
+ goto error;
+ }
+ return;
+ error:
+ intermcu_data.error_cnt++;
+ restart:
+ intermcu_data.status = UNINIT;
+ return;
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// USER
+
+
+struct link_mcu_msg link_mcu_from_ap_msg;
+struct link_mcu_msg link_mcu_from_fbw_msg;
+
+inline void parse_mavpilot_msg( void );
+
+void link_mcu_init( void )
+{
+ intermcu_data.status = UNINIT;
+ intermcu_data.msg_available = FALSE;
+ intermcu_data.error_cnt = 0;
+}
+
+void parse_mavpilot_msg( void )
+{
+ if (intermcu_data.msg_class == MSG_INTERMCU_ID)
+ {
+ if (intermcu_data.msg_id == MSG_INTERMCU_COMMAND_ID)
+ {
+#if COMMANDS_NB > 8
+#error "INTERMCU UART CAN ONLY SEND 8 COMMANDS OR THE UART WILL BE OVERFILLED"
+#endif
+
+ for (int i=0; i< COMMANDS_NB; i++)
+ {
+ ap_state->commands[i] = ((pprz_t)MSG_INTERMCU_COMMAND(intermcu_data.msg_buf, i));
+ }
+
+#ifdef LINK_MCU_LED
+ LED_TOGGLE(LINK_MCU_LED);
+#endif
+ inter_mcu_received_ap = TRUE;
+ }
+ else if (intermcu_data.msg_id == MSG_INTERMCU_RADIO_ID)
+ {
+#if RADIO_CONTROL_NB_CHANNEL > 10
+#error "INTERMCU UART CAN ONLY SEND 10 RADIO CHANNELS OR THE UART WILL BE OVERFILLED"
+#endif
+
+ for (int i=0; i< RADIO_CONTROL_NB_CHANNEL; i++)
+ {
+ fbw_state->channels[i] = ((pprz_t)MSG_INTERMCU_RADIO(intermcu_data.msg_buf, i));
+ }
+ }
+ else if (intermcu_data.msg_id == MSG_INTERMCU_TRIM_ID)
+ {
+ ap_state->command_roll_trim = ((pprz_t) MSG_INTERMCU_TRIM_ROLL(intermcu_data.msg_buf));
+ ap_state->command_pitch_trim = ((pprz_t) MSG_INTERMCU_TRIM_PITCH(intermcu_data.msg_buf));
+ }
+ else if (intermcu_data.msg_id == MSG_INTERMCU_FBW_ID)
+ {
+ fbw_state->ppm_cpt = MSG_INTERMCU_FBW_MOD(intermcu_data.msg_buf);
+ fbw_state->status = MSG_INTERMCU_FBW_STAT(intermcu_data.msg_buf);
+ fbw_state->nb_err = MSG_INTERMCU_FBW_ERR(intermcu_data.msg_buf);
+ fbw_state->vsupply = MSG_INTERMCU_FBW_VOLT(intermcu_data.msg_buf);
+ fbw_state->current = MSG_INTERMCU_FBW_CURRENT(intermcu_data.msg_buf);
+
+ inter_mcu_received_fbw = TRUE;
+ }
+ }
+}
+
+
+#ifdef AP
+void link_mcu_send( void )
+{
+#ifdef LINK_MCU_LED
+ LED_TOGGLE(LINK_MCU_LED);
+#endif
+ InterMcuSend_INTERMCU_COMMAND( ap_state->commands );
+ InterMcuSend_INTERMCU_TRIM( ap_state->command_roll_trim, ap_state->command_pitch_trim );
+}
+#endif
+
+#ifdef FBW
+// 60 Hz
+static uint8_t SixtyHzCounter = 0;
+
+void link_mcu_periodic_task( void )
+{
+ SixtyHzCounter++;
+ if (SixtyHzCounter >= 3)
+ {
+ // 20 Hz
+ SixtyHzCounter = 0;
+ inter_mcu_fill_fbw_state(); /** Prepares the next message for AP */
+
+ InterMcuSend_INTERMCU_FBW(
+ fbw_state->ppm_cpt,
+ fbw_state->status,
+ fbw_state->nb_err,
+ fbw_state->vsupply,
+ fbw_state->current);
+#if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1
+ InterMcuSend_INTERMCU_RADIO( fbw_state->channels );
+#endif
+
+ }
+}
+#endif
+
+void link_mcu_event_task( void ) {
+ /* A message has been received */
+ if (InterMcuBuffer()) {
+ while (InterMcuLink(ChAvailable())&&!intermcu_data.msg_available)
+ intermcu_parse(InterMcuLink(Getch()));
+ }
+
+ if (intermcu_data.msg_available) {
+ parse_mavpilot_msg();
+ intermcu_data.msg_available = FALSE;
+ }
+}
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c b/sw/airborne/link_mcu_usart.h
similarity index 56%
rename from sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c
rename to sw/airborne/link_mcu_usart.h
index 32a200b0d3..775ef90008 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c
+++ b/sw/airborne/link_mcu_usart.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Paparazzi Team
+ * Copyright (C) 2010-2012 The Paparazzi Team
*
* This file is part of paparazzi.
*
@@ -17,33 +17,34 @@
* 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 "generated/airframe.h"
+/** \brief Transport for the communication between FBW and AP via UART.
+ */
-#include "firmwares/rotorcraft/actuators.h"
-#include "firmwares/rotorcraft/commands.h"
-#include "subsystems/actuators/actuators_pwm.h"
+#ifndef LINK_MCU_H
+#define LINK_MCU_H
+
+#include
+#include "inter_mcu.h"
+
+struct link_mcu_msg {
+ union {
+ struct fbw_state from_fbw;
+ struct ap_state from_ap;
+ } payload;
+};
+
+extern struct link_mcu_msg link_mcu_from_ap_msg;
+extern struct link_mcu_msg link_mcu_from_fbw_msg;
+
+extern bool_t link_mcu_received;
+
+extern void link_mcu_send( void );
+extern void link_mcu_init( void );
+extern void link_mcu_event_task( void );
+extern void link_mcu_periodic_task( void );
-#define ESC_STOPPED SERVOS_TICS_OF_USEC(0)
-
-#ifndef KILL_MOTORS
-#define ESC_HOVER SERVOS_TICS_OF_USEC(5500)
-#else
-#define ESC_HOVER SERVOS_TICS_OF_USEC(0)
#endif
-
-int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
-
-void actuators_init(void)
-{
- actuators_pwm_arch_init();
-}
-
-
-void actuators_set(bool_t motors_on)
-{
- SetActuatorsFromCommands(commands);
-}
-
diff --git a/sw/airborne/lisa/lisa_stm_passthrough_main.c b/sw/airborne/lisa/lisa_stm_passthrough_main.c
index 0d95029419..c2b61689b9 100644
--- a/sw/airborne/lisa/lisa_stm_passthrough_main.c
+++ b/sw/airborne/lisa/lisa_stm_passthrough_main.c
@@ -26,9 +26,9 @@
#include "mcu_periph/uart.h"
#include "mcu_periph/sys_time.h"
#include "subsystems/datalink/downlink.h"
-#include "firmwares/rotorcraft/commands.h"
-#include "actuators.h"
-#include "actuators/actuators_pwm.h"
+#include "subsystems/commands.h"
+#include "subsystems/actuators.h"
+#include "subsystems/actuators/actuators_pwm.h"
#include "subsystems/imu.h"
#include "subsystems/radio_control.h"
#include "autopilot.h"
diff --git a/sw/airborne/lisa/test/lisa_test_actuators_mkk.c b/sw/airborne/lisa/test/lisa_test_actuators_mkk.c
index 04a5679034..25ab7e7e6f 100644
--- a/sw/airborne/lisa/test/lisa_test_actuators_mkk.c
+++ b/sw/airborne/lisa/test/lisa_test_actuators_mkk.c
@@ -24,8 +24,8 @@
#include "mcu.h"
#include "mcu_periph/sys_time.h"
-#include "firmwares/rotorcraft/commands.h"
-#include "actuators.h"
+#include "subsystems/commands.h"
+#include "subsystems/actuators.h"
#include "subsystems/datalink/downlink.h"
#include "led.h"
@@ -95,7 +95,7 @@ static inline void main_periodic_task( void ) {
commands[COMMAND_YAW] = 20;
commands[COMMAND_THRUST] = 0;
// actuators_set(TRUE);
- actuators_set(FALSE);
+ //actuators_set(FALSE);
}
LED_PERIODIC();
diff --git a/sw/airborne/lisa/test_servos.c b/sw/airborne/lisa/test_servos.c
index 30fe68c776..3270f8bb70 100644
--- a/sw/airborne/lisa/test_servos.c
+++ b/sw/airborne/lisa/test_servos.c
@@ -42,7 +42,7 @@ int main(void) {
static inline void main_init( void ) {
mcu_init();
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
- actuators_init();
+ ActuatorsPwmInit();
}
static inline void main_periodic( void ) {
@@ -50,9 +50,9 @@ static inline void main_periodic( void ) {
foo += 0.0025;
int32_t bar = 1500 + 500. * sin(foo);
for (int i = 0; i < ACTUATORS_PWM_NB; i++) {
- actuators_pwm_values[i] = bar;
+ ActuatorPwmSet(i, bar);
}
- actuators_pwm_commit();
+ ActuatorsPwmCommit();
LED_PERIODIC();
}
diff --git a/sw/airborne/math/pprz_geodetic_wmm2010.c b/sw/airborne/math/pprz_geodetic_wmm2010.c
old mode 100755
new mode 100644
diff --git a/sw/airborne/math/pprz_geodetic_wmm2010.h b/sw/airborne/math/pprz_geodetic_wmm2010.h
old mode 100755
new mode 100644
diff --git a/sw/airborne/mcu_periph/uart.h b/sw/airborne/mcu_periph/uart.h
index 1a4f487cbc..a8107ab99e 100644
--- a/sw/airborne/mcu_periph/uart.h
+++ b/sw/airborne/mcu_periph/uart.h
@@ -57,7 +57,7 @@ struct uart_periph {
};
extern void uart_periph_init(struct uart_periph* p);
-extern void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud);
+extern void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud, bool_t hw_flow_control);
//extern void uart_periph_init_param(struct uart_periph* p, uint32_t baud, uint8_t mode, uint8_t fmode, char * dev);
extern void uart_transmit(struct uart_periph* p, uint8_t data);
extern bool_t uart_check_free_space(struct uart_periph* p, uint8_t len);
@@ -82,7 +82,7 @@ extern void uart0_init(void);
#define Uart0ChAvailable() UartChAvailable(uart0)
#define Uart0Getch() UartGetch(uart0)
#define Uart0TxRunning uart0.tx_running
-#define Uart0SetBaudrate(_b) uart_periph_set_baudrate(&uart0, _b)
+#define Uart0SetBaudrate(_b) uart_periph_set_baudrate(&uart0, _b, FALSE)
//#define Uart0InitParam(_b, _m, _fm) uart_periph_init_param(&uart0, _b, _m, _fm, "")
#define UART0Init Uart0Init
@@ -107,7 +107,11 @@ extern void uart1_init(void);
#define Uart1ChAvailable() UartChAvailable(uart1)
#define Uart1Getch() UartGetch(uart1)
#define Uart1TxRunning uart1.tx_running
-#define Uart1SetBaudrate(_b) uart_periph_set_baudrate(&uart1, _b)
+#if UART1_HW_FLOW_CONTROL
+#define Uart1SetBaudrate(_b) uart_periph_set_baudrate(&uart1, _b, TRUE)
+#else
+#define Uart1SetBaudrate(_b) uart_periph_set_baudrate(&uart1, _b, FALSE)
+#endif
//#define Uart1InitParam(_b, _m, _fm) uart_periph_init_param(&uart1, _b, _m, _fm, "")
#define UART1Init Uart1Init
@@ -132,7 +136,7 @@ extern void uart2_init(void);
#define Uart2ChAvailable() UartChAvailable(uart2)
#define Uart2Getch() UartGetch(uart2)
#define Uart2TxRunning uart2.tx_running
-#define Uart2SetBaudrate(_b) uart_periph_set_baudrate(&uart2, _b)
+#define Uart2SetBaudrate(_b) uart_periph_set_baudrate(&uart2, _b, FALSE)
//#define Uart2InitParam(_b, _m, _fm) uart_periph_init_param(&uart2, _b, _m, _fm, "")
#define UART2Init Uart2Init
@@ -157,7 +161,7 @@ extern void uart3_init(void);
#define Uart3ChAvailable() UartChAvailable(uart3)
#define Uart3Getch() UartGetch(uart3)
#define Uart3TxRunning uart3.tx_running
-#define Uart3SetBaudrate(_b) uart_periph_set_baudrate(&uart3, _b)
+#define Uart3SetBaudrate(_b) uart_periph_set_baudrate(&uart3, _b, FALSE)
//#define Uart3InitParam(_b, _m, _fm) uart_periph_init_param(&uart3, _b, _m, _fm, "")
#define UART3Init Uart3Init
@@ -182,7 +186,7 @@ extern void uart5_init(void);
#define Uart5ChAvailable() UartChAvailable(uart5)
#define Uart5Getch() UartGetch(uart5)
#define Uart5TxRunning uart5.tx_running
-#define Uart5SetBaudrate(_b) uart_periph_set_baudrate(&uart5, _b)
+#define Uart5SetBaudrate(_b) uart_periph_set_baudrate(&uart5, _b, FALSE)
//#define Uart5InitParam(_b, _m, _fm) uart_periph_init_param(&uart5, _b, _m, _fm, "")
#define UART5Init Uart5Init
diff --git a/sw/airborne/modules/cam_control/booz_cam.c b/sw/airborne/modules/cam_control/booz_cam.c
deleted file mode 100644
index ddd5dd3451..0000000000
--- a/sw/airborne/modules/cam_control/booz_cam.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * $Id: $
- *
- * Copyright (C) 2009 Gautier Hattenberger ,
- * 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 "cam_control/booz_cam.h"
-#include "modules/core/booz_pwm_arch.h"
-#include "state.h"
-#include "firmwares/rotorcraft/navigation.h"
-#include "generated/flight_plan.h"
-#include "std.h"
-
-uint8_t booz_cam_mode;
-
-// Tilt definition
-int16_t booz_cam_tilt;
-int16_t booz_cam_tilt_pwm;
-#ifdef BOOZ_CAM_TILT_NEUTRAL
-#ifndef BOOZ_CAM_TILT_MIN
-#define BOOZ_CAM_TILT_MIN BOOZ_CAM_TILT_NEUTRAL
-#endif
-#ifndef BOOZ_CAM_TILT_MAX
-#define BOOZ_CAM_TILT_MAX BOOZ_CAM_TILT_NEUTRAL
-#endif
-#define BOOZ_CAM_USE_TILT 1
-#endif
-
-// Pan definition
-int16_t booz_cam_pan;
-#ifdef BOOZ_CAM_PAN_NEUTRAL
-#ifndef BOOZ_CAM_PAN_MIN
-#define BOOZ_CAM_PAN_MIN BOOZ_CAM_PAN_NEUTRAL
-#endif
-#ifndef BOOZ_CAM_PAN_MAX
-#define BOOZ_CAM_PAN_MAX BOOZ_CAM_PAN_NEUTRAL
-#endif
-#define BOOZ_CAM_USE_PAN 1
-#endif
-
-#if defined BOOZ_CAM_TILT_ANGLE_MIN && defined BOOZ_CAM_TILT_ANGLE_MAX && defined BOOZ_CAM_USE_TILT
-#define CAM_TA_MIN ANGLE_BFP_OF_REAL(BOOZ_CAM_TILT_ANGLE_MIN)
-#define CAM_TA_MAX ANGLE_BFP_OF_REAL(BOOZ_CAM_TILT_ANGLE_MAX)
-#define BOOZ_CAM_USE_TILT_ANGLES 1
-#endif
-
-// PWM definition
-#ifndef BOOZ_CAM_SetPwm
-#define BOOZ_CAM_SetPwm(_v) BoozSetPwmValue(_v)
-#endif
-
-#ifndef BOOZ_CAM_DEFAULT_MODE
-#define BOOZ_CAM_DEFAULT_MODE BOOZ_CAM_MODE_NONE
-#endif
-
-void booz_cam_init(void) {
- booz_cam_SetCamMode(BOOZ_CAM_DEFAULT_MODE);
-#ifdef BOOZ_CAM_USE_TILT
- booz_cam_tilt_pwm = BOOZ_CAM_TILT_NEUTRAL;
- BOOZ_CAM_SetPwm(booz_cam_tilt_pwm);
- booz_cam_tilt = 0;
-#else
- booz_cam_tilt_pwm = 1500;
- booz_cam_tilt = 0;
-#endif
-#ifdef BOOZ_CAM_USE_PAN
- booz_cam_pan = BOOZ_CAM_PAN_NEUTRAL;
-#else
- booz_cam_pan = 0;
-#endif
-}
-
-#define D_TILT (BOOZ_CAM_TILT_MAX - BOOZ_CAM_TILT_MIN)
-#define CT_MIN Min(BOOZ_CAM_TILT_MIN,BOOZ_CAM_TILT_MAX)
-#define CT_MAX Max(BOOZ_CAM_TILT_MIN,BOOZ_CAM_TILT_MAX)
-#define CP_MIN Min(BOOZ_CAM_PAN_MIN,BOOZ_CAM_PAN_MAX)
-#define CP_MAX Max(BOOZ_CAM_PAN_MIN,BOOZ_CAM_PAN_MAX)
-
-void booz_cam_periodic(void) {
-
- switch (booz_cam_mode) {
- case BOOZ_CAM_MODE_NONE:
-#ifdef BOOZ_CAM_USE_TILT
- booz_cam_tilt_pwm = BOOZ_CAM_TILT_NEUTRAL;
-#endif
-#ifdef BOOZ_CAM_USE_PAN
- booz_cam_pan = stateGetNedToBodyEulers_i()->psi;
-#endif
- break;
- case BOOZ_CAM_MODE_MANUAL:
-#ifdef BOOZ_CAM_USE_TILT
- Bound(booz_cam_tilt_pwm, CT_MIN, CT_MAX);
-#endif
- break;
- case BOOZ_CAM_MODE_HEADING:
-#ifdef BOOZ_CAM_USE_TILT_ANGLES
- Bound(booz_cam_tilt,CAM_TA_MIN,CAM_TA_MAX);
- booz_cam_tilt_pwm = BOOZ_CAM_TILT_MIN + D_TILT * (booz_cam_tilt - CAM_TA_MIN) / (CAM_TA_MAX - CAM_TA_MIN);
- Bound(booz_cam_tilt_pwm, CT_MIN, CT_MAX);
-#endif
-#ifdef BOOZ_CAM_USE_PAN
- Bound(booz_cam_pan, CP_MIN, CP_MAX);
- nav_heading = booz_cam_pan;
-#endif
- break;
- case BOOZ_CAM_MODE_WP:
-#ifdef WP_CAM
- {
- struct Int32Vect2 diff;
- VECT2_DIFF(diff, waypoints[WP_CAM], *stateGetPositionEnu_i());
- INT32_VECT2_RSHIFT(diff,diff,INT32_POS_FRAC);
- INT32_ATAN2(booz_cam_pan,diff.x,diff.y);
- nav_heading = booz_cam_pan;
-#ifdef BOOZ_CAM_USE_TILT_ANGLES
- int32_t dist, height;
- INT32_VECT2_NORM(dist, diff);
- height = (waypoints[WP_CAM].z - stateGetPositionEnu_i()->z) >> INT32_POS_FRAC;
- INT32_ATAN2(booz_cam_tilt, height, dist);
- Bound(booz_cam_tilt, CAM_TA_MIN, CAM_TA_MAX);
- booz_cam_tilt_pwm = BOOZ_CAM_TILT_MIN + D_TILT * (booz_cam_tilt - CAM_TA_MIN) / (CAM_TA_MAX - CAM_TA_MIN);
- Bound(booz_cam_tilt_pwm, CT_MIN, CT_MAX);
-#endif
- }
-#endif
- break;
- }
-#ifdef BOOZ_CAM_USE_TILT
- BOOZ_CAM_SetPwm(booz_cam_tilt_pwm);
-#endif
-}
-
diff --git a/sw/airborne/modules/cam_control/booz_cam.h b/sw/airborne/modules/cam_control/booz_cam.h
deleted file mode 100644
index 2a1fbfb0d8..0000000000
--- a/sw/airborne/modules/cam_control/booz_cam.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * $Id: $
- *
- * Copyright (C) 2009 Gautier Hattenberger ,
- * Antoine Drouin
- *
- * This file is part of paparazzi.
- *
- * paparazzi is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * paparazzi is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with paparazzi; see the file COPYING. If not, write to
- * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef BOOZ_CAM_H
-#define BOOZ_CAM_H
-
-#include "generated/airframe.h"
-#include "math/pprz_algebra_int.h"
-#include "std.h"
-#include "led.h"
-
-#define BOOZ_CAM_MODE_NONE 0
-#define BOOZ_CAM_MODE_MANUAL 1
-#define BOOZ_CAM_MODE_HEADING 2
-#define BOOZ_CAM_MODE_WP 3
-
-// Warning:
-// LED_ON set GPIO low
-// LED_OFF set GPIO high
-#ifndef BOOZ_CAM_ON
-#define BOOZ_CAM_ON LED_OFF(CAM_SWITCH_LED)
-#endif
-#ifndef BOOZ_CAM_OFF
-#define BOOZ_CAM_OFF LED_ON(CAM_SWITCH_LED)
-#endif
-
-extern uint8_t booz_cam_mode;
-
-extern int16_t booz_cam_tilt;
-extern int16_t booz_cam_pan;
-extern int16_t booz_cam_tilt_pwm;
-
-extern void booz_cam_init(void);
-extern void booz_cam_periodic(void);
-
-#define booz_cam_SetCamMode(_v) { \
- booz_cam_mode = _v; \
- if (booz_cam_mode == BOOZ_CAM_MODE_NONE) { BOOZ_CAM_OFF; } \
- else { BOOZ_CAM_ON; } \
-}
-
-#define BOOZ_CAM_STICK_TILT_INC (ANGLE_BFP_OF_REAL(RadOfDeg(10.))/127.)
-#define BOOZ_CAM_STICK_PAN_INC (ANGLE_BFP_OF_REAL(RadOfDeg(20.))/127.)
-
-#define BOOZ_CAM_STICK_PARSE(_dl_buffer) { \
- booz_cam_tilt += (int16_t)(BOOZ_CAM_STICK_TILT_INC*(float)DL_BOOZ_CAM_STICK_tilt(_dl_buffer)); \
- booz_cam_pan += (int16_t)(BOOZ_CAM_STICK_PAN_INC*(float)DL_BOOZ_CAM_STICK_pan(dl_buffer)); \
- INT32_COURSE_NORMALIZE(booz_cam_pan); \
-}
-
-#endif /* BOOZ2_CAM_H */
-
diff --git a/sw/airborne/modules/cam_control/rotorcraft_cam.c b/sw/airborne/modules/cam_control/rotorcraft_cam.c
new file mode 100644
index 0000000000..0df7e0ba3f
--- /dev/null
+++ b/sw/airborne/modules/cam_control/rotorcraft_cam.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2009-2012 Gautier Hattenberger ,
+ * 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 "modules/cam_control/rotorcraft_cam.h"
+
+#include "subsystems/actuators.h"
+#include "state.h"
+#include "firmwares/rotorcraft/navigation.h"
+#include "std.h"
+
+uint8_t rotorcraft_cam_mode;
+
+#define _SERVO_PARAM(_s,_p) SERVO_ ## _s ## _ ## _p
+#define SERVO_PARAM(_s,_p) _SERVO_PARAM(_s,_p)
+
+// Tilt definition
+int16_t rotorcraft_cam_tilt;
+int16_t rotorcraft_cam_tilt_pwm;
+#if ROTORCRAFT_CAM_USE_TILT
+#define ROTORCRAFT_CAM_TILT_NEUTRAL SERVO_PARAM(ROTORCRAFT_CAM_TILT_SERVO, NEUTRAL)
+#define ROTORCRAFT_CAM_TILT_MIN SERVO_PARAM(ROTORCRAFT_CAM_TILT_SERVO, MIN)
+#define ROTORCRAFT_CAM_TILT_MAX SERVO_PARAM(ROTORCRAFT_CAM_TILT_SERVO, MAX)
+#define D_TILT (ROTORCRAFT_CAM_TILT_MAX - ROTORCRAFT_CAM_TILT_MIN)
+#define CT_MIN Min(CAM_TA_MIN, CAM_TA_MAX)
+#define CT_MAX Max(CAM_TA_MIN, CAM_TA_MAX)
+#endif
+
+// Pan definition
+int16_t rotorcraft_cam_pan;
+#define ROTORCRAFT_CAM_PAN_MIN 0
+#define ROTORCRAFT_CAM_PAN_MAX INT32_ANGLE_2_PI
+
+void rotorcraft_cam_init(void) {
+ rotorcraft_cam_SetCamMode(ROTORCRAFT_CAM_DEFAULT_MODE);
+#if ROTORCRAFT_CAM_USE_TILT
+ rotorcraft_cam_tilt_pwm = ROTORCRAFT_CAM_TILT_NEUTRAL;
+ ActuatorSet(ROTORCRAFT_CAM_TILT_SERVO, rotorcraft_cam_tilt_pwm);
+#else
+ rotorcraft_cam_tilt_pwm = 1500;
+#endif
+ rotorcraft_cam_tilt = 0;
+ rotorcraft_cam_pan = 0;
+}
+
+void rotorcraft_cam_periodic(void) {
+
+ switch (rotorcraft_cam_mode) {
+ case ROTORCRAFT_CAM_MODE_NONE:
+#if ROTORCRAFT_CAM_USE_TILT
+ rotorcraft_cam_tilt_pwm = ROTORCRAFT_CAM_TILT_NEUTRAL;
+#endif
+#if ROTORCRAFT_CAM_USE_PAN
+ rotorcraft_cam_pan = stateGetNedToBodyEulers_i()->psi;
+#endif
+ break;
+ case ROTORCRAFT_CAM_MODE_MANUAL:
+ // nothing to do here, just apply tilt pwm at the end
+ break;
+ case ROTORCRAFT_CAM_MODE_HEADING:
+#if ROTORCRAFT_CAM_USE_TILT_ANGLES
+ Bound(rotorcraft_cam_tilt,CT_MIN,CT_MAX);
+ rotorcraft_cam_tilt_pwm = ROTORCRAFT_CAM_TILT_MIN + D_TILT * (rotorcraft_cam_tilt - CAM_TA_MIN) / (CAM_TA_MAX - CAM_TA_MIN);
+#endif
+#if ROTORCRAFT_CAM_USE_PAN
+ INT32_COURSE_NORMALIZE(rotorcraft_cam_pan);
+ nav_heading = rotorcraft_cam_pan;
+#endif
+ break;
+ case ROTORCRAFT_CAM_MODE_WP:
+#ifdef ROTORCRAFT_CAM_TRACK_WP
+ {
+ struct Int32Vect2 diff;
+ VECT2_DIFF(diff, waypoints[ROTORCRAFT_CAM_TRACK_WP], *stateGetPositionEnu_i());
+ INT32_VECT2_RSHIFT(diff,diff,INT32_POS_FRAC);
+ INT32_ATAN2(rotorcraft_cam_pan,diff.x,diff.y);
+ nav_heading = rotorcraft_cam_pan;
+#if ROTORCRAFT_CAM_USE_TILT_ANGLES
+ int32_t dist, height;
+ INT32_VECT2_NORM(dist, diff);
+ height = (waypoints[ROTORCRAFT_CAM_TRACK_WP].z - stateGetPositionEnu_i()->z) >> INT32_POS_FRAC;
+ INT32_ATAN2(rotorcraft_cam_tilt, height, dist);
+ Bound(rotorcraft_cam_tilt, CAM_TA_MIN, CAM_TA_MAX);
+ rotorcraft_cam_tilt_pwm = ROTORCRAFT_CAM_TILT_MIN + D_TILT * (rotorcraft_cam_tilt - CAM_TA_MIN) / (CAM_TA_MAX - CAM_TA_MIN);
+#endif
+ }
+#endif
+ break;
+ }
+#if ROTORCRAFT_CAM_USE_TILT
+ ActuatorSet(ROTORCRAFT_CAM_TILT_SERVO, rotorcraft_cam_tilt_pwm);
+#endif
+}
+
diff --git a/sw/airborne/modules/cam_control/rotorcraft_cam.h b/sw/airborne/modules/cam_control/rotorcraft_cam.h
new file mode 100644
index 0000000000..1b2babfe80
--- /dev/null
+++ b/sw/airborne/modules/cam_control/rotorcraft_cam.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2009-2012 Gautier Hattenberger ,
+ * 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.
+ */
+
+/** Camera control module for rotorcraft.
+ *
+ * The camera is controled by the heading of the vehicle for pan
+ * and can be controlled by a servo for tilt if defined.
+ *
+ * Four modes:
+ * - NONE: no control
+ * - MANUAL: the servo position is set with PWM
+ * - HEADING: the servo position and the heading of the rotorcraft are set with angles
+ * - WP: the camera is tracking a waypoint (Default: CAM)
+ *
+ * The CAM_SWITCH can be used to power the camera in normal modes
+ * and disable it when in NONE mode
+ */
+
+#ifndef ROTORCRAFT_CAM_H
+#define ROTORCRAFT_CAM_H
+
+#include "generated/airframe.h"
+#include "generated/flight_plan.h"
+#include "math/pprz_algebra_int.h"
+#include "std.h"
+#include "led.h"
+
+#define ROTORCRAFT_CAM_MODE_NONE 0
+#define ROTORCRAFT_CAM_MODE_MANUAL 1
+#define ROTORCRAFT_CAM_MODE_HEADING 2
+#define ROTORCRAFT_CAM_MODE_WP 3
+
+/** Default mode is NONE. */
+#ifndef ROTORCRAFT_CAM_DEFAULT_MODE
+#define ROTORCRAFT_CAM_DEFAULT_MODE ROTORCRAFT_CAM_MODE_NONE
+#endif
+
+/** Cam power control.
+ * By default CAM_SWITCH is used
+ * Warning:
+ * LED_ON set GPIO low on some boards (lpc)
+ * LED_OFF set GPIO high on some boards (lpc)
+ */
+#ifndef ROTORCRAFT_CAM_ON
+#define ROTORCRAFT_CAM_ON LED_OFF(CAM_SWITCH_LED)
+#endif
+#ifndef ROTORCRAFT_CAM_OFF
+#define ROTORCRAFT_CAM_OFF LED_ON(CAM_SWITCH_LED)
+#endif
+
+/** Cam tilt control.
+ * By default use tilt control if a servo is assigned
+ */
+#ifdef ROTORCRAFT_CAM_TILT_SERVO
+#define ROTORCRAFT_CAM_USE_TILT 1
+#else
+#define ROTORCRAFT_CAM_USE_TILT 0
+#endif
+
+/** Use angles for tilt in HEADING and WP modes.
+ */
+#if defined ROTORCRAFT_CAM_TILT_ANGLE_MIN && defined ROTORCRAFT_CAM_TILT_ANGLE_MAX && defined ROTORCRAFT_CAM_USE_TILT
+#define CAM_TA_MIN ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_TILT_ANGLE_MIN)
+#define CAM_TA_MAX ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_TILT_ANGLE_MAX)
+#define ROTORCRAFT_CAM_USE_TILT_ANGLES 1
+#endif
+
+/** Cam pan control.
+ * By default use pan control (heading)
+ */
+#ifndef ROTORCRAFT_CAM_USE_PAN
+#define ROTORCRAFT_CAM_USE_PAN 1
+#endif
+
+/** WP control.
+ * By default use WP_CAM waypoint if defined
+ */
+#ifndef ROTORCRAFT_CAM_TRACK_WP
+#ifdef WP_CAM
+#define ROTORCRAFT_CAM_TRACK_WP WP_CAM
+#endif
+#endif
+
+extern uint8_t rotorcraft_cam_mode;
+
+extern int16_t rotorcraft_cam_tilt;
+extern int16_t rotorcraft_cam_pan;
+extern int16_t rotorcraft_cam_tilt_pwm;
+
+extern void rotorcraft_cam_init(void);
+extern void rotorcraft_cam_periodic(void);
+
+/** Set camera mode.
+ * Camera is powered down in NONE mode if CAM_{ON|OFF} are defined
+ */
+#define rotorcraft_cam_SetCamMode(_v) { \
+ rotorcraft_cam_mode = _v; \
+ if (rotorcraft_cam_mode == ROTORCRAFT_CAM_MODE_NONE) { ROTORCRAFT_CAM_OFF; } \
+ else { ROTORCRAFT_CAM_ON; } \
+}
+
+/** Cam control from datalink message.
+ * camera tilt and pan are incremented by STICK_TILT_INC and STICK_PAN_INC
+ * when maximum command is received from the stick
+ */
+#ifndef ROTORCRAFT_CAM_STICK_TILT_INC
+#define ROTORCRAFT_CAM_STICK_TILT_INC RadOfDeg(10.)
+#endif
+#ifndef ROTORCRAFT_CAM_STICK_PAN_INC
+#define ROTORCRAFT_CAM_STICK_PAN_INC RadOfDeg(20.)
+#endif
+
+#define ROTORCRAFT_CAM_STICK_PARSE(_dl_buffer) { \
+ rotorcraft_cam_tilt += (int16_t)((ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_STICK_TILT_INC)/127.)*(float)DL_ROTORCRAFT_CAM_STICK_tilt(_dl_buffer)); \
+ rotorcraft_cam_pan += (int16_t)((ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_STICK_PAN_INC)/127.)*(float)DL_ROTORCRAFT_CAM_STICK_pan(dl_buffer)); \
+ INT32_COURSE_NORMALIZE(rotorcraft_cam_pan); \
+}
+
+#endif /* ROTORCRAFT_CAM_H */
+
diff --git a/sw/airborne/modules/digital_cam/led_cam_ctrl.h b/sw/airborne/modules/digital_cam/led_cam_ctrl.h
index 421d44b962..0283e6261c 100644
--- a/sw/airborne/modules/digital_cam/led_cam_ctrl.h
+++ b/sw/airborne/modules/digital_cam/led_cam_ctrl.h
@@ -52,15 +52,6 @@
extern uint8_t dc_timer;
-static inline void led_cam_ctrl_init(void)
-{
- // Call common DC init
- dc_init();
-
- // Do LED specific DC init
- dc_timer = 0;
-}
-
#ifndef DC_PUSH
#define DC_PUSH LED_ON
#endif
@@ -77,6 +68,26 @@ static inline void led_cam_ctrl_init(void)
#error DC: Please specify at least a SHUTTER LED
#endif
+static inline void led_cam_ctrl_init(void)
+{
+ // Call common DC init
+ dc_init();
+
+ // Do LED specific DC init
+ dc_timer = 0;
+
+ DC_RELEASE(DC_SHUTTER_LED);
+#ifdef DC_ZOOM_IN_LED
+ DC_RELEASE(DC_ZOOM_IN_LED);
+#endif
+#ifdef DC_ZOOM_OUT_LED
+ DC_RELEASE(DC_ZOOM_OUT_LED);
+#endif
+#ifdef DC_POWER_LED
+ DC_RELEASE(DC_POWER_LED);
+#endif
+}
+
/* 4Hz Periodic */
static inline void led_cam_ctrl_periodic( void )
diff --git a/sw/airborne/modules/drop/booz_drop.c b/sw/airborne/modules/drop/booz_drop.c
deleted file mode 100644
index 206c8a09f3..0000000000
--- a/sw/airborne/modules/drop/booz_drop.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * $Id: $
- *
- * Copyright (C) 2009 Flixr
- *
- * 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 "modules/drop/booz_drop.h"
-#include "modules/core/booz_pwm_arch.h"
-#include "generated/airframe.h"
-
-bool_t booz_drop_ball;
-int16_t booz_drop_servo;
-
-#ifndef DROP_SERVO_OPEN
-#define DROP_SERVO_OPEN 1700
-#endif
-#ifndef DROP_SERVO_CLOSED
-#define DROP_SERVO_CLOSED 900
-#endif
-
-// PWM definition
-#ifndef BoozDropPwm
-#define BoozDropPwm(_v) BoozSetPwmValue(_v)
-#endif
-
-void booz_drop_init(void) {
- booz_drop_ball = FALSE;
- booz_drop_periodic();
-}
-
-void booz_drop_periodic(void) {
- if (booz_drop_ball == TRUE)
- booz_drop_servo = DROP_SERVO_OPEN;
- else
- booz_drop_servo = DROP_SERVO_CLOSED;
- BoozDropPwm(booz_drop_servo);
-}
diff --git a/sw/airborne/modules/geo_mag/geo_mag.c b/sw/airborne/modules/geo_mag/geo_mag.c
old mode 100755
new mode 100644
diff --git a/sw/airborne/modules/geo_mag/geo_mag.h b/sw/airborne/modules/geo_mag/geo_mag.h
old mode 100755
new mode 100644
diff --git a/sw/airborne/modules/led_safety_status/led_safety_status.c b/sw/airborne/modules/led_safety_status/led_safety_status.c
new file mode 100644
index 0000000000..3e7f65ea81
--- /dev/null
+++ b/sw/airborne/modules/led_safety_status/led_safety_status.c
@@ -0,0 +1,80 @@
+/*
+ * $Id: $
+ *
+ * Copyright (C) 2012 Pranay Sinha
+ *
+ * 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 "led.h"
+#include "generated/airframe.h"
+#include "subsystems/electrical.h"
+#include "subsystems/radio_control.h"
+#include "autopilot.h"
+#include "subsystems/ahrs/ahrs_aligner.h"
+#include "autopilot_rc_helpers.h"
+
+#include "led_safety_status.h"
+
+#ifndef SAFETY_WARNING_LED
+#error You must define SAFETY_WARNING_LED to use this module!
+#else
+
+void led_safety_status_init(void) {
+ LED_ON(SAFETY_WARNING_LED);
+ led_safety_status_periodic();
+}
+
+void led_safety_status_periodic(void) {
+ if (radio_control.status == RC_LOST || radio_control.status == RC_REALLY_LOST){
+ RunXTimesEvery(0, 60, 5, 7, {LED_TOGGLE(SAFETY_WARNING_LED);});
+ RunXTimesEvery(130, 130, 10, 6, {LED_TOGGLE(SAFETY_WARNING_LED);});
+ }
+ else if (!(autopilot_mode == MODE_MANUAL) && !autopilot_motors_on){
+ RunXTimesEvery(20, 240, 40, 1, {LED_ON(SAFETY_WARNING_LED);});
+ RunXTimesEvery(0, 240, 40, 1, {LED_OFF(SAFETY_WARNING_LED);});
+ }
+ else if (!THROTTLE_STICK_DOWN() && !autopilot_motors_on){
+ RunXTimesEvery(20, 240, 40, 2, {LED_ON(SAFETY_WARNING_LED);});
+ RunXTimesEvery(0, 240, 40, 2, {LED_OFF(SAFETY_WARNING_LED);});
+ }
+ else if (!ROLL_STICK_CENTERED() && !autopilot_motors_on){
+ RunXTimesEvery(20, 240, 40, 3, {LED_ON(SAFETY_WARNING_LED);});
+ RunXTimesEvery(0, 240, 40, 3, {LED_OFF(SAFETY_WARNING_LED);});
+ }
+ else if (!PITCH_STICK_CENTERED() && !autopilot_motors_on){
+ RunXTimesEvery(20, 240, 40, 4, {LED_ON(SAFETY_WARNING_LED);});
+ RunXTimesEvery(0, 240, 40, 4, {LED_OFF(SAFETY_WARNING_LED);});
+ }
+ else if (!YAW_STICK_CENTERED() && !autopilot_motors_on){
+ RunXTimesEvery(20, 240, 40, 5, {LED_ON(SAFETY_WARNING_LED);});
+ RunXTimesEvery(0, 240, 40, 5, {LED_OFF(SAFETY_WARNING_LED);});
+ }
+#ifdef MIN_BAT_LEVEL
+ else if (electrical.vsupply < (MIN_BAT_LEVEL * 10)){
+ RunOnceEvery(20, {LED_TOGGLE(SAFETY_WARNING_LED);});
+ }
+ else if (electrical.vsupply < ((MIN_BAT_LEVEL + 0.5) * 10)){
+ RunXTimesEvery(0, 300, 10, 10, {LED_TOGGLE(SAFETY_WARNING_LED);});
+ }
+#endif
+ else {
+ LED_ON(SAFETY_WARNING_LED);
+ }
+}
+#endif
diff --git a/sw/airborne/modules/led_safety_status/led_safety_status.h b/sw/airborne/modules/led_safety_status/led_safety_status.h
new file mode 100644
index 0000000000..e49681644e
--- /dev/null
+++ b/sw/airborne/modules/led_safety_status/led_safety_status.h
@@ -0,0 +1,49 @@
+
+/*
+ * $Id: $
+ *
+ * Copyright (C) 2012 Pranay Sinha
+ *
+ * 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.
+ */
+
+/**
+ * @file led_safety_status.h
+ *
+ * Simple module to blink LEDs when battery voltage drops below a certain
+ * level, radio control is lost or when takeoff safety conditions are not met.
+ */
+
+#ifndef LED_SAFETY_STATUS_H
+#define LED_SAFETY_STATUS_H
+
+#include "std.h"
+
+/**
+ * Initialises periodic loop; place more init functions here if expanding driver
+ */
+extern void led_safety_status_init(void);
+
+/**
+ * Periodic function that makes the leds blink in the right pattern for
+ * each situation.
+ */
+extern void led_safety_status_periodic(void);
+
+#endif /* LED_SAFETY_STATUS_H */
+
diff --git a/sw/airborne/modules/sensors/baro_ets.c b/sw/airborne/modules/sensors/baro_ets.c
index aadc702abe..1649552454 100644
--- a/sw/airborne/modules/sensors/baro_ets.c
+++ b/sw/airborne/modules/sensors/baro_ets.c
@@ -62,7 +62,9 @@
#define BARO_ETS_ADDR 0xE8
#define BARO_ETS_REG 0x07
+#ifndef BARO_ETS_SCALE
#define BARO_ETS_SCALE 0.32
+#endif
#define BARO_ETS_OFFSET_MAX 30000
#define BARO_ETS_OFFSET_MIN 10
#define BARO_ETS_OFFSET_NBSAMPLES_INIT 20
diff --git a/sw/airborne/modules/sensors/ezcurrent.c b/sw/airborne/modules/sensors/ezcurrent.c
index 5e9db17cf9..af024d37ce 100644
--- a/sw/airborne/modules/sensors/ezcurrent.c
+++ b/sw/airborne/modules/sensors/ezcurrent.c
@@ -66,7 +66,7 @@ void ezcurrent_read_periodic( void ) {
void ezcurrent_read_event( void ) {
if (ezcurrent_i2c_trans.status == I2CTransSuccess) {
// Get electrical information from buffer
- electrical.vsupply = ((uint8_t)( (((ezcurrent_i2c_trans.buf[3]) << 8) + (ezcurrent_i2c_trans.buf[2])) * 0.01f) );
+ electrical.vsupply = ((uint16_t)( (((ezcurrent_i2c_trans.buf[3]) << 8) + ezcurrent_i2c_trans.buf[2]) * 0.01f) );
electrical.current = ((int32_t)(ezcurrent_i2c_trans.buf[9]) << 8) + (int32_t)(ezcurrent_i2c_trans.buf[8]);
electrical.consumed = ((int32_t)(ezcurrent_i2c_trans.buf[7]) << 8) + (int32_t)(ezcurrent_i2c_trans.buf[6]);
// Transaction has been read
diff --git a/sw/airborne/modules/servo_switch/servo_switch.c b/sw/airborne/modules/servo_switch/servo_switch.c
index 2d90ae53e6..d4a37adec7 100644
--- a/sw/airborne/modules/servo_switch/servo_switch.c
+++ b/sw/airborne/modules/servo_switch/servo_switch.c
@@ -1,6 +1,4 @@
/*
- * $Id: $
- *
* Copyright (C) 2010 Flixr
*
* This file is part of paparazzi.
@@ -23,10 +21,13 @@
#include "servo_switch/servo_switch.h"
#include "generated/airframe.h"
-#include "actuators.h"
+#include "subsystems/actuators.h"
bool_t servo_switch_on;
-int16_t servo_switch_value;
+
+// One level of macro stack to allow redefinition of the default servo
+#define _ServoSwitch(_n, _v) ActuatorSet(_n, _v)
+#define ServoSwitch(_n, _v) _ServoSwitch(_n, _v)
void servo_switch_init(void) {
servo_switch_on = FALSE;
@@ -34,8 +35,10 @@ void servo_switch_init(void) {
}
void servo_switch_periodic(void) {
- if (servo_switch_on == TRUE)
- SetServo(SERVO_SWITCH_SERVO, SERVO_SWITCH_ON_VALUE)
- else
- SetServo(SERVO_SWITCH_SERVO, SERVO_SWITCH_OFF_VALUE)
+ if (servo_switch_on == TRUE) {
+ ServoSwitch(SERVO_SWITCH_SERVO, SERVO_SWITCH_ON_VALUE);
+ }
+ else {
+ ServoSwitch(SERVO_SWITCH_SERVO, SERVO_SWITCH_OFF_VALUE);
+ }
}
diff --git a/sw/airborne/modules/servo_switch/servo_switch.h b/sw/airborne/modules/servo_switch/servo_switch.h
index 24a5a60da2..b2fbfc2476 100644
--- a/sw/airborne/modules/servo_switch/servo_switch.h
+++ b/sw/airborne/modules/servo_switch/servo_switch.h
@@ -26,6 +26,7 @@
#include "std.h"
#include "paparazzi.h"
+#include "generated/airframe.h"
extern bool_t servo_switch_on;
extern int16_t servo_switch_value;
@@ -37,7 +38,7 @@ extern int16_t servo_switch_value;
#define SERVO_SWITCH_OFF_VALUE 1000
#endif
#ifndef SERVO_SWITCH_SERVO
-#define SERVO_SWITCH_SERVO SERVO_SWITCH
+#define SERVO_SWITCH_SERVO SWITCH
#endif
diff --git a/sw/airborne/actuators.c b/sw/airborne/subsystems/actuators.c
similarity index 79%
rename from sw/airborne/actuators.c
rename to sw/airborne/subsystems/actuators.c
index 0d2a660b22..a2789ca768 100644
--- a/sw/airborne/actuators.c
+++ b/sw/airborne/subsystems/actuators.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Pascal Brisset, Antoine Drouin
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -24,6 +25,17 @@
*
*/
-#include "firmwares/fixedwing/actuators.h"
+#include "subsystems/actuators.h"
-uint16_t actuators[SERVOS_NB];
+#if ACTUATORS_NB
+
+int16_t actuators[ACTUATORS_NB];
+
+void actuators_init(void) {
+
+ // Init macro from generated airframe.h
+ AllActuatorsInit();
+
+}
+
+#endif
diff --git a/sw/airborne/firmwares/fixedwing/actuators.h b/sw/airborne/subsystems/actuators.h
similarity index 62%
rename from sw/airborne/firmwares/fixedwing/actuators.h
rename to sw/airborne/subsystems/actuators.h
index 5f310f7a3c..04d90811b6 100644
--- a/sw/airborne/firmwares/fixedwing/actuators.h
+++ b/sw/airborne/subsystems/actuators.h
@@ -1,5 +1,6 @@
/*
* (c) 2003-2005 Pascal Brisset, Antoine Drouin
+ * (c) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -26,32 +27,32 @@
#ifndef ACTUATORS_H
#define ACTUATORS_H
-#if defined ACTUATORS
-
#include "paparazzi.h"
-/** Defines SetActuatorsFromCommands() macro */
+/*
+ * Defines SetActuatorsFromCommands() macro
+ * Defines ACTUATORS_NB to 0 if no servo
+ * Include servos drivers
+ */
#include "generated/airframe.h"
-/** Must be defined by specific hardware implementation */
-extern void actuators_init( void );
+#if ACTUATORS_NB
-/** Temporary storage (for debugging purpose, downlinked via telemetry) */
-extern uint16_t actuators[SERVOS_NB];
+extern void actuators_init(void);
-#include ACTUATORS
+/** Actuators array.
+ * Temporary storage (for debugging purpose, downlinked via telemetry)
+ * */
+extern int16_t actuators[ACTUATORS_NB];
-#define SetServo(x, v) { \
- Actuator(x) = SERVOS_TICS_OF_USEC(ChopServo(v,700,2400)); \
- actuators[x] = v; \
- }
+/** Set actuators.
+ * @param _n actuators name as given in airframe file, servos section
+ * @param _v new actuator's value
+ */
+#define _ActuatorSet(_n, _v) Set_ ## _n ## _Servo(_v)
+#define ActuatorSet(_n, _v) _ActuatorSet(_n, _v)
-#else /* ACTUATORS */
-
-// define empty SetServo makro for sim
-#define SetServo(x, v) {}
-
-#endif /* ACTUATORS */
+#endif /* ACTUATORS_NB */
#endif /* ACTUATORS_H */
diff --git a/sw/airborne/subsystems/actuators/actuators_4015.h b/sw/airborne/subsystems/actuators/actuators_4015.h
new file mode 100644
index 0000000000..07cd56875d
--- /dev/null
+++ b/sw/airborne/subsystems/actuators/actuators_4015.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 Gautier Hattenberger
+ *
+ * This file is part of Paparazzi.
+ *
+ * Paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * Paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ACTUATORS_4015_H
+#define ACTUATORS_4015_H
+
+#include "subsystems/actuators/servos_4015_MAT_hw.h"
+
+#endif /* ACTUATORS_4015_H */
diff --git a/sw/airborne/subsystems/actuators/actuators_pwm.c b/sw/airborne/subsystems/actuators/actuators_4017.h
similarity index 81%
rename from sw/airborne/subsystems/actuators/actuators_pwm.c
rename to sw/airborne/subsystems/actuators/actuators_4017.h
index 8bde49ea92..315382d628 100644
--- a/sw/airborne/subsystems/actuators/actuators_pwm.c
+++ b/sw/airborne/subsystems/actuators/actuators_4017.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Paparazzi Team
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of Paparazzi.
*
@@ -19,10 +19,9 @@
* Boston, MA 02111-1307, USA.
*/
-#include "actuators_pwm.h"
+#ifndef ACTUATORS_4017_H
+#define ACTUATORS_4017_H
-int32_t actuators_pwm_values[ACTUATORS_PWM_NB];
+#include "subsystems/actuators/servos_4017_hw.h"
-void actuators_init(void) {
- actuators_pwm_arch_init();
-}
+#endif /* ACTUATORS_4017_H */
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_asctec.c b/sw/airborne/subsystems/actuators/actuators_asctec.c
similarity index 82%
rename from sw/airborne/firmwares/rotorcraft/actuators/actuators_asctec.c
rename to sw/airborne/subsystems/actuators/actuators_asctec.c
index e49eba07d5..d8ed2ce1c5 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_asctec.c
+++ b/sw/airborne/subsystems/actuators/actuators_asctec.c
@@ -23,14 +23,9 @@
* Actuators driver for Asctec motor controllers.
*/
-#include "firmwares/rotorcraft/actuators.h"
-#include "firmwares/rotorcraft/actuators/actuators_asctec.h"
+#include "subsystems/actuators.h"
+#include "subsystems/actuators/actuators_asctec.h"
-#ifdef ACTUATORS_ASCTEC_V2_PROTOCOL
-#include "firmwares/rotorcraft/actuators/supervision.h"
-#endif
-
-#include "firmwares/rotorcraft/commands.h"
#include "mcu_periph/i2c.h"
#include "mcu_periph/sys_time.h"
@@ -45,7 +40,7 @@ struct ActuatorsAsctec actuators_asctec;
uint32_t actuators_delay_time;
bool_t actuators_delay_done;
-void actuators_init(void) {
+void actuators_asctec_init(void) {
actuators_asctec.cmd = NONE;
actuators_asctec.cur_addr = FRONT;
actuators_asctec.new_addr = FRONT;
@@ -67,14 +62,10 @@ void actuators_init(void) {
actuators_delay_time = 0;
#endif
-#ifdef ACTUATORS_ASCTEC_V2_PROTOCOL
- supervision_init();
-#endif
-
}
#ifndef ACTUATORS_ASCTEC_V2_PROTOCOL
-void actuators_set(bool_t motors_on) {
+void actuators_asctec_set(bool_t motors_on) {
#if defined ACTUATORS_START_DELAY && ! defined SITL
if (!actuators_delay_done) {
if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) return;
@@ -102,10 +93,6 @@ void actuators_set(bool_t motors_on) {
actuators_asctec.cmds[YAW] = 0;
actuators_asctec.cmds[THRUST] = 0;
#else /* ! KILL_MOTORS */
- actuators_asctec.cmds[PITCH] = ((commands[COMMAND_PITCH] + SUPERVISION_TRIM_E) * ASCTEC_MAX_CMD) / MAX_PPRZ;
- actuators_asctec.cmds[ROLL] = ((commands[COMMAND_ROLL] + SUPERVISION_TRIM_A) * ASCTEC_MAX_CMD) / MAX_PPRZ;
- actuators_asctec.cmds[YAW] = ((commands[COMMAND_YAW] + SUPERVISION_TRIM_R) * ASCTEC_MAX_CMD) / MAX_PPRZ;
- actuators_asctec.cmds[THRUST] = (commands[COMMAND_THRUST] * ASCTEC_MAX_THROTTLE) / MAX_PPRZ;
Bound(actuators_asctec.cmds[PITCH],ASCTEC_MIN_CMD, ASCTEC_MAX_CMD);
Bound(actuators_asctec.cmds[ROLL], ASCTEC_MIN_CMD, ASCTEC_MAX_CMD);
Bound(actuators_asctec.cmds[YAW], ASCTEC_MIN_CMD, ASCTEC_MAX_CMD);
@@ -151,7 +138,7 @@ void actuators_set(bool_t motors_on) {
}
#else /* ! ACTUATORS_ASCTEC_V2_PROTOCOL */
-void actuators_set(bool_t motors_on) {
+void actuators_asctec_set(bool_t motors_on) {
#if defined ACTUATORS_START_DELAY && ! defined SITL
if (!actuators_delay_done) {
if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) {
@@ -178,7 +165,6 @@ void actuators_set(bool_t motors_on) {
return;
}
- supervision_run(motors_on, FALSE, commands);
#ifdef KILL_MOTORS
actuators_asctec.i2c_trans.buf[0] = 0;
actuators_asctec.i2c_trans.buf[1] = 0;
@@ -186,10 +172,10 @@ void actuators_set(bool_t motors_on) {
actuators_asctec.i2c_trans.buf[3] = 0;
actuators_asctec.i2c_trans.buf[4] = 0xAA;
#else
- actuators_asctec.i2c_trans.buf[0] = supervision.commands[SERVO_FRONT];
- actuators_asctec.i2c_trans.buf[1] = supervision.commands[SERVO_BACK];
- actuators_asctec.i2c_trans.buf[2] = supervision.commands[SERVO_LEFT];
- actuators_asctec.i2c_trans.buf[3] = supervision.commands[SERVO_RIGHT];
+ actuators_asctec.i2c_trans.buf[0] = actuators_asctec.cmds[SERVO_FRONT];
+ actuators_asctec.i2c_trans.buf[1] = actuators_asctec.cmds[SERVO_BACK];
+ actuators_asctec.i2c_trans.buf[2] = actuators_asctec.cmds[SERVO_LEFT];
+ actuators_asctec.i2c_trans.buf[3] = actuators_asctec.cmds[SERVO_RIGHT];
actuators_asctec.i2c_trans.buf[4] = 0xAA + actuators_asctec.i2c_trans.buf[0] + actuators_asctec.i2c_trans.buf[1] +
actuators_asctec.i2c_trans.buf[2] + actuators_asctec.i2c_trans.buf[3];
#endif
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_asctec.h b/sw/airborne/subsystems/actuators/actuators_asctec.h
similarity index 77%
rename from sw/airborne/firmwares/rotorcraft/actuators/actuators_asctec.h
rename to sw/airborne/subsystems/actuators/actuators_asctec.h
index 8a7ddddeef..1c4fa3dffd 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_asctec.h
+++ b/sw/airborne/subsystems/actuators/actuators_asctec.h
@@ -28,27 +28,29 @@
#include "mcu_periph/i2c.h"
-enum actuators_astec_cmd { NONE,
+#include "generated/airframe.h"
+
+enum actuators_asctec_cmd { NONE,
TEST,
REVERSE,
SET_ADDR };
-enum actuators_astec_addr { FRONT,
+enum actuators_asctec_addr { FRONT,
BACK,
LEFT,
RIGHT };
/* this is for the v1 protocol which does its own mixing */
-enum actuators_astec_cmds { PITCH,
+enum actuators_asctec_cmds { PITCH,
ROLL,
YAW,
THRUST,
CMD_NB };
struct ActuatorsAsctec {
- enum actuators_astec_cmd cmd;
- enum actuators_astec_addr cur_addr;
- enum actuators_astec_addr new_addr;
+ enum actuators_asctec_cmd cmd;
+ enum actuators_asctec_addr cur_addr;
+ enum actuators_asctec_addr new_addr;
int32_t cmds[CMD_NB];
struct i2c_transaction i2c_trans;
volatile uint32_t nb_err;
@@ -69,5 +71,12 @@ extern struct ActuatorsAsctec actuators_asctec;
actuators_asctec.cur_addr = _v; \
}
+extern void actuators_asctec_init(void);
+extern void actuators_asctec_set(bool_t motors_on);
+
+#define ActuatorAsctecSet(_i, _v) { actuators_asctec.cmds[_i] = _v; }
+#define ActuatorsAsctecInit() actuators_asctec_init()
+#define ActuatorsAsctecCommit() actuators_asctec_set(autopilot_motors_on)
+
#endif /* ACTUATORS_ASCTEC_H */
diff --git a/sw/airborne/subsystems/actuators/actuators_default.h b/sw/airborne/subsystems/actuators/actuators_default.h
new file mode 100644
index 0000000000..f3a0e750f0
--- /dev/null
+++ b/sw/airborne/subsystems/actuators/actuators_default.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 Gautier Hattenberger
+ *
+ * This file is part of Paparazzi.
+ *
+ * Paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * Paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ACTUATORS_DEFAULT_H
+#define ACTUATORS_DEFAULT_H
+
+/** Dummy include of default actuators header
+ */
+#include BOARD_CONFIG
+#include DEFAULT_ACTUATORS
+
+#endif /* ACTUATORS_DEFAULT_H */
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_dummy.c b/sw/airborne/subsystems/actuators/actuators_dummy.h
similarity index 78%
rename from sw/airborne/firmwares/rotorcraft/actuators/actuators_dummy.c
rename to sw/airborne/subsystems/actuators/actuators_dummy.h
index d8cbc1e706..5148c7b7b7 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_dummy.c
+++ b/sw/airborne/subsystems/actuators/actuators_dummy.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009 Antoine Drouin
+ * Copyright (C) 2012 Gautier Hattenberger
*
* This file is part of paparazzi.
*
@@ -19,11 +19,11 @@
* Boston, MA 02111-1307, USA.
*/
-#include "firmwares/rotorcraft/actuators.h"
+#ifndef ACTUATORS_DUMMY_H
+#define ACTUATORS_DUMMY_H
+#define ActuatorDummySet(_i, _v) {}
+#define ActuatorsDummyInit() {}
+#define ActuatorsDummyCommit() {}
-void actuators_init(void) {
-}
-
-void actuators_set(bool_t motors_on) {
-}
+#endif
diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c b/sw/airborne/subsystems/actuators/actuators_mkk.c
similarity index 85%
rename from sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c
rename to sw/airborne/subsystems/actuators/actuators_mkk.c
index 3a037eba0d..23f8c0c0e8 100644
--- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_mkk.c
+++ b/sw/airborne/subsystems/actuators/actuators_mkk.c
@@ -23,10 +23,9 @@
* Actuators driver for Mikrokopter motor controllers.
*/
-#include "firmwares/rotorcraft/actuators.h"
-#include "firmwares/rotorcraft/actuators/actuators_mkk.h"
+#include "subsystems/actuators.h"
+#include "subsystems/actuators/actuators_mkk.h"
-#include "firmwares/rotorcraft/commands.h"
#include "mcu_periph/i2c.h"
#include "mcu_periph/sys_time.h"
@@ -37,9 +36,8 @@ struct ActuatorsMkk actuators_mkk;
uint32_t actuators_delay_time;
bool_t actuators_delay_done;
-void actuators_init(void) {
+void actuators_mkk_init(void) {
- supervision_init();
const uint8_t actuators_addr[ACTUATORS_MKK_NB] = ACTUATORS_MKK_ADDR;
for (uint8_t i=0; i
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+
+#define MOTOR_MIXING_MIN_MOTOR 0
+#define MOTOR_MIXING_MAX_MOTOR MAX_PPRZ
+
+#ifndef MOTOR_MIXING_STOP_MOTOR
+#define MOTOR_MIXING_STOP_MOTOR -MAX_PPRZ
+#endif
+
+#ifndef MOTOR_MIXING_MIN_MOTOR_STARTUP
+#define MOTOR_MIXING_MIN_MOTOR_STARTUP MOTOR_MIXING_MIN_MOTOR
+#endif
+
+#if defined (MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP) || defined (MOTOR_MIXING_MAX_POSITIVE_MOTOR_STEP)
+#define MOTOR_MIXING_USE_MAX_MOTOR_STEP_BINDING
+
+#ifndef MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP
+#define MOTOR_MIXING_MAX_NEGATIVE_MOTOR_STEP INT32_MIN
+#endif
+/*
+#ifndef MOTOR_MIXING_MAX_POSITIVE_MOTOR_STEP
+#define MOTOR_MIXING_MAX_POSITIVE_MOTOR_STEP INT32_MAX
+#endif
+*/
+#endif
+
+static const int32_t roll_coef[MOTOR_MIXING_NB_MOTOR] = MOTOR_MIXING_ROLL_COEF;
+static const int32_t pitch_coef[MOTOR_MIXING_NB_MOTOR] = MOTOR_MIXING_PITCH_COEF;
+static const int32_t yaw_coef[MOTOR_MIXING_NB_MOTOR] = MOTOR_MIXING_YAW_COEF;
+static const int32_t thrust_coef[MOTOR_MIXING_NB_MOTOR] = MOTOR_MIXING_THRUST_COEF;
+
+struct MotorMixing motor_mixing;
+
+void motor_mixing_init(void) {
+ uint8_t i;
+ for (i=0; i i * max_counter / (MOTOR_MIXING_NB_MOTOR + MOTOR_MIXING_STARTUP_DELAY)) {
+ if (counter > MOTOR_MIXING_NB_MOTOR * max_counter / (MOTOR_MIXING_NB_MOTOR + MOTOR_MIXING_STARTUP_DELAY)) {
+ motor_mixing.commands[i] = MOTOR_MIXING_MIN_MOTOR_STARTUP + (MOTOR_MIXING_MIN_MOTOR - MOTOR_MIXING_MIN_MOTOR_STARTUP) * counter / max_counter;
+ } else {
+ motor_mixing.commands[i] = MOTOR_MIXING_MIN_MOTOR_STARTUP;
+ }
+ } else {
+ motor_mixing.commands[i] = 0;
+ }
+#else
+ if (counter < i * max_counter / MOTOR_MIXING_NB_MOTOR) {
+ motor_mixing.commands[i] = MOTOR_MIXING_MIN_MOTOR_STARTUP;
+ }
+#endif
+ }
+}
+
+void motor_mixing_run(bool_t motors_on, bool_t override_on, pprz_t in_cmd[] ) {
+ uint8_t i;
+ if (motors_on) {
+ int32_t min_cmd = INT32_MAX;
+ int32_t max_cmd = INT32_MIN;
+ /* do the mixing in float to avoid overflows, implicitly casted back to int32_t */
+ for (i=0; i max_cmd)
+ max_cmd = motor_mixing.commands[i];
+ }
+ if (min_cmd < MOTOR_MIXING_MIN_MOTOR && max_cmd > MOTOR_MIXING_MAX_MOTOR)
+ motor_mixing.nb_failure++;
+ if (min_cmd < MOTOR_MIXING_MIN_MOTOR)
+ offset_commands(-(min_cmd - MOTOR_MIXING_MIN_MOTOR));
+ if (max_cmd > MOTOR_MIXING_MAX_MOTOR)
+ offset_commands(-(max_cmd - MOTOR_MIXING_MAX_MOTOR));
+
+ /* For testing motor failure */
+ if (motors_on && override_on) {
+ for (i = 0; i < MOTOR_MIXING_NB_MOTOR; i++) {
+ if (motor_mixing.override_enabled[i])
+ motor_mixing.commands[i] = motor_mixing.override_value[i];
+ }
+ }
+ bound_commands();
+ bound_commands_step();
+ }
+ else {
+ for (i=0; ix - ecef_pos->x);
+ if ( xdiff > MAX_DISTANCE ) return TRUE;
+ int32_t ydiff = abs(ecef_ref->y - ecef_pos->y);
+ if ( ydiff > MAX_DISTANCE ) return TRUE;
+ int32_t zdiff = abs(ecef_ref->z - ecef_pos->z);
+ if ( zdiff > MAX_DISTANCE ) return TRUE;
+
+ return FALSE;
+}
diff --git a/sw/airborne/subsystems/ins/ins_alt_float.c b/sw/airborne/subsystems/ins/ins_alt_float.c
index f82ebc1143..4e927a31e1 100644
--- a/sw/airborne/subsystems/ins/ins_alt_float.c
+++ b/sw/airborne/subsystems/ins/ins_alt_float.c
@@ -32,6 +32,8 @@
#include "subsystems/gps.h"
#include "subsystems/nav.h"
+#include "generated/airframe.h"
+
#ifdef DEBUG_ALT_KALMAN
#include "mcu_periph/uart.h"
#include "ap_downlink.h"
diff --git a/sw/airborne/subsystems/navigation/gls.c b/sw/airborne/subsystems/navigation/gls.c
index b7e7806d58..33ea256b38 100644
--- a/sw/airborne/subsystems/navigation/gls.c
+++ b/sw/airborne/subsystems/navigation/gls.c
@@ -148,7 +148,7 @@ bool_t gls(uint8_t _af, uint8_t _tod, uint8_t _td) {
float start_alt = WaypointAlt(_tod);
float diff_alt = WaypointAlt(_td) - start_alt;
float alt = start_alt + nav_final_progress * diff_alt;
- Bound(alt, WaypointAlt(_td), start_alt +(pre_climb/(v_ctl_altitude_pgain))) // to prevent climbing before intercept
+ Bound(alt, WaypointAlt(_td), start_alt +(pre_climb/(-v_ctl_altitude_pgain))) // to prevent climbing before intercept
diff --git a/sw/airborne/test/test_actuators.c b/sw/airborne/test/test_actuators.c
index c7380336d0..d6e6c66a71 100644
--- a/sw/airborne/test/test_actuators.c
+++ b/sw/airborne/test/test_actuators.c
@@ -27,8 +27,8 @@
#include "led.h"
#include "mcu_periph/i2c.h"
-#include "firmwares/rotorcraft/commands.h"
-#include "firmwares/rotorcraft/actuators.h"
+#include "subsystems/commands.h"
+#include "subsystems/actuators.h"
static inline void main_init( void );
static inline void main_periodic_task( void );
@@ -61,7 +61,7 @@ static inline void main_periodic_task( void ) {
commands[COMMAND_YAW]=0;
commands[COMMAND_THRUST]=1;
- actuators_set(TRUE);
+ //actuators_set(TRUE);
LED_PERIODIC();
diff --git a/sw/ext/libopencm3 b/sw/ext/libopencm3
index 7011d47c70..4e4496f70d 160000
--- a/sw/ext/libopencm3
+++ b/sw/ext/libopencm3
@@ -1 +1 @@
-Subproject commit 7011d47c70076f995e8470c59eeaa8f3efcc9f05
+Subproject commit 4e4496f70d00fe24b2c5d594d6500f537eeb6478
diff --git a/sw/ext/luftboot b/sw/ext/luftboot
index 805d290c28..bac7a50720 160000
--- a/sw/ext/luftboot
+++ b/sw/ext/luftboot
@@ -1 +1 @@
-Subproject commit 805d290c28bb74e7cfb1a6daccc18c5646423f80
+Subproject commit bac7a50720a5ac111660baa6afa2cec4f36651fd
diff --git a/sw/ext/stm32loader b/sw/ext/stm32loader
deleted file mode 160000
index eca6b5a43a..0000000000
--- a/sw/ext/stm32loader
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit eca6b5a43a6898c798d36dbdbdaf84ffbb587e34
diff --git a/sw/ground_segment/tmtc/ivy_serial_bridge.c b/sw/ground_segment/tmtc/ivy_serial_bridge.c
index c31a6c990a..27486b9f82 100644
--- a/sw/ground_segment/tmtc/ivy_serial_bridge.c
+++ b/sw/ground_segment/tmtc/ivy_serial_bridge.c
@@ -231,7 +231,7 @@ void send_ivy(void)
-
+
*/
@@ -273,7 +273,7 @@ void send_ivy(void)
/*
-
+
diff --git a/sw/ground_segment/tmtc/link.ml b/sw/ground_segment/tmtc/link.ml
index f99f70f5a7..f16ddf08c9 100644
--- a/sw/ground_segment/tmtc/link.ml
+++ b/sw/ground_segment/tmtc/link.ml
@@ -426,6 +426,7 @@ let () =
let ivy_bus = ref Defivybus.default_ivy_bus
and port = ref "/dev/ttyUSB0"
and baudrate = ref "9600"
+ and hw_flow_control = ref false
and transport = ref "pprz"
and uplink = ref true
and audio = ref false
@@ -443,6 +444,7 @@ let () =
"-noac_info", Arg.Clear ac_info, (sprintf "Disables AC traffic info (uplink).");
"-nouplink", Arg.Clear uplink, (sprintf "Disables the uplink (from the ground to the aircraft).");
"-s", Arg.Set_string baudrate, (sprintf " Default is %s" !baudrate);
+ "-hfc", Arg.Set hw_flow_control, "Enable UART hardware flow control (CTS/RTS)";
"-local_timestamp", Arg.Unit (fun () -> add_timestamp := Some (Unix.gettimeofday ())), "Add local timestamp to messages sent over ivy";
"-transport", Arg.Set_string transport, (sprintf " Available protocols are modem,pprz,pprz2 and xbee. Default is %s" !transport);
"-udp", Arg.Set udp, "Listen a UDP connection on ";
@@ -475,7 +477,7 @@ let () =
end else if !audio then
Demod.init !port
else if on_serial_device then
- Serial.opendev !port (Serial.speed_of_baudrate !baudrate)
+ Serial.opendev !port (Serial.speed_of_baudrate !baudrate) !hw_flow_control
else
Unix.openfile !port [Unix.O_RDWR] 0o640
in
diff --git a/sw/in_progress/rctx/main_rctx.c b/sw/in_progress/rctx/main_rctx.c
index 96f2e6e910..9ad792c5b3 100644
--- a/sw/in_progress/rctx/main_rctx.c
+++ b/sw/in_progress/rctx/main_rctx.c
@@ -95,7 +95,7 @@ struct adc_buf vsupply_adc_buf;
#define LOW_BATTERY_DECIVOLT (CATASTROPHIC_BAT_LEVEL*10)
-uint8_t rctx_vsupply_decivolt;
+uint16_t rctx_vsupply_decivolt;
uint8_t rctx_under_voltage;
uint8_t rctx_mode;
diff --git a/sw/in_progress/satcom/tcp2ivy.c b/sw/in_progress/satcom/tcp2ivy.c
index 8a03082ce7..f8f1635e04 100644
--- a/sw/in_progress/satcom/tcp2ivy.c
+++ b/sw/in_progress/satcom/tcp2ivy.c
@@ -71,7 +71,7 @@ unsigned char gps_utm_zone;
int gps_lat, gps_lon; /* 1e7 deg */
int gps_hmsl;
short estimator_airspeed;
-unsigned char electrical_vsupply;
+unsigned short electrical_vsupply;
unsigned char nav_block;
unsigned char energy;
unsigned char throttle;
diff --git a/sw/in_progress/satcom/tcp2ivy_generic.c b/sw/in_progress/satcom/tcp2ivy_generic.c
index d93fa127f6..5f6a389b2a 100644
--- a/sw/in_progress/satcom/tcp2ivy_generic.c
+++ b/sw/in_progress/satcom/tcp2ivy_generic.c
@@ -74,7 +74,7 @@ unsigned char gps_utm_zone;
int gps_lat, gps_lon; /* 1e7 deg */
int gps_hmsl;
short estimator_airspeed;
-unsigned char electrical_vsupply;
+unsigned short electrical_vsupply;
unsigned char nav_block;
unsigned short energy;
unsigned char throttle;
@@ -124,6 +124,7 @@ static gboolean read_data(GIOChannel *chan, GIOCondition cond, gpointer data) {
// FillBufWith16bit(com_trans.buf, 15, (uint16_t)(estimator_airspeed*100)); // TAS (cm/s)
estimator_airspeed = buf2ushort(&buf[14]);
// com_trans.buf[17] = electrical.vsupply; // decivolt
+ //FIXME: electrical.vsupply is now a uint16
electrical_vsupply = buf[16];
// com_trans.buf[18] = (uint8_t)(energy / 100); // deciAh
energy = buf[17];
diff --git a/sw/include/std.h b/sw/include/std.h
index e99084da02..c3a258dc51 100644
--- a/sw/include/std.h
+++ b/sw/include/std.h
@@ -118,6 +118,20 @@ typedef uint8_t unit_t;
} \
}
+#define RunXTimesEvery(_jumpstart, _prescaler, _interval, _xtimes, _code) { \
+ static uint16_t prescaler = _jumpstart; \
+ static uint16_t xtimes = 0; \
+ prescaler++; \
+ if (prescaler >= _prescaler + _interval*xtimes && xtimes < _xtimes) { \
+ _code; \
+ xtimes++; \
+ } \
+ if (xtimes >= _xtimes) { \
+ xtimes = 0; \
+ prescaler = 0; \
+ } \
+}
+
#define PeriodicPrescaleBy5( _code_0, _code_1, _code_2, _code_3, _code_4) { \
static uint8_t _50hz = 0; \
diff --git a/sw/lib/ocaml/cserial.c b/sw/lib/ocaml/cserial.c
index a2c639d531..d6b9a66cb9 100644
--- a/sw/lib/ocaml/cserial.c
+++ b/sw/lib/ocaml/cserial.c
@@ -40,7 +40,7 @@ static int baudrates[] = { B0, B50, B75, B110, B134, B150, B200, B300, B600, B12
/****************************************************************************/
/* Open serial device for requested protocoll */
/****************************************************************************/
-value c_init_serial(value device, value speed)
+value c_init_serial(value device, value speed, value hw_flow_control)
{
struct termios orig_termios, cur_termios;
@@ -63,8 +63,14 @@ value c_init_serial(value device, value speed)
cur_termios.c_oflag &=~(OPOST|ONLCR|OCRNL|ONOCR|ONLRET);
/* control modes */
- cur_termios.c_cflag &= ~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL|CRTSCTS);
- cur_termios.c_cflag |= CREAD|CS8|CLOCAL;
+ if (Bool_val(hw_flow_control)) {
+ cur_termios.c_cflag &= ~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL);
+ cur_termios.c_cflag |= CREAD|CS8|CLOCAL|CRTSCTS;
+ }
+ else {
+ cur_termios.c_cflag &= ~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL|CRTSCTS);
+ cur_termios.c_cflag |= CREAD|CS8|CLOCAL;
+ }
/* local modes */
cur_termios.c_lflag &= ~(ISIG|ICANON|IEXTEN|ECHO|FLUSHO|PENDIN);
diff --git a/sw/lib/ocaml/serial.ml b/sw/lib/ocaml/serial.ml
index 6e11af4988..a7e0e87233 100644
--- a/sw/lib/ocaml/serial.ml
+++ b/sw/lib/ocaml/serial.ml
@@ -77,13 +77,13 @@ let string_of_payload = fun x -> x
let payload_of_string = fun x -> x
-external init_serial : string -> speed -> Unix.file_descr = "c_init_serial"
+external init_serial : string -> speed -> bool -> Unix.file_descr = "c_init_serial"
external set_dtr : Unix.file_descr -> bool -> unit = "c_set_dtr"
external set_speed : Unix.file_descr -> speed -> unit = "c_serial_set_baudrate"
-let opendev device speed =
+let opendev device speed hw_flow_control =
try
- init_serial device speed
+ init_serial device speed hw_flow_control
with
Failure x ->
failwith (Printf.sprintf "Error %s (%s)" x device)
diff --git a/sw/lib/ocaml/serial.mli b/sw/lib/ocaml/serial.mli
index 375559631d..9173d4b5df 100644
--- a/sw/lib/ocaml/serial.mli
+++ b/sw/lib/ocaml/serial.mli
@@ -49,7 +49,7 @@ type speed =
val speed_of_baudrate : string -> speed
-val opendev : string -> speed -> Unix.file_descr
+val opendev : string -> speed -> bool -> Unix.file_descr
val close : Unix.file_descr -> unit
val set_dtr : Unix.file_descr -> bool -> unit
val set_speed : Unix.file_descr -> speed -> unit
diff --git a/sw/logalizer/matlab_log/messages.xml b/sw/logalizer/matlab_log/messages.xml
index c749615108..8c8f23751b 100644
--- a/sw/logalizer/matlab_log/messages.xml
+++ b/sw/logalizer/matlab_log/messages.xml
@@ -62,7 +62,7 @@
-
+
@@ -241,7 +241,7 @@
-
+
diff --git a/sw/logalizer/play_core.ml b/sw/logalizer/play_core.ml
index d910eda6eb..86d7d871c0 100644
--- a/sw/logalizer/play_core.ml
+++ b/sw/logalizer/play_core.ml
@@ -122,6 +122,7 @@ let was_running = ref false
let bus = ref Defivybus.default_ivy_bus
let port = ref "/dev/ttyUSB0"
let baudrate = ref "9600"
+let hw_flow_control = ref false
let file_to_load = ref ""
let output_on_serial = ref false
@@ -177,7 +178,8 @@ let init = fun () ->
[ "-b", Arg.String (fun x -> bus := x), (sprintf " Default is %s" !bus);
"-d", Arg.Set_string port, (sprintf " Default is %s" !port);
"-o", Arg.Set output_on_serial, "Output binary messages on serial port";
- "-s", Arg.Set_string baudrate, (sprintf " Default is %s" !baudrate)]
+ "-s", Arg.Set_string baudrate, (sprintf " Default is %s" !baudrate);
+ "-shfc", Arg.Set hw_flow_control, "Enable UART hardware flow control (CTS/RTS)";]
(fun x -> file_to_load := x)
"Usage: ";
@@ -187,7 +189,7 @@ let init = fun () ->
let serial_port =
if !output_on_serial then
- Some (Unix.out_channel_of_descr (Serial.opendev !port (Serial.speed_of_baudrate !baudrate)))
+ Some (Unix.out_channel_of_descr (Serial.opendev !port (Serial.speed_of_baudrate !baudrate) !hw_flow_control))
else
None in
diff --git a/sw/simulator/nps/nps_autopilot_rotorcraft.c b/sw/simulator/nps/nps_autopilot_rotorcraft.c
index 08d5d19dd2..51ae195d95 100644
--- a/sw/simulator/nps/nps_autopilot_rotorcraft.c
+++ b/sw/simulator/nps/nps_autopilot_rotorcraft.c
@@ -32,7 +32,7 @@
#include "mcu_periph/sys_time.h"
#include "state.h"
-#include "actuators/supervision.h"
+#include "subsystems/actuators/motor_mixing.h"
struct NpsAutopilot autopilot;
@@ -100,8 +100,8 @@ void nps_autopilot_run_step(double time __attribute__ ((unused))) {
/* scale final motor commands to 0-1 for feeding the fdm */
/* FIXME: autopilot.commands is of length NB_COMMANDS instead of number of motors */
- for (uint8_t i=0; i
define (name^"_NEUTRAL") (sof neutral);
define (name^"_TRAVEL_UP") (sof travel_up);
+ define_integer (name^"_TRAVEL_UP") travel_up 16;
define (name^"_TRAVEL_DOWN") (sof travel_down);
+ define_integer (name^"_TRAVEL_DOWN") travel_down 16;
let min = Pervasives.min min max
and max = Pervasives.max min max in
@@ -150,7 +152,18 @@ let preprocess_value = fun s v prefix ->
let s = Str.global_replace pprz_value (sprintf "%s[%s_\\1]" v prefix) s in
Str.global_replace var_value "_var_\\1" s
-
+let print_actuators_idx = fun () ->
+ let nb = Hashtbl.fold (fun s d i ->
+ printf "#define SERVO_%s_IDX %d\n" s i;
+ (* Set servo macro *)
+ printf "#define Set_%s_Servo(_v) { \\\n" s;
+ printf " actuators[SERVO_%s_IDX] = Chop(_v, SERVO_%s_MIN, SERVO_%s_MAX); \\\n" s s s;
+ printf " Actuator%sSet(SERVO_%s, actuators[SERVO_%s_IDX]); \\\n" d s s;
+ printf "}\n\n";
+ i+1
+ ) servos_drivers 0 in
+ define "ACTUATORS_NB" (string_of_int nb);
+ nl ()
let parse_command_laws = fun command ->
let a = fun s -> ExtXml.attrib command s in
@@ -159,63 +172,30 @@ let parse_command_laws = fun command ->
let servo = a "servo"
and value = a "value" in
let v = preprocess_value value "values" "COMMAND" in
- printf " command_value = %s;\\\n" v;
- printf " command_value *= command_value>0 ? SERVO_%s_TRAVEL_UP : SERVO_%s_TRAVEL_DOWN;\\\n" servo servo;
- printf " servo_value = SERVO_%s_NEUTRAL + (int32_t)(command_value);\\\n" servo;
- printf " actuators[SERVO_%s] = ChopServo(servo_value, SERVO_%s_MIN, SERVO_%s_MAX);\\\n\\\n" servo servo servo;
-
- let driver = get_servo_driver servo in
- printf " Actuator%s(SERVO_%s) = SERVOS_TICS_OF_USEC(actuators[SERVO_%s]);\\\n\\\n" driver servo servo
+ printf " command_value = %s; \\\n" v;
+ printf " command_value *= command_value>0 ? SERVO_%s_TRAVEL_UP_NUM : SERVO_%s_TRAVEL_DOWN_NUM; \\\n" servo servo;
+ printf " command_value /= command_value>0 ? SERVO_%s_TRAVEL_UP_DEN : SERVO_%s_TRAVEL_DOWN_DEN; \\\n" servo servo;
+ printf " servo_value = SERVO_%s_NEUTRAL + command_value; \\\n" servo;
+ printf " Set_%s_Servo(servo_value); \\\n\\\n" servo
| "let" ->
let var = a "var"
and value = a "value" in
let v = preprocess_value value "values" "COMMAND" in
- printf " int16_t _var_%s = %s;\\\n" var v
+ printf " int16_t _var_%s = %s; \\\n" var v
+ | "call" ->
+ let f = a "fun" in
+ printf " %s; \\\n\\\n" f
| "ratelimit" ->
let var = a "var"
and value = a "value"
and rate_min = a "rate_min"
and rate_max = a "rate_max" in
let v = preprocess_value value "values" "COMMAND" in
- printf " static int16_t _var_%s = 0; _var_%s += Chop((%s) - (_var_%s), (%s), (%s));\\\n" var var v var rate_min rate_max
+ printf " static int16_t _var_%s = 0; _var_%s += Chop((%s) - (_var_%s), (%s), (%s)); \\\n" var var v var rate_min rate_max
| "define" ->
parse_element "" command
| _ -> xml_error "set|let"
-let parse_csc_fields = fun csc_fields ->
- let a = fun s -> ExtXml.attrib csc_fields s in
- match Xml.tag csc_fields with
- "field_map" ->
- let servo_id = a "servo_id"
- and field = a "field" in
- printf " temp.%s = actuators[%s]; \\\n" field servo_id;
- | _ -> xml_error "field_map"
-
-let parse_csc_messages = (let msg_index_ref = ref 0 in fun csc_id csc_messages ->
- let a = fun s -> ExtXml.attrib csc_messages s in
- match Xml.tag csc_messages with
- "msg" ->
- let msg_id = a "id"
- and msg_type = a "type"
- and msg_index = msg_index_ref.contents in
- msg_index_ref.contents <- msg_index + 1;
- printf "{\\\n struct Csc%s temp; \\\n" msg_type;
- List.iter parse_csc_fields (Xml.children csc_messages);
- printf " can_write_csc(%s, CSC_%s, (uint8_t *)&temp, sizeof(struct Csc%s)); \\\n" csc_id msg_id msg_type;
- printf "} \\\n"
- | _ -> xml_error "msg"
- )
-
-let parse_csc_boards = fun csc_board ->
- let a = fun s -> ExtXml.attrib csc_board s in
- match Xml.tag csc_board with
- "board" ->
- let csc_id = a "id" in
- List.iter (parse_csc_messages csc_id) (Xml.children csc_board);
- | "define" ->
- parse_element "" csc_board
- | _ -> xml_error "board"
-
let parse_rc_commands = fun rc ->
let a = fun s -> ExtXml.attrib rc s in
match Xml.tag rc with
@@ -255,11 +235,12 @@ let rec parse_section = fun s ->
List.iter (parse_element prefix) (Xml.children s);
nl ()
| "servos" ->
- let driver = ExtXml.attrib_or_default s "driver" "" in
+ let driver = ExtXml.attrib_or_default s "driver" "Default" in
let servos = Xml.children s in
let nb_servos = List.fold_right (fun s m -> Pervasives.max (int_of_string (ExtXml.attrib s "no")) m) servos min_int + 1 in
- define "SERVOS_NB" (string_of_int nb_servos);
+ define (sprintf "SERVOS_%s_NB" (String.uppercase driver)) (string_of_int nb_servos);
+ printf "#include \"subsystems/actuators/actuators_%s.h\"\n" (String.lowercase driver);
nl ();
List.iter (parse_servo driver) servos;
nl ()
@@ -282,9 +263,11 @@ let rec parse_section = fun s ->
List.iter parse_ap_only_commands (Xml.children s);
printf "}\n\n"
| "command_laws" ->
+ print_actuators_idx ();
+
printf "#define SetActuatorsFromCommands(values) { \\\n";
- printf " uint32_t servo_value;\\\n";
- printf " float command_value;\\\n";
+ printf " int32_t servo_value;\\\n";
+ printf " int32_t command_value;\\\n\\\n";
List.iter parse_command_laws (Xml.children s);
@@ -295,12 +278,6 @@ let rec parse_section = fun s ->
printf "#define AllActuatorsInit() { \\\n";
List.iter (fun d -> printf " Actuators%sInit();\\\n" d) drivers;
printf "}\n\n";
- | "csc_boards" ->
- let boards = Array.of_list (Xml.children s) in
- define "CSC_BOARD_NB" (string_of_int (Array.length boards));
- printf "#define SendCscFromActuators() { \\\n";
- List.iter parse_csc_boards (Xml.children s);
- printf "}\n"
| "include" ->
let filename = ExtXml.attrib s "href" in
let subxml = Xml.parse_file filename in
diff --git a/sw/tools/stm32loader/COPYING3 b/sw/tools/stm32loader/COPYING3
new file mode 100644
index 0000000000..20d40b6bce
--- /dev/null
+++ b/sw/tools/stm32loader/COPYING3
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
\ No newline at end of file
diff --git a/sw/tools/stm32loader/README b/sw/tools/stm32loader/README
new file mode 100644
index 0000000000..ac096dc88c
--- /dev/null
+++ b/sw/tools/stm32loader/README
@@ -0,0 +1,29 @@
+STM32Loader
+===========
+
+Python script which will talk to the STM32 bootloader to upload and download firmware.
+
+Original Version by: Ivan A-R
+
+
+Usage: ./stm32loader.py [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin]
+ -h This help
+ -q Quiet
+ -V Verbose
+ -e Erase
+ -w Write
+ -v Verify
+ -r Read
+ -l length Length of read
+ -p port Serial port (default: /dev/tty.usbserial-ftCYPMYJ)
+ -b baud Baud speed (default: 115200)
+ -a addr Target address
+
+ ./stm32loader.py -e -w -v example/main.bin
+
+
+Example:
+stm32loader.py -e -w -v somefile.bin
+
+This will pre-erase flash, write somefile.bin to the flash on the device, and then perform a verification after writing is finished.
+
diff --git a/sw/tools/stm32loader/stm32loader.py b/sw/tools/stm32loader/stm32loader.py
new file mode 100755
index 0000000000..67e3b6f625
--- /dev/null
+++ b/sw/tools/stm32loader/stm32loader.py
@@ -0,0 +1,431 @@
+#!/usr/bin/env python
+
+# -*- coding: utf-8 -*-
+# vim: sw=4:ts=4:si:et:enc=utf-8
+
+# Author: Ivan A-R
+# Project page: http://tuxotronic.org/wiki/projects/stm32loader
+#
+# This file is part of stm32loader.
+#
+# stm32loader 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 3, or (at your option) any later
+# version.
+#
+# stm32loader 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 stm32loader; see the file COPYING3. If not see
+# .
+
+import sys, getopt
+import serial
+import time
+
+try:
+ from progressbar import *
+ usepbar = 1
+except:
+ usepbar = 0
+
+# Verbose level
+QUIET = 20
+
+def mdebug(level, message):
+ if(QUIET >= level):
+ print >> sys.stderr , message
+
+
+class CmdException(Exception):
+ pass
+
+class CommandInterface:
+ def open(self, aport='/dev/tty.usbserial-ftCYPMYJ', abaudrate=115200) :
+ self.sp = serial.Serial(
+ port=aport,
+ baudrate=abaudrate, # baudrate
+ bytesize=8, # number of databits
+ parity=serial.PARITY_EVEN,
+ stopbits=1,
+ xonxoff=0, # enable software flow control
+ rtscts=0, # disable RTS/CTS flow control
+ timeout=5 # set a timeout value, None for waiting forever
+ )
+
+
+ def _wait_for_ask(self, info = ""):
+ # wait for ask
+ try:
+ ask = ord(self.sp.read())
+ except:
+ raise CmdException("Can't read port or timeout")
+ else:
+ if ask == 0x79:
+ # ACK
+ return 1
+ else:
+ if ask == 0x1F:
+ # NACK
+ raise CmdException("NACK "+info)
+ else:
+ # Unknow responce
+ raise CmdException("Unknow response. "+info+": "+hex(ask))
+
+
+ def reset(self):
+ self.sp.setDTR(0)
+ time.sleep(0.1)
+ self.sp.setDTR(1)
+ time.sleep(0.5)
+
+ def initChip(self):
+ # Set boot
+ self.sp.setRTS(0)
+ self.reset()
+
+ self.sp.write("\x7F") # Syncro
+ return self._wait_for_ask("Syncro")
+
+ def releaseChip(self):
+ self.sp.setRTS(1)
+ self.reset()
+
+ def cmdGeneric(self, cmd):
+ self.sp.write(chr(cmd))
+ self.sp.write(chr(cmd ^ 0xFF)) # Control byte
+ return self._wait_for_ask(hex(cmd))
+
+ def cmdGet(self):
+ if self.cmdGeneric(0x00):
+ mdebug(10, "*** Get command");
+ len = ord(self.sp.read())
+ version = ord(self.sp.read())
+ mdebug(10, " Bootloader version: "+hex(version))
+ dat = map(lambda c: hex(ord(c)), self.sp.read(len))
+ mdebug(10, " Available commands: "+str(dat))
+ self._wait_for_ask("0x00 end")
+ return version
+ else:
+ raise CmdException("Get (0x00) failed")
+
+ def cmdGetVersion(self):
+ if self.cmdGeneric(0x01):
+ mdebug(10, "*** GetVersion command")
+ version = ord(self.sp.read())
+ self.sp.read(2)
+ self._wait_for_ask("0x01 end")
+ mdebug(10, " Bootloader version: "+hex(version))
+ return version
+ else:
+ raise CmdException("GetVersion (0x01) failed")
+
+ def cmdGetID(self):
+ if self.cmdGeneric(0x02):
+ mdebug(10, "*** GetID command")
+ len = ord(self.sp.read())
+ id = self.sp.read(len+1)
+ self._wait_for_ask("0x02 end")
+ return id
+ else:
+ raise CmdException("GetID (0x02) failed")
+
+
+ def _encode_addr(self, addr):
+ byte3 = (addr >> 0) & 0xFF
+ byte2 = (addr >> 8) & 0xFF
+ byte1 = (addr >> 16) & 0xFF
+ byte0 = (addr >> 24) & 0xFF
+ crc = byte0 ^ byte1 ^ byte2 ^ byte3
+ return (chr(byte0) + chr(byte1) + chr(byte2) + chr(byte3) + chr(crc))
+
+
+ def cmdReadMemory(self, addr, lng):
+ assert(lng <= 256)
+ if self.cmdGeneric(0x11):
+ mdebug(10, "*** ReadMemory command")
+ self.sp.write(self._encode_addr(addr))
+ self._wait_for_ask("0x11 address failed")
+ N = (lng - 1) & 0xFF
+ crc = N ^ 0xFF
+ self.sp.write(chr(N) + chr(crc))
+ self._wait_for_ask("0x11 length failed")
+ return map(lambda c: ord(c), self.sp.read(lng))
+ else:
+ raise CmdException("ReadMemory (0x11) failed")
+
+
+ def cmdGo(self, addr):
+ if self.cmdGeneric(0x21):
+ mdebug(10, "*** Go command")
+ self.sp.write(self._encode_addr(addr))
+ self._wait_for_ask("0x21 go failed")
+ else:
+ raise CmdException("Go (0x21) failed")
+
+
+ def cmdWriteMemory(self, addr, data):
+ assert(len(data) <= 256)
+ if self.cmdGeneric(0x31):
+ mdebug(10, "*** Write memory command")
+ self.sp.write(self._encode_addr(addr))
+ self._wait_for_ask("0x31 address failed")
+ #map(lambda c: hex(ord(c)), data)
+ lng = (len(data)-1) & 0xFF
+ mdebug(10, " %s bytes to write" % [lng+1]);
+ self.sp.write(chr(lng)) # len really
+ crc = 0xFF
+ for c in data:
+ crc = crc ^ c
+ self.sp.write(chr(c))
+ self.sp.write(chr(crc))
+ self._wait_for_ask("0x31 programming failed")
+ mdebug(10, " Write memory done")
+ else:
+ raise CmdException("Write memory (0x31) failed")
+
+
+ def cmdEraseMemory(self, sectors = None):
+ if self.cmdGeneric(0x43):
+ mdebug(10, "*** Erase memory command")
+ if sectors is None:
+ # Global erase
+ self.sp.write(chr(0xFF))
+ self.sp.write(chr(0x00))
+ else:
+ # Sectors erase
+ self.sp.write(chr((len(sectors)-1) & 0xFF))
+ crc = 0xFF
+ for c in sectors:
+ crc = crc ^ c
+ self.sp.write(chr(c))
+ self.sp.write(chr(crc))
+ self._wait_for_ask("0x43 erasing failed")
+ mdebug(10, " Erase memory done")
+ else:
+ raise CmdException("Erase memory (0x43) failed")
+
+ def cmdWriteProtect(self, sectors):
+ if self.cmdGeneric(0x63):
+ mdebug(10, "*** Write protect command")
+ self.sp.write(chr((len(sectors)-1) & 0xFF))
+ crc = 0xFF
+ for c in sectors:
+ crc = crc ^ c
+ self.sp.write(chr(c))
+ self.sp.write(chr(crc))
+ self._wait_for_ask("0x63 write protect failed")
+ mdebug(10, " Write protect done")
+ else:
+ raise CmdException("Write Protect memory (0x63) failed")
+
+ def cmdWriteUnprotect(self):
+ if self.cmdGeneric(0x73):
+ mdebug(10, "*** Write Unprotect command")
+ self._wait_for_ask("0x73 write unprotect failed")
+ self._wait_for_ask("0x73 write unprotect 2 failed")
+ mdebug(10, " Write Unprotect done")
+ else:
+ raise CmdException("Write Unprotect (0x73) failed")
+
+ def cmdReadoutProtect(self):
+ if self.cmdGeneric(0x82):
+ mdebug(10, "*** Readout protect command")
+ self._wait_for_ask("0x82 readout protect failed")
+ self._wait_for_ask("0x82 readout protect 2 failed")
+ mdebug(10, " Read protect done")
+ else:
+ raise CmdException("Readout protect (0x82) failed")
+
+ def cmdReadoutUnprotect(self):
+ if self.cmdGeneric(0x92):
+ mdebug(10, "*** Readout Unprotect command")
+ self._wait_for_ask("0x92 readout unprotect failed")
+ self._wait_for_ask("0x92 readout unprotect 2 failed")
+ mdebug(10, " Read Unprotect done")
+ else:
+ raise CmdException("Readout unprotect (0x92) failed")
+
+
+# Complex commands section
+
+ def readMemory(self, addr, lng):
+ data = []
+ if usepbar:
+ widgets = ['Reading: ', Percentage(),', ', ETA(), ' ', Bar()]
+ pbar = ProgressBar(widgets=widgets,maxval=lng, term_width=79).start()
+
+ while lng > 256:
+ if usepbar:
+ pbar.update(pbar.maxval-lng)
+ else:
+ mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256})
+ data = data + self.cmdReadMemory(addr, 256)
+ addr = addr + 256
+ lng = lng - 256
+ if usepbar:
+ pbar.update(pbar.maxval-lng)
+ pbar.finish()
+ else:
+ mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256})
+ data = data + self.cmdReadMemory(addr, lng)
+ return data
+
+ def writeMemory(self, addr, data):
+ lng = len(data)
+ if usepbar:
+ widgets = ['Writing: ', Percentage(),' ', ETA(), ' ', Bar()]
+ pbar = ProgressBar(widgets=widgets, maxval=lng, term_width=79).start()
+
+ offs = 0
+ while lng > 256:
+ if usepbar:
+ pbar.update(pbar.maxval-lng)
+ else:
+ mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256})
+ self.cmdWriteMemory(addr, data[offs:offs+256])
+ offs = offs + 256
+ addr = addr + 256
+ lng = lng - 256
+ if usepbar:
+ pbar.update(pbar.maxval-lng)
+ pbar.finish()
+ else:
+ mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256})
+ self.cmdWriteMemory(addr, data[offs:offs+lng] + ([0xFF] * (256-lng)) )
+
+
+
+
+ def __init__(self) :
+ pass
+
+
+def usage():
+ print """Usage: %s [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin]
+ -h This help
+ -q Quiet
+ -V Verbose
+ -e Erase
+ -w Write
+ -v Verify
+ -r Read
+ -l length Length of read
+ -p port Serial port (default: /dev/tty.usbserial-ftCYPMYJ)
+ -b baud Baud speed (default: 115200)
+ -a addr Target address
+
+ ./stm32loader.py -e -w -v example/main.bin
+
+ """ % sys.argv[0]
+
+
+if __name__ == "__main__":
+
+ # Import Psyco if available
+ try:
+ import psyco
+ psyco.full()
+ print "Using Psyco..."
+ except ImportError:
+ pass
+
+ conf = {
+ 'port': '/dev/tty.usbserial-ftCYPMYJ',
+ 'baud': 115200,
+ 'address': 0x08000000,
+ 'erase': 0,
+ 'write': 0,
+ 'verify': 0,
+ 'read': 0,
+ }
+
+# http://www.python.org/doc/2.5.2/lib/module-getopt.html
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "hqVewvrp:b:a:l:")
+ except getopt.GetoptError, err:
+ # print help information and exit:
+ print str(err) # will print something like "option -a not recognized"
+ usage()
+ sys.exit(2)
+
+ QUIET = 5
+
+ for o, a in opts:
+ if o == '-V':
+ QUIET = 10
+ elif o == '-q':
+ QUIET = 0
+ elif o == '-h':
+ usage()
+ sys.exit(0)
+ elif o == '-e':
+ conf['erase'] = 1
+ elif o == '-w':
+ conf['write'] = 1
+ elif o == '-v':
+ conf['verify'] = 1
+ elif o == '-r':
+ conf['read'] = 1
+ elif o == '-p':
+ conf['port'] = a
+ elif o == '-b':
+ conf['baud'] = eval(a)
+ elif o == '-a':
+ conf['address'] = eval(a)
+ elif o == '-l':
+ conf['len'] = eval(a)
+ else:
+ assert False, "unhandled option"
+
+ cmd = CommandInterface()
+ cmd.open(conf['port'], conf['baud'])
+ mdebug(10, "Open port %(port)s, baud %(baud)d" % {'port':conf['port'], 'baud':conf['baud']})
+ try:
+ try:
+ cmd.initChip()
+ except:
+ print "Can't init. Ensure that BOOT0 is enabled and reset device"
+
+
+ bootversion = cmd.cmdGet()
+ mdebug(0, "Bootloader version %X" % bootversion)
+ mdebug(0, "Chip id `%s'" % str(map(lambda c: hex(ord(c)), cmd.cmdGetID())))
+# cmd.cmdGetVersion()
+# cmd.cmdGetID()
+# cmd.cmdReadoutUnprotect()
+# cmd.cmdWriteUnprotect()
+# cmd.cmdWriteProtect([0, 1])
+
+ if (conf['write'] or conf['verify']):
+ data = map(lambda c: ord(c), file(args[0]).read())
+
+ if conf['erase']:
+ cmd.cmdEraseMemory()
+
+ if conf['write']:
+ cmd.writeMemory(conf['address'], data)
+
+ if conf['verify']:
+ verify = cmd.readMemory(conf['address'], len(data))
+ if(data == verify):
+ print "Verification OK"
+ else:
+ print "Verification FAILED"
+ print str(len(data)) + ' vs ' + str(len(verify))
+ for i in xrange(0, len(data)):
+ if data[i] != verify[i]:
+ print hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i])
+
+ if not conf['write'] and conf['read']:
+ rdata = cmd.readMemory(conf['address'], conf['len'])
+ file(args[0], 'wb').write(''.join(map(chr,rdata)))
+
+# cmd.cmdGo(addr + 0x04)
+ finally:
+ cmd.releaseChip()
+