diff --git a/conf/airframes/demo.xml b/conf/airframes/demo.xml
new file mode 100644
index 0000000000..eac3967716
--- /dev/null
+++ b/conf/airframes/demo.xml
@@ -0,0 +1,114 @@
+
+
+
+
+ARCHI=arm7
+
+FLASH_MODE = IAP
+
+
+#
+# simple emtpy demo
+#
+demo1.ARCHDIR = $(ARCHI)
+demo1.ARCH = arm7tdmi
+demo1.TARGET = demo1
+demo1.TARGETDIR = demo1
+
+demo1.CFLAGS += -DCONFIG=\"conf_demo.h\"
+demo1.srcs = main_demo1.c
+
+#
+# hardware init ( pll ), system time and LEDs
+#
+demo2.ARCHDIR = $(ARCHI)
+demo2.ARCH = arm7tdmi
+demo2.TARGET = demo2
+demo2.TARGETDIR = demo2
+
+demo2.CFLAGS += -DCONFIG=\"conf_demo.h\"
+demo2.srcs = main_demo2.c
+
+demo2.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(10e-2)'
+demo2.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+
+demo2.CFLAGS += -DLED
+
+#
+# UART (interrupts) and formated ascii printing
+#
+demo3.ARCHDIR = $(ARCHI)
+demo3.ARCH = arm7tdmi
+demo3.TARGET = demo3
+demo3.TARGETDIR = demo3
+
+demo3.CFLAGS += -DCONFIG=\"conf_demo.h\"
+demo3.srcs = main_demo3.c
+
+demo3.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(10e-2)'
+demo3.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+
+demo3.CFLAGS += -DLED
+
+demo3.srcs += $(SRC_ARCH)/armVIC.c
+
+demo3.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400
+demo3.srcs += $(SRC_ARCH)/uart_hw.c
+
+#
+# DOWNLINK : send formated messages according to messages.xml description
+# requires "link" to run on the other side of the serial link
+#
+demo4.ARCHDIR = $(ARCHI)
+demo4.ARCH = arm7tdmi
+demo4.TARGET = demo4
+demo4.TARGETDIR = demo4
+
+demo4.CFLAGS += -DCONFIG=\"conf_demo.h\"
+demo4.srcs = main_demo4.c
+
+demo4.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(10e-2)'
+demo4.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+
+demo4.CFLAGS += -DLED
+
+demo4.srcs += $(SRC_ARCH)/armVIC.c
+
+demo4.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400
+demo4.srcs += $(SRC_ARCH)/uart_hw.c
+
+demo4.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart0
+demo4.srcs += downlink.c pprz_transport.c
+
+#
+# DATALINK : receives datalink messages. demonstrates the "settings" service
+# which lets you adjust variables described in the settings.xml file
+# IvySendMsg("1ME RAW_DATALINK 144 SETTING;0;0;%d", foo_value);
+#
+demo5.ARCHDIR = $(ARCHI)
+demo5.ARCH = arm7tdmi
+demo5.TARGET = demo5
+demo5.TARGETDIR = demo5
+
+demo5.CFLAGS += -DCONFIG=\"conf_demo.h\"
+demo5.srcs = main_demo5.c
+
+demo5.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(10e-2)'
+demo5.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+
+demo5.CFLAGS += -DLED
+
+demo5.srcs += $(SRC_ARCH)/armVIC.c
+
+demo5.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B38400
+demo5.srcs += $(SRC_ARCH)/uart_hw.c
+
+demo5.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart0
+demo5.srcs += downlink.c pprz_transport.c
+
+demo5.CFLAGS += -DDATALINK=PPRZ -DPPRZ_UART=Uart0
+
+
+
+
+
diff --git a/conf/autopilot/conf_demo.h b/conf/autopilot/conf_demo.h
new file mode 100644
index 0000000000..804b8def03
--- /dev/null
+++ b/conf/autopilot/conf_demo.h
@@ -0,0 +1,20 @@
+#ifndef CONFIG_DEMO_H
+#define CONFIG_DEMO_H
+
+/* Master oscillator freq. */
+#define FOSC (12000000)
+/* PLL multiplier */
+#define PLL_MUL (5)
+/* CPU clock freq. */
+#define CCLK (FOSC * PLL_MUL)
+/* Peripheral bus speed mask 0x00->4, 0x01-> 1, 0x02 -> 2 */
+#define PBSD_BITS 0x00
+#define PBSD_VAL 4
+/* Peripheral bus clock freq. */
+#define PCLK (CCLK / PBSD_VAL)
+
+#define LED_1_BANK 1
+#define LED_1_PIN 24
+
+
+#endif /* CONFIG_DEMO_H */
diff --git a/conf/conf.xml.example b/conf/conf.xml.example
index 70deb2169e..3cf821a1de 100644
--- a/conf/conf.xml.example
+++ b/conf/conf.xml.example
@@ -67,4 +67,15 @@
gui_color="#ba6293"
/>
+
+
+
diff --git a/conf/settings/demo5_settings.xml b/conf/settings/demo5_settings.xml
new file mode 100644
index 0000000000..4f147f475c
--- /dev/null
+++ b/conf/settings/demo5_settings.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/sw/airborne/Makefile b/sw/airborne/Makefile
index 2189b1c8e8..e2c02149c3 100644
--- a/sw/airborne/Makefile
+++ b/sw/airborne/Makefile
@@ -25,7 +25,7 @@ OBJDIR = $(PAPARAZZI_HOME)/var/$(AIRCRAFT)/$(TARGET)
VARINCLUDE=$(PAPARAZZI_HOME)/var/include
ACINCLUDE = $(PAPARAZZI_HOME)/var/$(AIRCRAFT)
-INCLUDES = -I $(PAPARAZZI_SRC)/sw/include -I $(PAPARAZZI_SRC)/sw/airborne -I $(PAPARAZZI_SRC)/conf/autopilot -I $(PAPARAZZI_SRC)/sw/airborne/$(ARCHI) -I $(VARINCLUDE) -I $(ACINCLUDE)
+INCLUDES = -I $(PAPARAZZI_SRC)/sw/include -I $(PAPARAZZI_SRC)/sw/airborne -I $(PAPARAZZI_SRC)/conf/autopilot -I $(PAPARAZZI_SRC)/sw/airborne/$($(TARGET).ARCHDIR) -I $(VARINCLUDE) -I $(ACINCLUDE)
SRC_ARCH = $(PAPARAZZI_SRC)/sw/airborne/$(ARCHDIR)
@@ -33,7 +33,7 @@ ifneq ($(MAKECMDGOALS),clean)
include $(PAPARAZZI_HOME)/var/$(AIRCRAFT)/Makefile.ac
$(TARGET).srcs += $($(TARGET).EXTRA_SRCS)
include ../../conf/Makefile.local
-include ../../conf/Makefile.$(ARCHI)
+include ../../conf/Makefile.$($(TARGET).ARCHDIR)
endif
$(TARGET).install : warn_conf
diff --git a/sw/airborne/i2c.h b/sw/airborne/i2c.h
index a6907d4185..9e3e5b251a 100644
--- a/sw/airborne/i2c.h
+++ b/sw/airborne/i2c.h
@@ -25,7 +25,10 @@ extern void i2c_transmit(uint8_t slave_addr, uint8_t len, volatile bool_t* finis
extern volatile uint8_t i2c_status;
+#ifndef I2C_BUF_LEN
#define I2C_BUF_LEN 8
+#endif
+
extern volatile uint8_t i2c_buf[I2C_BUF_LEN];
extern volatile uint8_t i2c_len;
extern volatile uint8_t i2c_index;
diff --git a/sw/airborne/main_demo1.c b/sw/airborne/main_demo1.c
new file mode 100644
index 0000000000..02ccf6727c
--- /dev/null
+++ b/sw/airborne/main_demo1.c
@@ -0,0 +1,10 @@
+
+#include "std.h"
+
+
+int main( void ) {
+ while(1) {
+
+ }
+ return 0;
+}
diff --git a/sw/airborne/main_demo2.c b/sw/airborne/main_demo2.c
new file mode 100644
index 0000000000..005b76e505
--- /dev/null
+++ b/sw/airborne/main_demo2.c
@@ -0,0 +1,27 @@
+
+#include "std.h"
+#include "init_hw.h"
+#include "sys_time.h"
+#include "led.h"
+
+static inline void main_init( void );
+static inline void main_periodic_task( void );
+
+int main( void ) {
+ main_init();
+ while(1) {
+ if (sys_time_periodic())
+ main_periodic_task();
+ }
+ return 0;
+}
+
+static inline void main_init( void ) {
+ hw_init();
+ sys_time_init();
+ led_init();
+}
+
+static inline void main_periodic_task( void ) {
+ LED_TOGGLE(1);
+}
diff --git a/sw/airborne/main_demo3.c b/sw/airborne/main_demo3.c
new file mode 100644
index 0000000000..b1d217d45c
--- /dev/null
+++ b/sw/airborne/main_demo3.c
@@ -0,0 +1,35 @@
+
+#include "std.h"
+#include "init_hw.h"
+#include "sys_time.h"
+#include "led.h"
+#include "interrupt_hw.h"
+#include "uart.h"
+#include "print.h"
+
+static inline void main_init( void );
+static inline void main_periodic_task( void );
+
+int main( void ) {
+ main_init();
+ while(1) {
+ if (sys_time_periodic())
+ main_periodic_task();
+ }
+ return 0;
+}
+
+static inline void main_init( void ) {
+ hw_init();
+ sys_time_init();
+ led_init();
+ uart0_init_tx();
+ int_enable();
+}
+
+static inline void main_periodic_task( void ) {
+ LED_TOGGLE(1);
+ Uart0PrintString("demo3 running since ");
+ Uart0PrintHex16(cpu_time_sec);
+ uart0_transmit(' seconds\n');
+}
diff --git a/sw/airborne/main_demo4.c b/sw/airborne/main_demo4.c
new file mode 100644
index 0000000000..1eb1e97e85
--- /dev/null
+++ b/sw/airborne/main_demo4.c
@@ -0,0 +1,34 @@
+#include "std.h"
+#include "init_hw.h"
+#include "sys_time.h"
+#include "led.h"
+#include "interrupt_hw.h"
+#include "uart.h"
+
+#include "messages.h"
+#include "downlink.h"
+
+static inline void main_init( void );
+static inline void main_periodic_task( void );
+
+int main( void ) {
+ main_init();
+ while(1) {
+ if (sys_time_periodic())
+ main_periodic_task();
+ }
+ return 0;
+}
+
+static inline void main_init( void ) {
+ hw_init();
+ sys_time_init();
+ led_init();
+ uart0_init_tx();
+ int_enable();
+}
+
+static inline void main_periodic_task( void ) {
+ LED_TOGGLE(1);
+ DOWNLINK_SEND_TAKEOFF(&cpu_time_sec);
+}
diff --git a/sw/airborne/main_demo5.c b/sw/airborne/main_demo5.c
new file mode 100644
index 0000000000..82eb80f522
--- /dev/null
+++ b/sw/airborne/main_demo5.c
@@ -0,0 +1,74 @@
+#include "std.h"
+#include "init_hw.h"
+#include "sys_time.h"
+#include "led.h"
+#include "interrupt_hw.h"
+#include "uart.h"
+
+#include "messages.h"
+#include "downlink.h"
+
+static inline void main_init( void );
+static inline void main_periodic_task( void );
+static inline void main_event_task( void );
+
+static inline void main_dl_parse_msg( void );
+
+int main( void ) {
+ main_init();
+ while(1) {
+ if (sys_time_periodic())
+ main_periodic_task();
+ main_event_task();
+ }
+ return 0;
+}
+
+static inline void main_init( void ) {
+ hw_init();
+ sys_time_init();
+ led_init();
+ uart0_init_tx();
+ int_enable();
+}
+
+static inline void main_periodic_task( void ) {
+ // LED_TOGGLE(1);
+ DOWNLINK_SEND_TAKEOFF(&cpu_time_sec);
+}
+
+static inline void main_event_task( void ) {
+ if (PprzBuffer()) {
+ ReadPprzBuffer();
+ if (pprz_msg_received) {
+ pprz_parse_payload();
+ pprz_msg_received = FALSE;
+ }
+ }
+ if (dl_msg_available) {
+ main_dl_parse_msg();
+ dl_msg_available = FALSE;
+ LED_TOGGLE(1);
+ }
+}
+
+uint16_t foo;
+
+bool_t dl_msg_available;
+
+#define MSG_SIZE 128
+uint8_t dl_buffer[MSG_SIZE] __attribute__ ((aligned));
+
+#include "settings.h"
+
+#define IdOfMsg(x) (x[1])
+
+static inline void main_dl_parse_msg(void) {
+ uint8_t msg_id = IdOfMsg(dl_buffer);
+ if (msg_id == DL_SETTING) {
+ uint8_t i = DL_SETTING_index(dl_buffer);
+ float var = DL_SETTING_value(dl_buffer);
+ DlSetting(i, var);
+ DOWNLINK_SEND_DL_VALUE(&i, &var);
+ }
+}