diff --git a/conf/airframes/examples/quadrotor_navstik.xml b/conf/airframes/examples/quadrotor_navstik.xml
new file mode 100644
index 0000000000..a1d6838a2c
--- /dev/null
+++ b/conf/airframes/examples/quadrotor_navstik.xml
@@ -0,0 +1,215 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/boards/navstik_1.0.makefile b/conf/boards/navstik_1.0.makefile
new file mode 100644
index 0000000000..a8ab68ce48
--- /dev/null
+++ b/conf/boards/navstik_1.0.makefile
@@ -0,0 +1,54 @@
+# Hey Emacs, this is a -*- makefile -*-
+#
+# navstik_1.0.makefile
+#
+# http://paparazzi.enac.fr/wiki/Navstik
+#
+
+BOARD=navstik
+BOARD_VERSION=1.0
+BOARD_CFG=\"boards/$(BOARD)_$(BOARD_VERSION).h\"
+
+ARCH=stm32
+ARCH_L=f4
+HARD_FLOAT=yes
+$(TARGET).ARCHDIR = $(ARCH)
+$(TARGET).OOCD_INTERFACE=ftdi/ivygs
+$(TARGET).OOCD_BOARD=navstik
+$(TARGET).LDSCRIPT=$(SRC_ARCH)/navstik.ld
+
+# -----------------------------------------------------------------------
+
+# default flash mode is via usb dfu bootloader
+# other possibilities: DFU-UTIL, JTAG
+FLASH_MODE ?= JTAG
+
+#
+# default LED configuration
+#
+RADIO_CONTROL_LED ?= none
+BARO_LED ?= none
+AHRS_ALIGNER_LED ?= 2
+GPS_LED ?= none
+SYS_TIME_LED ?= 1
+
+#
+# default uart configuration
+#
+RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT ?= UART6
+
+MODEM_PORT ?= UART5
+MODEM_BAUD ?= B57600
+
+GPS_PORT ?= UART2
+GPS_BAUD ?= B57600
+
+#
+# default actuator configuration
+#
+# you can use different actuators by adding a configure option to your firmware section
+# e.g.
+#
+ACTUATORS ?= actuators_pwm
diff --git a/conf/conf_example.xml b/conf/conf_example.xml
index 532ee1d205..9c3722225a 100644
--- a/conf/conf_example.xml
+++ b/conf/conf_example.xml
@@ -56,7 +56,7 @@
radio="radios/cockpitMM.xml"
telemetry="telemetry/default_fixedwing.xml"
flight_plan="flight_plans/basic.xml"
- settings=" settings/fixedwing_basic.xml settings/control/ctl_basic.xml settings/estimation/infrared.xml"
+ settings="settings/fixedwing_basic.xml settings/control/ctl_basic.xml settings/estimation/infrared.xml"
gui_color="#6293ba"
/>
+
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+#
+$(TARGET).CFLAGS += -DUSE_IMU -DIMU_NAVSTIK -DIMU_TYPE_H=\"imu/imu_navstik.h\"
+$(TARGET).srcs += $(SRC_SUBSYSTEMS)/imu.c $(SRC_SUBSYSTEMS)/imu/imu_navstik.c
+$(TARGET).srcs += peripherals/hmc58xx.c
+$(TARGET).srcs += peripherals/mpu60x0.c peripherals/mpu60x0_i2c.c
+
+
+NAVSTIK_MAG_I2C_DEV ?= i2c3
+NAVSTIK_MPU_I2C_DEV ?= i2c1
+
+NAVSTIK_MAG_I2C_DEV_UPPER=$(shell echo $(NAVSTIK_MAG_I2C_DEV) | tr a-z A-Z)
+NAVSTIK_MAG_I2C_DEV_LOWER=$(shell echo $(NAVSTIK_MAG_I2C_DEV) | tr A-Z a-z)
+NAVSTIK_MPU_I2C_DEV_UPPER=$(shell echo $(NAVSTIK_MPU_I2C_DEV) | tr a-z A-Z)
+NAVSTIK_MPU_I2C_DEV_LOWER=$(shell echo $(NAVSTIK_MPU_I2C_DEV) | tr A-Z a-z)
+
+$(TARGET).CFLAGS += -DNAVSTIK_MAG_I2C_DEV=$(NAVSTIK_MAG_I2C_DEV_LOWER) -DNAVSTIK_MPU_I2C_DEV_UPPER=$(NAVSTIK_MPU_I2C_DEV_LOWER)
+$(TARGET).CFLAGS += -DUSE_$(NAVSTIK_MAG_I2C_DEV_UPPER)=1 -DUSE_$(NAVSTIK_MPU_I2C_DEV_UPPER)=1
diff --git a/conf/firmwares/test_progs.makefile b/conf/firmwares/test_progs.makefile
index a98d2d2ab0..68d1003b29 100644
--- a/conf/firmwares/test_progs.makefile
+++ b/conf/firmwares/test_progs.makefile
@@ -86,6 +86,9 @@ ifeq ($(BOARD_VERSION), 2.0)
LED_DEFINES = -DLED_BLUE=3 -DLED_RED=4 -DLED_GREEN=5
endif
endif
+ifeq ($(BOARD), navstik)
+LED_DEFINES = -DLED_RED=1 -DLED_GREEN=2
+endif
LED_DEFINES ?= -DLED_RED=2 -DLED_GREEN=3
test_sys_time_timer.ARCHDIR = $(ARCH)
diff --git a/conf/flash_modes.xml b/conf/flash_modes.xml
index f7ebd9bda1..614bc97b39 100644
--- a/conf/flash_modes.xml
+++ b/conf/flash_modes.xml
@@ -53,6 +53,7 @@
+
@@ -88,6 +89,7 @@
+
diff --git a/conf/system/udev/rules/50-paparazzi.rules b/conf/system/udev/rules/50-paparazzi.rules
index 6d50b0b908..50c04ab97a 100644
--- a/conf/system/udev/rules/50-paparazzi.rules
+++ b/conf/system/udev/rules/50-paparazzi.rules
@@ -9,6 +9,10 @@ SUBSYSTEM=="tty", ATTRS{product}=="FT232R USB UART", SYMLINK+="paparazzi/serial"
# MaxStream xbee pro box
SUBSYSTEM=="tty", ATTRS{product}=="MaxStream PKG-U", SYMLINK+="paparazzi/xbee", GROUP="plugdev"
+# Navstik Xbee port
+SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"
+SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", ATTRS{product}=="Quad RS232-HS", ENV{.LOCAL_ifNum}=="02", SYMLINK+="paparazzi/xbee", GROUP="plugdev"
+
# Recent Digi XBee pro modems (XBP24-PKC-001-UA)
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{product}=="USB <-> Serial", SYMLINK+="paparazzi/xbee", GROUP="plugdev"
@@ -27,6 +31,9 @@ ATTRS{idVendor}=="0403", ATTRS{idProduct}=="cff8", GROUP="plugdev"
# FTDI 2232 based jtag for Lisa/L and usb upload
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666", GROUP="plugdev"
+# FTDI 2232 based jtag for Navstik
+ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", MODE="0666", GROUP="plugdev"
+
# dfu devices
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0666", GROUP="plugdev"
diff --git a/sw/airborne/arch/stm32/mcu_arch.c b/sw/airborne/arch/stm32/mcu_arch.c
index 86ba9a1e6b..d34894aa6f 100644
--- a/sw/airborne/arch/stm32/mcu_arch.c
+++ b/sw/airborne/arch/stm32/mcu_arch.c
@@ -39,6 +39,21 @@
#include "std.h"
+/** 25MHz external clock to PLL it to 168MHz */
+const clock_scale_t hse_25mhz_3v3_168mhz = { /* 168MHz */
+ .pllm = 25,
+ .plln = 336,
+ .pllp = 2,
+ .pllq = 7,
+ .hpre = RCC_CFGR_HPRE_DIV_NONE,
+ .ppre1 = RCC_CFGR_PPRE_DIV_4,
+ .ppre2 = RCC_CFGR_PPRE_DIV_2,
+ .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE |
+ FLASH_ACR_LATENCY_5WS,
+ .apb1_frequency = 42000000,
+ .apb2_frequency = 84000000,
+};
+
void mcu_arch_init(void) {
#if LUFTBOOT
PRINT_CONFIG_MSG("We are running luftboot, the interrupt vector is being relocated.")
@@ -65,6 +80,11 @@ PRINT_CONFIG_MSG("Using 12MHz external clock to PLL it to 168MHz.")
PRINT_CONFIG_MSG("Using 16MHz external clock to PLL it to 168MHz.")
rcc_clock_setup_hse_3v3(&hse_16mhz_3v3[CLOCK_3V3_168MHZ]);
#endif
+#elif EXT_CLK == 25000000
+#if defined(STM32F4)
+PRINT_CONFIG_MSG("Using 25MHz external clock to PLL it to 168MHz.")
+ rcc_clock_setup_hse_3v3(&hse_25mhz_3v3_168mhz);
+#endif
#else
#error EXT_CLK is either set to an unsupported frequency or not defined at all. Please check!
#endif
diff --git a/sw/airborne/arch/stm32/navstik.ld b/sw/airborne/arch/stm32/navstik.ld
new file mode 100644
index 0000000000..076eeac966
--- /dev/null
+++ b/sw/airborne/arch/stm32/navstik.ld
@@ -0,0 +1,35 @@
+/*
+ * Hey Emacs, this is a -*- makefile -*-
+ *
+ * Copyright (C) 2014 Freek van Tienen
+ *
+ * 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.
+ */
+
+/* Linker script for Navstik (STM32F415, 1024K flash, 192K RAM). */
+
+/* Define memory regions. */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
+ /* TODO: Pages on stm32f4 are not just 2k in size, stored settings have to deal with that correctly. */
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 1022K
+}
+
+/* Include the common ld script. */
+INCLUDE libopencm3_stm32f4.ld
diff --git a/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.h b/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.h
index 1e9d302e6b..aa028b47e7 100644
--- a/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.h
+++ b/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.h
@@ -74,6 +74,9 @@
#ifndef TIM5_SERVO_HZ
#define TIM5_SERVO_HZ SERVO_HZ
#endif
+#ifndef TIM8_SERVO_HZ
+#define TIM8_SERVO_HZ SERVO_HZ
+#endif
#ifndef TIM9_SERVO_HZ
#define TIM9_SERVO_HZ SERVO_HZ
#endif
diff --git a/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c b/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c
index 4536f3bd82..7bb3eb1377 100644
--- a/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c
+++ b/sw/airborne/arch/stm32/subsystems/radio_control/spektrum_arch.c
@@ -691,8 +691,13 @@ void radio_control_spektrum_try_bind(void) {
/* exit if the BIND_PIN is high, it needs to
be pulled low at startup to initiate bind */
+#ifdef SPEKTRUM_BIND_PIN_HIGH
+ if (gpio_get(SPEKTRUM_BIND_PIN_PORT, SPEKTRUM_BIND_PIN) == 0)
+ return;
+#else
if (gpio_get(SPEKTRUM_BIND_PIN_PORT, SPEKTRUM_BIND_PIN) != 0)
return;
+#endif
/* Master receiver Rx push-pull */
gpio_setup_output(SPEKTRUM_PRIMARY_BIND_CONF_PORT, SPEKTRUM_PRIMARY_BIND_CONF_PIN);
diff --git a/sw/airborne/boards/navstik/baro_board.c b/sw/airborne/boards/navstik/baro_board.c
new file mode 100644
index 0000000000..b0d030e2ec
--- /dev/null
+++ b/sw/airborne/boards/navstik/baro_board.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 Freek van Tienen
+ *
+ * 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 boards/navstik/baro_board.c
+ * Baro board interface for Bosch BMP185 on Navstik I2C3 without EOC check.
+ */
+
+#include "std.h"
+
+#include "subsystems/sensors/baro.h"
+#include "peripherals/bmp085.h"
+#include "peripherals/bmp085_regs.h"
+#include
+#include "subsystems/abi.h"
+
+#include "led.h"
+
+
+struct Bmp085 baro_bmp085;
+
+void baro_init(void) {
+ bmp085_init(&baro_bmp085, &i2c3, BMP085_SLAVE_ADDR);
+
+#ifdef BARO_LED
+ LED_OFF(BARO_LED);
+#endif
+}
+
+void baro_periodic(void) {
+ if (baro_bmp085.initialized) {
+ bmp085_periodic(&baro_bmp085);
+ }
+ else {
+ bmp085_read_eeprom_calib(&baro_bmp085);
+ }
+}
+
+void baro_event(void) {
+ bmp085_event(&baro_bmp085);
+
+ if (baro_bmp085.data_available) {
+ float pressure = (float)baro_bmp085.pressure;
+ AbiSendMsgBARO_ABS(BARO_BOARD_SENDER_ID, &pressure);
+ baro_bmp085.data_available = FALSE;
+#ifdef BARO_LED
+ RunOnceEvery(10,LED_TOGGLE(BARO_LED));
+#endif
+ }
+}
diff --git a/sw/airborne/boards/navstik/baro_board.h b/sw/airborne/boards/navstik/baro_board.h
new file mode 100644
index 0000000000..b213ea597d
--- /dev/null
+++ b/sw/airborne/boards/navstik/baro_board.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Freek van Tienen
+ *
+ * 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.
+ */
+
+/*
+ * board specific functions for the navstik board
+ */
+
+#ifndef BOARDS_NAVSTIK_BARO_H
+#define BOARDS_NAVSTIK_BARO_H
+
+// only for printing the baro type during compilation
+#ifndef BARO_BOARD
+#define BARO_BOARD BARO_BOARD_BMP085
+#endif
+
+extern void baro_event(void);
+#define BaroEvent baro_event
+
+#endif /* BOARDS_NAVSTIK_BARO_H */
diff --git a/sw/airborne/boards/navstik_1.0.h b/sw/airborne/boards/navstik_1.0.h
new file mode 100644
index 0000000000..106ed47772
--- /dev/null
+++ b/sw/airborne/boards/navstik_1.0.h
@@ -0,0 +1,330 @@
+/*
+ * Copyright (C) 2014 Freek van Tienen
+ *
+ * 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 CONFIG_NAVSTIK_1_0_H
+#define CONFIG_NAVSTIK_1_0_H
+
+/* #include "boards/lisa_m_common.h" */
+
+#define BOARD_NAVSTIK
+
+/* Navstik has a 12MHz external clock and 168MHz internal. */
+#define EXT_CLK 25000000
+#define AHB_CLK 168000000
+
+/*
+ * Onboard LEDs
+ */
+
+/* red, on PA8 */
+#ifndef USE_LED_1
+#define USE_LED_1 1
+#endif
+#define LED_1_GPIO GPIOC
+#define LED_1_GPIO_PIN GPIO4
+#define LED_1_GPIO_ON gpio_set
+#define LED_1_GPIO_OFF gpio_clear
+#define LED_1_AFIO_REMAP ((void)0)
+
+/* green, shared with JTAG_TRST */
+#ifndef USE_LED_2
+#define USE_LED_2 1
+#endif
+#define LED_2_GPIO GPIOC
+#define LED_2_GPIO_PIN GPIO5
+#define LED_2_GPIO_ON gpio_set
+#define LED_2_GPIO_OFF gpio_clear
+#define LED_2_AFIO_REMAP ((void)0)
+
+
+/*
+ * not actual LEDS, used as GPIOs
+ */
+#define GPS_POWER_GPIO GPIOA,GPIO4
+#define IMU_POWER_GPIO GPIOC,GPIO15
+
+/* Default actuators driver */
+#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
+#define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
+#define ActuatorsDefaultInit() ActuatorsPwmInit()
+#define ActuatorsDefaultCommit() ActuatorsPwmCommit()
+
+
+/* UART */
+#define UART1_GPIO_AF GPIO_AF7
+#define UART1_GPIO_PORT_RX GPIOB
+#define UART1_GPIO_RX GPIO7
+#define UART1_GPIO_PORT_TX GPIOB
+#define UART1_GPIO_TX GPIO6
+
+#define UART2_GPIO_AF GPIO_AF7
+#define UART2_GPIO_PORT_RX GPIOA
+#define UART2_GPIO_RX GPIO3
+#define UART2_GPIO_PORT_TX GPIOA
+#define UART2_GPIO_TX GPIO2
+
+#define UART5_GPIO_AF GPIO_AF8
+#define UART5_GPIO_PORT_RX GPIOD
+#define UART5_GPIO_RX GPIO2
+#define UART5_GPIO_PORT_TX GPIOC
+#define UART5_GPIO_TX GPIO12
+
+#define UART6_GPIO_AF GPIO_AF8
+#define UART6_GPIO_PORT_RX GPIOC
+#define UART6_GPIO_RX GPIO7
+#define UART6_GPIO_PORT_TX GPIOC
+#define UART6_GPIO_TX GPIO6
+
+/*
+ * Spektrum
+ */
+/* The line that is pulled low at power up to initiate the bind process */
+#define SPEKTRUM_BIND_PIN GPIO6
+#define SPEKTRUM_BIND_PIN_PORT GPIOC
+#define SPEKTRUM_BIND_PIN_HIGH 1
+
+#define SPEKTRUM_UART6_RCC RCC_USART6
+#define SPEKTRUM_UART6_BANK GPIOC
+#define SPEKTRUM_UART6_PIN GPIO7
+#define SPEKTRUM_UART6_AF GPIO_AF8
+#define SPEKTRUM_UART6_IRQ NVIC_USART6_IRQ
+#define SPEKTRUM_UART6_ISR usart6_isr
+#define SPEKTRUM_UART6_DEV USART6
+
+/*
+ * PPM
+ */
+
+/* input on PC6 (Spektrum Tx) */
+#define USE_PPM_TIM8 8
+#define PPM_CHANNEL TIM_IC3
+#define PPM_TIMER_INPUT TIM_IC_IN_TI2
+#define PPM_IRQ NVIC_TIM3_CC_IRQ
+#define PPM_IRQ2 NVIC_TIM1_UP_TIM10_IRQ
+// Capture/Compare InteruptEnable and InterruptFlag
+#define PPM_CC_IE TIM_DIER_CC2IE
+#define PPM_CC_IF TIM_SR_CC2IF
+#define PPM_GPIO_PORT GPIOC
+#define PPM_GPIO_PIN GPIO7
+#define PPM_GPIO_AF GPIO_AF8
+
+/* SPI */
+#define SPI1_GPIO_AF GPIO_AF5
+#define SPI1_GPIO_PORT_MISO GPIOA
+#define SPI1_GPIO_MISO GPIO6
+#define SPI1_GPIO_PORT_MOSI GPIOA
+#define SPI1_GPIO_MOSI GPIO7
+#define SPI1_GPIO_PORT_SCK GPIOA
+#define SPI1_GPIO_SCK GPIO5
+
+#define SPI2_GPIO_AF GPIO_AF5
+#define SPI2_GPIO_PORT_MISO GPIOB
+#define SPI2_GPIO_MISO GPIO14
+#define SPI2_GPIO_PORT_MOSI GPIOB
+#define SPI2_GPIO_MOSI GPIO15
+#define SPI2_GPIO_PORT_SCK GPIOB
+#define SPI2_GPIO_SCK GPIO13
+
+#define SPI_SELECT_SLAVE0_PORT GPIOA
+#define SPI_SELECT_SLAVE0_PIN GPIO15
+
+#define SPI_SELECT_SLAVE1_PORT GPIOA
+#define SPI_SELECT_SLAVE1_PIN GPIO4
+
+#define SPI_SELECT_SLAVE2_PORT GPIOB
+#define SPI_SELECT_SLAVE2_PIN GPIO12
+
+#define SPI_SELECT_SLAVE3_PORT GPIOC
+#define SPI_SELECT_SLAVE3_PIN GPIO13
+
+#define SPI_SELECT_SLAVE4_PORT GPIOC
+#define SPI_SELECT_SLAVE4_PIN GPIO12
+
+#define SPI_SELECT_SLAVE5_PORT GPIOC
+#define SPI_SELECT_SLAVE5_PIN GPIO4
+
+
+/* I2C mapping */
+#define I2C1_GPIO_PORT GPIOB
+#define I2C1_GPIO_SCL GPIO8
+#define I2C1_GPIO_SDA GPIO9
+
+#define I2C3_GPIO_PORT_SCL GPIOA
+#define I2C3_GPIO_SCL GPIO8
+#define I2C3_GPIO_PORT_SDA GPIOC
+#define I2C3_GPIO_SDA GPIO9
+
+
+/*
+ * ADC
+ */
+
+/* Onboard ADCs */
+/*
+ BATT_volt PC1/ADC123 (ADC123_IN11)
+ BATT_current PA1/ADC123 (ADC123_IN1)
+*/
+
+// Internal ADC for battery enabled by default
+#ifndef USE_ADC_1
+#define USE_ADC_1 1
+#endif
+#if USE_ADC_1
+#define AD1_1_CHANNEL 11
+#define ADC_1 AD1_1
+#define ADC_1_GPIO_PORT GPIOC
+#define ADC_1_GPIO_PIN GPIO1
+#endif
+
+#ifndef USE_ADC_2
+#define USE_ADC_2 1
+#endif
+#if USE_ADC_2
+#define AD1_2_CHANNEL 1
+#define ADC_2 AD1_2
+#define ADC_2_GPIO_PORT GPIOA
+#define ADC_2_GPIO_PIN GPIO1
+#endif
+
+/* allow to define ADC_CHANNEL_VSUPPLY and ADC_CHANNEL_CURRENT in the airframe file*/
+#ifndef ADC_CHANNEL_VSUPPLY
+#define ADC_CHANNEL_VSUPPLY ADC_1
+#endif
+#ifndef ADC_CHANNEL_CURRENT
+#define ADC_CHANNEL_CURRENT ADC_2
+#endif
+
+#define DefaultVoltageOfAdc(adc) (0.00382*adc)
+#define DefaultMilliAmpereOfAdc(adc) (0.42497*adc)
+
+
+/*
+ * PWM
+ *
+ */
+#define PWM_USE_TIM1 1
+#define PWM_USE_TIM2 2
+#define PWM_USE_TIM3 3
+#define PWM_USE_TIM8 8
+
+#define USE_PWM1 1
+#define USE_PWM2 1
+#define USE_PWM3 1
+#define USE_PWM4 1
+#define USE_PWM5 1
+#define USE_PWM6 1
+
+
+// PWM_SERVO_x is the index of the servo in the actuators_pwm_values array
+#if USE_PWM1
+#define PWM_SERVO_1 0
+#define PWM_SERVO_1_TIMER TIM3
+#define PWM_SERVO_1_RCC RCC_GPIOB
+#define PWM_SERVO_1_GPIO GPIOB
+#define PWM_SERVO_1_PIN GPIO5
+#define PWM_SERVO_1_AF GPIO_AF2
+#define PWM_SERVO_1_OC TIM_OC2
+#define PWM_SERVO_1_OC_BIT (1<<1)
+#else
+#define PWM_SERVO_1_OC_BIT 0
+#endif
+
+#if USE_PWM2
+#define PWM_SERVO_2 1
+#define PWM_SERVO_2_TIMER TIM1
+#define PWM_SERVO_2_RCC RCC_GPIOA
+#define PWM_SERVO_2_GPIO GPIOA
+#define PWM_SERVO_2_PIN GPIO10
+#define PWM_SERVO_2_AF GPIO_AF1
+#define PWM_SERVO_2_OC TIM_OC3
+#define PWM_SERVO_2_OC_BIT (1<<2)
+#else
+#define PWM_SERVO_2_OC_BIT 0
+#endif
+
+#if USE_PWM3
+#define PWM_SERVO_3 2
+#define PWM_SERVO_3_TIMER TIM8
+#define PWM_SERVO_3_RCC RCC_GPIOC
+#define PWM_SERVO_3_GPIO GPIOC
+#define PWM_SERVO_3_PIN GPIO8
+#define PWM_SERVO_3_AF GPIO_AF3
+#define PWM_SERVO_3_OC TIM_OC3
+#define PWM_SERVO_3_OC_BIT (1<<2)
+#else
+#define PWM_SERVO_3_OC_BIT 0
+#endif
+
+#if USE_PWM4
+#define PWM_SERVO_4 3
+#define PWM_SERVO_4_TIMER TIM2
+#define PWM_SERVO_4_RCC RCC_GPIOB
+#define PWM_SERVO_4_GPIO GPIOB
+#define PWM_SERVO_4_PIN GPIO11
+#define PWM_SERVO_4_AF GPIO_AF1
+#define PWM_SERVO_4_OC TIM_OC4
+#define PWM_SERVO_4_OC_BIT (1<<3)
+#else
+#define PWM_SERVO_4_OC_BIT 0
+#endif
+
+#if USE_PWM5
+#define PWM_SERVO_5 4
+#define PWM_SERVO_5_TIMER TIM3
+#define PWM_SERVO_5_RCC RCC_GPIOB
+#define PWM_SERVO_5_GPIO GPIOB
+#define PWM_SERVO_5_PIN GPIO1
+#define PWM_SERVO_5_AF GPIO_AF2
+#define PWM_SERVO_5_OC TIM_OC4
+#define PWM_SERVO_5_OC_BIT (1<<3)
+#else
+#define PWM_SERVO_5_OC_BIT 0
+#endif
+
+#if USE_PWM6
+#define PWM_SERVO_6 5
+#define PWM_SERVO_6_TIMER TIM3
+#define PWM_SERVO_6_RCC RCC_GPIOB
+#define PWM_SERVO_6_GPIO GPIOB
+#define PWM_SERVO_6_PIN GPIO0
+#define PWM_SERVO_6_AF GPIO_AF2
+#define PWM_SERVO_6_OC TIM_OC3
+#define PWM_SERVO_6_OC_BIT (1<<2)
+#else
+#define PWM_SERVO_6_OC_BIT 0
+#endif
+
+/* servo 2 on TIM1 */
+#define PWM_TIM1_CHAN_MASK (PWM_SERVO_2_OC_BIT)
+/* servo 4 on TIM2 */
+#define PWM_TIM2_CHAN_MASK (PWM_SERVO_4_OC_BIT)
+/* servos 1,5,6 on TIM3 */
+#define PWM_TIM3_CHAN_MASK (PWM_SERVO_1_OC_BIT|PWM_SERVO_5_OC_BIT|PWM_SERVO_6_OC_BIT)
+/* servo 3 on TIM8 */
+#define PWM_TIM8_CHAN_MASK (PWM_SERVO_3_OC_BIT)
+
+/* by default activate onboard baro */
+#ifndef USE_BARO_BOARD
+#define USE_BARO_BOARD 1
+#endif
+
+#endif /* CONFIG_NAVSTIK_1_0_H */
diff --git a/sw/airborne/subsystems/imu.c b/sw/airborne/subsystems/imu.c
index 85a1e22b8b..4e28480169 100644
--- a/sw/airborne/subsystems/imu.c
+++ b/sw/airborne/subsystems/imu.c
@@ -24,6 +24,7 @@
* Inertial Measurement Unit interface.
*/
+#include BOARD_CONFIG
#include "subsystems/imu.h"
#ifdef IMU_POWER_GPIO
diff --git a/sw/airborne/subsystems/imu/imu_navstik.c b/sw/airborne/subsystems/imu/imu_navstik.c
new file mode 100644
index 0000000000..3fcba91e40
--- /dev/null
+++ b/sw/airborne/subsystems/imu/imu_navstik.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2014 Freek van Tienen
+ *
+ * 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 subsystems/imu/imu_navstik.c
+ * Driver for the Navstik magnetometer, accelerometer and gyroscope
+ */
+
+#include "subsystems/imu.h"
+#include "mcu_periph/i2c.h"
+
+
+/* defaults suitable for Navstik */
+#ifndef NAVSTIK_MAG_I2C_DEV
+#define NAVSTIK_MAG_I2C_DEV i2c3
+#endif
+PRINT_CONFIG_VAR(NAVSTIK_MAG_I2C_DEV)
+
+#ifndef NAVSTIK_MPU_I2C_DEV
+#define NAVSTIK_MPU_I2C_DEV i2c1
+#endif
+PRINT_CONFIG_VAR(NAVSTIK_MPU_I2C_DEV)
+
+#if !defined NAVSTIK_LOWPASS_FILTER && !defined NAVSTIK_SMPLRT_DIV
+#if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
+/* Accelerometer: Bandwidth 44Hz, Delay 4.9ms
+ * Gyroscope: Bandwidth 42Hz, Delay 4.8ms sampling 1kHz
+ */
+#define NAVSTIK_LOWPASS_FILTER MPU60X0_DLPF_42HZ
+#define NAVSTIK_SMPLRT_DIV 9
+PRINT_CONFIG_MSG("Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
+#elif PERIODIC_FREQUENCY == 512
+/* Accelerometer: Bandwidth 260Hz, Delay 0ms
+ * Gyroscope: Bandwidth 256Hz, Delay 0.98ms sampling 8kHz
+ */
+#define NAVSTIK_LOWPASS_FILTER MPU60X0_DLPF_256HZ
+#define NAVSTIK_SMPLRT_DIV 3
+PRINT_CONFIG_MSG("Gyro/Accel output rate is 2kHz at 8kHz internal sampling")
+#endif
+#endif
+PRINT_CONFIG_VAR(NAVSTIK_SMPLRT_DIV)
+PRINT_CONFIG_VAR(NAVSTIK_LOWPASS_FILTER)
+
+#ifndef NAVSTIK_GYRO_RANGE
+#define NAVSTIK_GYRO_RANGE MPU60X0_GYRO_RANGE_1000
+#endif
+PRINT_CONFIG_VAR(NAVSTIK_GYRO_RANGE)
+
+#ifndef NAVSTIK_ACCEL_RANGE
+#define NAVSTIK_ACCEL_RANGE MPU60X0_ACCEL_RANGE_8G
+#endif
+PRINT_CONFIG_VAR(NAVSTIK_ACCEL_RANGE)
+
+/** Basic Navstik IMU data */
+struct ImuNavstik imu_navstik;
+
+/**
+ * Navstik IMU initializtion of the MPU-60x0 and HMC58xx
+ */
+void imu_impl_init(void)
+{
+ imu_navstik.accel_valid = FALSE;
+ imu_navstik.gyro_valid = FALSE;
+ imu_navstik.mag_valid = FALSE;
+
+ /* MPU-60X0 */
+ mpu60x0_i2c_init(&imu_navstik.mpu, &(NAVSTIK_MPU_I2C_DEV), MPU60X0_ADDR_ALT);
+ imu_navstik.mpu.config.smplrt_div = NAVSTIK_SMPLRT_DIV;
+ imu_navstik.mpu.config.dlpf_cfg = NAVSTIK_LOWPASS_FILTER;
+ imu_navstik.mpu.config.gyro_range = NAVSTIK_GYRO_RANGE;
+ imu_navstik.mpu.config.accel_range = NAVSTIK_ACCEL_RANGE;
+
+ /* HMC58XX */
+ hmc58xx_init(&imu_navstik.hmc, &(NAVSTIK_MAG_I2C_DEV), HMC58XX_ADDR);
+}
+
+/**
+ * Handle all the periodic tasks of the Navstik IMU components.
+ * Read the MPU60x0 every periodic call and the HMC58XX every 10th call.
+ */
+void imu_periodic(void)
+{
+ // Start reading the latest gyroscope data
+ mpu60x0_i2c_periodic(&imu_navstik.mpu);
+
+ // Read HMC58XX at 50Hz (main loop for rotorcraft: 512Hz)
+ RunOnceEvery(10, hmc58xx_periodic(&imu_navstik.hmc));
+}
+
+/**
+ * Handle all the events of the Navstik IMU components.
+ * When there is data available convert it to the correct axis and save it in the imu structure.
+ */
+void imu_navstik_event(void)
+{
+ /* MPU-60x0 event taks */
+ mpu60x0_i2c_event(&imu_navstik.mpu);
+
+ if (imu_navstik.mpu.data_available) {
+ /* default orientation as should be printed on the pcb, z-down, ICs down */
+ RATES_COPY(imu.gyro_unscaled, imu_navstik.mpu.data_rates.rates);
+ VECT3_COPY(imu.accel_unscaled, imu_navstik.mpu.data_accel.vect);
+
+ imu_navstik.mpu.data_available = FALSE;
+ imu_navstik.gyro_valid = TRUE;
+ imu_navstik.accel_valid = TRUE;
+ }
+
+ /* HMC58XX event task */
+ hmc58xx_event(&imu_navstik.hmc);
+ if (imu_navstik.hmc.data_available) {
+ imu.mag_unscaled.x = imu_navstik.hmc.data.vect.y;
+ imu.mag_unscaled.y = -imu_navstik.hmc.data.vect.x;
+ imu.mag_unscaled.z = imu_navstik.hmc.data.vect.z;
+
+ imu_navstik.hmc.data_available = FALSE;
+ imu_navstik.mag_valid = TRUE;
+ }
+}
diff --git a/sw/airborne/subsystems/imu/imu_navstik.h b/sw/airborne/subsystems/imu/imu_navstik.h
new file mode 100644
index 0000000000..88c2901bb8
--- /dev/null
+++ b/sw/airborne/subsystems/imu/imu_navstik.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2014 Freek van Tienen
+ *
+ * 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 subsystems/imu/imu_navstik.h
+ * Interface for the Navstik magnetometer, accelerometer and gyroscope
+ */
+
+
+#ifndef IMU_NAVSTIK_H
+#define IMU_NAVSTIK_H
+
+#include "generated/airframe.h"
+#include "subsystems/imu.h"
+
+#include "peripherals/hmc58xx.h"
+#include "peripherals/mpu60x0_i2c.h"
+
+/* Defaults */
+#if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN
+#define IMU_MAG_X_SIGN 1
+#define IMU_MAG_Y_SIGN 1
+#define IMU_MAG_Z_SIGN 1
+#endif
+#if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN
+#define IMU_GYRO_P_SIGN 1
+#define IMU_GYRO_Q_SIGN 1
+#define IMU_GYRO_R_SIGN 1
+#endif
+#if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN
+#define IMU_ACCEL_X_SIGN 1
+#define IMU_ACCEL_Y_SIGN 1
+#define IMU_ACCEL_Z_SIGN 1
+#endif
+
+/** default gyro sensitivy and neutral from the datasheet
+ * MPU with 1000 deg/s has 32.8 LSB/(deg/s)
+ * sens = 1/32.8 * pi/180 * 2^INT32_RATE_FRAC
+ * sens = 1/32.8 * pi/180 * 4096 = 2.17953
+ I*/
+#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
+// FIXME
+#define IMU_GYRO_P_SENS 2.17953
+#define IMU_GYRO_P_SENS_NUM 18271
+#define IMU_GYRO_P_SENS_DEN 8383
+#define IMU_GYRO_Q_SENS 2.17953
+#define IMU_GYRO_Q_SENS_NUM 18271
+#define IMU_GYRO_Q_SENS_DEN 8383
+#define IMU_GYRO_R_SENS 2.17953
+#define IMU_GYRO_R_SENS_NUM 18271
+#define IMU_GYRO_R_SENS_DEN 8383
+#endif
+#if !defined IMU_GYRO_P_NEUTRAL & !defined IMU_GYRO_Q_NEUTRAL & !defined IMU_GYRO_R_NEUTRAL
+#define IMU_GYRO_P_NEUTRAL 0
+#define IMU_GYRO_Q_NEUTRAL 0
+#define IMU_GYRO_R_NEUTRAL 0
+#endif
+
+/** default accel sensitivy from the datasheet
+ * MPU with 8g has 4096 LSB/g
+ * sens = 9.81 [m/s^2] / 4096 [LSB/g] * 2^INT32_ACCEL_FRAC = 2.4525
+ */
+#if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
+// FIXME
+#define IMU_ACCEL_X_SENS 2.4525
+#define IMU_ACCEL_X_SENS_NUM 981
+#define IMU_ACCEL_X_SENS_DEN 400
+#define IMU_ACCEL_Y_SENS 2.4525
+#define IMU_ACCEL_Y_SENS_NUM 981
+#define IMU_ACCEL_Y_SENS_DEN 400
+#define IMU_ACCEL_Z_SENS 2.4525
+#define IMU_ACCEL_Z_SENS_NUM 981
+#define IMU_ACCEL_Z_SENS_DEN 400
+#endif
+#if !defined IMU_ACCEL_X_NEUTRAL & !defined IMU_ACCEL_Y_NEUTRAL & !defined IMU_ACCEL_Z_NEUTRAL
+#define IMU_ACCEL_X_NEUTRAL 0
+#define IMU_ACCEL_Y_NEUTRAL 0
+#define IMU_ACCEL_Z_NEUTRAL 0
+#endif
+
+
+struct ImuNavstik {
+ volatile uint8_t accel_valid;
+ volatile uint8_t gyro_valid;
+ volatile uint8_t mag_valid;
+ struct Mpu60x0_I2c mpu;
+ struct Hmc58xx hmc;
+};
+
+extern struct ImuNavstik imu_navstik;
+extern void imu_navstik_event(void);
+
+
+static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void)) {
+ imu_navstik_event();
+ if (imu_navstik.gyro_valid) {
+ imu_navstik.gyro_valid = FALSE;
+ _gyro_handler();
+ }
+ if (imu_navstik.accel_valid) {
+ imu_navstik.accel_valid = FALSE;
+ _accel_handler();
+ }
+ if (imu_navstik.mag_valid) {
+ imu_navstik.mag_valid = FALSE;
+ _mag_handler();
+ }
+}
+
+#endif /* IMU_NAVSTIK_H */