mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-21 03:43:26 +08:00
[navstik] Added a new board
This commit is contained in:
@@ -0,0 +1,215 @@
|
||||
<!DOCTYPE airframe SYSTEM "../airframe.dtd">
|
||||
|
||||
<!-- this is a quadrotor frame in X-configuration equiped with
|
||||
* Autopilot: Navstik http://wiki.paparazziuav.org/wiki/Navstik
|
||||
* IMU: Navstik http://wiki.paparazziuav.org/wiki/Navstik
|
||||
* Actuators: Asctec V2 http://wiki.paparazziuav.org/wiki/Subsystem/actuators#Asctec_v2
|
||||
* GPS: Ublox http://wiki.paparazziuav.org/wiki/Subsystem/gps
|
||||
* RC: one Spektrum sat http://wiki.paparazziuav.org/wiki/Subsystem/radio_control#Spektrum
|
||||
-->
|
||||
|
||||
<airframe name="Quadrotor Navstik">
|
||||
|
||||
<firmware name="rotorcraft">
|
||||
<target name="ap" board="navstik_1.0">
|
||||
<subsystem name="radio_control" type="spektrum"/>
|
||||
<configure name="ACTUATORS_ASCTEC_V2_I2C_DEV" value="i2c3"/>
|
||||
<define name="RADIO_KILL_SWITCH" value="RADIO_GEAR"/>
|
||||
<define name="RADIO_MODE" value="RADIO_AUX1"/>
|
||||
<define name="ACTUATORS_START_DELAY" value="1"/>
|
||||
</target>
|
||||
|
||||
<target name="nps" board="pc">
|
||||
<subsystem name="fdm" type="jsbsim"/>
|
||||
<subsystem name="radio_control" type="ppm"/>
|
||||
</target>
|
||||
|
||||
<subsystem name="motor_mixing"/>
|
||||
<subsystem name="actuators" type="asctec_v2"/>
|
||||
<subsystem name="telemetry" type="xbee_api"/>
|
||||
<subsystem name="imu" type="navstik"/>
|
||||
<subsystem name="gps" type="ublox"/>
|
||||
<subsystem name="stabilization" type="int_quat"/>
|
||||
<subsystem name="ahrs" type="int_cmpl_quat"/>
|
||||
<subsystem name="ins" type="hff"/>
|
||||
</firmware>
|
||||
|
||||
<firmware name="test_progs">
|
||||
<configure name="MODEM_PORT" value="UART1"/>
|
||||
|
||||
<target name="test_sys_time_timer" board="navstik_1.0"/>
|
||||
<target name="test_telemetry" board="navstik_1.0"/>
|
||||
<target name="test_actuators_pwm" board="navstik_1.0"/>
|
||||
<target name="test_actuators_pwm_sin" board="navstik_1.0"/>
|
||||
</firmware>
|
||||
|
||||
<modules>
|
||||
<load name="gps_ubx_ucenter.xml"/>
|
||||
<!-- load name="airspeed_ms45xx.xml"/ -->
|
||||
</modules>
|
||||
|
||||
<servos driver="Asctec_v2">
|
||||
<servo name="FRONT" no="0" min="0" neutral="3" max="200"/>
|
||||
<servo name="BACK" no="1" min="0" neutral="3" max="200"/>
|
||||
<servo name="LEFT" no="2" min="0" neutral="3" max="200"/>
|
||||
<servo name="RIGHT" no="3" min="0" neutral="3" max="200"/>
|
||||
</servos>
|
||||
|
||||
<commands>
|
||||
<axis name="ROLL" failsafe_value="0"/>
|
||||
<axis name="PITCH" failsafe_value="0"/>
|
||||
<axis name="YAW" failsafe_value="0"/>
|
||||
<axis name="THRUST" failsafe_value="0"/>
|
||||
</commands>
|
||||
|
||||
<section name="MIXING" prefix="MOTOR_MIXING_">
|
||||
<define name="TRIM_ROLL" value="0"/>
|
||||
<define name="TRIM_PITCH" value="0"/>
|
||||
<define name="TRIM_YAW" value="0"/>
|
||||
<define name="NB_MOTOR" value="4"/>
|
||||
<define name="SCALE" value="256"/>
|
||||
<!-- order (and rotation direction) : NE (CW), SE (CCW), SW (CW), NW (CCW) -->
|
||||
<define name="ROLL_COEF" value="{ -256, -256, 256, 256 }"/>
|
||||
<define name="PITCH_COEF" value="{ 256, -256, -256, 256 }"/>
|
||||
<define name="YAW_COEF" value="{ -256, 256, -256, 256 }"/>
|
||||
<define name="THRUST_COEF" value="{ 256, 256, 256, 256 }"/>
|
||||
</section>
|
||||
|
||||
<command_laws>
|
||||
<call fun="motor_mixing_run(autopilot_motors_on,FALSE,values)"/>
|
||||
<set servo="FRONT" value="motor_mixing.commands[0]"/>
|
||||
<set servo="BACK" value="motor_mixing.commands[1]"/>
|
||||
<set servo="LEFT" value="motor_mixing.commands[2]"/>
|
||||
<set servo="RIGHT" value="motor_mixing.commands[3]"/>
|
||||
</command_laws>
|
||||
|
||||
<section name="IMU" prefix="IMU_">
|
||||
<define name="ACCEL_X_NEUTRAL" value="11"/>
|
||||
<define name="ACCEL_Y_NEUTRAL" value="11"/>
|
||||
<define name="ACCEL_Z_NEUTRAL" value="-25"/>
|
||||
|
||||
<!-- replace this with your own calibration -->
|
||||
<define name="MAG_X_NEUTRAL" value="-179"/>
|
||||
<define name="MAG_Y_NEUTRAL" value="-21"/>
|
||||
<define name="MAG_Z_NEUTRAL" value="79"/>
|
||||
<define name="MAG_X_SENS" value="4.17334785618" integer="16"/>
|
||||
<define name="MAG_Y_SENS" value="3.98885954135" integer="16"/>
|
||||
<define name="MAG_Z_SENS" value="4.40442339014" integer="16"/>
|
||||
|
||||
<define name="BODY_TO_IMU_PHI" value="0." unit="deg"/>
|
||||
<define name="BODY_TO_IMU_THETA" value="0." unit="deg"/>
|
||||
<define name="BODY_TO_IMU_PSI" value="0." unit="deg"/>
|
||||
</section>
|
||||
|
||||
<section name="AHRS" prefix="AHRS_">
|
||||
<define name="H_X" value="0.3770441"/>
|
||||
<define name="H_Y" value="0.0193986"/>
|
||||
<define name="H_Z" value="0.9259921"/>
|
||||
</section>
|
||||
|
||||
<section name="STABILIZATION_RATE" prefix="STABILIZATION_RATE_">
|
||||
<!-- setpoints -->
|
||||
<define name="SP_MAX_P" value="10000"/>
|
||||
<define name="SP_MAX_Q" value="10000"/>
|
||||
<define name="SP_MAX_R" value="10000"/>
|
||||
<define name="DEADBAND_P" value="20"/>
|
||||
<define name="DEADBAND_Q" value="20"/>
|
||||
<define name="DEADBAND_R" value="200"/>
|
||||
<define name="REF_TAU" value="4"/>
|
||||
|
||||
<!-- feedback -->
|
||||
<define name="GAIN_P" value="400"/>
|
||||
<define name="GAIN_Q" value="400"/>
|
||||
<define name="GAIN_R" value="350"/>
|
||||
|
||||
<define name="IGAIN_P" value="75"/>
|
||||
<define name="IGAIN_Q" value="75"/>
|
||||
<define name="IGAIN_R" value="50"/>
|
||||
|
||||
<!-- feedforward -->
|
||||
<define name="DDGAIN_P" value="300"/>
|
||||
<define name="DDGAIN_Q" value="300"/>
|
||||
<define name="DDGAIN_R" value="300"/>
|
||||
</section>
|
||||
|
||||
|
||||
<section name="STABILIZATION_ATTITUDE" prefix="STABILIZATION_ATTITUDE_">
|
||||
<!-- setpoints -->
|
||||
<define name="SP_MAX_PHI" value="45." unit="deg"/>
|
||||
<define name="SP_MAX_THETA" value="45." unit="deg"/>
|
||||
<define name="SP_MAX_R" value="90." unit="deg/s"/>
|
||||
<define name="DEADBAND_R" value="250"/>
|
||||
<!-- reference -->
|
||||
<define name="REF_OMEGA_P" value="800" unit="deg/s"/>
|
||||
<define name="REF_ZETA_P" value="0.85"/>
|
||||
<define name="REF_MAX_P" value="300." unit="deg/s"/>
|
||||
<define name="REF_MAX_PDOT" value="RadOfDeg(7000.)"/>
|
||||
<define name="REF_OMEGA_Q" value="800" unit="deg/s"/>
|
||||
<define name="REF_ZETA_Q" value="0.85"/>
|
||||
<define name="REF_MAX_Q" value="300." unit="deg/s"/>
|
||||
<define name="REF_MAX_QDOT" value="RadOfDeg(7000.)"/>
|
||||
<define name="REF_OMEGA_R" value="500" unit="deg/s"/>
|
||||
<define name="REF_ZETA_R" value="0.85"/>
|
||||
<define name="REF_MAX_R" value="180." unit="deg/s"/>
|
||||
<define name="REF_MAX_RDOT" value="RadOfDeg(1800.)"/>
|
||||
<!-- feedback -->
|
||||
<define name="PHI_PGAIN" value="900"/>
|
||||
<define name="PHI_DGAIN" value="200"/>
|
||||
<define name="PHI_IGAIN" value="200"/>
|
||||
<define name="THETA_PGAIN" value="900"/>
|
||||
<define name="THETA_DGAIN" value="200"/>
|
||||
<define name="THETA_IGAIN" value="200"/>
|
||||
<define name="PSI_PGAIN" value="900"/>
|
||||
<define name="PSI_DGAIN" value="200"/>
|
||||
<define name="PSI_IGAIN" value="10"/>
|
||||
<!-- feedforward -->
|
||||
<define name="PHI_DDGAIN" value="75"/>
|
||||
<define name="THETA_DDGAIN" value="75"/>
|
||||
<define name="PSI_DDGAIN" value="75"/>
|
||||
</section>
|
||||
|
||||
<section name="GUIDANCE_V" prefix="GUIDANCE_V_">
|
||||
<define name="MIN_ERR_Z" value="POS_BFP_OF_REAL(-10.)"/>
|
||||
<define name="MAX_ERR_Z" value="POS_BFP_OF_REAL( 10.)"/>
|
||||
<define name="MIN_ERR_ZD" value="SPEED_BFP_OF_REAL(-10.)"/>
|
||||
<define name="MAX_ERR_ZD" value="SPEED_BFP_OF_REAL( 10.)"/>
|
||||
<define name="MAX_SUM_ERR" value="2000000"/>
|
||||
<define name="HOVER_KP" value="150"/>
|
||||
<define name="HOVER_KD" value="80"/>
|
||||
<define name="HOVER_KI" value="20"/>
|
||||
<define name="NOMINAL_HOVER_THROTTLE" value="0.5"/>
|
||||
<define name="ADAPT_THROTTLE_ENABLED" value="TRUE"/>
|
||||
</section>
|
||||
|
||||
<section name="GUIDANCE_H" prefix="GUIDANCE_H_">
|
||||
<define name="MAX_BANK" value="20" unit="deg"/>
|
||||
<define name="USE_SPEED_REF" value="TRUE"/>
|
||||
<define name="PGAIN" value="50"/>
|
||||
<define name="DGAIN" value="100"/>
|
||||
<define name="AGAIN" value="100"/>
|
||||
<define name="IGAIN" value="20"/>
|
||||
</section>
|
||||
|
||||
<section name="SIMULATOR" prefix="NPS_">
|
||||
<define name="ACTUATOR_NAMES" value="{"ne_motor", "se_motor", "sw_motor", "nw_motor"}"/>
|
||||
<define name="JSBSIM_INIT" value=""reset00""/>
|
||||
<define name="JSBSIM_MODEL" value=""simple_x_quad""/>
|
||||
<define name="SENSORS_PARAMS" value=""nps_sensors_params_default.h""/>
|
||||
<!-- mode switch on joystick channel 5 (axis numbering starting at zero) -->
|
||||
<define name="JS_AXIS_MODE" value="4"/>
|
||||
</section>
|
||||
|
||||
<section name="AUTOPILOT">
|
||||
<define name="MODE_MANUAL" value="AP_MODE_ATTITUDE_DIRECT"/>
|
||||
<define name="MODE_AUTO1" value="AP_MODE_ATTITUDE_DIRECT"/>
|
||||
<define name="MODE_AUTO2" value="AP_MODE_ATTITUDE_DIRECT"/>
|
||||
</section>
|
||||
|
||||
<section name="BAT">
|
||||
<define name="CATASTROPHIC_BAT_LEVEL" value="9.3" unit="V"/>
|
||||
<define name="CRITIC_BAT_LEVEL" value="9.6" unit="V"/>
|
||||
<define name="LOW_BAT_LEVEL" value="10.1" unit="V"/>
|
||||
<define name="MAX_BAT_LEVEL" value="12.4" unit="V"/>
|
||||
</section>
|
||||
|
||||
</airframe>
|
||||
@@ -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. <configure name="ACTUATORS" value="actuators_ppm/>
|
||||
# and by setting the correct "driver" attribute in servo section
|
||||
# e.g. <servo driver="Ppm">
|
||||
#
|
||||
ACTUATORS ?= actuators_pwm
|
||||
+11
-1
@@ -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"
|
||||
/>
|
||||
<aircraft
|
||||
@@ -109,6 +109,16 @@
|
||||
settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/modules/rotorcraft_cam.xml settings/modules/servo_switch.xml"
|
||||
gui_color="white"
|
||||
/>
|
||||
<aircraft
|
||||
name="Quad_Navstik"
|
||||
ac_id="180"
|
||||
airframe="airframes/examples/quadrotor_navstik.xml"
|
||||
radio="radios/cockpitSX.xml"
|
||||
telemetry="telemetry/default_rotorcraft.xml"
|
||||
flight_plan="flight_plans/rotorcraft_basic.xml"
|
||||
settings=" settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/control/stabilization_rate.xml settings/estimation/ahrs_int_cmpl_quat.xml settings/modules/config_asctec_v2.xml"
|
||||
gui_color="#710080"
|
||||
/>
|
||||
<aircraft
|
||||
name="Twinjet"
|
||||
ac_id="6"
|
||||
|
||||
@@ -18,6 +18,13 @@ else ifeq ($(BOARD), lisa_l)
|
||||
BARO_BOARD_CFLAGS += -DUSE_I2C2
|
||||
BARO_BOARD_SRCS += $(SRC_BOARD)/baro_board.c
|
||||
|
||||
# Navstik baro
|
||||
else ifeq ($(BOARD), navstik)
|
||||
ap.CFLAGS += -DUSE_I2C3
|
||||
ap.CFLAGS += -DBARO_BOARD=BARO_BOARD_BMP085
|
||||
ap.srcs += peripherals/bmp085.c
|
||||
ap.srcs += $(SRC_BOARD)/baro_board.c
|
||||
|
||||
# Ardrone baro
|
||||
else ifeq ($(BOARD)$(BOARD_TYPE), ardroneraw)
|
||||
BARO_BOARD_SRCS += $(SRC_BOARD)/baro_board.c
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#
|
||||
# Navstik onboard IMU
|
||||
#
|
||||
#
|
||||
# if ACCEL and GYRO SENS/NEUTRAL are not defined,
|
||||
# the defaults from the datasheet will be used
|
||||
#
|
||||
# required xml:
|
||||
# <section name="IMU" prefix="IMU_">
|
||||
#
|
||||
# <define name="MAG_X_NEUTRAL" value="2358"/>
|
||||
# <define name="MAG_Y_NEUTRAL" value="2362"/>
|
||||
# <define name="MAG_Z_NEUTRAL" value="2119"/>
|
||||
#
|
||||
# <define name="MAG_X_SENS" value="3.4936416" integer="16"/>
|
||||
# <define name="MAG_Y_SENS" value="3.607713" integer="16"/>
|
||||
# <define name="MAG_Z_SENS" value="4.90788848" integer="16"/>
|
||||
#
|
||||
# </section>
|
||||
#
|
||||
$(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
|
||||
@@ -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)
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<board name="apogee_.*"/>
|
||||
<board name="stm32f4_discovery"/>
|
||||
<board name="li[s]?a_mx_.*"/>
|
||||
<board name="navstik_.*"/>
|
||||
</boards>
|
||||
</mode>
|
||||
<mode name="STLink (SWD)">
|
||||
@@ -88,6 +89,7 @@
|
||||
<boards>
|
||||
<board name="krooz_sd"/>
|
||||
<board name="li[s]?a_[lm]?_.*"/>
|
||||
<board name="navstik_.*"/>
|
||||
</boards>
|
||||
</mode>
|
||||
</flash_modes>
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Hey Emacs, this is a -*- makefile -*-
|
||||
*
|
||||
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* 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 <libopencm3/stm32/gpio.h>
|
||||
#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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* 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 */
|
||||
@@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* 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 */
|
||||
@@ -24,6 +24,7 @@
|
||||
* Inertial Measurement Unit interface.
|
||||
*/
|
||||
|
||||
#include BOARD_CONFIG
|
||||
#include "subsystems/imu.h"
|
||||
|
||||
#ifdef IMU_POWER_GPIO
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* 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 */
|
||||
Reference in New Issue
Block a user