mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Copy the revo project to revo mini
This commit is contained in:
parent
d58831d3f1
commit
60160001c6
383
flight/Bootloaders/RevoMini/Makefile
Normal file
383
flight/Bootloaders/RevoMini/Makefile
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
#####
|
||||||
|
# Project: OpenPilot INS_BOOTLOADER
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Makefile for OpenPilot INS project
|
||||||
|
#
|
||||||
|
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#####
|
||||||
|
|
||||||
|
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
|
TOP := $(realpath $(WHEREAMI)/../../../)
|
||||||
|
include $(TOP)/make/firmware-defs.mk
|
||||||
|
include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET := bl_$(BOARD_NAME)
|
||||||
|
|
||||||
|
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
|
||||||
|
OUTDIR := $(TOP)/build/$(TARGET)
|
||||||
|
|
||||||
|
# Set developer code and compile options
|
||||||
|
# Set to YES for debugging
|
||||||
|
DEBUG ?= NO
|
||||||
|
|
||||||
|
# Set to YES when using Code Sourcery toolchain
|
||||||
|
CODE_SOURCERY ?= NO
|
||||||
|
|
||||||
|
ifeq ($(CODE_SOURCERY), YES)
|
||||||
|
REMOVE_CMD = cs-rm
|
||||||
|
else
|
||||||
|
REMOVE_CMD = rm
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Paths
|
||||||
|
REVO_BL = $(WHEREAMI)
|
||||||
|
REVO_BLINC = $(REVO_BL)/inc
|
||||||
|
PIOS = ../../PiOS
|
||||||
|
PIOSINC = $(PIOS)/inc
|
||||||
|
FLIGHTLIB = ../../Libraries
|
||||||
|
FLIGHTLIBINC = ../../Libraries/inc
|
||||||
|
PIOSSTM32F4XX = $(PIOS)/STM32F4xx
|
||||||
|
PIOSCOMMON = $(PIOS)/Common
|
||||||
|
PIOSBOARDS = $(PIOS)/Boards
|
||||||
|
PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries
|
||||||
|
APPLIBDIR = $(PIOSSTM32F4XX)/Libraries
|
||||||
|
STMLIBDIR = $(APPLIBDIR)
|
||||||
|
STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver
|
||||||
|
STMSPDSRCDIR = $(STMSPDDIR)/src
|
||||||
|
STMSPDINCDIR = $(STMSPDDIR)/inc
|
||||||
|
HWDEFSINC = ../../board_hw_defs/$(BOARD_NAME)
|
||||||
|
|
||||||
|
# List C source files here. (C dependencies are automatically generated.)
|
||||||
|
# use file-extension c for "c-only"-files
|
||||||
|
|
||||||
|
## BOOTLOADER:
|
||||||
|
SRC += main.c
|
||||||
|
SRC += pios_board.c
|
||||||
|
SRC += pios_usb_board_data.c
|
||||||
|
SRC += op_dfu.c
|
||||||
|
|
||||||
|
## PIOS Hardware (STM32F4xx)
|
||||||
|
include $(PIOS)/STM32F4xx/library.mk
|
||||||
|
|
||||||
|
# PIOS Hardware (Common)
|
||||||
|
SRC += $(PIOSCOMMON)/pios_board_info.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_com_msg.c
|
||||||
|
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_usb_util.c
|
||||||
|
|
||||||
|
# List C source files here which must be compiled in ARM-Mode (no -mthumb).
|
||||||
|
# use file-extension c for "c-only"-files
|
||||||
|
## just for testing, timer.c could be compiled in thumb-mode too
|
||||||
|
SRCARM =
|
||||||
|
|
||||||
|
# List C++ source files here.
|
||||||
|
# use file-extension .cpp for C++-files (not .C)
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# List C++ source files here which must be compiled in ARM-Mode.
|
||||||
|
# use file-extension .cpp for C++-files (not .C)
|
||||||
|
#CPPSRCARM = $(TARGET).cpp
|
||||||
|
CPPSRCARM =
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS += $(PIOS)
|
||||||
|
EXTRAINCDIRS += $(PIOSINC)
|
||||||
|
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
||||||
|
EXTRAINCDIRS += $(PIOSSTM34FXX)
|
||||||
|
EXTRAINCDIRS += $(PIOSCOMMON)
|
||||||
|
EXTRAINCDIRS += $(PIOSBOARDS)
|
||||||
|
EXTRAINCDIRS += $(STMSPDINCDIR)
|
||||||
|
EXTRAINCDIRS += $(CMSISDIR)
|
||||||
|
EXTRAINCDIRS += $(REVO_BLINC)
|
||||||
|
EXTRAINCDIRS += $(HWDEFSINC)
|
||||||
|
|
||||||
|
# List any extra directories to look for library files here.
|
||||||
|
# Also add directories where the linker should search for
|
||||||
|
# includes from linker-script to the list
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRA_LIBDIRS =
|
||||||
|
|
||||||
|
# Extra Libraries
|
||||||
|
# Each library-name must be seperated by a space.
|
||||||
|
# i.e. to link with libxyz.a, libabc.a and libefsl.a:
|
||||||
|
# EXTRA_LIBS = xyz abc efsl
|
||||||
|
# for newlib-lpc (file: libnewlibc-lpc.a):
|
||||||
|
# EXTRA_LIBS = newlib-lpc
|
||||||
|
EXTRA_LIBS =
|
||||||
|
|
||||||
|
# Path to Linker-Scripts
|
||||||
|
LINKERSCRIPTPATH = $(PIOSSTM32FXX)
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),YES)
|
||||||
|
OPT = 0
|
||||||
|
else
|
||||||
|
OPT = s
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Output format. (can be ihex or binary or both)
|
||||||
|
# binary to create a load-image in raw-binary format i.e. for SAM-BA,
|
||||||
|
# ihex to create a load-image in Intel hex format
|
||||||
|
#LOADFORMAT = ihex
|
||||||
|
#LOADFORMAT = binary
|
||||||
|
LOADFORMAT = both
|
||||||
|
|
||||||
|
# Debugging format.
|
||||||
|
DEBUGF = dwarf-2
|
||||||
|
|
||||||
|
# Place project-specific -D (define) and/or
|
||||||
|
# -U options for C here.
|
||||||
|
CDEFS = -DSTM32F4XX
|
||||||
|
CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ)
|
||||||
|
CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ)
|
||||||
|
CDEFS += -DUSE_STDPERIPH_DRIVER
|
||||||
|
CDEFS += -DUSE_$(BOARD)
|
||||||
|
|
||||||
|
# Provide (only) the bootloader with board-specific defines
|
||||||
|
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
||||||
|
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
||||||
|
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
|
||||||
|
BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE)
|
||||||
|
BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE)
|
||||||
|
BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE)
|
||||||
|
|
||||||
|
# Place project-specific -D and/or -U options for
|
||||||
|
# Assembler with preprocessor here.
|
||||||
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
|
ADEFS = -D__ASSEMBLY__
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
#-----
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
|
||||||
|
# -g*: generate debugging information
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
#
|
||||||
|
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),YES)
|
||||||
|
CFLAGS =
|
||||||
|
endif
|
||||||
|
|
||||||
|
# This is not the best place for these. Really should abstract out
|
||||||
|
# to the board file or something
|
||||||
|
CFLAGS += -DSTM32F4XX
|
||||||
|
CFLAGS += -DMEM_SIZE=1024000000
|
||||||
|
|
||||||
|
CFLAGS += -g$(DEBUGF)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
ifeq ($(DEBUG),NO)
|
||||||
|
CFLAGS += -fdata-sections -ffunction-sections
|
||||||
|
endif
|
||||||
|
CFLAGS += -mcpu=$(MCU)
|
||||||
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(BLONLY_CDEFS)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
|
CFLAGS += -mapcs-frame
|
||||||
|
CFLAGS += -fomit-frame-pointer
|
||||||
|
ifeq ($(CODE_SOURCERY), YES)
|
||||||
|
CFLAGS += -fpromote-loop-indices
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -Wall
|
||||||
|
#CFLAGS += -Werror
|
||||||
|
CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
|
# Compiler flags to generate dependency files:
|
||||||
|
CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d
|
||||||
|
|
||||||
|
# flags only for C
|
||||||
|
#CONLYFLAGS += -Wnested-externs
|
||||||
|
CONLYFLAGS += $(CSTANDARD)
|
||||||
|
|
||||||
|
# Assembler flags.
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -ahlns: create listing
|
||||||
|
ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp
|
||||||
|
ASFLAGS += $(ADEFS)
|
||||||
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
|
||||||
|
MATH_LIB = -lm
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections
|
||||||
|
ifeq ($(DEBUG),NO)
|
||||||
|
LDFLAGS += -Wl,-static
|
||||||
|
endif
|
||||||
|
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
|
||||||
|
LDFLAGS += -lc
|
||||||
|
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
|
||||||
|
LDFLAGS += $(MATH_LIB)
|
||||||
|
LDFLAGS += -lc -lgcc
|
||||||
|
|
||||||
|
#Linker scripts
|
||||||
|
LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_BL))
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
REMOVE = $(REMOVE_CMD) -f
|
||||||
|
|
||||||
|
# List of all source files.
|
||||||
|
ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC)
|
||||||
|
# List of all source files without directory and file-extension.
|
||||||
|
ALLSRCBASE = $(notdir $(basename $(ALLSRC)))
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
|
||||||
|
|
||||||
|
# Define all listing files (used for make clean).
|
||||||
|
LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE)))
|
||||||
|
# Define all depedency-files (used for make clean).
|
||||||
|
DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE)))
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: build
|
||||||
|
|
||||||
|
ifeq ($(LOADFORMAT),ihex)
|
||||||
|
build: elf hex sym
|
||||||
|
else
|
||||||
|
ifeq ($(LOADFORMAT),binary)
|
||||||
|
build: elf bin sym
|
||||||
|
else
|
||||||
|
ifeq ($(LOADFORMAT),both)
|
||||||
|
build: elf hex bin sym
|
||||||
|
else
|
||||||
|
$(error "$(MSG_FORMATERROR) $(FORMAT)")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ)))
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files. ARM-only
|
||||||
|
$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C source files. ARM-only
|
||||||
|
$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C++ source files.
|
||||||
|
$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C++ source files. ARM-only
|
||||||
|
$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files. ARM/Thumb
|
||||||
|
$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC))
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files. ARM only
|
||||||
|
$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM))
|
||||||
|
|
||||||
|
$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
|
||||||
|
|
||||||
|
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
|
||||||
|
|
||||||
|
# Add jtag targets (program and wipe)
|
||||||
|
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG)))
|
||||||
|
|
||||||
|
.PHONY: elf lss sym hex bin bino
|
||||||
|
elf: $(OUTDIR)/$(TARGET).elf
|
||||||
|
lss: $(OUTDIR)/$(TARGET).lss
|
||||||
|
sym: $(OUTDIR)/$(TARGET).sym
|
||||||
|
hex: $(OUTDIR)/$(TARGET).hex
|
||||||
|
bin: $(OUTDIR)/$(TARGET).bin
|
||||||
|
bino: $(OUTDIR)/$(TARGET).bin.o
|
||||||
|
|
||||||
|
# Display sizes of sections.
|
||||||
|
$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf))
|
||||||
|
|
||||||
|
# Generate Doxygen documents
|
||||||
|
docs:
|
||||||
|
doxygen $(DOXYGENDIR)/doxygen.cfg
|
||||||
|
|
||||||
|
# Install: install binary file with prefix/suffix into install directory
|
||||||
|
install: $(OUTDIR)/$(TARGET).bin
|
||||||
|
ifneq ($(INSTALL_DIR),)
|
||||||
|
@echo $(MSG_INSTALLING) $(call toprel, $<)
|
||||||
|
$(V1) mkdir -p $(INSTALL_DIR)
|
||||||
|
$(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin
|
||||||
|
else
|
||||||
|
$(error INSTALL_DIR must be specified for $@)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: clean_list
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o
|
||||||
|
$(V1) $(REMOVE) $(ALLOBJ)
|
||||||
|
$(V1) $(REMOVE) $(LSTFILES)
|
||||||
|
$(V1) $(REMOVE) $(DEPFILES)
|
||||||
|
$(V1) $(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(V1) $(REMOVE) $(SRCARM:.c=.s)
|
||||||
|
$(V1) $(REMOVE) $(CPPSRC:.cpp=.s)
|
||||||
|
$(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s)
|
||||||
|
|
||||||
|
|
||||||
|
# Create output files directory
|
||||||
|
# all known MS Windows OS define the ComSpec environment variable
|
||||||
|
ifdef ComSpec
|
||||||
|
$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL)
|
||||||
|
else
|
||||||
|
$(shell mkdir -p $(OUTDIR) 2>/dev/null)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
ifdef ComSpec
|
||||||
|
-include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*)
|
||||||
|
else
|
||||||
|
-include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all build clean clean_list install
|
115
flight/Bootloaders/RevoMini/inc/common.h
Normal file
115
flight/Bootloaders/RevoMini/inc/common.h
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup CopterControlBL CopterControl BootLoader
|
||||||
|
* @brief These files contain the code to the CopterControl Bootloader.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
* @file common.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief This file contains various common defines for the BootLoader
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef COMMON_H_
|
||||||
|
#define COMMON_H_
|
||||||
|
|
||||||
|
//#include "board.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
start, keepgoing,
|
||||||
|
} DownloadAction;
|
||||||
|
|
||||||
|
/**************************************************/
|
||||||
|
/* OP_DFU states */
|
||||||
|
/**************************************************/
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DFUidle, //0
|
||||||
|
uploading, //1
|
||||||
|
wrong_packet_received, //2
|
||||||
|
too_many_packets, //3
|
||||||
|
too_few_packets, //4
|
||||||
|
Last_operation_Success, //5
|
||||||
|
downloading, //6
|
||||||
|
BLidle, //7
|
||||||
|
Last_operation_failed, //8
|
||||||
|
uploadingStarting, //9
|
||||||
|
outsideDevCapabilities, //10
|
||||||
|
CRC_Fail,//11
|
||||||
|
failed_jump,
|
||||||
|
//12
|
||||||
|
} DFUStates;
|
||||||
|
/**************************************************/
|
||||||
|
/* OP_DFU commands */
|
||||||
|
/**************************************************/
|
||||||
|
typedef enum {
|
||||||
|
Reserved, //0
|
||||||
|
Req_Capabilities, //1
|
||||||
|
Rep_Capabilities, //2
|
||||||
|
EnterDFU, //3
|
||||||
|
JumpFW, //4
|
||||||
|
Reset, //5
|
||||||
|
Abort_Operation, //6
|
||||||
|
Upload, //7
|
||||||
|
Op_END, //8
|
||||||
|
Download_Req, //9
|
||||||
|
Download, //10
|
||||||
|
Status_Request, //11
|
||||||
|
Status_Rep
|
||||||
|
//12
|
||||||
|
} DFUCommands;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
High_Density, Medium_Density
|
||||||
|
} DeviceType;
|
||||||
|
/**************************************************/
|
||||||
|
/* OP_DFU transfer types */
|
||||||
|
/**************************************************/
|
||||||
|
typedef enum {
|
||||||
|
FW, //0
|
||||||
|
Descript
|
||||||
|
//2
|
||||||
|
} DFUTransfer;
|
||||||
|
/**************************************************/
|
||||||
|
/* OP_DFU transfer port */
|
||||||
|
/**************************************************/
|
||||||
|
typedef enum {
|
||||||
|
Usb, //0
|
||||||
|
Serial
|
||||||
|
//2
|
||||||
|
} DFUPort;
|
||||||
|
/**************************************************/
|
||||||
|
/* OP_DFU programable programable HW types */
|
||||||
|
/**************************************************/
|
||||||
|
typedef enum {
|
||||||
|
Self_flash, //0
|
||||||
|
Remote_flash_via_spi
|
||||||
|
//1
|
||||||
|
} DFUProgType;
|
||||||
|
/**************************************************/
|
||||||
|
/* OP_DFU programable sources */
|
||||||
|
/**************************************************/
|
||||||
|
#define USB 0
|
||||||
|
#define SPI 1
|
||||||
|
|
||||||
|
#define DownloadDelay 100000
|
||||||
|
|
||||||
|
#define MAX_DEL_RETRYS 3
|
||||||
|
#define MAX_WRI_RETRYS 3
|
||||||
|
|
||||||
|
#endif /* COMMON_H_ */
|
60
flight/Bootloaders/RevoMini/inc/op_dfu.h
Normal file
60
flight/Bootloaders/RevoMini/inc/op_dfu.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file op_dfu.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __OP_DFU_H
|
||||||
|
#define __OP_DFU_H
|
||||||
|
#include "common.h"
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t programmingType;
|
||||||
|
uint8_t readWriteFlags;
|
||||||
|
uint32_t startOfUserCode;
|
||||||
|
uint32_t sizeOfCode;
|
||||||
|
uint8_t sizeOfDescription;
|
||||||
|
uint8_t BL_Version;
|
||||||
|
uint16_t devID;
|
||||||
|
DeviceType devType;
|
||||||
|
uint32_t FW_Crc;
|
||||||
|
} Device;
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported define -----------------------------------------------------------*/
|
||||||
|
#define COMMAND 0
|
||||||
|
#define COUNT 1
|
||||||
|
#define DATA 5
|
||||||
|
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void processComand(uint8_t *Receive_Buffer);
|
||||||
|
uint32_t baseOfAdressType(uint8_t type);
|
||||||
|
uint8_t isBiggerThanAvailable(uint8_t type, uint32_t size);
|
||||||
|
void OPDfuIni(uint8_t discover);
|
||||||
|
void DataDownload(DownloadAction);
|
||||||
|
bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type);
|
||||||
|
#endif /* __OP_DFU_H */
|
||||||
|
|
||||||
|
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
43
flight/Bootloaders/RevoMini/inc/pios_config.h
Normal file
43
flight/Bootloaders/RevoMini/inc/pios_config.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file pios_config.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief PiOS configuration header.
|
||||||
|
* - Central compile time config for the project.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PIOS_CONFIG_H
|
||||||
|
#define PIOS_CONFIG_H
|
||||||
|
|
||||||
|
/* Enable/Disable PiOS Modules */
|
||||||
|
#define PIOS_INCLUDE_DELAY
|
||||||
|
#define PIOS_INCLUDE_IRQ
|
||||||
|
#define PIOS_INCLUDE_LED
|
||||||
|
#define PIOS_INCLUDE_SPI
|
||||||
|
#define PIOS_INCLUDE_SYS
|
||||||
|
#define PIOS_INCLUDE_IAP
|
||||||
|
#define PIOS_INCLUDE_USB
|
||||||
|
#define PIOS_INCLUDE_USB_HID
|
||||||
|
#define PIOS_INCLUDE_COM_MSG
|
||||||
|
#define PIOS_INCLUDE_BL_HELPER
|
||||||
|
#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT
|
||||||
|
|
||||||
|
#endif /* PIOS_CONFIG_H */
|
52
flight/Bootloaders/RevoMini/inc/pios_usb_board_data.h
Normal file
52
flight/Bootloaders/RevoMini/inc/pios_usb_board_data.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||||
|
* @{
|
||||||
|
* @addtogroup PIOS_USB_BOARD Board specific USB definitions
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_usb_board_data.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PIOS_USB_BOARD_DATA_H
|
||||||
|
#define PIOS_USB_BOARD_DATA_H
|
||||||
|
|
||||||
|
#define PIOS_USB_BOARD_HID_DATA_LENGTH 64
|
||||||
|
|
||||||
|
#define PIOS_USB_BOARD_EP_NUM 2
|
||||||
|
|
||||||
|
#include "pios_usb_defs.h" /* struct usb_* */
|
||||||
|
|
||||||
|
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_REVOLUTION
|
||||||
|
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_REVOLUTION, USB_OP_BOARD_MODE_BL)
|
||||||
|
#define PIOS_USB_BOARD_SN_SUFFIX "+BL"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The bootloader uses a simplified report structure
|
||||||
|
* BL: <REPORT_ID><DATA>...<DATA>
|
||||||
|
* FW: <REPORT_ID><LENGTH><DATA>...<DATA>
|
||||||
|
* This define changes the behaviour in pios_usb_hid.c
|
||||||
|
*/
|
||||||
|
#define PIOS_USB_BOARD_BL_HID_HAS_NO_LENGTH_BYTE
|
||||||
|
|
||||||
|
#endif /* PIOS_USB_BOARD_DATA_H */
|
230
flight/Bootloaders/RevoMini/main.c
Normal file
230
flight/Bootloaders/RevoMini/main.c
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup RevolutionBL Revolution BootLoader
|
||||||
|
* @brief These files contain the code to the Revolution Bootloader.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
* @file main.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief This is the file with the main function of the Revolution BootLoader
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
/* Bootloader Includes */
|
||||||
|
#include <pios.h>
|
||||||
|
#include <pios_board_info.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "op_dfu.h"
|
||||||
|
#include "pios_iap.h"
|
||||||
|
#include "fifo_buffer.h"
|
||||||
|
#include "pios_com_msg.h"
|
||||||
|
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||||
|
/* Prototype of PIOS_Board_Init() function */
|
||||||
|
extern void PIOS_Board_Init(void);
|
||||||
|
extern void FLASH_Download();
|
||||||
|
void check_bor();
|
||||||
|
#define BSL_HOLD_STATE ((PIOS_USB_DETECT_GPIO_PORT->IDR & PIOS_USB_DETECT_GPIO_PIN) ? 0 : 1)
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
typedef void (*pFunction)(void);
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
pFunction Jump_To_Application;
|
||||||
|
uint32_t JumpAddress;
|
||||||
|
|
||||||
|
/// LEDs PWM
|
||||||
|
uint32_t period1 = 5000; // 5 mS
|
||||||
|
uint32_t sweep_steps1 = 100; // * 5 mS -> 500 mS
|
||||||
|
uint32_t period2 = 5000; // 5 mS
|
||||||
|
uint32_t sweep_steps2 = 100; // * 5 mS -> 500 mS
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
uint8_t tempcount = 0;
|
||||||
|
|
||||||
|
/* Extern variables ----------------------------------------------------------*/
|
||||||
|
DFUStates DeviceState;
|
||||||
|
int16_t status = 0;
|
||||||
|
bool JumpToApp = false;
|
||||||
|
bool GO_dfu = false;
|
||||||
|
bool USB_connected = false;
|
||||||
|
bool User_DFU_request = false;
|
||||||
|
static uint8_t mReceive_Buffer[63];
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count);
|
||||||
|
uint8_t processRX();
|
||||||
|
void jump_to_app();
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
PIOS_SYS_Init();
|
||||||
|
PIOS_Board_Init();
|
||||||
|
PIOS_IAP_Init();
|
||||||
|
|
||||||
|
// Make sure the brown out reset value for this chip
|
||||||
|
// is 2.7 volts
|
||||||
|
check_bor();
|
||||||
|
|
||||||
|
USB_connected = PIOS_USB_CheckAvailable(0);
|
||||||
|
|
||||||
|
if (PIOS_IAP_CheckRequest() == true) {
|
||||||
|
PIOS_DELAY_WaitmS(1000);
|
||||||
|
User_DFU_request = true;
|
||||||
|
PIOS_IAP_ClearRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
GO_dfu = (USB_connected == true) || (User_DFU_request == true);
|
||||||
|
|
||||||
|
if (GO_dfu == true) {
|
||||||
|
if (User_DFU_request == true)
|
||||||
|
DeviceState = DFUidle;
|
||||||
|
else
|
||||||
|
DeviceState = BLidle;
|
||||||
|
} else
|
||||||
|
JumpToApp = true;
|
||||||
|
|
||||||
|
uint32_t stopwatch = 0;
|
||||||
|
uint32_t prev_ticks = PIOS_DELAY_GetuS();
|
||||||
|
while (true) {
|
||||||
|
/* Update the stopwatch */
|
||||||
|
uint32_t elapsed_ticks = PIOS_DELAY_GetuSSince(prev_ticks);
|
||||||
|
prev_ticks += elapsed_ticks;
|
||||||
|
stopwatch += elapsed_ticks;
|
||||||
|
|
||||||
|
if (JumpToApp == true)
|
||||||
|
jump_to_app();
|
||||||
|
|
||||||
|
switch (DeviceState) {
|
||||||
|
case Last_operation_Success:
|
||||||
|
case uploadingStarting:
|
||||||
|
case DFUidle:
|
||||||
|
period1 = 5000;
|
||||||
|
sweep_steps1 = 100;
|
||||||
|
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||||
|
period2 = 0;
|
||||||
|
break;
|
||||||
|
case uploading:
|
||||||
|
period1 = 5000;
|
||||||
|
sweep_steps1 = 100;
|
||||||
|
period2 = 2500;
|
||||||
|
sweep_steps2 = 50;
|
||||||
|
break;
|
||||||
|
case downloading:
|
||||||
|
period1 = 2500;
|
||||||
|
sweep_steps1 = 50;
|
||||||
|
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||||
|
period2 = 0;
|
||||||
|
break;
|
||||||
|
case BLidle:
|
||||||
|
period1 = 0;
|
||||||
|
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||||
|
period2 = 0;
|
||||||
|
break;
|
||||||
|
default://error
|
||||||
|
period1 = 5000;
|
||||||
|
sweep_steps1 = 100;
|
||||||
|
period2 = 5000;
|
||||||
|
sweep_steps2 = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (period1 != 0) {
|
||||||
|
if (LedPWM(period1, sweep_steps1, stopwatch))
|
||||||
|
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||||
|
else
|
||||||
|
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||||
|
} else
|
||||||
|
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||||
|
|
||||||
|
if (period2 != 0) {
|
||||||
|
if (LedPWM(period2, sweep_steps2, stopwatch))
|
||||||
|
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||||
|
else
|
||||||
|
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||||
|
} else
|
||||||
|
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||||
|
|
||||||
|
if (stopwatch > 50 * 1000 * 1000)
|
||||||
|
stopwatch = 0;
|
||||||
|
if ((stopwatch > 6 * 1000 * 1000) && (DeviceState
|
||||||
|
== BLidle))
|
||||||
|
JumpToApp = true;
|
||||||
|
|
||||||
|
processRX();
|
||||||
|
DataDownload(start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void jump_to_app() {
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
|
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||||
|
if (((*(__IO uint32_t*) bdinfo->fw_base) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */
|
||||||
|
FLASH_Lock();
|
||||||
|
RCC_APB2PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
|
RCC_APB1PeriphResetCmd(0xffffffff, ENABLE);
|
||||||
|
RCC_APB2PeriphResetCmd(0xffffffff, DISABLE);
|
||||||
|
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);
|
||||||
|
|
||||||
|
PIOS_USBHOOK_Deactivate();
|
||||||
|
|
||||||
|
JumpAddress = *(__IO uint32_t*) (bdinfo->fw_base + 4);
|
||||||
|
Jump_To_Application = (pFunction) JumpAddress;
|
||||||
|
/* Initialize user application's Stack Pointer */
|
||||||
|
__set_MSP(*(__IO uint32_t*) bdinfo->fw_base);
|
||||||
|
Jump_To_Application();
|
||||||
|
} else {
|
||||||
|
DeviceState = failed_jump;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32_t LedPWM(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t count) {
|
||||||
|
uint32_t curr_step = (count / pwm_period) % pwm_sweep_steps; /* 0 - pwm_sweep_steps */
|
||||||
|
uint32_t pwm_duty = pwm_period * curr_step / pwm_sweep_steps; /* fraction of pwm_period */
|
||||||
|
|
||||||
|
uint32_t curr_sweep = (count / (pwm_period * pwm_sweep_steps)); /* ticks once per full sweep */
|
||||||
|
if (curr_sweep & 1) {
|
||||||
|
pwm_duty = pwm_period - pwm_duty; /* reverse direction in odd sweeps */
|
||||||
|
}
|
||||||
|
return ((count % pwm_period) > pwm_duty) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t processRX() {
|
||||||
|
if (PIOS_COM_MSG_Receive(PIOS_COM_TELEM_USB, mReceive_Buffer, sizeof(mReceive_Buffer))) {
|
||||||
|
processComand(mReceive_Buffer);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the brown out reset threshold is 2.7 volts and if not
|
||||||
|
* resets it. This solves an issue that can prevent boards
|
||||||
|
* powering up with some BEC
|
||||||
|
*/
|
||||||
|
void check_bor()
|
||||||
|
{
|
||||||
|
uint8_t bor = FLASH_OB_GetBOR();
|
||||||
|
if(bor != OB_BOR_LEVEL3) {
|
||||||
|
FLASH_OB_Unlock();
|
||||||
|
FLASH_OB_BORConfig(OB_BOR_LEVEL3);
|
||||||
|
FLASH_OB_Launch();
|
||||||
|
while(FLASH_WaitForLastOperation() == FLASH_BUSY);
|
||||||
|
FLASH_OB_Lock();
|
||||||
|
while(FLASH_WaitForLastOperation() == FLASH_BUSY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
468
flight/Bootloaders/RevoMini/op_dfu.c
Normal file
468
flight/Bootloaders/RevoMini/op_dfu.c
Normal file
@ -0,0 +1,468 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup CopterControlBL CopterControl BootLoader
|
||||||
|
* @brief These files contain the code to the CopterControl Bootloader.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
* @file op_dfu.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief This file contains the DFU commands handling code
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "pios.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "op_dfu.h"
|
||||||
|
#include "pios_bl_helper.h"
|
||||||
|
#include "pios_com_msg.h"
|
||||||
|
#include <pios_board_info.h>
|
||||||
|
//programmable devices
|
||||||
|
Device devicesTable[10];
|
||||||
|
uint8_t numberOfDevices = 0;
|
||||||
|
|
||||||
|
DFUProgType currentProgrammingDestination; //flash, flash_trough spi
|
||||||
|
uint8_t currentDeviceCanRead;
|
||||||
|
uint8_t currentDeviceCanWrite;
|
||||||
|
Device currentDevice;
|
||||||
|
|
||||||
|
uint8_t Buffer[64];
|
||||||
|
uint8_t echoBuffer[64];
|
||||||
|
uint8_t SendBuffer[64];
|
||||||
|
uint8_t Command = 0;
|
||||||
|
uint8_t EchoReqFlag = 0;
|
||||||
|
uint8_t EchoAnsFlag = 0;
|
||||||
|
uint8_t StartFlag = 0;
|
||||||
|
uint32_t Aditionals = 0;
|
||||||
|
uint32_t SizeOfTransfer = 0;
|
||||||
|
uint32_t Expected_CRC = 0;
|
||||||
|
uint8_t SizeOfLastPacket = 0;
|
||||||
|
uint32_t Next_Packet = 0;
|
||||||
|
uint8_t TransferType;
|
||||||
|
uint32_t Count = 0;
|
||||||
|
uint32_t Data;
|
||||||
|
uint8_t Data0;
|
||||||
|
uint8_t Data1;
|
||||||
|
uint8_t Data2;
|
||||||
|
uint8_t Data3;
|
||||||
|
uint8_t offset = 0;
|
||||||
|
uint32_t aux;
|
||||||
|
//Download vars
|
||||||
|
uint32_t downSizeOfLastPacket = 0;
|
||||||
|
uint32_t downPacketTotal = 0;
|
||||||
|
uint32_t downPacketCurrent = 0;
|
||||||
|
DFUTransfer downType = 0;
|
||||||
|
/* Extern variables ----------------------------------------------------------*/
|
||||||
|
extern DFUStates DeviceState;
|
||||||
|
extern uint8_t JumpToApp;
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
void sendData(uint8_t * buf, uint16_t size);
|
||||||
|
uint32_t CalcFirmCRC(void);
|
||||||
|
|
||||||
|
void DataDownload(DownloadAction action) {
|
||||||
|
if ((DeviceState == downloading)) {
|
||||||
|
|
||||||
|
uint8_t packetSize;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t partoffset;
|
||||||
|
SendBuffer[0] = 0x01;
|
||||||
|
SendBuffer[1] = Download;
|
||||||
|
SendBuffer[2] = downPacketCurrent >> 24;
|
||||||
|
SendBuffer[3] = downPacketCurrent >> 16;
|
||||||
|
SendBuffer[4] = downPacketCurrent >> 8;
|
||||||
|
SendBuffer[5] = downPacketCurrent;
|
||||||
|
if (downPacketCurrent == downPacketTotal - 1) {
|
||||||
|
packetSize = downSizeOfLastPacket;
|
||||||
|
} else {
|
||||||
|
packetSize = 14;
|
||||||
|
}
|
||||||
|
for (uint8_t x = 0; x < packetSize; ++x) {
|
||||||
|
partoffset = (downPacketCurrent * 14 * 4) + (x * 4);
|
||||||
|
offset = baseOfAdressType(downType) + partoffset;
|
||||||
|
if (!flash_read(SendBuffer + (6 + x * 4), offset,
|
||||||
|
currentProgrammingDestination)) {
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
downPacketCurrent = downPacketCurrent + 1;
|
||||||
|
if (downPacketCurrent > downPacketTotal - 1) {
|
||||||
|
DeviceState = Last_operation_Success;
|
||||||
|
Aditionals = (uint32_t) Download;
|
||||||
|
}
|
||||||
|
sendData(SendBuffer + 1, 63);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void processComand(uint8_t *xReceive_Buffer) {
|
||||||
|
|
||||||
|
Command = xReceive_Buffer[COMMAND];
|
||||||
|
#ifdef DEBUG_SSP
|
||||||
|
char str[63]= {0};
|
||||||
|
sprintf(str,"Received COMMAND:%d|",Command);
|
||||||
|
PIOS_COM_SendString(PIOS_COM_TELEM_USB,str);
|
||||||
|
#endif
|
||||||
|
EchoReqFlag = (Command >> 7);
|
||||||
|
EchoAnsFlag = (Command >> 6) & 0x01;
|
||||||
|
StartFlag = (Command >> 5) & 0x01;
|
||||||
|
Count = xReceive_Buffer[COUNT] << 24;
|
||||||
|
Count += xReceive_Buffer[COUNT + 1] << 16;
|
||||||
|
Count += xReceive_Buffer[COUNT + 2] << 8;
|
||||||
|
Count += xReceive_Buffer[COUNT + 3];
|
||||||
|
|
||||||
|
Data = xReceive_Buffer[DATA] << 24;
|
||||||
|
Data += xReceive_Buffer[DATA + 1] << 16;
|
||||||
|
Data += xReceive_Buffer[DATA + 2] << 8;
|
||||||
|
Data += xReceive_Buffer[DATA + 3];
|
||||||
|
Data0 = xReceive_Buffer[DATA];
|
||||||
|
Data1 = xReceive_Buffer[DATA + 1];
|
||||||
|
Data2 = xReceive_Buffer[DATA + 2];
|
||||||
|
Data3 = xReceive_Buffer[DATA + 3];
|
||||||
|
Command = Command & 0b00011111;
|
||||||
|
|
||||||
|
if (EchoReqFlag == 1) {
|
||||||
|
memcpy(echoBuffer, xReceive_Buffer, 64);
|
||||||
|
}
|
||||||
|
switch (Command) {
|
||||||
|
case EnterDFU:
|
||||||
|
if (((DeviceState == BLidle) && (Data0 < numberOfDevices))
|
||||||
|
|| (DeviceState == DFUidle)) {
|
||||||
|
if (Data0 > 0)
|
||||||
|
OPDfuIni(true);
|
||||||
|
DeviceState = DFUidle;
|
||||||
|
currentProgrammingDestination = devicesTable[Data0].programmingType;
|
||||||
|
currentDeviceCanRead = devicesTable[Data0].readWriteFlags & 0x01;
|
||||||
|
currentDeviceCanWrite = devicesTable[Data0].readWriteFlags >> 1
|
||||||
|
& 0x01;
|
||||||
|
currentDevice = devicesTable[Data0];
|
||||||
|
uint8_t result = 0;
|
||||||
|
switch (currentProgrammingDestination) {
|
||||||
|
case Self_flash:
|
||||||
|
result = PIOS_BL_HELPER_FLASH_Ini();
|
||||||
|
break;
|
||||||
|
case Remote_flash_via_spi:
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
Aditionals = (uint16_t) Command;
|
||||||
|
}
|
||||||
|
if (result != 1) {
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Upload:
|
||||||
|
if ((DeviceState == DFUidle) || (DeviceState == uploading)) {
|
||||||
|
if ((StartFlag == 1) && (Next_Packet == 0)) {
|
||||||
|
TransferType = Data0;
|
||||||
|
SizeOfTransfer = Count;
|
||||||
|
Next_Packet = 1;
|
||||||
|
Expected_CRC = Data2 << 24;
|
||||||
|
Expected_CRC += Data3 << 16;
|
||||||
|
Expected_CRC += xReceive_Buffer[DATA + 4] << 8;
|
||||||
|
Expected_CRC += xReceive_Buffer[DATA + 5];
|
||||||
|
SizeOfLastPacket = Data1;
|
||||||
|
|
||||||
|
if (isBiggerThanAvailable(TransferType, (SizeOfTransfer - 1)
|
||||||
|
* 14 * 4 + SizeOfLastPacket * 4) == true) {
|
||||||
|
DeviceState = outsideDevCapabilities;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
} else {
|
||||||
|
uint8_t result = 1;
|
||||||
|
if (TransferType == FW) {
|
||||||
|
switch (currentProgrammingDestination) {
|
||||||
|
case Self_flash:
|
||||||
|
result = PIOS_BL_HELPER_FLASH_Start();
|
||||||
|
break;
|
||||||
|
case Remote_flash_via_spi:
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result != 1) {
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
DeviceState = uploading;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((StartFlag != 1) && (Next_Packet != 0)) {
|
||||||
|
if (Count > SizeOfTransfer) {
|
||||||
|
DeviceState = too_many_packets;
|
||||||
|
Aditionals = Count;
|
||||||
|
} else if (Count == Next_Packet - 1) {
|
||||||
|
uint8_t numberOfWords = 14;
|
||||||
|
if (Count == SizeOfTransfer - 1)//is this the last packet?
|
||||||
|
{
|
||||||
|
numberOfWords = SizeOfLastPacket;
|
||||||
|
}
|
||||||
|
uint8_t result = 0;
|
||||||
|
switch (currentProgrammingDestination) {
|
||||||
|
case Self_flash:
|
||||||
|
for (uint8_t x = 0; x < numberOfWords; ++x) {
|
||||||
|
offset = 4 * x;
|
||||||
|
Data = xReceive_Buffer[DATA + offset] << 24;
|
||||||
|
Data += xReceive_Buffer[DATA + 1 + offset] << 16;
|
||||||
|
Data += xReceive_Buffer[DATA + 2 + offset] << 8;
|
||||||
|
Data += xReceive_Buffer[DATA + 3 + offset];
|
||||||
|
aux = baseOfAdressType(TransferType) + (uint32_t)(
|
||||||
|
Count * 14 * 4 + x * 4);
|
||||||
|
result = 0;
|
||||||
|
for (int retry = 0; retry < MAX_WRI_RETRYS; ++retry) {
|
||||||
|
if (result == 0) {
|
||||||
|
result = (FLASH_ProgramWord(aux, Data)
|
||||||
|
== FLASH_COMPLETE) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Remote_flash_via_spi:
|
||||||
|
result = false; // No support for this for the PipX
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result != 1) {
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
}
|
||||||
|
|
||||||
|
++Next_Packet;
|
||||||
|
} else {
|
||||||
|
DeviceState = wrong_packet_received;
|
||||||
|
Aditionals = Count;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Req_Capabilities:
|
||||||
|
OPDfuIni(true);
|
||||||
|
Buffer[0] = 0x01;
|
||||||
|
Buffer[1] = Rep_Capabilities;
|
||||||
|
if (Data0 == 0) {
|
||||||
|
Buffer[2] = 0;
|
||||||
|
Buffer[3] = 0;
|
||||||
|
Buffer[4] = 0;
|
||||||
|
Buffer[5] = 0;
|
||||||
|
Buffer[6] = 0;
|
||||||
|
Buffer[7] = numberOfDevices;
|
||||||
|
uint16_t WRFlags = 0;
|
||||||
|
for (int x = 0; x < numberOfDevices; ++x) {
|
||||||
|
WRFlags = ((devicesTable[x].readWriteFlags << (x * 2))
|
||||||
|
| WRFlags);
|
||||||
|
}
|
||||||
|
Buffer[8] = WRFlags >> 8;
|
||||||
|
Buffer[9] = WRFlags;
|
||||||
|
} else {
|
||||||
|
Buffer[2] = devicesTable[Data0 - 1].sizeOfCode >> 24;
|
||||||
|
Buffer[3] = devicesTable[Data0 - 1].sizeOfCode >> 16;
|
||||||
|
Buffer[4] = devicesTable[Data0 - 1].sizeOfCode >> 8;
|
||||||
|
Buffer[5] = devicesTable[Data0 - 1].sizeOfCode;
|
||||||
|
Buffer[6] = Data0;
|
||||||
|
Buffer[7] = devicesTable[Data0 - 1].BL_Version;
|
||||||
|
Buffer[8] = devicesTable[Data0 - 1].sizeOfDescription;
|
||||||
|
Buffer[9] = devicesTable[Data0 - 1].devID;
|
||||||
|
Buffer[10] = devicesTable[Data0 - 1].FW_Crc >> 24;
|
||||||
|
Buffer[11] = devicesTable[Data0 - 1].FW_Crc >> 16;
|
||||||
|
Buffer[12] = devicesTable[Data0 - 1].FW_Crc >> 8;
|
||||||
|
Buffer[13] = devicesTable[Data0 - 1].FW_Crc;
|
||||||
|
Buffer[14] = devicesTable[Data0 - 1].devID >> 8;
|
||||||
|
Buffer[15] = devicesTable[Data0 - 1].devID;
|
||||||
|
}
|
||||||
|
sendData(Buffer + 1, 63);
|
||||||
|
break;
|
||||||
|
case JumpFW:
|
||||||
|
if (Data == 0x5AFE) {
|
||||||
|
/* Force board into safe mode */
|
||||||
|
PIOS_IAP_WriteBootCount(0xFFFF);
|
||||||
|
}
|
||||||
|
FLASH_Lock();
|
||||||
|
JumpToApp = 1;
|
||||||
|
break;
|
||||||
|
case Reset:
|
||||||
|
PIOS_SYS_Reset();
|
||||||
|
break;
|
||||||
|
case Abort_Operation:
|
||||||
|
Next_Packet = 0;
|
||||||
|
DeviceState = DFUidle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Op_END:
|
||||||
|
if (DeviceState == uploading) {
|
||||||
|
if (Next_Packet - 1 == SizeOfTransfer) {
|
||||||
|
Next_Packet = 0;
|
||||||
|
if ((TransferType != FW) || (Expected_CRC == CalcFirmCRC())) {
|
||||||
|
DeviceState = Last_operation_Success;
|
||||||
|
} else {
|
||||||
|
DeviceState = CRC_Fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Next_Packet - 1 < SizeOfTransfer) {
|
||||||
|
Next_Packet = 0;
|
||||||
|
DeviceState = too_few_packets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Download_Req:
|
||||||
|
#ifdef DEBUG_SSP
|
||||||
|
sprintf(str,"COMMAND:DOWNLOAD_REQ 1 Status=%d|",DeviceState);
|
||||||
|
PIOS_COM_SendString(PIOS_COM_TELEM_USB,str);
|
||||||
|
#endif
|
||||||
|
if (DeviceState == DFUidle) {
|
||||||
|
#ifdef DEBUG_SSP
|
||||||
|
PIOS_COM_SendString(PIOS_COM_TELEM_USB,"COMMAND:DOWNLOAD_REQ 1|");
|
||||||
|
#endif
|
||||||
|
downType = Data0;
|
||||||
|
downPacketTotal = Count;
|
||||||
|
downSizeOfLastPacket = Data1;
|
||||||
|
if (isBiggerThanAvailable(downType, (downPacketTotal - 1) * 14 * 4
|
||||||
|
+ downSizeOfLastPacket * 4) == 1) {
|
||||||
|
DeviceState = outsideDevCapabilities;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
downPacketCurrent = 0;
|
||||||
|
DeviceState = downloading;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DeviceState = Last_operation_failed;
|
||||||
|
Aditionals = (uint32_t) Command;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Status_Request:
|
||||||
|
Buffer[0] = 0x01;
|
||||||
|
Buffer[1] = Status_Rep;
|
||||||
|
if (DeviceState == wrong_packet_received) {
|
||||||
|
Buffer[2] = Aditionals >> 24;
|
||||||
|
Buffer[3] = Aditionals >> 16;
|
||||||
|
Buffer[4] = Aditionals >> 8;
|
||||||
|
Buffer[5] = Aditionals;
|
||||||
|
} else {
|
||||||
|
Buffer[2] = 0;
|
||||||
|
Buffer[3] = ((uint16_t) Aditionals) >> 8;
|
||||||
|
Buffer[4] = ((uint16_t) Aditionals);
|
||||||
|
Buffer[5] = 0;
|
||||||
|
}
|
||||||
|
Buffer[6] = DeviceState;
|
||||||
|
Buffer[7] = 0;
|
||||||
|
Buffer[8] = 0;
|
||||||
|
Buffer[9] = 0;
|
||||||
|
sendData(Buffer + 1, 63);
|
||||||
|
if (DeviceState == Last_operation_Success) {
|
||||||
|
DeviceState = DFUidle;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Status_Rep:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (EchoReqFlag == 1) {
|
||||||
|
echoBuffer[0] = echoBuffer[0] | (1 << 6);
|
||||||
|
sendData(echoBuffer, 63);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void OPDfuIni(uint8_t discover) {
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
Device dev;
|
||||||
|
|
||||||
|
dev.programmingType = Self_flash;
|
||||||
|
dev.readWriteFlags = (BOARD_READABLE | (BOARD_WRITABLE << 1));
|
||||||
|
dev.startOfUserCode = bdinfo->fw_base;
|
||||||
|
dev.sizeOfCode = bdinfo->fw_size;
|
||||||
|
dev.sizeOfDescription = bdinfo->desc_size;
|
||||||
|
dev.BL_Version = bdinfo->bl_rev;
|
||||||
|
dev.FW_Crc = CalcFirmCRC();
|
||||||
|
dev.devID = (bdinfo->board_type << 8) | (bdinfo->board_rev);
|
||||||
|
dev.devType = bdinfo->hw_type;
|
||||||
|
numberOfDevices = 1;
|
||||||
|
devicesTable[0] = dev;
|
||||||
|
if (discover) {
|
||||||
|
//TODO check other devices trough spi or whatever
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32_t baseOfAdressType(DFUTransfer type) {
|
||||||
|
switch (type) {
|
||||||
|
case FW:
|
||||||
|
return currentDevice.startOfUserCode;
|
||||||
|
break;
|
||||||
|
case Descript:
|
||||||
|
return currentDevice.startOfUserCode + currentDevice.sizeOfCode;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t isBiggerThanAvailable(DFUTransfer type, uint32_t size) {
|
||||||
|
switch (type) {
|
||||||
|
case FW:
|
||||||
|
return (size > currentDevice.sizeOfCode) ? 1 : 0;
|
||||||
|
break;
|
||||||
|
case Descript:
|
||||||
|
return (size > currentDevice.sizeOfDescription) ? 1 : 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CalcFirmCRC() {
|
||||||
|
switch (currentProgrammingDestination) {
|
||||||
|
case Self_flash:
|
||||||
|
return PIOS_BL_HELPER_CRC_Memory_Calc();
|
||||||
|
break;
|
||||||
|
case Remote_flash_via_spi:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void sendData(uint8_t * buf, uint16_t size) {
|
||||||
|
PIOS_COM_MSG_Send(PIOS_COM_TELEM_USB, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool flash_read(uint8_t * buffer, uint32_t adr, DFUProgType type) {
|
||||||
|
switch (type) {
|
||||||
|
case Remote_flash_via_spi:
|
||||||
|
return false; // We should not get this for the PipX
|
||||||
|
break;
|
||||||
|
case Self_flash:
|
||||||
|
for (uint8_t x = 0; x < 4; ++x) {
|
||||||
|
buffer[x] = *PIOS_BL_HELPER_FLASH_If_Read(adr + x);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
78
flight/Bootloaders/RevoMini/pios_board.c
Normal file
78
flight/Bootloaders/RevoMini/pios_board.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file pios_board.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Defines board specific static initializers for hardware for the AHRS board.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Pull in the board-specific static HW definitions.
|
||||||
|
* Including .c files is a bit ugly but this allows all of
|
||||||
|
* the HW definitions to be const and static to limit their
|
||||||
|
* scope.
|
||||||
|
*
|
||||||
|
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
|
||||||
|
*/
|
||||||
|
#include "board_hw_defs.c"
|
||||||
|
|
||||||
|
#include <pios_board_info.h>
|
||||||
|
#include <pios.h>
|
||||||
|
|
||||||
|
uint32_t pios_com_telem_usb_id;
|
||||||
|
|
||||||
|
static bool board_init_complete = false;
|
||||||
|
void PIOS_Board_Init() {
|
||||||
|
if (board_init_complete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delay system */
|
||||||
|
PIOS_DELAY_Init();
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_LED)
|
||||||
|
PIOS_LED_Init(&pios_led_cfg);
|
||||||
|
#endif /* PIOS_INCLUDE_LED */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB)
|
||||||
|
/* Initialize board specific USB data */
|
||||||
|
PIOS_USB_BOARD_DATA_Init();
|
||||||
|
|
||||||
|
/* Activate the HID-only USB configuration */
|
||||||
|
PIOS_USB_DESC_HID_ONLY_Init();
|
||||||
|
|
||||||
|
uint32_t pios_usb_id;
|
||||||
|
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
|
||||||
|
uint32_t pios_usb_hid_id;
|
||||||
|
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
|
||||||
|
|
||||||
|
PIOS_USBHOOK_Activate();
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_USB */
|
||||||
|
|
||||||
|
board_init_complete = true;
|
||||||
|
}
|
98
flight/Bootloaders/RevoMini/pios_usb_board_data.c
Normal file
98
flight/Bootloaders/RevoMini/pios_usb_board_data.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||||
|
* @{
|
||||||
|
* @addtogroup PIOS_USB_BOARD Board specific USB definitions
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_usb_board_data.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
|
||||||
|
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||||
|
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||||
|
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
|
||||||
|
|
||||||
|
static const uint8_t usb_product_id[22] = {
|
||||||
|
sizeof(usb_product_id),
|
||||||
|
USB_DESC_TYPE_STRING,
|
||||||
|
'R', 0,
|
||||||
|
'e', 0,
|
||||||
|
'v', 0,
|
||||||
|
'o', 0,
|
||||||
|
'l', 0,
|
||||||
|
'u', 0,
|
||||||
|
't', 0,
|
||||||
|
'i', 0,
|
||||||
|
'o', 0,
|
||||||
|
'n', 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
|
||||||
|
sizeof(usb_serial_number),
|
||||||
|
USB_DESC_TYPE_STRING,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct usb_string_langid usb_lang_id = {
|
||||||
|
.bLength = sizeof(usb_lang_id),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_STRING,
|
||||||
|
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t usb_vendor_id[28] = {
|
||||||
|
sizeof(usb_vendor_id),
|
||||||
|
USB_DESC_TYPE_STRING,
|
||||||
|
'o', 0,
|
||||||
|
'p', 0,
|
||||||
|
'e', 0,
|
||||||
|
'n', 0,
|
||||||
|
'p', 0,
|
||||||
|
'i', 0,
|
||||||
|
'l', 0,
|
||||||
|
'o', 0,
|
||||||
|
't', 0,
|
||||||
|
'.', 0,
|
||||||
|
'o', 0,
|
||||||
|
'r', 0,
|
||||||
|
'g', 0
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||||
|
{
|
||||||
|
/* Load device serial number into serial number string */
|
||||||
|
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
|
||||||
|
PIOS_SYS_SerialNumberGet((char *)sn);
|
||||||
|
|
||||||
|
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
|
||||||
|
uint8_t * utf8 = &(usb_serial_number[2]);
|
||||||
|
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
|
||||||
|
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
|
||||||
|
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
|
||||||
|
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
495
flight/RevoMini/Makefile
Normal file
495
flight/RevoMini/Makefile
Normal file
@ -0,0 +1,495 @@
|
|||||||
|
#####
|
||||||
|
# Project: OpenPilot INS
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Makefile for OpenPilot INS project
|
||||||
|
#
|
||||||
|
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#####
|
||||||
|
|
||||||
|
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
|
TOP := $(realpath $(WHEREAMI)/../../)
|
||||||
|
include $(TOP)/make/firmware-defs.mk
|
||||||
|
include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET := fw_$(BOARD_NAME)
|
||||||
|
|
||||||
|
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
|
||||||
|
OUTDIR := $(TOP)/build/$(TARGET)
|
||||||
|
|
||||||
|
# Set developer code and compile options
|
||||||
|
# Set to YES for debugging
|
||||||
|
DEBUG ?= NO
|
||||||
|
|
||||||
|
# Set to YES when using Code Sourcery toolchain
|
||||||
|
CODE_SOURCERY ?= NO
|
||||||
|
|
||||||
|
ifeq ($(CODE_SOURCERY), YES)
|
||||||
|
REMOVE_CMD = cs-rm
|
||||||
|
else
|
||||||
|
REMOVE_CMD = rm
|
||||||
|
endif
|
||||||
|
|
||||||
|
FLASH_TOOL = OPENOCD
|
||||||
|
|
||||||
|
# List of modules to include
|
||||||
|
MODULES = Sensors Attitude/revolution ManualControl Stabilization Actuator
|
||||||
|
MODULES += Battery
|
||||||
|
MODULES += Altitude/revolution GPS FirmwareIAP
|
||||||
|
MODULES += Airspeed/revolution
|
||||||
|
MODULES += AltitudeHold VtolPathFollower FixedWingPathFollower PathPlanner
|
||||||
|
MODULES += CameraStab
|
||||||
|
MODULES += OveroSync
|
||||||
|
MODULES += Telemetry
|
||||||
|
PYMODULES =
|
||||||
|
#FlightPlan
|
||||||
|
|
||||||
|
# Paths
|
||||||
|
OPSYSTEM = ./System
|
||||||
|
OPSYSTEMINC = $(OPSYSTEM)/inc
|
||||||
|
OPUAVTALK = ../UAVTalk
|
||||||
|
OPUAVTALKINC = $(OPUAVTALK)/inc
|
||||||
|
OPUAVOBJ = ../UAVObjects
|
||||||
|
OPUAVOBJINC = $(OPUAVOBJ)/inc
|
||||||
|
PIOS = ../PiOS
|
||||||
|
PIOSINC = $(PIOS)/inc
|
||||||
|
OPMODULEDIR = ../Modules
|
||||||
|
FLIGHTLIB = ../Libraries
|
||||||
|
FLIGHTLIBINC = ../Libraries/inc
|
||||||
|
PIOSSTM32F4XX = $(PIOS)/STM32F4xx
|
||||||
|
PIOSCOMMON = $(PIOS)/Common
|
||||||
|
PIOSBOARDS = $(PIOS)/Boards
|
||||||
|
PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries
|
||||||
|
APPLIBDIR = $(PIOSSTM32F4XX)/Libraries
|
||||||
|
STMLIBDIR = $(APPLIBDIR)
|
||||||
|
STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver
|
||||||
|
STMSPDSRCDIR = $(STMSPDDIR)/src
|
||||||
|
STMSPDINCDIR = $(STMSPDDIR)/inc
|
||||||
|
OPUAVOBJ = ../UAVObjects
|
||||||
|
OPUAVOBJINC = $(OPUAVOBJ)/inc
|
||||||
|
BOOT = ../Bootloaders/INS
|
||||||
|
BOOTINC = $(BOOT)/inc
|
||||||
|
PYMITE = $(FLIGHTLIB)/PyMite
|
||||||
|
PYMITELIB = $(PYMITE)/lib
|
||||||
|
PYMITEPLAT = $(PYMITE)/platform/openpilot
|
||||||
|
PYMITETOOLS = $(PYMITE)/tools
|
||||||
|
PYMITEVM = $(PYMITE)/vm
|
||||||
|
PYMITEINC = $(PYMITEVM)
|
||||||
|
PYMITEINC += $(PYMITEPLAT)
|
||||||
|
PYMITEINC += $(OUTDIR)
|
||||||
|
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
||||||
|
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
||||||
|
HWDEFSINC = ../board_hw_defs/$(BOARD_NAME)
|
||||||
|
UAVOBJSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
||||||
|
|
||||||
|
SRC =
|
||||||
|
# optional component libraries
|
||||||
|
include $(PIOSCOMMONLIB)/FreeRTOS/library.mk
|
||||||
|
#include $(PIOSCOMMONLIB)/dosfs/library.mk
|
||||||
|
include $(PIOSCOMMONLIB)/msheap/library.mk
|
||||||
|
|
||||||
|
|
||||||
|
# List C source files here. (C dependencies are automatically generated.)
|
||||||
|
# use file-extension c for "c-only"-files
|
||||||
|
|
||||||
|
## PyMite files and modules
|
||||||
|
SRC += $(OUTDIR)/pmlib_img.c
|
||||||
|
SRC += $(OUTDIR)/pmlib_nat.c
|
||||||
|
SRC += $(OUTDIR)/pmlibusr_img.c
|
||||||
|
SRC += $(OUTDIR)/pmlibusr_nat.c
|
||||||
|
PYSRC += $(wildcard ${PYMITEVM}/*.c)
|
||||||
|
PYSRC += $(wildcard ${PYMITEPLAT}/*.c)
|
||||||
|
PYSRC += ${foreach MOD, ${PYMODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}}
|
||||||
|
SRC += $(PYSRC)
|
||||||
|
|
||||||
|
## MODULES
|
||||||
|
SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}}
|
||||||
|
## OPENPILOT CORE:
|
||||||
|
SRC += ${OPMODULEDIR}/System/systemmod.c
|
||||||
|
SRC += $(OPSYSTEM)/revolution.c
|
||||||
|
SRC += $(OPSYSTEM)/pios_board.c
|
||||||
|
SRC += $(OPSYSTEM)/pios_usb_board_data.c
|
||||||
|
SRC += $(OPSYSTEM)/alarms.c
|
||||||
|
SRC += $(OPUAVTALK)/uavtalk.c
|
||||||
|
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
||||||
|
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
||||||
|
|
||||||
|
#ifeq ($(DEBUG),YES)
|
||||||
|
SRC += $(OPSYSTEM)/dcc_stdio.c
|
||||||
|
SRC += $(OPSYSTEM)/cm3_fault_handlers.c
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SRC += $(FLIGHTLIB)/CoordinateConversions.c
|
||||||
|
SRC += $(FLIGHTLIB)/paths.c
|
||||||
|
SRC += $(FLIGHTLIB)/fifo_buffer.c
|
||||||
|
SRC += $(FLIGHTLIB)/WorldMagModel.c
|
||||||
|
SRC += $(FLIGHTLIB)/insgps13state.c
|
||||||
|
SRC += $(FLIGHTLIB)/taskmonitor.c
|
||||||
|
|
||||||
|
## PIOS Hardware (STM32F4xx)
|
||||||
|
include $(PIOS)/STM32F4xx/library.mk
|
||||||
|
|
||||||
|
## PIOS Hardware (Common)
|
||||||
|
SRC += $(PIOSCOMMON)/pios_mpu6000.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_bma180.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_etasv3.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_gcsrcvr.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_l3gd20.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_hmc5883.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_ms5611.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_crc.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_com.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_rcvr.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_flash_jedec.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c
|
||||||
|
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
|
||||||
|
SRC += $(PIOSCOMMON)/pios_usb_util.c
|
||||||
|
|
||||||
|
include ./UAVObjects.inc
|
||||||
|
SRC += $(UAVOBJSRC)
|
||||||
|
|
||||||
|
# List C source files here which must be compiled in ARM-Mode (no -mthumb).
|
||||||
|
# use file-extension c for "c-only"-files
|
||||||
|
## just for testing, timer.c could be compiled in thumb-mode too
|
||||||
|
SRCARM =
|
||||||
|
|
||||||
|
# List C++ source files here.
|
||||||
|
# use file-extension .cpp for C++-files (not .C)
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# List C++ source files here which must be compiled in ARM-Mode.
|
||||||
|
# use file-extension .cpp for C++-files (not .C)
|
||||||
|
#CPPSRCARM = $(TARGET).cpp
|
||||||
|
CPPSRCARM =
|
||||||
|
|
||||||
|
# List Assembler source files here.
|
||||||
|
# Make them always end in a capital .S. Files ending in a lowercase .s
|
||||||
|
# will not be considered source files but generated files (assembler
|
||||||
|
# output from the compiler), and will be deleted upon "make clean"!
|
||||||
|
# Even though the DOS/Win* filesystem matches both .s and .S the same,
|
||||||
|
# it will preserve the spelling of the filenames, and gcc itself does
|
||||||
|
# care about how the name is spelled on its command-line.
|
||||||
|
|
||||||
|
|
||||||
|
# List Assembler source files here which must be assembled in ARM-Mode..
|
||||||
|
ASRCARM =
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS += $(PIOS)
|
||||||
|
EXTRAINCDIRS += $(PIOSINC)
|
||||||
|
EXTRAINCDIRS += $(OPSYSTEMINC)
|
||||||
|
EXTRAINCDIRS += $(OPUAVTALK)
|
||||||
|
EXTRAINCDIRS += $(OPUAVTALKINC)
|
||||||
|
EXTRAINCDIRS += $(OPUAVOBJ)
|
||||||
|
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||||
|
EXTRAINCDIRS += $(UAVOBJSYNTHDIR)
|
||||||
|
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
||||||
|
EXTRAINCDIRS += $(PIOSSTM32F4XX)
|
||||||
|
EXTRAINCDIRS += $(PIOSCOMMON)
|
||||||
|
EXTRAINCDIRS += $(PIOSBOARDS)
|
||||||
|
EXTRAINCDIRS += $(STMSPDINCDIR)
|
||||||
|
EXTRAINCDIRS += $(CMSISDIR)
|
||||||
|
EXTRAINCDIRS += $(OPUAVSYNTHDIR)
|
||||||
|
EXTRAINCDIRS += $(BOOTINC)
|
||||||
|
EXTRAINCDIRS += $(PYMITEINC)
|
||||||
|
EXTRAINCDIRS += $(HWDEFSINC)
|
||||||
|
|
||||||
|
# Generate intermediate code
|
||||||
|
gencode: ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h
|
||||||
|
|
||||||
|
$(PYSRC): gencode
|
||||||
|
|
||||||
|
PYTHON = python
|
||||||
|
|
||||||
|
# Generate code for PyMite
|
||||||
|
${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h: $(wildcard ${PYMITELIB}/*.py) $(wildcard ${PYMITEPLAT}/*.py) $(wildcard ${FLIGHTPLANLIB}/*.py) $(wildcard ${FLIGHTPLANS}/*.py)
|
||||||
|
@echo $(MSG_PYMITEINIT) $(call toprel, $@)
|
||||||
|
@$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py)
|
||||||
|
@$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h
|
||||||
|
@$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py
|
||||||
|
EXTRAINCDIRS += ${foreach MOD, ${MODULES} ${PYMODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc
|
||||||
|
|
||||||
|
# List any extra directories to look for library files here.
|
||||||
|
# Also add directories where the linker should search for
|
||||||
|
# includes from linker-script to the list
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRA_LIBDIRS =
|
||||||
|
|
||||||
|
# Extra Libraries
|
||||||
|
# Each library-name must be seperated by a space.
|
||||||
|
# i.e. to link with libxyz.a, libabc.a and libefsl.a:
|
||||||
|
# EXTRA_LIBS = xyz abc efsl
|
||||||
|
# for newlib-lpc (file: libnewlibc-lpc.a):
|
||||||
|
# EXTRA_LIBS = newlib-lpc
|
||||||
|
EXTRA_LIBS =
|
||||||
|
|
||||||
|
# Path to Linker-Scripts
|
||||||
|
LINKERSCRIPTPATH = $(PIOSSTM32F4XX)
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),YES)
|
||||||
|
CFLAGS += -O0
|
||||||
|
CFLAGS += -DGENERAL_COV
|
||||||
|
CFLAGS += -finstrument-functions -ffixed-r10
|
||||||
|
else
|
||||||
|
CFLAGS += -Os
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# common architecture-specific flags from the device-specific library makefile
|
||||||
|
CFLAGS += $(ARCHFLAGS)
|
||||||
|
|
||||||
|
CFLAGS += -DDIAGNOSTICS
|
||||||
|
CFLAGS += -DDIAG_TASKS
|
||||||
|
|
||||||
|
# This is not the best place for these. Really should abstract out
|
||||||
|
# to the board file or something
|
||||||
|
CFLAGS += -DSTM32F4XX
|
||||||
|
CFLAGS += -DMEM_SIZE=1024000000
|
||||||
|
|
||||||
|
# Output format. (can be ihex or binary or both)
|
||||||
|
# binary to create a load-image in raw-binary format i.e. for SAM-BA,
|
||||||
|
# ihex to create a load-image in Intel hex format
|
||||||
|
#LOADFORMAT = ihex
|
||||||
|
#LOADFORMAT = binary
|
||||||
|
LOADFORMAT = both
|
||||||
|
|
||||||
|
# Debugging format.
|
||||||
|
DEBUGF = dwarf-2
|
||||||
|
|
||||||
|
# Place project-specific -D (define) and/or
|
||||||
|
# -U options for C here.
|
||||||
|
CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ)
|
||||||
|
CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ)
|
||||||
|
CDEFS += -DUSE_STDPERIPH_DRIVER
|
||||||
|
CDEFS += -DUSE_$(BOARD)
|
||||||
|
|
||||||
|
# Place project-specific -D and/or -U options for
|
||||||
|
# Assembler with preprocessor here.
|
||||||
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
|
ADEFS = -D__ASSEMBLY__
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
#-----
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
|
||||||
|
# -g*: generate debugging information
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
#
|
||||||
|
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
|
||||||
|
|
||||||
|
CFLAGS += -g$(DEBUGF)
|
||||||
|
|
||||||
|
CFLAGS += -ffast-math
|
||||||
|
|
||||||
|
CFLAGS += -mcpu=$(MCU)
|
||||||
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
|
CFLAGS += -mapcs-frame
|
||||||
|
CFLAGS += -fomit-frame-pointer
|
||||||
|
ifeq ($(CODE_SOURCERY), YES)
|
||||||
|
CFLAGS += -fpromote-loop-indices
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -Wall
|
||||||
|
#CFLAGS += -Werror
|
||||||
|
CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
|
# Compiler flags to generate dependency files:
|
||||||
|
CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d
|
||||||
|
|
||||||
|
# flags only for C
|
||||||
|
#CONLYFLAGS += -Wnested-externs
|
||||||
|
CONLYFLAGS += $(CSTANDARD)
|
||||||
|
|
||||||
|
# Assembler flags.
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -ahlns: create listing
|
||||||
|
ASFLAGS = $(ARCHFLAGS) -mthumb -I. -x assembler-with-cpp
|
||||||
|
ASFLAGS += $(ADEFS)
|
||||||
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
|
||||||
|
MATH_LIB = -lm
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections
|
||||||
|
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
|
||||||
|
LDFLAGS += -lc
|
||||||
|
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
|
||||||
|
LDFLAGS += $(MATH_LIB)
|
||||||
|
LDFLAGS += -lc -lgcc
|
||||||
|
|
||||||
|
#Linker scripts
|
||||||
|
LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_APP))
|
||||||
|
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
REMOVE = $(REMOVE_CMD) -f
|
||||||
|
PYHON = python
|
||||||
|
|
||||||
|
# List of all source files.
|
||||||
|
ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC)
|
||||||
|
# List of all source files without directory and file-extension.
|
||||||
|
ALLSRCBASE = $(notdir $(basename $(ALLSRC)))
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
|
||||||
|
|
||||||
|
# Define all listing files (used for make clean).
|
||||||
|
LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE)))
|
||||||
|
# Define all depedency-files (used for make clean).
|
||||||
|
DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE)))
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: gccversion build
|
||||||
|
|
||||||
|
ifeq ($(LOADFORMAT),ihex)
|
||||||
|
build: elf hex lss sym
|
||||||
|
else
|
||||||
|
ifeq ($(LOADFORMAT),binary)
|
||||||
|
build: elf bin lss sym
|
||||||
|
else
|
||||||
|
ifeq ($(LOADFORMAT),both)
|
||||||
|
build: elf hex bin lss sym
|
||||||
|
else
|
||||||
|
$(error "$(MSG_FORMATERROR) $(FORMAT)")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ)))
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files. ARM-only
|
||||||
|
$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C source files. ARM-only
|
||||||
|
$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C++ source files.
|
||||||
|
$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C++ source files. ARM-only
|
||||||
|
$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files. ARM/Thumb
|
||||||
|
$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC))
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files. ARM only
|
||||||
|
$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM))
|
||||||
|
|
||||||
|
$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
|
||||||
|
|
||||||
|
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
|
||||||
|
|
||||||
|
# Add jtag targets (program and wipe)
|
||||||
|
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG)))
|
||||||
|
|
||||||
|
.PHONY: elf lss sym hex bin bino opfw
|
||||||
|
elf: $(OUTDIR)/$(TARGET).elf
|
||||||
|
lss: $(OUTDIR)/$(TARGET).lss
|
||||||
|
sym: $(OUTDIR)/$(TARGET).sym
|
||||||
|
hex: $(OUTDIR)/$(TARGET).hex
|
||||||
|
bin: $(OUTDIR)/$(TARGET).bin
|
||||||
|
bino: $(OUTDIR)/$(TARGET).bin.o
|
||||||
|
opfw: $(OUTDIR)/$(TARGET).opfw
|
||||||
|
|
||||||
|
# Display sizes of sections.
|
||||||
|
$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf))
|
||||||
|
|
||||||
|
# Generate Doxygen documents
|
||||||
|
docs:
|
||||||
|
doxygen $(DOXYGENDIR)/doxygen.cfg
|
||||||
|
|
||||||
|
# Install: install binary file with prefix/suffix into install directory
|
||||||
|
install: $(OUTDIR)/$(TARGET).opfw
|
||||||
|
ifneq ($(INSTALL_DIR),)
|
||||||
|
@echo $(MSG_INSTALLING) $(call toprel, $<)
|
||||||
|
$(V1) mkdir -p $(INSTALL_DIR)
|
||||||
|
$(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw
|
||||||
|
else
|
||||||
|
$(error INSTALL_DIR must be specified for $@)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: clean_list
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss
|
||||||
|
$(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o
|
||||||
|
$(V1) $(REMOVE) $(ALLOBJ)
|
||||||
|
$(V1) $(REMOVE) $(LSTFILES)
|
||||||
|
$(V1) $(REMOVE) $(DEPFILES)
|
||||||
|
$(V1) $(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(V1) $(REMOVE) $(SRCARM:.c=.s)
|
||||||
|
$(V1) $(REMOVE) $(CPPSRC:.cpp=.s)
|
||||||
|
$(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s)
|
||||||
|
|
||||||
|
# Create output files directory
|
||||||
|
# all known MS Windows OS define the ComSpec environment variable
|
||||||
|
ifdef ComSpec
|
||||||
|
$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL)
|
||||||
|
else
|
||||||
|
$(shell mkdir -p $(OUTDIR) 2>/dev/null)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
ifdef ComSpec
|
||||||
|
-include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*)
|
||||||
|
else
|
||||||
|
-include $(shell mkdir $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all build clean clean_list install
|
669
flight/RevoMini/Makefile.osx
Normal file
669
flight/RevoMini/Makefile.osx
Normal file
@ -0,0 +1,669 @@
|
|||||||
|
#####
|
||||||
|
# Project: RevoMini
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Makefile for OpenPilot project build PiOS and the AP.
|
||||||
|
#
|
||||||
|
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2012.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#####
|
||||||
|
|
||||||
|
|
||||||
|
# Set developer code and compile options
|
||||||
|
# Set to YES to compile for debugging
|
||||||
|
DEBUG ?= YES
|
||||||
|
|
||||||
|
# Set to YES to use the Servo output pins for debugging via scope or logic analyser
|
||||||
|
ENABLE_DEBUG_PINS ?= NO
|
||||||
|
|
||||||
|
# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs
|
||||||
|
ENABLE_AUX_UART ?= NO
|
||||||
|
|
||||||
|
#
|
||||||
|
USE_BOOTLOADER ?= NO
|
||||||
|
|
||||||
|
|
||||||
|
# Set to YES when using Code Sourcery toolchain
|
||||||
|
CODE_SOURCERY ?= NO
|
||||||
|
|
||||||
|
# Remove command is different for Code Sourcery on Windows
|
||||||
|
REMOVE_CMD ?= rm
|
||||||
|
|
||||||
|
FLASH_TOOL = OPENOCD
|
||||||
|
|
||||||
|
# YES enables -mthumb option to flags for source-files listed
|
||||||
|
# in SRC and CPPSRC
|
||||||
|
USE_THUMB_MODE = YES
|
||||||
|
|
||||||
|
# List of modules to include
|
||||||
|
MODULES += Actuator ManualControl Stabilization
|
||||||
|
MODULES += AltitudeHold VtolPathFollower FixedWingPathFollower PathPlanner
|
||||||
|
MODULES += Attitude/revolution
|
||||||
|
#MODULES += OveroSync/simulated
|
||||||
|
|
||||||
|
# To run simulation instead of connect to SITL
|
||||||
|
MODULES += Sensors/simulated
|
||||||
|
|
||||||
|
MODULES += Telemetry
|
||||||
|
|
||||||
|
# MCU name, submodel and board
|
||||||
|
# - MCU used for compiler-option (-mtune)
|
||||||
|
# - MODEL used for linker-script name (-T) and passed as define
|
||||||
|
# - BOARD just passed as define (optional)
|
||||||
|
MCU = i686
|
||||||
|
#CHIP = STM32F103RET
|
||||||
|
#BOARD = STM3210E_OP
|
||||||
|
MODEL = HD
|
||||||
|
ifeq ($(USE_BOOTLOADER), YES)
|
||||||
|
BOOT_MODEL = $(MODEL)_BL
|
||||||
|
|
||||||
|
else
|
||||||
|
BOOT_MODEL = $(MODEL)_NB
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
|
||||||
|
OUTDIR = ../../build/sim_osx
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = RevoMini
|
||||||
|
|
||||||
|
# Paths
|
||||||
|
OPSYSTEM = ./System
|
||||||
|
OPSYSTEMINC = $(OPSYSTEM)/inc
|
||||||
|
OPUAVTALK = ../UAVTalk
|
||||||
|
OPUAVTALKINC = $(OPUAVTALK)/inc
|
||||||
|
OPUAVOBJ = ../UAVObjects
|
||||||
|
OPUAVOBJINC = $(OPUAVOBJ)/inc
|
||||||
|
OPTESTS = ./Tests
|
||||||
|
OPMODULEDIR = ../Modules
|
||||||
|
FLIGHTLIB = ../Libraries
|
||||||
|
FLIGHTLIBINC = $(FLIGHTLIB)/inc
|
||||||
|
PIOS = ../PiOS.osx
|
||||||
|
PIOSINC = $(PIOS)/inc
|
||||||
|
PIOSPOSIX = $(PIOS)/osx
|
||||||
|
APPLIBDIR = $(PIOSPOSIX)/Libraries
|
||||||
|
RTOSDIR = $(APPLIBDIR)/FreeRTOS
|
||||||
|
RTOSSRCDIR = $(RTOSDIR)/Source
|
||||||
|
RTOSINCDIR = $(RTOSSRCDIR)/include
|
||||||
|
DOXYGENDIR = ../Doc/Doxygen
|
||||||
|
PYMITE = $(FLIGHTLIB)/PyMite
|
||||||
|
PYMITELIB = $(PYMITE)/lib
|
||||||
|
PYMITEPLAT = $(PYMITE)/platform/openpilot_sitl
|
||||||
|
PYMITETOOLS = $(PYMITE)/tools
|
||||||
|
PYMITEVM = $(PYMITE)/vm
|
||||||
|
PYMITEINC = $(PYMITEVM)
|
||||||
|
PYMITEINC += $(PYMITEPLAT)
|
||||||
|
PYMITEINC += $(OUTDIR)
|
||||||
|
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
||||||
|
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
||||||
|
|
||||||
|
UAVOBJSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
||||||
|
UAVOBJPYTHONSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/python
|
||||||
|
|
||||||
|
# List C source files here. (C dependencies are automatically generated.)
|
||||||
|
# use file-extension c for "c-only"-files
|
||||||
|
|
||||||
|
MODNAMES = $(notdir ${MODULES})
|
||||||
|
|
||||||
|
ifndef TESTAPP
|
||||||
|
|
||||||
|
## PyMite files
|
||||||
|
SRC += $(OUTDIR)/pmlib_img.c
|
||||||
|
SRC += $(OUTDIR)/pmlib_nat.c
|
||||||
|
SRC += $(OUTDIR)/pmlibusr_img.c
|
||||||
|
SRC += $(OUTDIR)/pmlibusr_nat.c
|
||||||
|
SRC += $(wildcard ${PYMITEVM}/*.c)
|
||||||
|
SRC += $(wildcard ${PYMITEPLAT}/*.c)
|
||||||
|
|
||||||
|
## MODULES
|
||||||
|
SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}}
|
||||||
|
SRC += ${OUTDIR}/InitMods.c
|
||||||
|
## OPENPILOT CORE:
|
||||||
|
SRC += ${OPMODULEDIR}/System/systemmod.c
|
||||||
|
SRC += $(OPSYSTEM)/revolution.c
|
||||||
|
SRC += $(OPSYSTEM)/pios_board_sim.c
|
||||||
|
SRC += $(OPSYSTEM)/alarms.c
|
||||||
|
SRC += $(OPUAVTALK)/uavtalk.c
|
||||||
|
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
||||||
|
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
||||||
|
SRC += $(UAVOBJSYNTHDIR)/uavobjectsinit.c
|
||||||
|
else
|
||||||
|
## TESTCODE
|
||||||
|
SRC += $(OPTESTS)/test_common.c
|
||||||
|
SRC += $(OPTESTS)/$(TESTAPP).c
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## UAVOBJECTS
|
||||||
|
ifndef TESTAPP
|
||||||
|
#include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||||
|
include ./UAVObjects.inc
|
||||||
|
|
||||||
|
UAVOBJSRCFILENAMES += attitudesimulated
|
||||||
|
UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(UAVOBJSYNTHDIR)/$(UAVOBJSRCFILE).c )
|
||||||
|
UAVOBJDEFINE = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),-DUAVOBJ_INIT_$(UAVOBJSRCFILE) )
|
||||||
|
|
||||||
|
SRC += $(UAVOBJSRC)
|
||||||
|
CFLAGS_UAVOBJECTS = $(UAVOBJDEFINE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
## PIOS Hardware (posix)
|
||||||
|
SRC += $(PIOSPOSIX)/pios_crc.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_sys.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_led.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_irq.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_delay.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_sdcard.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_udp.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_tcp.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_com.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_servo.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_wdg.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_debug.c
|
||||||
|
|
||||||
|
SRC += $(PIOSPOSIX)/pios_rcvr.c
|
||||||
|
SRC += $(PIOSPOSIX)/pios_gcsrcvr.c
|
||||||
|
|
||||||
|
## Libraries for flight calculations
|
||||||
|
SRC += $(FLIGHTLIB)/fifo_buffer.c
|
||||||
|
SRC += $(FLIGHTLIB)/WorldMagModel.c
|
||||||
|
SRC += $(FLIGHTLIB)/CoordinateConversions.c
|
||||||
|
SRC += $(FLIGHTLIB)/paths.c
|
||||||
|
SRC += $(FLIGHTLIB)/insgps13state.c
|
||||||
|
SRC += $(FLIGHTLIB)/taskmonitor.c
|
||||||
|
|
||||||
|
## RTOS and RTOS Portable
|
||||||
|
SRC += $(RTOSSRCDIR)/list.c
|
||||||
|
SRC += $(RTOSSRCDIR)/queue.c
|
||||||
|
UNAME := $(shell uname)
|
||||||
|
SRC += $(RTOSSRCDIR)/task.c
|
||||||
|
SRC += $(RTOSSRCDIR)/timers.c
|
||||||
|
SRC += $(RTOSSRCDIR)/portable/GCC/Posix/port.c
|
||||||
|
SRC += $(RTOSSRCDIR)/portable/MemMang/heap_3.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# List C source files here which must be compiled in ARM-Mode (no -mthumb).
|
||||||
|
# use file-extension c for "c-only"-files
|
||||||
|
## just for testing, timer.c could be compiled in thumb-mode too
|
||||||
|
SRCARM =
|
||||||
|
|
||||||
|
# List C++ source files here.
|
||||||
|
# use file-extension .cpp for C++-files (not .C)
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# List C++ source files here which must be compiled in ARM-Mode.
|
||||||
|
# use file-extension .cpp for C++-files (not .C)
|
||||||
|
#CPPSRCARM = $(TARGET).cpp
|
||||||
|
CPPSRCARM =
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS = $(OPSYSTEM)
|
||||||
|
EXTRAINCDIRS += $(OPSYSTEMINC)
|
||||||
|
EXTRAINCDIRS += $(OPUAVTALK)
|
||||||
|
EXTRAINCDIRS += $(OPUAVTALKINC)
|
||||||
|
EXTRAINCDIRS += $(OPUAVOBJ)
|
||||||
|
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||||
|
EXTRAINCDIRS += $(UAVOBJSYNTHDIR)
|
||||||
|
EXTRAINCDIRS += $(PIOS)
|
||||||
|
EXTRAINCDIRS += $(PIOSINC)
|
||||||
|
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
||||||
|
EXTRAINCDIRS += $(PIOSPOSIX)
|
||||||
|
EXTRAINCDIRS += $(RTOSINCDIR)
|
||||||
|
EXTRAINCDIRS += $(APPLIBDIR)
|
||||||
|
EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/Posix
|
||||||
|
EXTRAINCDIRS += $(PYMITEINC)
|
||||||
|
|
||||||
|
EXTRAINCDIRS += ${foreach MOD, ${MODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for library files here.
|
||||||
|
# Also add directories where the linker should search for
|
||||||
|
# includes from linker-script to the list
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRA_LIBDIRS =
|
||||||
|
|
||||||
|
# Extra Libraries
|
||||||
|
# Each library-name must be seperated by a space.
|
||||||
|
# i.e. to link with libxyz.a, libabc.a and libefsl.a:
|
||||||
|
# EXTRA_LIBS = xyz abc efsl
|
||||||
|
# for newlib-lpc (file: libnewlibc-lpc.a):
|
||||||
|
# EXTRA_LIBS = newlib-lpc
|
||||||
|
EXTRA_LIBS =
|
||||||
|
|
||||||
|
# Path to Linker-Scripts
|
||||||
|
LINKERSCRIPTPATH = $(PIOSSTM32F10X)
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),YES)
|
||||||
|
OPT = 0
|
||||||
|
else
|
||||||
|
OPT = s
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Output format. (can be ihex or binary or both)
|
||||||
|
# binary to create a load-image in raw-binary format i.e. for SAM-BA,
|
||||||
|
# ihex to create a load-image in Intel hex format
|
||||||
|
#LOADFORMAT = ihex
|
||||||
|
#LOADFORMAT = binary
|
||||||
|
LOADFORMAT = both
|
||||||
|
|
||||||
|
# Debugging format.
|
||||||
|
#DEBUGF = dwarf-2
|
||||||
|
|
||||||
|
# Place project-specific -D (define) and/or
|
||||||
|
# -U options for C here.
|
||||||
|
ifeq ($(ENABLE_DEBUG_PINS), YES)
|
||||||
|
CDEFS += -DPIOS_ENABLE_DEBUG_PINS
|
||||||
|
endif
|
||||||
|
ifeq ($(ENABLE_AUX_UART), YES)
|
||||||
|
CDEFS += -DPIOS_ENABLE_AUX_UART
|
||||||
|
endif
|
||||||
|
ifeq ($(USE_BOOTLOADER), YES)
|
||||||
|
CDEFS += -DUSE_BOOTLOADER
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
#-----
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
|
||||||
|
# -g*: generate debugging information
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
#
|
||||||
|
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),YES)
|
||||||
|
CFLAGS = -g$(DEBUGF) -DDEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -DDIAGNOSTICS
|
||||||
|
CFLAGS += -DDIAG_TASKS
|
||||||
|
|
||||||
|
CFLAGS += $(CFLAGS_UAVOBJECTS)
|
||||||
|
CFLAGS += -DARCH_POSIX
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
CFLAGS += -mtune=$(MCU)
|
||||||
|
CFLAGS += $(CDEFS)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
|
|
||||||
|
#CFLAGS += ARCH=arm
|
||||||
|
#CROSS_COMPILE=/usr/local/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-
|
||||||
|
|
||||||
|
CFLAGS += -fomit-frame-pointer
|
||||||
|
ifeq ($(CODE_SOURCERY), YES)
|
||||||
|
CFLAGS += -fpromote-loop-indices
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -Wall
|
||||||
|
CFLAGS += -Werror
|
||||||
|
# Compiler flags to generate dependency files:
|
||||||
|
CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d
|
||||||
|
|
||||||
|
# flags only for C
|
||||||
|
#CONLYFLAGS += -Wnested-externs
|
||||||
|
CONLYFLAGS += $(CSTANDARD)
|
||||||
|
|
||||||
|
# Assembler flags.
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -ahlns: create listing
|
||||||
|
ASFLAGS = -mtune=$(MCU) -I. -x assembler-with-cpp
|
||||||
|
ASFLAGS += $(ADEFS)
|
||||||
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
|
||||||
|
MATH_LIB = -lm
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS += -lpthread
|
||||||
|
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
|
||||||
|
LDFLAGS += -lc
|
||||||
|
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
|
||||||
|
LDFLAGS += $(MATH_LIB)
|
||||||
|
LDFLAGS += -lc -lgcc
|
||||||
|
|
||||||
|
# To include simulation model
|
||||||
|
LDFLAGS += -L$(OUTDIR)
|
||||||
|
#LDFLAGS += -lsimmodel
|
||||||
|
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
CC = $(TCHAIN_PREFIX)gcc
|
||||||
|
CPP = $(TCHAIN_PREFIX)g++
|
||||||
|
AR = $(TCHAIN_PREFIX)ar
|
||||||
|
OBJCOPY = $(TCHAIN_PREFIX)objcopy
|
||||||
|
OBJDUMP = $(TCHAIN_PREFIX)objdump
|
||||||
|
SIZE = $(TCHAIN_PREFIX)size
|
||||||
|
NM = $(TCHAIN_PREFIX)nm
|
||||||
|
REMOVE = $(REMOVE_CMD) -f
|
||||||
|
PYTHON = python
|
||||||
|
###SHELL = sh
|
||||||
|
###COPY = cp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define Messages
|
||||||
|
# English
|
||||||
|
MSG_ERRORS_NONE = Errors: none
|
||||||
|
MSG_BEGIN = ${quote}-------- begin (mode: $(RUN_MODE)) --------${quote}
|
||||||
|
MSG_END = ${quote}-------- end --------${quote}
|
||||||
|
MSG_MODINIT = ${quote}**** Generating ModInit.c${quote}
|
||||||
|
MSG_SIZE_BEFORE = ${quote}Size before:${quote}
|
||||||
|
MSG_SIZE_AFTER = ${quote}Size after build:${quote}
|
||||||
|
MSG_LOAD_FILE = ${quote}Creating load file:${quote}
|
||||||
|
MSG_EXTENDED_LISTING = ${quote}Creating Extended Listing/Disassembly:${quote}
|
||||||
|
MSG_SYMBOL_TABLE = ${quote}Creating Symbol Table:${quote}
|
||||||
|
MSG_LINKING = ${quote}**** Linking :${quote}
|
||||||
|
MSG_COMPILING = ${quote}**** Compiling C :${quote}
|
||||||
|
MSG_COMPILING_ARM = ${quote}**** Compiling C (ARM-only):${quote}
|
||||||
|
MSG_COMPILINGCPP = ${quote}Compiling C++ :${quote}
|
||||||
|
MSG_COMPILINGCPP_ARM = ${quote}Compiling C++ (ARM-only):${quote}
|
||||||
|
MSG_ASSEMBLING = ${quote}**** Assembling:${quote}
|
||||||
|
MSG_ASSEMBLING_ARM = ${quote}****Assembling (ARM-only):${quote}
|
||||||
|
MSG_CLEANING = ${quote}Cleaning project:${quote}
|
||||||
|
MSG_FORMATERROR = ${quote}Can not handle output-format${quote}
|
||||||
|
MSG_ASMFROMC = ${quote}Creating asm-File from C-Source:${quote}
|
||||||
|
MSG_ASMFROMC_ARM = ${quote}Creating asm-File from C-Source (ARM-only):${quote}
|
||||||
|
MSG_PYMITEINIT = ${quote}**** Generating PyMite intermediate code${quote}
|
||||||
|
|
||||||
|
# List of all source files.
|
||||||
|
ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC)
|
||||||
|
# List of all source files without directory and file-extension.
|
||||||
|
ALLSRCBASE = $(notdir $(basename $(ALLSRC)))
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
|
||||||
|
|
||||||
|
# Define all listing files (used for make clean).
|
||||||
|
LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE)))
|
||||||
|
# Define all depedency-files (used for make clean).
|
||||||
|
DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE)))
|
||||||
|
|
||||||
|
elf: $(OUTDIR)/$(TARGET).elf
|
||||||
|
lss: $(OUTDIR)/$(TARGET).lss
|
||||||
|
sym: $(OUTDIR)/$(TARGET).sym
|
||||||
|
hex: $(OUTDIR)/$(TARGET).hex
|
||||||
|
bin: $(OUTDIR)/$(TARGET).bin
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
#all: begin gccversion sizebefore build sizeafter finished end
|
||||||
|
#all: begin gencode gccversion build sizeafter finished end
|
||||||
|
all: elf
|
||||||
|
|
||||||
|
ifeq ($(LOADFORMAT),ihex)
|
||||||
|
build: elf hex lss sym
|
||||||
|
else
|
||||||
|
ifeq ($(LOADFORMAT),binary)
|
||||||
|
build: elf bin lss sym
|
||||||
|
else
|
||||||
|
ifeq ($(LOADFORMAT),both)
|
||||||
|
build: elf hex bin lss sym
|
||||||
|
else
|
||||||
|
$(error "$(MSG_FORMATERROR) $(FORMAT)")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Test if quotes are needed for the echo-command
|
||||||
|
result = ${shell echo "test"}
|
||||||
|
ifeq (${result}, test)
|
||||||
|
quote = '
|
||||||
|
else
|
||||||
|
quote =
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Generate intermediate code
|
||||||
|
gencode: ${OUTDIR}/InitMods.c ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h
|
||||||
|
|
||||||
|
getmodname = $(firstword $(subst /, ,$1))
|
||||||
|
|
||||||
|
MOD_GEN := $(foreach MOD,$(MODULES),$(call getmodname,$(MOD)))
|
||||||
|
|
||||||
|
# Generate code for module initialization
|
||||||
|
${OUTDIR}/InitMods.c: Makefile.osx
|
||||||
|
echo ${MOD_GEN}
|
||||||
|
@echo ${MSG_MODINIT}
|
||||||
|
@echo ${quote}// Autogenerated file${quote} > ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}${foreach MOD, ${MOD_GEN}, extern unsigned int ${MOD}Initialize(void);}${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}${foreach MOD, ${MOD_GEN}, extern unsigned int ${MOD}Start(void);}${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}${foreach MOD, ${MOD_GEN}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}void StartModules() {${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}${foreach MOD, ${MOD_GEN}, ${MOD}Start();}${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
@echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c
|
||||||
|
|
||||||
|
# Generate code for PyMite
|
||||||
|
${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h: $(wildcard ${PYMITELIB}/*.py) $(wildcard ${PYMITEPLAT}/*.py) $(wildcard ${FLIGHTPLANLIB}/*.py) $(wildcard ${FLIGHTPLANS}/*.py) $(wildcard $(UAVOBJPYTHONSYNTHDIR)/*.py)
|
||||||
|
@echo ${MSG_PYMITEINIT}
|
||||||
|
@$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py) $(wildcard $(UAVOBJPYTHONSYNTHDIR)/*.py)
|
||||||
|
@$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h
|
||||||
|
@$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py
|
||||||
|
|
||||||
|
# Eye candy.
|
||||||
|
begin:
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
## @echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
## @echo
|
||||||
|
|
||||||
|
# Display sizes of sections.
|
||||||
|
ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf
|
||||||
|
##ELFSIZE = $(SIZE) --format=Berkeley --common $(OUTDIR)/$(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
@echo $(MSG_SIZE_AFTER)
|
||||||
|
$(ELFSIZE)
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
# @echo $(ALLOBJ)
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
ifeq ($(USE_BOOTLOADER), YES)
|
||||||
|
# Program the device with OP Upload Tool".
|
||||||
|
program: $(OUTDIR)/$(TARGET).bin
|
||||||
|
@echo ${quote}Programming with OP Upload Tool${quote}
|
||||||
|
../../ground/src/experimental/upload-build-desktop/debug/OPUploadTool -d 0 -p $(OUTDIR)/$(TARGET).bin
|
||||||
|
else
|
||||||
|
ifeq ($(FLASH_TOOL),OPENOCD)
|
||||||
|
# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script".
|
||||||
|
program: $(OUTDIR)/$(TARGET).elf
|
||||||
|
@echo ${quote}Programming with OPENOCD${quote}
|
||||||
|
$(OOCD_EXE) $(OOCD_CL)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Create final output file (.hex) from ELF output file.
|
||||||
|
%.hex: %.elf
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_LOAD_FILE) $@
|
||||||
|
$(OBJCOPY) -O ihex $< $@
|
||||||
|
|
||||||
|
# Create final output file (.bin) from ELF output file.
|
||||||
|
%.bin: %.elf
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_LOAD_FILE) $@
|
||||||
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
# Create extended listing file/disassambly from ELF output file.
|
||||||
|
# using objdump testing: option -C
|
||||||
|
%.lss: %.elf
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_EXTENDED_LISTING) $@
|
||||||
|
$(OBJDUMP) -h -S -C -r $< > $@
|
||||||
|
# $(OBJDUMP) -x -S $< > $@
|
||||||
|
|
||||||
|
# Create a symbol table from ELF output file.
|
||||||
|
%.sym: %.elf
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_SYMBOL_TABLE) $@
|
||||||
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
.SECONDARY : $(TARGET).elf
|
||||||
|
.PRECIOUS : $(ALLOBJ)
|
||||||
|
%.elf: $(ALLOBJ)
|
||||||
|
@echo $(MSG_LINKING) $@
|
||||||
|
# use $(CC) for C-only projects or $(CPP) for C++-projects:
|
||||||
|
$(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
|
||||||
|
# $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
define ASSEMBLE_TEMPLATE
|
||||||
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_ASSEMBLING) $$< to $$@
|
||||||
|
$(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@
|
||||||
|
endef
|
||||||
|
$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files. ARM-only
|
||||||
|
define ASSEMBLE_ARM_TEMPLATE
|
||||||
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_ASSEMBLING_ARM) $$< to $$@
|
||||||
|
$(CC) -c $$(ASFLAGS) $$< -o $$@
|
||||||
|
endef
|
||||||
|
$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
define COMPILE_C_TEMPLATE
|
||||||
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_COMPILING) $$< to $$@
|
||||||
|
$(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
||||||
|
endef
|
||||||
|
$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C source files. ARM-only
|
||||||
|
define COMPILE_C_ARM_TEMPLATE
|
||||||
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_COMPILING_ARM) $$< to $$@
|
||||||
|
$(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
||||||
|
endef
|
||||||
|
$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C++ source files.
|
||||||
|
define COMPILE_CPP_TEMPLATE
|
||||||
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_COMPILINGCPP) $$< to $$@
|
||||||
|
$(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
|
||||||
|
endef
|
||||||
|
$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
# Compile: create object files from C++ source files. ARM-only
|
||||||
|
define COMPILE_CPP_ARM_TEMPLATE
|
||||||
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_COMPILINGCPP_ARM) $$< to $$@
|
||||||
|
$(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
|
||||||
|
endef
|
||||||
|
$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src))))
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files. ARM/Thumb
|
||||||
|
$(SRC:.c=.s) : %.s : %.c
|
||||||
|
@echo $(MSG_ASMFROMC) $< to $@
|
||||||
|
$(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files. ARM only
|
||||||
|
$(SRCARM:.c=.s) : %.s : %.c
|
||||||
|
@echo $(MSG_ASMFROMC_ARM) $< to $@
|
||||||
|
$(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
|
||||||
|
|
||||||
|
# Generate Doxygen documents
|
||||||
|
docs:
|
||||||
|
doxygen $(DOXYGENDIR)/doxygen.cfg
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: begin clean_list finished end
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
## @echo
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(REMOVE) $(OUTDIR)/$(TARGET).map
|
||||||
|
$(REMOVE) $(OUTDIR)/$(TARGET).elf
|
||||||
|
$(REMOVE) $(OUTDIR)/$(TARGET).hex
|
||||||
|
$(REMOVE) $(OUTDIR)/$(TARGET).bin
|
||||||
|
$(REMOVE) $(OUTDIR)/$(TARGET).sym
|
||||||
|
$(REMOVE) $(OUTDIR)/$(TARGET).lss
|
||||||
|
$(REMOVE) $(wildcard $(OUTDIR)/*.c)
|
||||||
|
$(REMOVE) $(wildcard $(OUTDIR)/*.h)
|
||||||
|
$(REMOVE) $(ALLOBJ)
|
||||||
|
$(REMOVE) $(LSTFILES)
|
||||||
|
$(REMOVE) $(DEPFILES)
|
||||||
|
$(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(REMOVE) $(SRCARM:.c=.s)
|
||||||
|
$(REMOVE) $(CPPSRC:.cpp=.s)
|
||||||
|
$(REMOVE) $(CPPSRCARM:.cpp=.s)
|
||||||
|
|
||||||
|
|
||||||
|
# Create output files directory
|
||||||
|
# all known MS Windows OS define the ComSpec environment variable
|
||||||
|
ifdef ComSpec
|
||||||
|
$(shell md $(OUTDIR) 2>NUL)
|
||||||
|
else
|
||||||
|
$(shell mkdir $(OUTDIR) 2>/dev/null)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
ifdef ComSpec
|
||||||
|
-include $(shell md $(OUTDIR)\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*)
|
||||||
|
else
|
||||||
|
-include $(shell mkdir $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
|
build elf hex bin lss sym clean clean_list program gencode
|
||||||
|
|
210
flight/RevoMini/System/alarms.c
Normal file
210
flight/RevoMini/System/alarms.c
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
|
||||||
|
* @brief OpenPilot System libraries are available to all OP modules.
|
||||||
|
* @{
|
||||||
|
* @file alarms.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Library for setting and clearing system alarms
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "openpilot.h"
|
||||||
|
#include "alarms.h"
|
||||||
|
|
||||||
|
// Private constants
|
||||||
|
|
||||||
|
// Private types
|
||||||
|
|
||||||
|
// Private variables
|
||||||
|
static xSemaphoreHandle lock;
|
||||||
|
|
||||||
|
// Private functions
|
||||||
|
static int32_t hasSeverity(SystemAlarmsAlarmOptions severity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the alarms library
|
||||||
|
*/
|
||||||
|
int32_t AlarmsInitialize(void)
|
||||||
|
{
|
||||||
|
SystemAlarmsInitialize();
|
||||||
|
lock = xSemaphoreCreateRecursiveMutex();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an alarm
|
||||||
|
* @param alarm The system alarm to be modified
|
||||||
|
* @param severity The alarm severity
|
||||||
|
* @return 0 if success, -1 if an error
|
||||||
|
*/
|
||||||
|
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
|
||||||
|
{
|
||||||
|
SystemAlarmsData alarms;
|
||||||
|
|
||||||
|
// Check that this is a valid alarm
|
||||||
|
if (alarm >= SYSTEMALARMS_ALARM_NUMELEM)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock
|
||||||
|
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
|
||||||
|
|
||||||
|
// Read alarm and update its severity only if it was changed
|
||||||
|
SystemAlarmsGet(&alarms);
|
||||||
|
if ( alarms.Alarm[alarm] != severity )
|
||||||
|
{
|
||||||
|
alarms.Alarm[alarm] = severity;
|
||||||
|
SystemAlarmsSet(&alarms);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release lock
|
||||||
|
xSemaphoreGiveRecursive(lock);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an alarm
|
||||||
|
* @param alarm The system alarm to be read
|
||||||
|
* @return Alarm severity
|
||||||
|
*/
|
||||||
|
SystemAlarmsAlarmOptions AlarmsGet(SystemAlarmsAlarmElem alarm)
|
||||||
|
{
|
||||||
|
SystemAlarmsData alarms;
|
||||||
|
|
||||||
|
// Check that this is a valid alarm
|
||||||
|
if (alarm >= SYSTEMALARMS_ALARM_NUMELEM)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read alarm
|
||||||
|
SystemAlarmsGet(&alarms);
|
||||||
|
return alarms.Alarm[alarm];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an alarm to it's default value
|
||||||
|
* @param alarm The system alarm to be modified
|
||||||
|
* @return 0 if success, -1 if an error
|
||||||
|
*/
|
||||||
|
int32_t AlarmsDefault(SystemAlarmsAlarmElem alarm)
|
||||||
|
{
|
||||||
|
return AlarmsSet(alarm, SYSTEMALARMS_ALARM_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default all alarms
|
||||||
|
*/
|
||||||
|
void AlarmsDefaultAll()
|
||||||
|
{
|
||||||
|
uint32_t n;
|
||||||
|
for (n = 0; n < SYSTEMALARMS_ALARM_NUMELEM; ++n)
|
||||||
|
{
|
||||||
|
AlarmsDefault(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear an alarm
|
||||||
|
* @param alarm The system alarm to be modified
|
||||||
|
* @return 0 if success, -1 if an error
|
||||||
|
*/
|
||||||
|
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm)
|
||||||
|
{
|
||||||
|
return AlarmsSet(alarm, SYSTEMALARMS_ALARM_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all alarms
|
||||||
|
*/
|
||||||
|
void AlarmsClearAll()
|
||||||
|
{
|
||||||
|
uint32_t n;
|
||||||
|
for (n = 0; n < SYSTEMALARMS_ALARM_NUMELEM; ++n)
|
||||||
|
{
|
||||||
|
AlarmsClear(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if there are any alarms with the given or higher severity
|
||||||
|
* @return 0 if no alarms are found, 1 if at least one alarm is found
|
||||||
|
*/
|
||||||
|
int32_t AlarmsHasWarnings()
|
||||||
|
{
|
||||||
|
return hasSeverity(SYSTEMALARMS_ALARM_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if there are any alarms with error or higher severity
|
||||||
|
* @return 0 if no alarms are found, 1 if at least one alarm is found
|
||||||
|
*/
|
||||||
|
int32_t AlarmsHasErrors()
|
||||||
|
{
|
||||||
|
return hasSeverity(SYSTEMALARMS_ALARM_ERROR);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if there are any alarms with critical or higher severity
|
||||||
|
* @return 0 if no alarms are found, 1 if at least one alarm is found
|
||||||
|
*/
|
||||||
|
int32_t AlarmsHasCritical()
|
||||||
|
{
|
||||||
|
return hasSeverity(SYSTEMALARMS_ALARM_CRITICAL);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if there are any alarms with the given or higher severity
|
||||||
|
* @return 0 if no alarms are found, 1 if at least one alarm is found
|
||||||
|
*/
|
||||||
|
static int32_t hasSeverity(SystemAlarmsAlarmOptions severity)
|
||||||
|
{
|
||||||
|
SystemAlarmsData alarms;
|
||||||
|
uint32_t n;
|
||||||
|
|
||||||
|
// Lock
|
||||||
|
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
|
||||||
|
|
||||||
|
// Read alarms
|
||||||
|
SystemAlarmsGet(&alarms);
|
||||||
|
|
||||||
|
// Go through alarms and check if any are of the given severity or higher
|
||||||
|
for (n = 0; n < SYSTEMALARMS_ALARM_NUMELEM; ++n)
|
||||||
|
{
|
||||||
|
if ( alarms.Alarm[n] >= severity)
|
||||||
|
{
|
||||||
|
xSemaphoreGiveRecursive(lock);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this point is reached then no alarms found
|
||||||
|
xSemaphoreGiveRecursive(lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
87
flight/RevoMini/System/cm3_fault_handlers.c
Normal file
87
flight/RevoMini/System/cm3_fault_handlers.c
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* cm3_fault_handlers.c
|
||||||
|
*
|
||||||
|
* Created on: Apr 24, 2011
|
||||||
|
* Author: msmith
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "dcc_stdio.h"
|
||||||
|
#ifdef STM32F4XX
|
||||||
|
# include "stm32f4xx.h"
|
||||||
|
#endif
|
||||||
|
#ifdef STM32F2XX
|
||||||
|
# include "stm32f2xx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FAULT_TRAMPOLINE(_vec) \
|
||||||
|
__attribute__((naked, no_instrument_function)) \
|
||||||
|
void \
|
||||||
|
_vec##_Handler(void) \
|
||||||
|
{ \
|
||||||
|
__asm( ".syntax unified\n" \
|
||||||
|
"MOVS R0, #4 \n" \
|
||||||
|
"MOV R1, LR \n" \
|
||||||
|
"TST R0, R1 \n" \
|
||||||
|
"BEQ 1f \n" \
|
||||||
|
"MRS R0, PSP \n" \
|
||||||
|
"B " #_vec "_Handler2 \n" \
|
||||||
|
"1: \n" \
|
||||||
|
"MRS R0, MSP \n" \
|
||||||
|
"B " #_vec "_Handler2 \n" \
|
||||||
|
".syntax divided\n"); \
|
||||||
|
} \
|
||||||
|
struct hack
|
||||||
|
|
||||||
|
struct cm3_frame {
|
||||||
|
uint32_t r0;
|
||||||
|
uint32_t r1;
|
||||||
|
uint32_t r2;
|
||||||
|
uint32_t r3;
|
||||||
|
uint32_t r12;
|
||||||
|
uint32_t lr;
|
||||||
|
uint32_t pc;
|
||||||
|
uint32_t psr;
|
||||||
|
};
|
||||||
|
|
||||||
|
FAULT_TRAMPOLINE(HardFault);
|
||||||
|
FAULT_TRAMPOLINE(BusFault);
|
||||||
|
FAULT_TRAMPOLINE(UsageFault);
|
||||||
|
|
||||||
|
/* this is a hackaround to avoid an issue where dereferencing SCB seems to result in bad codegen and a link error */
|
||||||
|
#define SCB_REG(_reg) (*(uint32_t *)&(SCB->_reg))
|
||||||
|
|
||||||
|
void
|
||||||
|
HardFault_Handler2(struct cm3_frame *frame)
|
||||||
|
{
|
||||||
|
dbg_write_str("\nHARD FAULT");
|
||||||
|
dbg_write_hex32(frame->pc);
|
||||||
|
dbg_write_char('\n');
|
||||||
|
dbg_write_hex32(SCB_REG(HFSR));
|
||||||
|
dbg_write_char('\n');
|
||||||
|
for (;;);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BusFault_Handler2(struct cm3_frame *frame)
|
||||||
|
{
|
||||||
|
dbg_write_str("\nBUS FAULT");
|
||||||
|
dbg_write_hex32(frame->pc);
|
||||||
|
dbg_write_char('\n');
|
||||||
|
dbg_write_hex32(SCB_REG(CFSR));
|
||||||
|
dbg_write_char('\n');
|
||||||
|
dbg_write_hex32(SCB_REG(BFAR));
|
||||||
|
dbg_write_char('\n');
|
||||||
|
for (;;);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UsageFault_Handler2(struct cm3_frame *frame)
|
||||||
|
{
|
||||||
|
dbg_write_str("\nUSAGE FAULT");
|
||||||
|
dbg_write_hex32(frame->pc);
|
||||||
|
dbg_write_char('\n');
|
||||||
|
dbg_write_hex32(SCB_REG(CFSR));
|
||||||
|
dbg_write_char('\n');
|
||||||
|
for (;;);
|
||||||
|
}
|
149
flight/RevoMini/System/dcc_stdio.c
Normal file
149
flight/RevoMini/System/dcc_stdio.c
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Dominic Rath *
|
||||||
|
* Dominic.Rath@gmx.de *
|
||||||
|
* Copyright (C) 2008 by Spencer Oliver *
|
||||||
|
* spen@spen-soft.co.uk *
|
||||||
|
* Copyright (C) 2008 by Frederik Kriewtz *
|
||||||
|
* frederik@kriewitz.eu *
|
||||||
|
* *
|
||||||
|
* 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 2 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, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "dcc_stdio.h"
|
||||||
|
|
||||||
|
#define TARGET_REQ_TRACEMSG 0x00
|
||||||
|
#define TARGET_REQ_DEBUGMSG_ASCII 0x01
|
||||||
|
#define TARGET_REQ_DEBUGMSG_HEXMSG(size) (0x01 | ((size & 0xff) << 8))
|
||||||
|
#define TARGET_REQ_DEBUGCHAR 0x02
|
||||||
|
|
||||||
|
/* we use the cortex_m3 DCRDR reg to simulate a arm7_9 dcc channel
|
||||||
|
* DCRDR[7:0] is used by target for status
|
||||||
|
* DCRDR[15:8] is used by target for write buffer
|
||||||
|
* DCRDR[23:16] is used for by host for status
|
||||||
|
* DCRDR[31:24] is used for by host for write buffer */
|
||||||
|
|
||||||
|
#define NVIC_DBG_DATA_R (*((volatile unsigned short *)0xE000EDF8))
|
||||||
|
|
||||||
|
#define BUSY 1
|
||||||
|
|
||||||
|
void dbg_write(unsigned long dcc_data)
|
||||||
|
{
|
||||||
|
int len = 4;
|
||||||
|
|
||||||
|
while (len--)
|
||||||
|
{
|
||||||
|
/* wait for data ready */
|
||||||
|
while (NVIC_DBG_DATA_R & BUSY);
|
||||||
|
|
||||||
|
/* write our data and set write flag - tell host there is data*/
|
||||||
|
NVIC_DBG_DATA_R = (unsigned short)(((dcc_data & 0xff) << 8) | BUSY);
|
||||||
|
dcc_data >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_trace_point(unsigned long number)
|
||||||
|
{
|
||||||
|
dbg_write(TARGET_REQ_TRACEMSG | (number << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_write_u32(const unsigned long *val, long len)
|
||||||
|
{
|
||||||
|
dbg_write(TARGET_REQ_DEBUGMSG_HEXMSG(4) | ((len & 0xffff) << 16));
|
||||||
|
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
dbg_write(*val);
|
||||||
|
|
||||||
|
val++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_write_u16(const unsigned short *val, long len)
|
||||||
|
{
|
||||||
|
unsigned long dcc_data;
|
||||||
|
|
||||||
|
dbg_write(TARGET_REQ_DEBUGMSG_HEXMSG(2) | ((len & 0xffff) << 16));
|
||||||
|
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
dcc_data = val[0]
|
||||||
|
| ((len > 1) ? val[1] << 16: 0x0000);
|
||||||
|
|
||||||
|
dbg_write(dcc_data);
|
||||||
|
|
||||||
|
val += 2;
|
||||||
|
len -= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_write_u8(const unsigned char *val, long len)
|
||||||
|
{
|
||||||
|
unsigned long dcc_data;
|
||||||
|
|
||||||
|
dbg_write(TARGET_REQ_DEBUGMSG_HEXMSG(1) | ((len & 0xffff) << 16));
|
||||||
|
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
dcc_data = val[0]
|
||||||
|
| ((len > 1) ? val[1] << 8 : 0x00)
|
||||||
|
| ((len > 2) ? val[2] << 16 : 0x00)
|
||||||
|
| ((len > 3) ? val[3] << 24 : 0x00);
|
||||||
|
|
||||||
|
dbg_write(dcc_data);
|
||||||
|
|
||||||
|
val += 4;
|
||||||
|
len -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_write_str(const char *msg)
|
||||||
|
{
|
||||||
|
long len;
|
||||||
|
unsigned long dcc_data;
|
||||||
|
|
||||||
|
for (len = 0; msg[len] && (len < 65536); len++);
|
||||||
|
|
||||||
|
dbg_write(TARGET_REQ_DEBUGMSG_ASCII | ((len & 0xffff) << 16));
|
||||||
|
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
dcc_data = msg[0]
|
||||||
|
| ((len > 1) ? msg[1] << 8 : 0x00)
|
||||||
|
| ((len > 2) ? msg[2] << 16 : 0x00)
|
||||||
|
| ((len > 3) ? msg[3] << 24 : 0x00);
|
||||||
|
dbg_write(dcc_data);
|
||||||
|
|
||||||
|
msg += 4;
|
||||||
|
len -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_write_char(char msg)
|
||||||
|
{
|
||||||
|
dbg_write(TARGET_REQ_DEBUGCHAR | ((msg & 0xff) << 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbg_write_hex32(const unsigned long val)
|
||||||
|
{
|
||||||
|
static const char hextab[] = {
|
||||||
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||||
|
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int shift = 28; shift >= 0; shift -= 4)
|
||||||
|
dbg_write_char(hextab[(val >> shift) & 0xf]);
|
||||||
|
}
|
103
flight/RevoMini/System/inc/FreeRTOSConfig.h
Normal file
103
flight/RevoMini/System/inc/FreeRTOSConfig.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
#ifndef FREERTOS_CONFIG_H
|
||||||
|
#define FREERTOS_CONFIG_H
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------
|
||||||
|
* Application specific definitions.
|
||||||
|
*
|
||||||
|
* These definitions should be adjusted for your particular hardware and
|
||||||
|
* application requirements.
|
||||||
|
*
|
||||||
|
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||||
|
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||||
|
*
|
||||||
|
* See http://www.freertos.org/a00110.html.
|
||||||
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup PIOS PIOS
|
||||||
|
* @{
|
||||||
|
* @addtogroup FreeRTOS FreeRTOS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Notes: We use 5 task priorities */
|
||||||
|
|
||||||
|
#define configCPU_CLOCK_HZ (SYSCLK_FREQ) // really the NVIC clock ...
|
||||||
|
#define configTICK_RATE_HZ ((portTickType )1000)
|
||||||
|
#define configMAX_PRIORITIES ((unsigned portBASE_TYPE)5)
|
||||||
|
#define configMINIMAL_STACK_SIZE ((unsigned short)512)
|
||||||
|
#define configTOTAL_HEAP_SIZE ((size_t)(180 * 1024)) // this is minimum, not total
|
||||||
|
#define configMAX_TASK_NAME_LEN (16)
|
||||||
|
|
||||||
|
#define configUSE_PREEMPTION 1
|
||||||
|
#define configUSE_IDLE_HOOK 1
|
||||||
|
#define configUSE_TICK_HOOK 0
|
||||||
|
#define configUSE_TRACE_FACILITY 0
|
||||||
|
#define configUSE_16_BIT_TICKS 0
|
||||||
|
#define configIDLE_SHOULD_YIELD 0
|
||||||
|
#define configUSE_MUTEXES 1
|
||||||
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
|
#define configUSE_COUNTING_SEMAPHORES 0
|
||||||
|
#define configUSE_ALTERNATIVE_API 0
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
|
#define configQUEUE_REGISTRY_SIZE 10
|
||||||
|
|
||||||
|
#define configUSE_TIMERS 1
|
||||||
|
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) /* run timers at max priority */
|
||||||
|
#define configTIMER_QUEUE_LENGTH 10
|
||||||
|
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||||
|
|
||||||
|
/* Co-routine definitions. */
|
||||||
|
#define configUSE_CO_ROUTINES 0
|
||||||
|
//#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||||
|
|
||||||
|
/* Set the following definitions to 1 to include the API function, or zero
|
||||||
|
to exclude the API function. */
|
||||||
|
|
||||||
|
#define INCLUDE_vTaskPrioritySet 1
|
||||||
|
#define INCLUDE_uxTaskPriorityGet 1
|
||||||
|
#define INCLUDE_vTaskDelete 1
|
||||||
|
#define INCLUDE_vTaskCleanUpResources 1
|
||||||
|
#define INCLUDE_vTaskSuspend 1
|
||||||
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
|
#define INCLUDE_vTaskDelay 1
|
||||||
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
|
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||||
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
|
||||||
|
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
|
||||||
|
(lowest) to 1 (highest maskable) to 0 (highest non-maskable). */
|
||||||
|
#define configKERNEL_INTERRUPT_PRIORITY 15 << 4 /* equivalent to NVIC priority 15 */
|
||||||
|
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 3 << 4 /* equivalent to NVIC priority 3 */
|
||||||
|
|
||||||
|
/* This is the value being used as per the ST library which permits 16
|
||||||
|
priority values, 0 to 15. This must correspond to the
|
||||||
|
configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest
|
||||||
|
NVIC value of 255. */
|
||||||
|
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
|
||||||
|
|
||||||
|
/* Enable run time stats collection */
|
||||||
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
#define INCLUDE_uxTaskGetRunTime 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Once we move to CMSIS2 we can at least use:
|
||||||
|
*
|
||||||
|
* CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||||
|
*
|
||||||
|
* (still nothing for the DWT registers, surprisingly)
|
||||||
|
*/
|
||||||
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() \
|
||||||
|
do { \
|
||||||
|
(*(unsigned long *)0xe000edfc) |= (1<<24); /* DEMCR |= DEMCR_TRCENA */ \
|
||||||
|
(*(unsigned long *)0xe0001000) |= 1; /* DWT_CTRL |= DWT_CYCCNT_ENA */ \
|
||||||
|
} while(0)
|
||||||
|
#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004) /* DWT_CYCCNT */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* FREERTOS_CONFIG_H */
|
50
flight/RevoMini/System/inc/alarms.h
Normal file
50
flight/RevoMini/System/inc/alarms.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotLibraries OpenPilot System Libraries
|
||||||
|
* @{
|
||||||
|
* @file alarms.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Include file of the alarm library
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef ALARMS_H
|
||||||
|
#define ALARMS_H
|
||||||
|
|
||||||
|
#include "systemalarms.h"
|
||||||
|
#define SYSTEMALARMS_ALARM_DEFAULT SYSTEMALARMS_ALARM_UNINITIALISED
|
||||||
|
|
||||||
|
int32_t AlarmsInitialize(void);
|
||||||
|
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity);
|
||||||
|
SystemAlarmsAlarmOptions AlarmsGet(SystemAlarmsAlarmElem alarm);
|
||||||
|
int32_t AlarmsDefault(SystemAlarmsAlarmElem alarm);
|
||||||
|
void AlarmsDefaultAll();
|
||||||
|
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm);
|
||||||
|
void AlarmsClearAll();
|
||||||
|
int32_t AlarmsHasWarnings();
|
||||||
|
int32_t AlarmsHasErrors();
|
||||||
|
int32_t AlarmsHasCritical();
|
||||||
|
|
||||||
|
#endif // ALARMS_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
36
flight/RevoMini/System/inc/dcc_stdio.h
Normal file
36
flight/RevoMini/System/inc/dcc_stdio.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Dominic Rath *
|
||||||
|
* Dominic.Rath@gmx.de *
|
||||||
|
* Copyright (C) 2008 by Spencer Oliver *
|
||||||
|
* spen@spen-soft.co.uk *
|
||||||
|
* *
|
||||||
|
* 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 2 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, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DCC_STDIO_H
|
||||||
|
#define DCC_STDIO_H
|
||||||
|
|
||||||
|
void dbg_trace_point(unsigned long number);
|
||||||
|
|
||||||
|
void dbg_write_u32(const unsigned long *val, long len);
|
||||||
|
void dbg_write_u16(const unsigned short *val, long len);
|
||||||
|
void dbg_write_u8(const unsigned char *val, long len);
|
||||||
|
|
||||||
|
void dbg_write_str(const char *msg);
|
||||||
|
void dbg_write_char(char msg);
|
||||||
|
void dbg_write_hex32(const unsigned long val);
|
||||||
|
|
||||||
|
#endif /* DCC_STDIO_H */
|
39
flight/RevoMini/System/inc/op_config.h
Normal file
39
flight/RevoMini/System/inc/op_config.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotCore OpenPilot Core
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file op_config.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief OpenPilot configuration header.
|
||||||
|
* Compile time config for OpenPilot Application
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OP_CONFIG_H
|
||||||
|
#define OP_CONFIG_H
|
||||||
|
|
||||||
|
#endif /* OP_CONFIG_H */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
53
flight/RevoMini/System/inc/openpilot.h
Normal file
53
flight/RevoMini/System/inc/openpilot.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotCore OpenPilot Core
|
||||||
|
* @{
|
||||||
|
* @file openpilot.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Main OpenPilot header.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OPENPILOT_H
|
||||||
|
#define OPENPILOT_H
|
||||||
|
|
||||||
|
|
||||||
|
/* PIOS Includes */
|
||||||
|
#include <pios.h>
|
||||||
|
|
||||||
|
/* OpenPilot Libraries */
|
||||||
|
#include "op_config.h"
|
||||||
|
#include "utlist.h"
|
||||||
|
#include "uavobjectmanager.h"
|
||||||
|
#include "eventdispatcher.h"
|
||||||
|
#include "alarms.h"
|
||||||
|
#include "taskmonitor.h"
|
||||||
|
#include "uavtalk.h"
|
||||||
|
|
||||||
|
/* Global Functions */
|
||||||
|
void OpenPilotInit(void);
|
||||||
|
|
||||||
|
#endif /* OPENPILOT_H */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
85
flight/RevoMini/System/inc/pios_board_sim.h
Normal file
85
flight/RevoMini/System/inc/pios_board_sim.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file pios_board.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Defines board hardware for the OpenPilot Version 1.1 hardware.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PIOS_BOARD_H
|
||||||
|
#define PIOS_BOARD_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// PIOS_LED
|
||||||
|
//------------------------
|
||||||
|
#define PIOS_LED_ALARM 0
|
||||||
|
#define PIOS_LED_HEARTBEAT 1
|
||||||
|
#define PIOS_LED_NUM 2
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
// COM
|
||||||
|
//
|
||||||
|
// See also pios_board_posix.c
|
||||||
|
//-------------------------
|
||||||
|
//#define PIOS_USART_TX_BUFFER_SIZE 256
|
||||||
|
#define PIOS_COM_BUFFER_SIZE 1024
|
||||||
|
#define PIOS_COM_MAX_DEVS 255
|
||||||
|
#define PIOS_UDP_RX_BUFFER_SIZE PIOS_COM_BUFFER_SIZE
|
||||||
|
#define PIOS_TCP_RX_BUFFER_SIZE PIOS_COM_BUFFER_SIZE
|
||||||
|
|
||||||
|
extern uint32_t pios_com_telem_rf_id;
|
||||||
|
extern uint32_t pios_com_telem_usb_id;
|
||||||
|
extern uint32_t pios_com_gps_id;
|
||||||
|
extern uint32_t pios_com_aux_id;
|
||||||
|
extern uint32_t pios_com_spectrum_id;
|
||||||
|
|
||||||
|
#define PIOS_COM_TELEM_RF (pios_com_telem_rf_id)
|
||||||
|
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
|
||||||
|
#define PIOS_COM_GPS (pios_com_gps_id)
|
||||||
|
|
||||||
|
#ifdef PIOS_ENABLE_AUX_UART
|
||||||
|
#define PIOS_COM_AUX (pios_com_aux_id)
|
||||||
|
#define PIOS_COM_DEBUG (PIOS_COM_AUX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PIOS_GCSRCVR_TIMEOUT_MS 200
|
||||||
|
/**
|
||||||
|
* glue macros for file IO
|
||||||
|
* STM32 uses DOSFS for file IO
|
||||||
|
*/
|
||||||
|
#define PIOS_FOPEN_READ(filename,file) (file=fopen((char*)filename,"r"))==NULL
|
||||||
|
|
||||||
|
#define PIOS_FOPEN_WRITE(filename,file) (file=fopen((char*)filename,"w"))==NULL
|
||||||
|
|
||||||
|
#define PIOS_FREAD(file,bufferadr,length,resultadr) (*resultadr=fread((uint8_t*)bufferadr,1,length,*file)) != length
|
||||||
|
|
||||||
|
#define PIOS_FWRITE(file,bufferadr,length,resultadr) *resultadr=fwrite((uint8_t*)bufferadr,1,length,*file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define PIOS_FCLOSE(file) fclose(file)
|
||||||
|
|
||||||
|
#define PIOS_FUNLINK(file) unlink((char*)filename)
|
||||||
|
|
||||||
|
#endif /* PIOS_BOARD_H */
|
122
flight/RevoMini/System/inc/pios_config.h
Normal file
122
flight/RevoMini/System/inc/pios_config.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotCore OpenPilot Core
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_config.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief PiOS configuration header.
|
||||||
|
* Central compile time config for the project.
|
||||||
|
* In particular, pios_config.h is where you define which PiOS libraries
|
||||||
|
* and features are included in the firmware.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PIOS_CONFIG_H
|
||||||
|
#define PIOS_CONFIG_H
|
||||||
|
|
||||||
|
/* Major features */
|
||||||
|
#define PIOS_INCLUDE_FREERTOS
|
||||||
|
#define PIOS_INCLUDE_BL_HELPER
|
||||||
|
|
||||||
|
/* Enable/Disable PiOS Modules */
|
||||||
|
#define PIOS_INCLUDE_ADC
|
||||||
|
#define PIOS_INCLUDE_DELAY
|
||||||
|
#define PIOS_INCLUDE_I2C
|
||||||
|
#define PIOS_INCLUDE_IRQ
|
||||||
|
#define PIOS_INCLUDE_LED
|
||||||
|
#define PIOS_INCLUDE_IAP
|
||||||
|
#define PIOS_INCLUDE_SERVO
|
||||||
|
#define PIOS_INCLUDE_SPI
|
||||||
|
#define PIOS_INCLUDE_SYS
|
||||||
|
#define PIOS_INCLUDE_USART
|
||||||
|
#define PIOS_INCLUDE_USB
|
||||||
|
#define PIOS_INCLUDE_USB_HID
|
||||||
|
//#define PIOS_INCLUDE_GPIO
|
||||||
|
#define PIOS_INCLUDE_EXTI
|
||||||
|
#define PIOS_INCLUDE_RTC
|
||||||
|
#define PIOS_INCLUDE_WDG
|
||||||
|
|
||||||
|
/* Select the sensors to include */
|
||||||
|
#define PIOS_INCLUDE_BMA180
|
||||||
|
#define PIOS_INCLUDE_HMC5883
|
||||||
|
#define PIOS_INCLUDE_MPU6000
|
||||||
|
#define PIOS_MPU6000_ACCEL
|
||||||
|
#define PIOS_INCLUDE_L3GD20
|
||||||
|
#define PIOS_INCLUDE_MS5611
|
||||||
|
#define PIOS_INCLUDE_ETASV3
|
||||||
|
//#define PIOS_INCLUDE_HCSR04
|
||||||
|
#define PIOS_FLASH_ON_ACCEL /* true for second revo */
|
||||||
|
#define FLASH_FREERTOS
|
||||||
|
/* Com systems to include */
|
||||||
|
#define PIOS_INCLUDE_COM
|
||||||
|
#define PIOS_INCLUDE_COM_TELEM
|
||||||
|
#define PIOS_INCLUDE_COM_AUX
|
||||||
|
#define PIOS_INCLUDE_COM_AUXSBUS
|
||||||
|
#define PIOS_INCLUDE_COM_FLEXI
|
||||||
|
|
||||||
|
#define PIOS_INCLUDE_GPS
|
||||||
|
#define PIOS_INCLUDE_GPS_NMEA_PARSER
|
||||||
|
#define PIOS_INCLUDE_GPS_UBX_PARSER
|
||||||
|
#define PIOS_GPS_SETS_HOMELOCATION
|
||||||
|
|
||||||
|
#define PIOS_OVERO_SPI
|
||||||
|
/* Supported receiver interfaces */
|
||||||
|
#define PIOS_INCLUDE_RCVR
|
||||||
|
#define PIOS_INCLUDE_DSM
|
||||||
|
//#define PIOS_INCLUDE_SBUS
|
||||||
|
#define PIOS_INCLUDE_PPM
|
||||||
|
#define PIOS_INCLUDE_PWM
|
||||||
|
#define PIOS_INCLUDE_GCSRCVR
|
||||||
|
|
||||||
|
#define PIOS_INCLUDE_SETTINGS
|
||||||
|
#define PIOS_INCLUDE_FLASH
|
||||||
|
/* A really shitty setting saving implementation */
|
||||||
|
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
||||||
|
|
||||||
|
/* Other Interfaces */
|
||||||
|
//#define PIOS_INCLUDE_I2C_ESC
|
||||||
|
|
||||||
|
/* Flags that alter behaviors - mostly to lower resources for CC */
|
||||||
|
#define PIOS_INCLUDE_INITCALL /* Include init call structures */
|
||||||
|
#define PIOS_TELEM_PRIORITY_QUEUE /* Enable a priority queue in telemetry */
|
||||||
|
//#define PIOS_QUATERNION_STABILIZATION /* Stabilization options */
|
||||||
|
#define PIOS_GPS_SETS_HOMELOCATION /* GPS options */
|
||||||
|
|
||||||
|
/* Alarm Thresholds */
|
||||||
|
#define HEAP_LIMIT_WARNING 1000
|
||||||
|
#define HEAP_LIMIT_CRITICAL 500
|
||||||
|
#define IRQSTACK_LIMIT_WARNING 150
|
||||||
|
#define IRQSTACK_LIMIT_CRITICAL 80
|
||||||
|
#define CPULOAD_LIMIT_WARNING 80
|
||||||
|
#define CPULOAD_LIMIT_CRITICAL 95
|
||||||
|
|
||||||
|
// This actually needs calibrating
|
||||||
|
#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD (8379692)
|
||||||
|
|
||||||
|
#define REVOLUTION
|
||||||
|
|
||||||
|
#endif /* PIOS_CONFIG_H */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
79
flight/RevoMini/System/inc/pios_config_sim.h
Normal file
79
flight/RevoMini/System/inc/pios_config_sim.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file pios_config.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief PiOS configuration header.
|
||||||
|
* Central compile time config for the project.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PIOS_CONFIG_POSIX_H
|
||||||
|
#define PIOS_CONFIG_POSIX_H
|
||||||
|
|
||||||
|
|
||||||
|
/* Enable/Disable PiOS Modules */
|
||||||
|
#define PIOS_INCLUDE_SYS
|
||||||
|
#define PIOS_INCLUDE_DELAY
|
||||||
|
#define PIOS_INCLUDE_LED
|
||||||
|
#define PIOS_INCLUDE_SDCARD
|
||||||
|
#define PIOS_INCLUDE_FREERTOS
|
||||||
|
#define PIOS_INCLUDE_COM
|
||||||
|
//#define PIOS_INCLUDE_GPS
|
||||||
|
#define PIOS_INCLUDE_IRQ
|
||||||
|
#define PIOS_INCLUDE_TELEMETRY_RF
|
||||||
|
#define PIOS_INCLUDE_TCP
|
||||||
|
#define PIOS_INCLUDE_UDP
|
||||||
|
#define PIOS_INCLUDE_SERVO
|
||||||
|
#define PIOS_INCLUDE_RCVR
|
||||||
|
#define PIOS_INCLUDE_GCSRCVR
|
||||||
|
|
||||||
|
#define PIOS_RCVR_MAX_CHANNELS 12
|
||||||
|
#define PIOS_RCVR_MAX_DEVS 3
|
||||||
|
|
||||||
|
/* Defaults for Logging */
|
||||||
|
#define LOG_FILENAME "PIOS.LOG"
|
||||||
|
#define STARTUP_LOG_ENABLED 1
|
||||||
|
|
||||||
|
/* COM Module */
|
||||||
|
#define GPS_BAUDRATE 19200
|
||||||
|
#define TELEM_BAUDRATE 19200
|
||||||
|
#define AUXUART_ENABLED 0
|
||||||
|
#define AUXUART_BAUDRATE 19200
|
||||||
|
|
||||||
|
#define TELEM_QUEUE_SIZE 20
|
||||||
|
#define PIOS_TELEM_STACK_SIZE 2048
|
||||||
|
|
||||||
|
/* Stabilization options */
|
||||||
|
#define PIOS_QUATERNION_STABILIZATION
|
||||||
|
|
||||||
|
/* GPS options */
|
||||||
|
#define PIOS_GPS_SETS_HOMELOCATION
|
||||||
|
|
||||||
|
#define HEAP_LIMIT_WARNING 4000
|
||||||
|
#define HEAP_LIMIT_CRITICAL 1000
|
||||||
|
#define IRQSTACK_LIMIT_WARNING 150
|
||||||
|
#define IRQSTACK_LIMIT_CRITICAL 80
|
||||||
|
#define CPULOAD_LIMIT_WARNING 80
|
||||||
|
#define CPULOAD_LIMIT_CRITICAL 95
|
||||||
|
|
||||||
|
#define REVOLUTION
|
||||||
|
|
||||||
|
#endif /* PIOS_CONFIG_POSIX_H */
|
46
flight/RevoMini/System/inc/pios_usb_board_data.h
Normal file
46
flight/RevoMini/System/inc/pios_usb_board_data.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||||
|
* @{
|
||||||
|
* @addtogroup PIOS_USB_BOARD Board specific USB definitions
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_usb_board_data.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PIOS_USB_BOARD_DATA_H
|
||||||
|
#define PIOS_USB_BOARD_DATA_H
|
||||||
|
|
||||||
|
#define PIOS_USB_BOARD_CDC_DATA_LENGTH 64
|
||||||
|
#define PIOS_USB_BOARD_CDC_MGMT_LENGTH 32
|
||||||
|
#define PIOS_USB_BOARD_HID_DATA_LENGTH 64
|
||||||
|
|
||||||
|
#define PIOS_USB_BOARD_EP_NUM 4
|
||||||
|
|
||||||
|
#include "pios_usb_defs.h" /* USB_* macros */
|
||||||
|
|
||||||
|
#define PIOS_USB_BOARD_PRODUCT_ID USB_PRODUCT_ID_REVOLUTION
|
||||||
|
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(USB_OP_BOARD_ID_REVOLUTION, USB_OP_BOARD_MODE_FW)
|
||||||
|
#define PIOS_USB_BOARD_SN_SUFFIX "+FW"
|
||||||
|
|
||||||
|
#endif /* PIOS_USB_BOARD_DATA_H */
|
885
flight/RevoMini/System/pios_board.c
Normal file
885
flight/RevoMini/System/pios_board.c
Normal file
@ -0,0 +1,885 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup Revolution Revolution configuration files
|
||||||
|
* @{
|
||||||
|
* @brief Configures the revolution board
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_board.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||||
|
* @brief Defines board specific static initializers for hardware for the Revolution board.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Pull in the board-specific static HW definitions.
|
||||||
|
* Including .c files is a bit ugly but this allows all of
|
||||||
|
* the HW definitions to be const and static to limit their
|
||||||
|
* scope.
|
||||||
|
*
|
||||||
|
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
|
||||||
|
*/
|
||||||
|
#include "board_hw_defs.c"
|
||||||
|
|
||||||
|
#include <pios.h>
|
||||||
|
#include <openpilot.h>
|
||||||
|
#include <uavobjectsinit.h>
|
||||||
|
#include "hwsettings.h"
|
||||||
|
#include "manualcontrolsettings.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sensor configurations
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_ADC)
|
||||||
|
#include "pios_adc_priv.h"
|
||||||
|
void PIOS_ADC_DMC_irq_handler(void);
|
||||||
|
void DMA2_Stream4_IRQHandler(void) __attribute__((alias("PIOS_ADC_DMC_irq_handler")));
|
||||||
|
struct pios_adc_cfg pios_adc_cfg = {
|
||||||
|
.adc_dev = ADC1,
|
||||||
|
.dma = {
|
||||||
|
.irq = {
|
||||||
|
.flags = (DMA_FLAG_TCIF4 | DMA_FLAG_TEIF4 | DMA_FLAG_HTIF4),
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = DMA2_Stream4_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.channel = DMA2_Stream4,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & ADC1->DR
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.half_flag = DMA_IT_HTIF4,
|
||||||
|
.full_flag = DMA_IT_TCIF4,
|
||||||
|
|
||||||
|
};
|
||||||
|
void PIOS_ADC_DMC_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_ADC_DMA_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_HMC5883)
|
||||||
|
#include "pios_hmc5883.h"
|
||||||
|
static const struct pios_exti_cfg pios_exti_hmc5883_cfg __exti_config = {
|
||||||
|
.vector = PIOS_HMC5883_IRQHandler,
|
||||||
|
.line = EXTI_Line5,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_5,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_IN,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = EXTI9_5_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.exti = {
|
||||||
|
.init = {
|
||||||
|
.EXTI_Line = EXTI_Line5, // matches above GPIO pin
|
||||||
|
.EXTI_Mode = EXTI_Mode_Interrupt,
|
||||||
|
.EXTI_Trigger = EXTI_Trigger_Rising,
|
||||||
|
.EXTI_LineCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_hmc5883_cfg pios_hmc5883_cfg = {
|
||||||
|
.exti_cfg = &pios_exti_hmc5883_cfg,
|
||||||
|
.M_ODR = PIOS_HMC5883_ODR_75,
|
||||||
|
.Meas_Conf = PIOS_HMC5883_MEASCONF_NORMAL,
|
||||||
|
.Gain = PIOS_HMC5883_GAIN_1_9,
|
||||||
|
.Mode = PIOS_HMC5883_MODE_CONTINUOUS,
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_HMC5883 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for the MS5611 chip
|
||||||
|
*/
|
||||||
|
#if defined(PIOS_INCLUDE_MS5611)
|
||||||
|
#include "pios_ms5611.h"
|
||||||
|
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||||
|
.oversampling = 1,
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_MS5611 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for the BMA180 chip
|
||||||
|
*/
|
||||||
|
#if defined(PIOS_INCLUDE_BMA180)
|
||||||
|
#include "pios_bma180.h"
|
||||||
|
static const struct pios_exti_cfg pios_exti_bma180_cfg __exti_config = {
|
||||||
|
.vector = PIOS_BMA180_IRQHandler,
|
||||||
|
.line = EXTI_Line4,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_4,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_IN,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = EXTI4_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.exti = {
|
||||||
|
.init = {
|
||||||
|
.EXTI_Line = EXTI_Line4, // matches above GPIO pin
|
||||||
|
.EXTI_Mode = EXTI_Mode_Interrupt,
|
||||||
|
.EXTI_Trigger = EXTI_Trigger_Rising,
|
||||||
|
.EXTI_LineCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
static const struct pios_bma180_cfg pios_bma180_cfg = {
|
||||||
|
.exti_cfg = &pios_exti_bma180_cfg,
|
||||||
|
.bandwidth = BMA_BW_600HZ,
|
||||||
|
.range = BMA_RANGE_8G,
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_BMA180 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for the MPU6000 chip
|
||||||
|
*/
|
||||||
|
#if defined(PIOS_INCLUDE_MPU6000)
|
||||||
|
#include "pios_mpu6000.h"
|
||||||
|
static const struct pios_exti_cfg pios_exti_mpu6000_cfg __exti_config = {
|
||||||
|
.vector = PIOS_MPU6000_IRQHandler,
|
||||||
|
.line = EXTI_Line8,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_8,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_IN,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = EXTI9_5_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.exti = {
|
||||||
|
.init = {
|
||||||
|
.EXTI_Line = EXTI_Line8, // matches above GPIO pin
|
||||||
|
.EXTI_Mode = EXTI_Mode_Interrupt,
|
||||||
|
.EXTI_Trigger = EXTI_Trigger_Rising,
|
||||||
|
.EXTI_LineCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_mpu6000_cfg pios_mpu6000_cfg = {
|
||||||
|
.exti_cfg = &pios_exti_mpu6000_cfg,
|
||||||
|
.Fifo_store = PIOS_MPU6000_FIFO_TEMP_OUT | PIOS_MPU6000_FIFO_GYRO_X_OUT | PIOS_MPU6000_FIFO_GYRO_Y_OUT | PIOS_MPU6000_FIFO_GYRO_Z_OUT,
|
||||||
|
// Clock at 8 khz, downsampled by 8 for 1khz
|
||||||
|
.Smpl_rate_div = 11,
|
||||||
|
.interrupt_cfg = PIOS_MPU6000_INT_CLR_ANYRD,
|
||||||
|
.interrupt_en = PIOS_MPU6000_INTEN_DATA_RDY,
|
||||||
|
.User_ctl = PIOS_MPU6000_USERCTL_FIFO_EN | PIOS_MPU6000_USERCTL_DIS_I2C,
|
||||||
|
.Pwr_mgmt_clk = PIOS_MPU6000_PWRMGMT_PLL_X_CLK,
|
||||||
|
.accel_range = PIOS_MPU6000_ACCEL_8G,
|
||||||
|
.gyro_range = PIOS_MPU6000_SCALE_500_DEG,
|
||||||
|
.filter = PIOS_MPU6000_LOWPASS_256_HZ
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_MPU6000 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for L3GD20 chip
|
||||||
|
*/
|
||||||
|
#if defined(PIOS_INCLUDE_L3GD20)
|
||||||
|
#include "pios_l3gd20.h"
|
||||||
|
static const struct pios_exti_cfg pios_exti_l3gd20_cfg __exti_config = {
|
||||||
|
.vector = PIOS_L3GD20_IRQHandler,
|
||||||
|
.line = EXTI_Line8,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_8,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_IN,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = EXTI9_5_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.exti = {
|
||||||
|
.init = {
|
||||||
|
.EXTI_Line = EXTI_Line8, // matches above GPIO pin
|
||||||
|
.EXTI_Mode = EXTI_Mode_Interrupt,
|
||||||
|
.EXTI_Trigger = EXTI_Trigger_Rising,
|
||||||
|
.EXTI_LineCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_l3gd20_cfg pios_l3gd20_cfg = {
|
||||||
|
.exti_cfg = &pios_exti_l3gd20_cfg,
|
||||||
|
.range = PIOS_L3GD20_SCALE_500_DEG,
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_L3GD20 */
|
||||||
|
|
||||||
|
|
||||||
|
static const struct flashfs_cfg flashfs_m25p_cfg = {
|
||||||
|
.table_magic = 0x85FB3D35,
|
||||||
|
.obj_magic = 0x3015A371,
|
||||||
|
.obj_table_start = 0x00000010,
|
||||||
|
.obj_table_end = 0x00010000,
|
||||||
|
.sector_size = 0x00010000,
|
||||||
|
.chip_size = 0x00200000,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_flash_jedec_cfg flash_m25p_cfg = {
|
||||||
|
.sector_erase = 0xD8,
|
||||||
|
.chip_erase = 0xC7
|
||||||
|
};
|
||||||
|
|
||||||
|
/* One slot per selectable receiver group.
|
||||||
|
* eg. PWM, PPM, GCS, SPEKTRUM1, SPEKTRUM2, SBUS
|
||||||
|
* NOTE: No slot in this map for NONE.
|
||||||
|
*/
|
||||||
|
uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE];
|
||||||
|
|
||||||
|
#define PIOS_COM_TELEM_RF_RX_BUF_LEN 512
|
||||||
|
#define PIOS_COM_TELEM_RF_TX_BUF_LEN 512
|
||||||
|
|
||||||
|
#define PIOS_COM_GPS_RX_BUF_LEN 32
|
||||||
|
|
||||||
|
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 65
|
||||||
|
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 65
|
||||||
|
|
||||||
|
#define PIOS_COM_BRIDGE_RX_BUF_LEN 65
|
||||||
|
#define PIOS_COM_BRIDGE_TX_BUF_LEN 12
|
||||||
|
|
||||||
|
#define PIOS_COM_AUX_RX_BUF_LEN 512
|
||||||
|
#define PIOS_COM_AUX_TX_BUF_LEN 512
|
||||||
|
|
||||||
|
uint32_t pios_com_aux_id = 0;
|
||||||
|
uint32_t pios_com_gps_id = 0;
|
||||||
|
uint32_t pios_com_telem_usb_id = 0;
|
||||||
|
uint32_t pios_com_telem_rf_id = 0;
|
||||||
|
uint32_t pios_com_bridge_id = 0;
|
||||||
|
uint32_t pios_com_overo_id = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup a com port based on the passed cfg, driver and buffer sizes. tx size of -1 make the port rx only
|
||||||
|
*/
|
||||||
|
static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg, size_t rx_buf_len, size_t tx_buf_len,
|
||||||
|
const struct pios_com_driver *com_driver, uint32_t *pios_com_id)
|
||||||
|
{
|
||||||
|
uint32_t pios_usart_id;
|
||||||
|
if (PIOS_USART_Init(&pios_usart_id, usart_port_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(rx_buf_len);
|
||||||
|
PIOS_Assert(rx_buffer);
|
||||||
|
if(tx_buf_len!= -1){ // this is the case for rx/tx ports
|
||||||
|
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(tx_buf_len);
|
||||||
|
PIOS_Assert(tx_buffer);
|
||||||
|
|
||||||
|
if (PIOS_COM_Init(pios_com_id, com_driver, pios_usart_id,
|
||||||
|
rx_buffer, rx_buf_len,
|
||||||
|
tx_buffer, tx_buf_len)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{ //rx only port
|
||||||
|
if (PIOS_COM_Init(pios_com_id, com_driver, pios_usart_id,
|
||||||
|
rx_buffer, rx_buf_len,
|
||||||
|
NULL, 0)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PIOS_Board_configure_dsm(const struct pios_usart_cfg *pios_usart_dsm_cfg, const struct pios_dsm_cfg *pios_dsm_cfg,
|
||||||
|
const struct pios_com_driver *pios_usart_com_driver,enum pios_dsm_proto *proto,
|
||||||
|
ManualControlSettingsChannelGroupsOptions channelgroup,uint8_t *bind)
|
||||||
|
{
|
||||||
|
uint32_t pios_usart_dsm_id;
|
||||||
|
if (PIOS_USART_Init(&pios_usart_dsm_id, pios_usart_dsm_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t pios_dsm_id;
|
||||||
|
if (PIOS_DSM_Init(&pios_dsm_id, pios_dsm_cfg, pios_usart_com_driver,
|
||||||
|
pios_usart_dsm_id, *proto, *bind)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t pios_dsm_rcvr_id;
|
||||||
|
if (PIOS_RCVR_Init(&pios_dsm_rcvr_id, &pios_dsm_rcvr_driver, pios_dsm_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
pios_rcvr_group_map[channelgroup] = pios_dsm_rcvr_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PIOS_Board_Init()
|
||||||
|
* initializes all the core subsystems on this specific hardware
|
||||||
|
* called from System/openpilot.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pios_board_info.h>
|
||||||
|
|
||||||
|
void PIOS_Board_Init(void) {
|
||||||
|
|
||||||
|
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||||
|
|
||||||
|
/* Delay system */
|
||||||
|
PIOS_DELAY_Init();
|
||||||
|
|
||||||
|
PIOS_LED_Init(&pios_led_cfg);
|
||||||
|
|
||||||
|
/* Set up the SPI interface to the accelerometer*/
|
||||||
|
if (PIOS_SPI_Init(&pios_spi_accel_id, &pios_spi_accel_cfg)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set up the SPI interface to the gyro */
|
||||||
|
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
#if !defined(PIOS_FLASH_ON_ACCEL)
|
||||||
|
/* Set up the SPI interface to the flash */
|
||||||
|
if (PIOS_SPI_Init(&pios_spi_flash_id, &pios_spi_flash_cfg)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
PIOS_Flash_Jedec_Init(pios_spi_flash_id, 0, &flash_m25p_cfg);
|
||||||
|
#else
|
||||||
|
PIOS_Flash_Jedec_Init(pios_spi_accel_id, 1, &flash_m25p_cfg);
|
||||||
|
#endif
|
||||||
|
PIOS_FLASHFS_Init(&flashfs_m25p_cfg);
|
||||||
|
|
||||||
|
/* Initialize UAVObject libraries */
|
||||||
|
EventDispatcherInitialize();
|
||||||
|
UAVObjInitialize();
|
||||||
|
|
||||||
|
HwSettingsInitialize();
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_RTC)
|
||||||
|
PIOS_RTC_Init(&pios_rtc_main_cfg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize the alarms library */
|
||||||
|
AlarmsInitialize();
|
||||||
|
|
||||||
|
/* Initialize the task monitor library */
|
||||||
|
TaskMonitorInitialize();
|
||||||
|
|
||||||
|
/* Set up pulse timers */
|
||||||
|
PIOS_TIM_InitClock(&tim_1_cfg);
|
||||||
|
PIOS_TIM_InitClock(&tim_3_cfg);
|
||||||
|
PIOS_TIM_InitClock(&tim_4_cfg);
|
||||||
|
PIOS_TIM_InitClock(&tim_5_cfg);
|
||||||
|
PIOS_TIM_InitClock(&tim_9_cfg);
|
||||||
|
PIOS_TIM_InitClock(&tim_10_cfg);
|
||||||
|
PIOS_TIM_InitClock(&tim_11_cfg);
|
||||||
|
|
||||||
|
/* IAP System Setup */
|
||||||
|
PIOS_IAP_Init();
|
||||||
|
uint16_t boot_count = PIOS_IAP_ReadBootCount();
|
||||||
|
if (boot_count < 3) {
|
||||||
|
PIOS_IAP_WriteBootCount(++boot_count);
|
||||||
|
AlarmsClear(SYSTEMALARMS_ALARM_BOOTFAULT);
|
||||||
|
} else {
|
||||||
|
/* Too many failed boot attempts, force hwsettings to defaults */
|
||||||
|
HwSettingsSetDefaults(HwSettingsHandle(), 0);
|
||||||
|
AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//PIOS_IAP_Init();
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB)
|
||||||
|
/* Initialize board specific USB data */
|
||||||
|
PIOS_USB_BOARD_DATA_Init();
|
||||||
|
|
||||||
|
/* Flags to determine if various USB interfaces are advertised */
|
||||||
|
bool usb_hid_present = false;
|
||||||
|
bool usb_cdc_present = false;
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||||
|
if (PIOS_USB_DESC_HID_CDC_Init()) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
usb_hid_present = true;
|
||||||
|
usb_cdc_present = true;
|
||||||
|
#else
|
||||||
|
if (PIOS_USB_DESC_HID_ONLY_Init()) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
usb_hid_present = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t pios_usb_id;
|
||||||
|
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||||
|
|
||||||
|
uint8_t hwsettings_usb_vcpport;
|
||||||
|
/* Configure the USB VCP port */
|
||||||
|
HwSettingsUSB_VCPPortGet(&hwsettings_usb_vcpport);
|
||||||
|
|
||||||
|
if (!usb_cdc_present) {
|
||||||
|
/* Force VCP port function to disabled if we haven't advertised VCP in our USB descriptor */
|
||||||
|
hwsettings_usb_vcpport = HWSETTINGS_USB_VCPPORT_DISABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (hwsettings_usb_vcpport) {
|
||||||
|
case HWSETTINGS_USB_VCPPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_USB_VCPPORT_USBTELEMETRY:
|
||||||
|
#if defined(PIOS_INCLUDE_COM)
|
||||||
|
PIOS_Board_configure_com(&pios_usb_cdc_cfg, PIOS_COM_TELEM_USB_RX_BUF_LEN, PIOS_COM_TELEM_USB_TX_BUF_LEN, &pios_usb_cdc_com_driver, &pios_com_telem_usb_id);
|
||||||
|
#endif /* PIOS_INCLUDE_COM */
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_USB_VCPPORT_COMBRIDGE:
|
||||||
|
#if defined(PIOS_INCLUDE_COM)
|
||||||
|
PIOS_Board_configure_com(&pios_usb_cdc_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usb_cdc_com_driver, &pios_com_vcp_id);
|
||||||
|
#endif /* PIOS_INCLUDE_COM */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_USB_CDC */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB_HID)
|
||||||
|
/* Configure the usb HID port */
|
||||||
|
uint8_t hwsettings_usb_hidport;
|
||||||
|
HwSettingsUSB_HIDPortGet(&hwsettings_usb_hidport);
|
||||||
|
|
||||||
|
if (!usb_hid_present) {
|
||||||
|
/* Force HID port function to disabled if we haven't advertised HID in our USB descriptor */
|
||||||
|
hwsettings_usb_hidport = HWSETTINGS_USB_HIDPORT_DISABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (hwsettings_usb_hidport) {
|
||||||
|
case HWSETTINGS_USB_HIDPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_USB_HIDPORT_USBTELEMETRY:
|
||||||
|
#if defined(PIOS_INCLUDE_COM)
|
||||||
|
{
|
||||||
|
uint32_t pios_usb_hid_id;
|
||||||
|
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
|
||||||
|
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
|
||||||
|
PIOS_Assert(rx_buffer);
|
||||||
|
PIOS_Assert(tx_buffer);
|
||||||
|
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
|
||||||
|
rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN,
|
||||||
|
tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_COM */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_USB_HID */
|
||||||
|
|
||||||
|
if (usb_hid_present || usb_cdc_present) {
|
||||||
|
PIOS_USBHOOK_Activate();
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_USB */
|
||||||
|
|
||||||
|
/* Configure IO ports */
|
||||||
|
uint8_t hwsettings_DSMxBind;
|
||||||
|
HwSettingsDSMxBindGet(&hwsettings_DSMxBind);
|
||||||
|
|
||||||
|
/* Configure Telemetry port */
|
||||||
|
uint8_t hwsettings_rv_telemetryport;
|
||||||
|
HwSettingsRV_TelemetryPortGet(&hwsettings_rv_telemetryport);
|
||||||
|
|
||||||
|
switch (hwsettings_rv_telemetryport){
|
||||||
|
case HWSETTINGS_RV_TELEMETRYPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_TELEMETRYPORT_TELEMETRY:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_telem_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id);
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_TELEMETRYPORT_COMAUX:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_telem_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_aux_id);
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_TELEMETRYPORT_COMBRIDGE:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_telem_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_bridge_id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
} /* hwsettings_rv_telemetryport */
|
||||||
|
|
||||||
|
/* Configure GPS port */
|
||||||
|
uint8_t hwsettings_rv_gpsport;
|
||||||
|
HwSettingsRV_GPSPortGet(&hwsettings_rv_gpsport);
|
||||||
|
switch (hwsettings_rv_gpsport){
|
||||||
|
case HWSETTINGS_RV_GPSPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_GPSPORT_TELEMETRY:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_gps_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_GPSPORT_GPS:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_gps_cfg, PIOS_COM_GPS_RX_BUF_LEN, -1, &pios_usart_com_driver, &pios_com_gps_id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_GPSPORT_COMAUX:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_gps_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_aux_id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_GPSPORT_COMBRIDGE:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_gps_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_bridge_id);
|
||||||
|
break;
|
||||||
|
}/* hwsettings_rv_gpsport */
|
||||||
|
|
||||||
|
/* Configure AUXPort */
|
||||||
|
uint8_t hwsettings_rv_auxport;
|
||||||
|
HwSettingsRV_AuxPortGet(&hwsettings_rv_auxport);
|
||||||
|
|
||||||
|
switch (hwsettings_rv_auxport) {
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_AUXPORT_TELEMETRY:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_aux_cfg, PIOS_COM_TELEM_RF_RX_BUF_LEN, PIOS_COM_TELEM_RF_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_telem_rf_id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DSM2:
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DSMX10BIT:
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DSMX11BIT:
|
||||||
|
{
|
||||||
|
enum pios_dsm_proto proto;
|
||||||
|
switch (hwsettings_rv_auxport) {
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DSM2:
|
||||||
|
proto = PIOS_DSM_PROTO_DSM2;
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DSMX10BIT:
|
||||||
|
proto = PIOS_DSM_PROTO_DSMX10BIT;
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXPORT_DSMX11BIT:
|
||||||
|
proto = PIOS_DSM_PROTO_DSMX11BIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PIOS_Assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//TODO: Define the various Channelgroup for Revo dsm inputs and handle here
|
||||||
|
PIOS_Board_configure_dsm(&pios_usart_dsm_aux_cfg, &pios_dsm_aux_cfg,
|
||||||
|
&pios_usart_com_driver, &proto, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT,&hwsettings_DSMxBind);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXPORT_COMAUX:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_aux_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_aux_id);
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXPORT_COMBRIDGE:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_aux_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_bridge_id);
|
||||||
|
break;
|
||||||
|
} /* hwsettings_rv_auxport */
|
||||||
|
/* Configure AUXSbusPort */
|
||||||
|
//TODO: ensure that the serial invertion pin is setted correctly
|
||||||
|
uint8_t hwsettings_rv_auxsbusport;
|
||||||
|
HwSettingsRV_AuxSBusPortGet(&hwsettings_rv_auxsbusport);
|
||||||
|
|
||||||
|
switch (hwsettings_rv_auxsbusport) {
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_SBUS:
|
||||||
|
#ifdef PIOS_INCLUDE_SBUS
|
||||||
|
{
|
||||||
|
uint32_t pios_usart_sbus_id;
|
||||||
|
if (PIOS_USART_Init(&pios_usart_sbus_id, &pios_usart_sbus_auxsbus_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t pios_sbus_id;
|
||||||
|
if (PIOS_SBus_Init(&pios_sbus_id, &pios_sbus_cfg, &pios_usart_com_driver, pios_usart_sbus_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t pios_sbus_rcvr_id;
|
||||||
|
if (PIOS_RCVR_Init(&pios_sbus_rcvr_id, &pios_sbus_rcvr_driver, pios_sbus_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_SBUS] = pios_sbus_rcvr_id;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_SBUS */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DSM2:
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DSMX10BIT:
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DSMX11BIT:
|
||||||
|
{
|
||||||
|
enum pios_dsm_proto proto;
|
||||||
|
switch (hwsettings_rv_auxsbusport) {
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DSM2:
|
||||||
|
proto = PIOS_DSM_PROTO_DSM2;
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DSMX10BIT:
|
||||||
|
proto = PIOS_DSM_PROTO_DSMX10BIT;
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_DSMX11BIT:
|
||||||
|
proto = PIOS_DSM_PROTO_DSMX11BIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PIOS_Assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//TODO: Define the various Channelgroup for Revo dsm inputs and handle here
|
||||||
|
PIOS_Board_configure_dsm(&pios_usart_dsm_auxsbus_cfg, &pios_dsm_auxsbus_cfg,
|
||||||
|
&pios_usart_com_driver, &proto, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT,&hwsettings_DSMxBind);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_COMAUX:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_auxsbus_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_aux_id);
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_AUXSBUSPORT_COMBRIDGE:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_auxsbus_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_bridge_id);
|
||||||
|
break;
|
||||||
|
} /* hwsettings_rv_auxport */
|
||||||
|
|
||||||
|
/* Configure FlexiPort */
|
||||||
|
|
||||||
|
uint8_t hwsettings_rv_flexiport;
|
||||||
|
HwSettingsRV_FlexiPortGet(&hwsettings_rv_flexiport);
|
||||||
|
|
||||||
|
switch (hwsettings_rv_flexiport) {
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_I2C:
|
||||||
|
#if defined(PIOS_INCLUDE_I2C)
|
||||||
|
{
|
||||||
|
if (PIOS_I2C_Init(&pios_i2c_flexiport_adapter_id, &pios_i2c_flexiport_adapter_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_I2C */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DSM2:
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DSMX10BIT:
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DSMX11BIT:
|
||||||
|
{
|
||||||
|
enum pios_dsm_proto proto;
|
||||||
|
switch (hwsettings_rv_flexiport) {
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DSM2:
|
||||||
|
proto = PIOS_DSM_PROTO_DSM2;
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DSMX10BIT:
|
||||||
|
proto = PIOS_DSM_PROTO_DSMX10BIT;
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_DSMX11BIT:
|
||||||
|
proto = PIOS_DSM_PROTO_DSMX11BIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PIOS_Assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//TODO: Define the various Channelgroup for Revo dsm inputs and handle here
|
||||||
|
PIOS_Board_configure_dsm(&pios_usart_dsm_flexi_cfg, &pios_dsm_flexi_cfg,
|
||||||
|
&pios_usart_com_driver, &proto, MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT,&hwsettings_DSMxBind);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_COMAUX:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_AUX_RX_BUF_LEN, PIOS_COM_AUX_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_aux_id);
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_FLEXIPORT_COMBRIDGE:
|
||||||
|
PIOS_Board_configure_com(&pios_usart_flexi_cfg, PIOS_COM_BRIDGE_RX_BUF_LEN, PIOS_COM_BRIDGE_TX_BUF_LEN, &pios_usart_com_driver, &pios_com_bridge_id);
|
||||||
|
break;
|
||||||
|
} /* hwsettings_rv_flexiport */
|
||||||
|
|
||||||
|
|
||||||
|
/* Configure the receiver port*/
|
||||||
|
uint8_t hwsettings_rcvrport;
|
||||||
|
HwSettingsRV_RcvrPortGet(&hwsettings_rcvrport);
|
||||||
|
//
|
||||||
|
switch (hwsettings_rcvrport){
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_DISABLED:
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_PWM:
|
||||||
|
#if defined(PIOS_INCLUDE_PWM)
|
||||||
|
{
|
||||||
|
/* Set up the receiver port. Later this should be optional */
|
||||||
|
uint32_t pios_pwm_id;
|
||||||
|
PIOS_PWM_Init(&pios_pwm_id, &pios_pwm_cfg);
|
||||||
|
|
||||||
|
uint32_t pios_pwm_rcvr_id;
|
||||||
|
if (PIOS_RCVR_Init(&pios_pwm_rcvr_id, &pios_pwm_rcvr_driver, pios_pwm_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_PWM] = pios_pwm_rcvr_id;
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_PWM */
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_PPM:
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_PPMOUTPUTS:
|
||||||
|
#if defined(PIOS_INCLUDE_PPM)
|
||||||
|
{
|
||||||
|
uint32_t pios_ppm_id;
|
||||||
|
PIOS_PPM_Init(&pios_ppm_id, &pios_ppm_cfg);
|
||||||
|
|
||||||
|
uint32_t pios_ppm_rcvr_id;
|
||||||
|
if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, pios_ppm_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_PPM] = pios_ppm_rcvr_id;
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_PPM */
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_OUTPUTS:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PIOS_OVERO_SPI)
|
||||||
|
/* Set up the SPI based PIOS_COM interface to the overo */
|
||||||
|
{
|
||||||
|
HwSettingsData hwSettings;
|
||||||
|
HwSettingsGet(&hwSettings);
|
||||||
|
if(hwSettings.OptionalModules[HWSETTINGS_OPTIONALMODULES_OVERO] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
|
||||||
|
if (PIOS_OVERO_Init(&pios_overo_id, &pios_overo_cfg)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
const uint32_t PACKET_SIZE = 1024;
|
||||||
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PACKET_SIZE);
|
||||||
|
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PACKET_SIZE);
|
||||||
|
PIOS_Assert(rx_buffer);
|
||||||
|
PIOS_Assert(tx_buffer);
|
||||||
|
if (PIOS_COM_Init(&pios_com_overo_id, &pios_overo_com_driver, pios_overo_id,
|
||||||
|
rx_buffer, PACKET_SIZE,
|
||||||
|
tx_buffer, PACKET_SIZE)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||||
|
GCSReceiverInitialize();
|
||||||
|
uint32_t pios_gcsrcvr_id;
|
||||||
|
PIOS_GCSRCVR_Init(&pios_gcsrcvr_id);
|
||||||
|
uint32_t pios_gcsrcvr_rcvr_id;
|
||||||
|
if (PIOS_RCVR_Init(&pios_gcsrcvr_rcvr_id, &pios_gcsrcvr_rcvr_driver, pios_gcsrcvr_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
|
||||||
|
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||||
|
|
||||||
|
#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
|
||||||
|
switch (hwsettings_rcvrport) {
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_DISABLED:
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_PWM:
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_PPM:
|
||||||
|
/* Set up the servo outputs */
|
||||||
|
PIOS_Servo_Init(&pios_servo_cfg);
|
||||||
|
break;
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_PPMOUTPUTS:
|
||||||
|
case HWSETTINGS_RV_RCVRPORT_OUTPUTS:
|
||||||
|
//PIOS_Servo_Init(&pios_servo_rcvr_cfg);
|
||||||
|
//TODO: Prepare the configurations on board_hw_defs and handle here:
|
||||||
|
PIOS_Servo_Init(&pios_servo_cfg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (PIOS_I2C_Init(&pios_i2c_mag_adapter_id, &pios_i2c_mag_adapter_cfg)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PIOS_I2C_Init(&pios_i2c_pressure_adapter_id, &pios_i2c_pressure_adapter_cfg)) {
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
PIOS_DELAY_WaitmS(50);
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_ADC)
|
||||||
|
PIOS_ADC_Init(&pios_adc_cfg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_HMC5883)
|
||||||
|
PIOS_HMC5883_Init(&pios_hmc5883_cfg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_MS5611)
|
||||||
|
PIOS_MS5611_Init(&pios_ms5611_cfg, pios_i2c_pressure_adapter_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch(bdinfo->board_rev) {
|
||||||
|
case 0x01:
|
||||||
|
#if defined(PIOS_INCLUDE_L3GD20)
|
||||||
|
PIOS_L3GD20_Init(pios_spi_gyro_id, 0, &pios_l3gd20_cfg);
|
||||||
|
PIOS_Assert(PIOS_L3GD20_Test() == 0);
|
||||||
|
#endif
|
||||||
|
#if defined(PIOS_INCLUDE_BMA180)
|
||||||
|
PIOS_BMA180_Init(pios_spi_accel_id, 0, &pios_bma180_cfg);
|
||||||
|
PIOS_Assert(PIOS_BMA180_Test() == 0);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case 0x02:
|
||||||
|
#if defined(PIOS_INCLUDE_MPU6000)
|
||||||
|
PIOS_MPU6000_Init(pios_spi_gyro_id,0, &pios_mpu6000_cfg);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PIOS_DEBUG_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
229
flight/RevoMini/System/pios_board_sim.c
Normal file
229
flight/RevoMini/System/pios_board_sim.c
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file pios_board.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Defines board specific static initializers for hardware for the OpenPilot board.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pios.h>
|
||||||
|
#include <pios_com_priv.h>
|
||||||
|
#include <pios_tcp_priv.h>
|
||||||
|
#include <pios_udp_priv.h>
|
||||||
|
#include <openpilot.h>
|
||||||
|
#include <uavobjectsinit.h>
|
||||||
|
|
||||||
|
#include "accels.h"
|
||||||
|
#include "baroaltitude.h"
|
||||||
|
#include "gpsposition.h"
|
||||||
|
#include "gyros.h"
|
||||||
|
#include "gyrosbias.h"
|
||||||
|
#include "magnetometer.h"
|
||||||
|
#include "manualcontrolsettings.h"
|
||||||
|
|
||||||
|
#include "pios_rcvr_priv.h"
|
||||||
|
#include "pios_gcsrcvr_priv.h"
|
||||||
|
|
||||||
|
void Stack_Change() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stack_Change_Weak() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const struct pios_tcp_cfg pios_tcp_telem_cfg = {
|
||||||
|
.ip = "0.0.0.0",
|
||||||
|
.port = 9001,
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct pios_udp_cfg pios_udp_telem_cfg = {
|
||||||
|
.ip = "0.0.0.0",
|
||||||
|
.port = 9001,
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct pios_tcp_cfg pios_tcp_gps_cfg = {
|
||||||
|
.ip = "0.0.0.0",
|
||||||
|
.port = 9001,
|
||||||
|
};
|
||||||
|
const struct pios_tcp_cfg pios_tcp_debug_cfg = {
|
||||||
|
.ip = "0.0.0.0",
|
||||||
|
.port = 9002,
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef PIOS_COM_AUX
|
||||||
|
/*
|
||||||
|
* AUX USART
|
||||||
|
*/
|
||||||
|
const struct pios_tcp_cfg pios_tcp_aux_cfg = {
|
||||||
|
.ip = "0.0.0.0",
|
||||||
|
.port = 9003,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PIOS_COM_TELEM_RF_RX_BUF_LEN 192
|
||||||
|
#define PIOS_COM_TELEM_RF_TX_BUF_LEN 192
|
||||||
|
#define PIOS_COM_GPS_RX_BUF_LEN 96
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Board specific number of devices.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
struct pios_udp_dev pios_udp_devs[] = {
|
||||||
|
#define PIOS_UDP_TELEM 0
|
||||||
|
{
|
||||||
|
.cfg = &pios_udp0_cfg,
|
||||||
|
},
|
||||||
|
#define PIOS_UDP_GPS 1
|
||||||
|
{
|
||||||
|
.cfg = &pios_udp1_cfg,
|
||||||
|
},
|
||||||
|
#define PIOS_UDP_LOCAL 2
|
||||||
|
{
|
||||||
|
.cfg = &pios_udp2_cfg,
|
||||||
|
},
|
||||||
|
#ifdef PIOS_COM_AUX
|
||||||
|
#define PIOS_UDP_AUX 3
|
||||||
|
{
|
||||||
|
.cfg = &pios_udp3_cfg,
|
||||||
|
},
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t pios_udp_num_devices = NELEMENTS(pios_udp_devs);
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* COM devices
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Board specific number of devices.
|
||||||
|
*/
|
||||||
|
extern const struct pios_com_driver pios_serial_com_driver;
|
||||||
|
extern const struct pios_com_driver pios_udp_com_driver;
|
||||||
|
extern const struct pios_com_driver pios_tcp_com_driver;
|
||||||
|
|
||||||
|
uint32_t pios_com_telem_rf_id;
|
||||||
|
uint32_t pios_com_telem_usb_id;
|
||||||
|
uint32_t pios_com_gps_id;
|
||||||
|
uint32_t pios_com_aux_id;
|
||||||
|
uint32_t pios_com_spectrum_id;
|
||||||
|
uint32_t pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PIOS_Board_Init()
|
||||||
|
* initializes all the core systems on this specific hardware
|
||||||
|
* called from System/openpilot.c
|
||||||
|
*/
|
||||||
|
void PIOS_Board_Init(void) {
|
||||||
|
|
||||||
|
/* Delay system */
|
||||||
|
PIOS_DELAY_Init();
|
||||||
|
|
||||||
|
/* Initialize UAVObject libraries */
|
||||||
|
EventDispatcherInitialize();
|
||||||
|
UAVObjInitialize();
|
||||||
|
UAVObjectsInitializeAll();
|
||||||
|
|
||||||
|
AccelsInitialize();
|
||||||
|
BaroAltitudeInitialize();
|
||||||
|
MagnetometerInitialize();
|
||||||
|
GPSPositionInitialize();
|
||||||
|
GyrosInitialize();
|
||||||
|
GyrosBiasInitialize();
|
||||||
|
|
||||||
|
/* Initialize the alarms library */
|
||||||
|
AlarmsInitialize();
|
||||||
|
|
||||||
|
/* Initialize the task monitor library */
|
||||||
|
TaskMonitorInitialize();
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_COM)
|
||||||
|
#if defined(PIOS_INCLUDE_TELEMETRY_RF) && 1
|
||||||
|
{
|
||||||
|
uint32_t pios_tcp_telem_rf_id;
|
||||||
|
if (PIOS_TCP_Init(&pios_tcp_telem_rf_id, &pios_tcp_telem_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
|
||||||
|
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
|
||||||
|
PIOS_Assert(rx_buffer);
|
||||||
|
PIOS_Assert(tx_buffer);
|
||||||
|
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_tcp_com_driver, pios_tcp_telem_rf_id,
|
||||||
|
rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN,
|
||||||
|
tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_TELEMETRY_RF) && 0
|
||||||
|
{
|
||||||
|
uint32_t pios_udp_telem_rf_id;
|
||||||
|
if (PIOS_UDP_Init(&pios_udp_telem_rf_id, &pios_udp_telem_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
|
||||||
|
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
|
||||||
|
PIOS_Assert(rx_buffer);
|
||||||
|
PIOS_Assert(tx_buffer);
|
||||||
|
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_udp_com_driver, pios_udp_telem_rf_id,
|
||||||
|
rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN,
|
||||||
|
tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_GPS)
|
||||||
|
{
|
||||||
|
uint32_t pios_tcp_gps_id;
|
||||||
|
if (PIOS_TCP_Init(&pios_tcp_gps_id, &pios_tcp_gps_cfg)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN);
|
||||||
|
PIOS_Assert(rx_buffer);
|
||||||
|
if (PIOS_COM_Init(&pios_com_gps_id, &pios_tcp_com_driver, pios_tcp_gps_id,
|
||||||
|
rx_buffer, PIOS_COM_GPS_RX_BUF_LEN,
|
||||||
|
NULL, 0)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_GPS */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||||
|
GCSReceiverInitialize();
|
||||||
|
uint32_t pios_gcsrcvr_id;
|
||||||
|
PIOS_GCSRCVR_Init(&pios_gcsrcvr_id);
|
||||||
|
uint32_t pios_gcsrcvr_rcvr_id;
|
||||||
|
if (PIOS_RCVR_Init(&pios_gcsrcvr_rcvr_id, &pios_gcsrcvr_rcvr_driver, pios_gcsrcvr_id)) {
|
||||||
|
PIOS_Assert(0);
|
||||||
|
}
|
||||||
|
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
|
||||||
|
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
98
flight/RevoMini/System/pios_usb_board_data.c
Normal file
98
flight/RevoMini/System/pios_usb_board_data.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||||
|
* @{
|
||||||
|
* @addtogroup PIOS_USB_BOARD Board specific USB definitions
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file pios_usb_board_data.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Board specific USB definitions
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
|
||||||
|
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
|
||||||
|
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
|
||||||
|
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
|
||||||
|
|
||||||
|
static const uint8_t usb_product_id[22] = {
|
||||||
|
sizeof(usb_product_id),
|
||||||
|
USB_DESC_TYPE_STRING,
|
||||||
|
'R', 0,
|
||||||
|
'e', 0,
|
||||||
|
'v', 0,
|
||||||
|
'o', 0,
|
||||||
|
'l', 0,
|
||||||
|
'u', 0,
|
||||||
|
't', 0,
|
||||||
|
'i', 0,
|
||||||
|
'o', 0,
|
||||||
|
'n', 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
|
||||||
|
sizeof(usb_serial_number),
|
||||||
|
USB_DESC_TYPE_STRING,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct usb_string_langid usb_lang_id = {
|
||||||
|
.bLength = sizeof(usb_lang_id),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_STRING,
|
||||||
|
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t usb_vendor_id[28] = {
|
||||||
|
sizeof(usb_vendor_id),
|
||||||
|
USB_DESC_TYPE_STRING,
|
||||||
|
'o', 0,
|
||||||
|
'p', 0,
|
||||||
|
'e', 0,
|
||||||
|
'n', 0,
|
||||||
|
'p', 0,
|
||||||
|
'i', 0,
|
||||||
|
'l', 0,
|
||||||
|
'o', 0,
|
||||||
|
't', 0,
|
||||||
|
'.', 0,
|
||||||
|
'o', 0,
|
||||||
|
'r', 0,
|
||||||
|
'g', 0
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||||
|
{
|
||||||
|
/* Load device serial number into serial number string */
|
||||||
|
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
|
||||||
|
PIOS_SYS_SerialNumberGet((char *)sn);
|
||||||
|
|
||||||
|
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
|
||||||
|
uint8_t * utf8 = &(usb_serial_number[2]);
|
||||||
|
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
|
||||||
|
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
|
||||||
|
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
|
||||||
|
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
|
||||||
|
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
142
flight/RevoMini/System/revolution.c
Normal file
142
flight/RevoMini/System/revolution.c
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @brief These files are the core system files of OpenPilot.
|
||||||
|
* They are the ground layer just above PiOS. In practice, OpenPilot actually starts
|
||||||
|
* in the main() function of openpilot.c
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotCore OpenPilot Core
|
||||||
|
* @brief This is where the OP firmware starts. Those files also define the compile-time
|
||||||
|
* options of the firmware.
|
||||||
|
* @{
|
||||||
|
* @file openpilot.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Sets up and runs main OpenPilot tasks.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* OpenPilot Includes */
|
||||||
|
#include "openpilot.h"
|
||||||
|
#include "uavobjectsinit.h"
|
||||||
|
#include "systemmod.h"
|
||||||
|
|
||||||
|
/* Task Priorities */
|
||||||
|
#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3)
|
||||||
|
|
||||||
|
/* Global Variables */
|
||||||
|
|
||||||
|
/* Local Variables */
|
||||||
|
#define INCLUDE_TEST_TASKS 0
|
||||||
|
#if INCLUDE_TEST_TASKS
|
||||||
|
static uint8_t sdcard_available;
|
||||||
|
#endif
|
||||||
|
char Buffer[1024];
|
||||||
|
uint32_t Cache;
|
||||||
|
|
||||||
|
/* Function Prototypes */
|
||||||
|
#if INCLUDE_TEST_TASKS
|
||||||
|
static void TaskTick(void *pvParameters);
|
||||||
|
static void TaskTesting(void *pvParameters);
|
||||||
|
static void TaskHIDTest(void *pvParameters);
|
||||||
|
static void TaskServos(void *pvParameters);
|
||||||
|
static void TaskSDCard(void *pvParameters);
|
||||||
|
#endif
|
||||||
|
int32_t CONSOLE_Parse(uint8_t port, char c);
|
||||||
|
void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value);
|
||||||
|
|
||||||
|
/* Prototype of PIOS_Board_Init() function */
|
||||||
|
extern void PIOS_Board_Init(void);
|
||||||
|
extern void Stack_Change(void);
|
||||||
|
static void Stack_Change_Weak () __attribute__ ((weakref ("Stack_Change")));
|
||||||
|
|
||||||
|
/* Local Variables */
|
||||||
|
#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority
|
||||||
|
#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive
|
||||||
|
static xTaskHandle initTaskHandle;
|
||||||
|
|
||||||
|
/* Function Prototypes */
|
||||||
|
static void initTask(void *parameters);
|
||||||
|
|
||||||
|
/* Prototype of generated InitModules() function */
|
||||||
|
extern void InitModules(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenPilot Main function:
|
||||||
|
*
|
||||||
|
* Initialize PiOS<BR>
|
||||||
|
* Create the "System" task (SystemModInitializein Modules/System/systemmod.c) <BR>
|
||||||
|
* Start FreeRTOS Scheduler (vTaskStartScheduler)<BR>
|
||||||
|
* If something goes wrong, blink LED1 and LED2 every 100ms
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
/* NOTE: Do NOT modify the following start-up sequence */
|
||||||
|
/* Any new initialization functions should be added in OpenPilotInit() */
|
||||||
|
vPortInitialiseBlocks();
|
||||||
|
|
||||||
|
/* Brings up System using CMSIS functions, enables the LEDs. */
|
||||||
|
PIOS_SYS_Init();
|
||||||
|
|
||||||
|
/* For Revolution we use a FreeRTOS task to bring up the system so we can */
|
||||||
|
/* always rely on FreeRTOS primitive */
|
||||||
|
result = xTaskCreate(initTask, (const signed char *)"init",
|
||||||
|
INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY,
|
||||||
|
&initTaskHandle);
|
||||||
|
PIOS_Assert(result == pdPASS);
|
||||||
|
|
||||||
|
/* Start the FreeRTOS scheduler */
|
||||||
|
vTaskStartScheduler();
|
||||||
|
|
||||||
|
/* If all is well we will never reach here as the scheduler will now be running. */
|
||||||
|
/* Do some PIOS_LED_HEARTBEAT to user that something bad just happened */
|
||||||
|
PIOS_LED_Off(PIOS_LED_HEARTBEAT); \
|
||||||
|
for(;;) { \
|
||||||
|
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); \
|
||||||
|
PIOS_DELAY_WaitmS(100); \
|
||||||
|
};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initialisation task.
|
||||||
|
*
|
||||||
|
* Runs board and module initialisation, then terminates.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
initTask(void *parameters)
|
||||||
|
{
|
||||||
|
/* board driver init */
|
||||||
|
PIOS_Board_Init();
|
||||||
|
|
||||||
|
/* Initialize modules */
|
||||||
|
MODULE_INITIALISE_ALL;
|
||||||
|
|
||||||
|
/* terminate this task */
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
96
flight/RevoMini/UAVObjects.inc
Normal file
96
flight/RevoMini/UAVObjects.inc
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#####
|
||||||
|
# Project: OpenPilot
|
||||||
|
#
|
||||||
|
# Makefile for OpenPilot UAVObject code
|
||||||
|
#
|
||||||
|
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2011.
|
||||||
|
#
|
||||||
|
# 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, write to the Free Software Foundation, Inc.,
|
||||||
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#####
|
||||||
|
|
||||||
|
# These are the UAVObjects supposed to be build as part of the OpenPilot target
|
||||||
|
# (all architectures)
|
||||||
|
|
||||||
|
UAVOBJSRCFILENAMES =
|
||||||
|
UAVOBJSRCFILENAMES += accessorydesired
|
||||||
|
UAVOBJSRCFILENAMES += actuatorcommand
|
||||||
|
UAVOBJSRCFILENAMES += actuatordesired
|
||||||
|
UAVOBJSRCFILENAMES += actuatorsettings
|
||||||
|
UAVOBJSRCFILENAMES += altholdsmoothed
|
||||||
|
UAVOBJSRCFILENAMES += attitudesettings
|
||||||
|
UAVOBJSRCFILENAMES += attitudeactual
|
||||||
|
UAVOBJSRCFILENAMES += gyros
|
||||||
|
UAVOBJSRCFILENAMES += gyrosbias
|
||||||
|
UAVOBJSRCFILENAMES += accels
|
||||||
|
UAVOBJSRCFILENAMES += magnetometer
|
||||||
|
UAVOBJSRCFILENAMES += magbias
|
||||||
|
UAVOBJSRCFILENAMES += baroaltitude
|
||||||
|
UAVOBJSRCFILENAMES += baroairspeed
|
||||||
|
UAVOBJSRCFILENAMES += fixedwingpathfollowersettings
|
||||||
|
UAVOBJSRCFILENAMES += fixedwingpathfollowerstatus
|
||||||
|
UAVOBJSRCFILENAMES += flightbatterysettings
|
||||||
|
UAVOBJSRCFILENAMES += firmwareiapobj
|
||||||
|
UAVOBJSRCFILENAMES += flightbatterystate
|
||||||
|
UAVOBJSRCFILENAMES += flightplancontrol
|
||||||
|
UAVOBJSRCFILENAMES += flightplansettings
|
||||||
|
UAVOBJSRCFILENAMES += flightplanstatus
|
||||||
|
UAVOBJSRCFILENAMES += flighttelemetrystats
|
||||||
|
UAVOBJSRCFILENAMES += gcstelemetrystats
|
||||||
|
UAVOBJSRCFILENAMES += gcsreceiver
|
||||||
|
UAVOBJSRCFILENAMES += gpsposition
|
||||||
|
UAVOBJSRCFILENAMES += gpssatellites
|
||||||
|
UAVOBJSRCFILENAMES += gpssettings
|
||||||
|
UAVOBJSRCFILENAMES += gpstime
|
||||||
|
UAVOBJSRCFILENAMES += gpsvelocity
|
||||||
|
UAVOBJSRCFILENAMES += vtolpathfollowersettings
|
||||||
|
UAVOBJSRCFILENAMES += homelocation
|
||||||
|
UAVOBJSRCFILENAMES += i2cstats
|
||||||
|
UAVOBJSRCFILENAMES += manualcontrolcommand
|
||||||
|
UAVOBJSRCFILENAMES += manualcontrolsettings
|
||||||
|
UAVOBJSRCFILENAMES += mixersettings
|
||||||
|
UAVOBJSRCFILENAMES += mixerstatus
|
||||||
|
UAVOBJSRCFILENAMES += nedaccel
|
||||||
|
UAVOBJSRCFILENAMES += nedposition
|
||||||
|
UAVOBJSRCFILENAMES += objectpersistence
|
||||||
|
UAVOBJSRCFILENAMES += overosyncstats
|
||||||
|
UAVOBJSRCFILENAMES += overosyncsettings
|
||||||
|
UAVOBJSRCFILENAMES += pathplannersettings
|
||||||
|
UAVOBJSRCFILENAMES += pathdesired
|
||||||
|
UAVOBJSRCFILENAMES += positionactual
|
||||||
|
UAVOBJSRCFILENAMES += ratedesired
|
||||||
|
UAVOBJSRCFILENAMES += revocalibration
|
||||||
|
UAVOBJSRCFILENAMES += revosettings
|
||||||
|
UAVOBJSRCFILENAMES += sonaraltitude
|
||||||
|
UAVOBJSRCFILENAMES += stabilizationdesired
|
||||||
|
UAVOBJSRCFILENAMES += stabilizationsettings
|
||||||
|
UAVOBJSRCFILENAMES += systemalarms
|
||||||
|
UAVOBJSRCFILENAMES += systemsettings
|
||||||
|
UAVOBJSRCFILENAMES += systemstats
|
||||||
|
UAVOBJSRCFILENAMES += taskinfo
|
||||||
|
UAVOBJSRCFILENAMES += velocityactual
|
||||||
|
UAVOBJSRCFILENAMES += velocitydesired
|
||||||
|
UAVOBJSRCFILENAMES += watchdogstatus
|
||||||
|
UAVOBJSRCFILENAMES += flightstatus
|
||||||
|
UAVOBJSRCFILENAMES += hwsettings
|
||||||
|
UAVOBJSRCFILENAMES += receiveractivity
|
||||||
|
UAVOBJSRCFILENAMES += cameradesired
|
||||||
|
UAVOBJSRCFILENAMES += camerastabsettings
|
||||||
|
UAVOBJSRCFILENAMES += altitudeholdsettings
|
||||||
|
UAVOBJSRCFILENAMES += altitudeholddesired
|
||||||
|
UAVOBJSRCFILENAMES += waypoint
|
||||||
|
UAVOBJSRCFILENAMES += waypointactive
|
||||||
|
|
||||||
|
UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(UAVOBJSYNTHDIR)/$(UAVOBJSRCFILE).c )
|
||||||
|
UAVOBJDEFINE = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),-DUAVOBJ_INIT_$(UAVOBJSRCFILE) )
|
1823
flight/board_hw_defs/revomini/board_hw_defs.c
Normal file
1823
flight/board_hw_defs/revomini/board_hw_defs.c
Normal file
@ -0,0 +1,1823 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @addtogroup OpenPilotSystem OpenPilot System
|
||||||
|
* @{
|
||||||
|
* @addtogroup OpenPilotCore OpenPilot Core
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file board_hw_defs.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @brief Defines board specific static initializers for hardware for the OpenPilot board.
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include <pios_config.h>
|
||||||
|
#include <pios_board_info.h>
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_LED)
|
||||||
|
|
||||||
|
#include <pios_led_priv.h>
|
||||||
|
static const struct pios_led pios_leds[] = {
|
||||||
|
[PIOS_LED_HEARTBEAT] = {
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_2,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[PIOS_LED_ALARM] = {
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_3,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_led_cfg pios_led_cfg = {
|
||||||
|
.leds = pios_leds,
|
||||||
|
.num_leds = NELEMENTS(pios_leds),
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revision)
|
||||||
|
{
|
||||||
|
return &pios_led_cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_LED */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_SPI)
|
||||||
|
#include <pios_spi_priv.h>
|
||||||
|
/* SPI1 Interface
|
||||||
|
* - Used for BMA180 accelerometer
|
||||||
|
*/
|
||||||
|
void PIOS_SPI_accel_irq_handler(void);
|
||||||
|
void DMA2_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_accel_irq_handler")));
|
||||||
|
void DMA2_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_accel_irq_handler")));
|
||||||
|
static const struct pios_spi_cfg pios_spi_accel_cfg = {
|
||||||
|
.regs = SPI1,
|
||||||
|
.remap = GPIO_AF_SPI1,
|
||||||
|
.init = {
|
||||||
|
.SPI_Mode = SPI_Mode_Master,
|
||||||
|
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
|
||||||
|
.SPI_DataSize = SPI_DataSize_8b,
|
||||||
|
.SPI_NSS = SPI_NSS_Soft,
|
||||||
|
.SPI_FirstBit = SPI_FirstBit_MSB,
|
||||||
|
.SPI_CRCPolynomial = 7,
|
||||||
|
.SPI_CPOL = SPI_CPOL_High,
|
||||||
|
.SPI_CPHA = SPI_CPHA_2Edge,
|
||||||
|
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16,
|
||||||
|
},
|
||||||
|
.use_crc = false,
|
||||||
|
.dma = {
|
||||||
|
.irq = {
|
||||||
|
.flags = (DMA_IT_TCIF0 | DMA_IT_TEIF0 | DMA_IT_HTIF0),
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = DMA2_Stream0_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
.rx = {
|
||||||
|
.channel = DMA2_Stream0,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_3,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_PeripheralToMemory,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Normal,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
/* .DMA_FIFOThreshold */
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.channel = DMA2_Stream3,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_3,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_MemoryToPeripheral,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Normal,
|
||||||
|
.DMA_Priority = DMA_Priority_High,
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
/* .DMA_FIFOThreshold */
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sclk = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_5,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.miso = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_6,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.mosi = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_7,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.slave_count = 2,
|
||||||
|
.ssel = { {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_4,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
} },
|
||||||
|
{
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_5,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
} },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint32_t pios_spi_accel_id;
|
||||||
|
void PIOS_SPI_accel_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_SPI_IRQ_Handler(pios_spi_accel_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* SPI2 Interface
|
||||||
|
* - Used for gyro communications
|
||||||
|
*/
|
||||||
|
void PIOS_SPI_GYRO_irq_handler(void);
|
||||||
|
void DMA1_Stream3_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
|
||||||
|
void DMA1_Stream4_IRQHandler(void) __attribute__((alias("PIOS_SPI_gyro_irq_handler")));
|
||||||
|
static const struct pios_spi_cfg pios_spi_gyro_cfg = {
|
||||||
|
.regs = SPI2,
|
||||||
|
.remap = GPIO_AF_SPI2,
|
||||||
|
.init = {
|
||||||
|
.SPI_Mode = SPI_Mode_Master,
|
||||||
|
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
|
||||||
|
.SPI_DataSize = SPI_DataSize_8b,
|
||||||
|
.SPI_NSS = SPI_NSS_Soft,
|
||||||
|
.SPI_FirstBit = SPI_FirstBit_MSB,
|
||||||
|
.SPI_CRCPolynomial = 7,
|
||||||
|
.SPI_CPOL = SPI_CPOL_High,
|
||||||
|
.SPI_CPHA = SPI_CPHA_2Edge,
|
||||||
|
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8,
|
||||||
|
},
|
||||||
|
.use_crc = false,
|
||||||
|
.dma = {
|
||||||
|
.irq = {
|
||||||
|
// Note this is the stream ID that triggers interrupts (in this case RX)
|
||||||
|
.flags = (DMA_IT_TCIF3 | DMA_IT_TEIF3 | DMA_IT_HTIF3),
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = DMA1_Stream3_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
.rx = {
|
||||||
|
.channel = DMA1_Stream3,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & (SPI2->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_PeripheralToMemory,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Normal,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
//TODO: Enable FIFO
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.channel = DMA1_Stream4,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & (SPI2->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_MemoryToPeripheral,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Normal,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sclk = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_13,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.miso = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_14,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.mosi = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_15,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.slave_count = 1,
|
||||||
|
.ssel = { {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_12,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t pios_spi_gyro_id;
|
||||||
|
void PIOS_SPI_gyro_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_SPI_IRQ_Handler(pios_spi_gyro_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(PIOS_FLASH_ON_ACCEL)
|
||||||
|
/* SPI3 Interface
|
||||||
|
* - Used for flash communications
|
||||||
|
*/
|
||||||
|
void PIOS_SPI_flash_irq_handler(void);
|
||||||
|
void DMA1_Stream0_IRQHandler(void) __attribute__((alias("PIOS_SPI_flash_irq_handler")));
|
||||||
|
void DMA1_Stream5_IRQHandler(void) __attribute__((alias("PIOS_SPI_flash_irq_handler")));
|
||||||
|
static const struct pios_spi_cfg pios_spi_flash_cfg = {
|
||||||
|
.regs = SPI3,
|
||||||
|
.remap = GPIO_AF_SPI3,
|
||||||
|
.init = {
|
||||||
|
.SPI_Mode = SPI_Mode_Master,
|
||||||
|
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
|
||||||
|
.SPI_DataSize = SPI_DataSize_8b,
|
||||||
|
.SPI_NSS = SPI_NSS_Soft,
|
||||||
|
.SPI_FirstBit = SPI_FirstBit_MSB,
|
||||||
|
.SPI_CRCPolynomial = 7,
|
||||||
|
.SPI_CPOL = SPI_CPOL_High,
|
||||||
|
.SPI_CPHA = SPI_CPHA_2Edge,
|
||||||
|
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2,
|
||||||
|
},
|
||||||
|
.use_crc = false,
|
||||||
|
.dma = {
|
||||||
|
.irq = {
|
||||||
|
// Note this is the stream ID that triggers interrupts (in this case RX)
|
||||||
|
.flags = (DMA_IT_TCIF0 | DMA_IT_TEIF0 | DMA_IT_HTIF0),
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = DMA1_Stream0_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
.rx = {
|
||||||
|
.channel = DMA1_Stream0,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_PeripheralToMemory,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Normal,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
//TODO: Enable FIFO
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.channel = DMA1_Stream5,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_MemoryToPeripheral,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Normal,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sclk = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_10,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.miso = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.mosi = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_12,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.slave_count = 1,
|
||||||
|
.ssel = { {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_2,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t pios_spi_flash_id;
|
||||||
|
void PIOS_SPI_flash_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_SPI_IRQ_Handler(pios_spi_flash_id);
|
||||||
|
}
|
||||||
|
#endif /* PIOS_FLASH_ON_ACCEL */
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_SPI */
|
||||||
|
|
||||||
|
#if defined(PIOS_OVERO_SPI)
|
||||||
|
/* SPI3 Interface
|
||||||
|
* - Used for flash communications
|
||||||
|
*/
|
||||||
|
#include <pios_overo_priv.h>
|
||||||
|
void PIOS_OVERO_irq_handler(void);
|
||||||
|
void DMA1_Stream7_IRQHandler(void) __attribute__((alias("PIOS_OVERO_irq_handler")));
|
||||||
|
static const struct pios_overo_cfg pios_overo_cfg = {
|
||||||
|
.regs = SPI3,
|
||||||
|
.remap = GPIO_AF_SPI3,
|
||||||
|
.init = {
|
||||||
|
.SPI_Mode = SPI_Mode_Slave,
|
||||||
|
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
|
||||||
|
.SPI_DataSize = SPI_DataSize_8b,
|
||||||
|
.SPI_NSS = SPI_NSS_Hard,
|
||||||
|
.SPI_FirstBit = SPI_FirstBit_MSB,
|
||||||
|
.SPI_CRCPolynomial = 7,
|
||||||
|
.SPI_CPOL = SPI_CPOL_High,
|
||||||
|
.SPI_CPHA = SPI_CPHA_2Edge,
|
||||||
|
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2,
|
||||||
|
},
|
||||||
|
.use_crc = false,
|
||||||
|
.dma = {
|
||||||
|
.irq = {
|
||||||
|
// Note this is the stream ID that triggers interrupts (in this case TX)
|
||||||
|
.flags = (DMA_IT_TCIF7),
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = DMA1_Stream7_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
.rx = {
|
||||||
|
.channel = DMA1_Stream0,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_PeripheralToMemory,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Circular,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
//TODO: Enable FIFO
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.channel = DMA1_Stream7,
|
||||||
|
.init = {
|
||||||
|
.DMA_Channel = DMA_Channel_0,
|
||||||
|
.DMA_PeripheralBaseAddr = (uint32_t) & (SPI3->DR),
|
||||||
|
.DMA_DIR = DMA_DIR_MemoryToPeripheral,
|
||||||
|
.DMA_PeripheralInc = DMA_PeripheralInc_Disable,
|
||||||
|
.DMA_MemoryInc = DMA_MemoryInc_Enable,
|
||||||
|
.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte,
|
||||||
|
.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte,
|
||||||
|
.DMA_Mode = DMA_Mode_Circular,
|
||||||
|
.DMA_Priority = DMA_Priority_Medium,
|
||||||
|
.DMA_FIFOMode = DMA_FIFOMode_Disable,
|
||||||
|
.DMA_FIFOThreshold = DMA_FIFOThreshold_Full,
|
||||||
|
.DMA_MemoryBurst = DMA_MemoryBurst_Single,
|
||||||
|
.DMA_PeripheralBurst = DMA_PeripheralBurst_Single,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sclk = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_10,
|
||||||
|
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.miso = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.mosi = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_12,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.slave_count = 1,
|
||||||
|
.ssel = { {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_15,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
};
|
||||||
|
uint32_t pios_overo_id = 0;
|
||||||
|
void PIOS_OVERO_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_OVERO_DMA_irq_handler(pios_overo_id);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif /* PIOS_OVERO_SPI */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <pios_usart_priv.h>
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_COM_TELEM
|
||||||
|
/*
|
||||||
|
* Telemetry on main USART
|
||||||
|
*/
|
||||||
|
static const struct pios_usart_cfg pios_usart_telem_cfg = {
|
||||||
|
.regs = USART2,
|
||||||
|
.remap = GPIO_AF_USART2,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 57600,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl =
|
||||||
|
USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = USART2_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_6,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_5,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_COM_TELEM */
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_GPS
|
||||||
|
/*
|
||||||
|
* GPS USART
|
||||||
|
*/
|
||||||
|
static const struct pios_usart_cfg pios_usart_gps_cfg = {
|
||||||
|
.regs = USART1,
|
||||||
|
.remap = GPIO_AF_USART1,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 57600,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl =
|
||||||
|
USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = USART1_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_10,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_9,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_GPS */
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_COM_AUX
|
||||||
|
/*
|
||||||
|
* AUX USART (UART label on rev2)
|
||||||
|
*/
|
||||||
|
static const struct pios_usart_cfg pios_usart_aux_cfg = {
|
||||||
|
.regs = USART6,
|
||||||
|
.remap = GPIO_AF_USART6,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 57600,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl =
|
||||||
|
USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = USART6_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_7,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_6,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_COM_AUX */
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_COM_AUXSBUS
|
||||||
|
/*
|
||||||
|
* AUX USART SBUS ( UART/ S Bus label on rev2)
|
||||||
|
*/
|
||||||
|
static const struct pios_usart_cfg pios_usart_auxsbus_cfg = {
|
||||||
|
.regs = UART4,
|
||||||
|
.remap = GPIO_AF_UART4,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 57600,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl =
|
||||||
|
USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = UART4_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_1,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_0,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_COM_AUXSBUS */
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_COM_FLEXI
|
||||||
|
/*
|
||||||
|
* FLEXI PORT
|
||||||
|
*/
|
||||||
|
static const struct pios_usart_cfg pios_usart_flexi_cfg = {
|
||||||
|
.regs = USART3,
|
||||||
|
.remap = GPIO_AF_USART3,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 57600,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl =
|
||||||
|
USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = USART3_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_10,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_COM_FLEXI */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_DSM)
|
||||||
|
/*
|
||||||
|
* Spektrum/JR DSM USART
|
||||||
|
*/
|
||||||
|
#include <pios_dsm_priv.h>
|
||||||
|
|
||||||
|
static const struct pios_usart_cfg pios_usart_dsm_aux_cfg = {
|
||||||
|
.regs = USART6,
|
||||||
|
.remap = GPIO_AF_USART6,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 115200,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = USART6_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_7,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_6,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_dsm_cfg pios_dsm_aux_cfg = {
|
||||||
|
.bind = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_7,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_usart_cfg pios_usart_dsm_auxsbus_cfg = {
|
||||||
|
.regs = UART4,
|
||||||
|
.remap = GPIO_AF_UART4,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 115200,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = UART4_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_1,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_0,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_dsm_cfg pios_dsm_auxsbus_cfg = {
|
||||||
|
.bind = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_1,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_usart_cfg pios_usart_dsm_flexi_cfg = {
|
||||||
|
.regs = USART3,
|
||||||
|
.remap = GPIO_AF_USART3,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 115200,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_No,
|
||||||
|
.USART_StopBits = USART_StopBits_1,
|
||||||
|
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = USART3_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_10,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_dsm_cfg pios_dsm_flexi_cfg = {
|
||||||
|
.bind = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_DSM */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_SBUS)
|
||||||
|
/*
|
||||||
|
* S.Bus USART
|
||||||
|
*/
|
||||||
|
#include <pios_sbus_priv.h>
|
||||||
|
|
||||||
|
static const struct pios_usart_cfg pios_usart_sbus_auxsbus_cfg = {
|
||||||
|
.regs = UART4,
|
||||||
|
.init = {
|
||||||
|
.USART_BaudRate = 100000,
|
||||||
|
.USART_WordLength = USART_WordLength_8b,
|
||||||
|
.USART_Parity = USART_Parity_Even,
|
||||||
|
.USART_StopBits = USART_StopBits_2,
|
||||||
|
.USART_HardwareFlowControl = USART_HardwareFlowControl_None,
|
||||||
|
.USART_Mode = USART_Mode_Rx,
|
||||||
|
},
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = UART4_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.rx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_1,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.tx = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_0,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_sbus_cfg pios_sbus_cfg = {
|
||||||
|
/* Inverter configuration */
|
||||||
|
.inv = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_3,
|
||||||
|
.GPIO_Mode = GPIO_Mode_OUT,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.gpio_clk_func = RCC_AHB1PeriphClockCmd,
|
||||||
|
.gpio_clk_periph = RCC_AHB1Periph_GPIOB,
|
||||||
|
.gpio_inv_enable = Bit_SET,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_SBUS */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_COM)
|
||||||
|
|
||||||
|
#include <pios_com_priv.h>
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_COM */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_I2C)
|
||||||
|
|
||||||
|
#include <pios_i2c_priv.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C Adapters
|
||||||
|
*/
|
||||||
|
void PIOS_I2C_mag_adapter_ev_irq_handler(void);
|
||||||
|
void PIOS_I2C_mag_adapter_er_irq_handler(void);
|
||||||
|
void I2C1_EV_IRQHandler()
|
||||||
|
__attribute__ ((alias("PIOS_I2C_mag_adapter_ev_irq_handler")));
|
||||||
|
void I2C1_ER_IRQHandler()
|
||||||
|
__attribute__ ((alias("PIOS_I2C_mag_adapter_er_irq_handler")));
|
||||||
|
|
||||||
|
static const struct pios_i2c_adapter_cfg pios_i2c_mag_adapter_cfg = {
|
||||||
|
.regs = I2C1,
|
||||||
|
.remap = GPIO_AF_I2C1,
|
||||||
|
.init = {
|
||||||
|
.I2C_Mode = I2C_Mode_I2C,
|
||||||
|
.I2C_OwnAddress1 = 0,
|
||||||
|
.I2C_Ack = I2C_Ack_Enable,
|
||||||
|
.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
|
||||||
|
.I2C_DutyCycle = I2C_DutyCycle_2,
|
||||||
|
.I2C_ClockSpeed = 400000, /* bits/s */
|
||||||
|
},
|
||||||
|
.transfer_timeout_ms = 50,
|
||||||
|
.scl = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_6,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sda = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_7,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.event = {
|
||||||
|
.flags = 0, /* FIXME: check this */
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = I2C1_EV_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.error = {
|
||||||
|
.flags = 0, /* FIXME: check this */
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = I2C1_ER_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t pios_i2c_mag_adapter_id;
|
||||||
|
void PIOS_I2C_mag_adapter_ev_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_I2C_EV_IRQ_Handler(pios_i2c_mag_adapter_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIOS_I2C_mag_adapter_er_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_I2C_ER_IRQ_Handler(pios_i2c_mag_adapter_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIOS_I2C_flexiport_adapter_ev_irq_handler(void);
|
||||||
|
void PIOS_I2C_flexiport_adapter_er_irq_handler(void);
|
||||||
|
void I2C2_EV_IRQHandler() __attribute__ ((alias ("PIOS_I2C_flexiport_adapter_ev_irq_handler")));
|
||||||
|
void I2C2_ER_IRQHandler() __attribute__ ((alias ("PIOS_I2C_flexiport_adapter_er_irq_handler")));
|
||||||
|
|
||||||
|
static const struct pios_i2c_adapter_cfg pios_i2c_flexiport_adapter_cfg = {
|
||||||
|
.regs = I2C2,
|
||||||
|
.remap = GPIO_AF_I2C2,
|
||||||
|
.init = {
|
||||||
|
.I2C_Mode = I2C_Mode_I2C,
|
||||||
|
.I2C_OwnAddress1 = 0,
|
||||||
|
.I2C_Ack = I2C_Ack_Enable,
|
||||||
|
.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
|
||||||
|
.I2C_DutyCycle = I2C_DutyCycle_2,
|
||||||
|
.I2C_ClockSpeed = 400000, /* bits/s */
|
||||||
|
},
|
||||||
|
.transfer_timeout_ms = 50,
|
||||||
|
.scl = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_10,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sda = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.event = {
|
||||||
|
.flags = 0, /* FIXME: check this */
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = I2C2_EV_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.error = {
|
||||||
|
.flags = 0, /* FIXME: check this */
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = I2C2_ER_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t pios_i2c_flexiport_adapter_id;
|
||||||
|
void PIOS_I2C_flexiport_adapter_ev_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_I2C_EV_IRQ_Handler(pios_i2c_flexiport_adapter_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIOS_I2C_flexiport_adapter_er_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_I2C_ER_IRQ_Handler(pios_i2c_flexiport_adapter_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIOS_I2C_pressure_adapter_ev_irq_handler(void);
|
||||||
|
void PIOS_I2C_pressure_adapter_er_irq_handler(void);
|
||||||
|
void I2C3_EV_IRQHandler() __attribute__ ((alias ("PIOS_I2C_pressure_adapter_ev_irq_handler")));
|
||||||
|
void I2C3_ER_IRQHandler() __attribute__ ((alias ("PIOS_I2C_pressure_adapter_er_irq_handler")));
|
||||||
|
|
||||||
|
static const struct pios_i2c_adapter_cfg pios_i2c_pressure_adapter_cfg = {
|
||||||
|
.regs = I2C3,
|
||||||
|
.remap = GPIO_AF_I2C3,
|
||||||
|
.init = {
|
||||||
|
.I2C_Mode = I2C_Mode_I2C,
|
||||||
|
.I2C_OwnAddress1 = 0,
|
||||||
|
.I2C_Ack = I2C_Ack_Enable,
|
||||||
|
.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
|
||||||
|
.I2C_DutyCycle = I2C_DutyCycle_2,
|
||||||
|
.I2C_ClockSpeed = 40000, /* bits/s */
|
||||||
|
},
|
||||||
|
.transfer_timeout_ms = 50,
|
||||||
|
.scl = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_8,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.sda = {
|
||||||
|
.gpio = GPIOC,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_9,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_NOPULL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.event = {
|
||||||
|
.flags = 0, /* FIXME: check this */
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = I2C3_EV_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.error = {
|
||||||
|
.flags = 0, /* FIXME: check this */
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = I2C3_ER_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGHEST,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t pios_i2c_pressure_adapter_id;
|
||||||
|
void PIOS_I2C_pressure_adapter_ev_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_I2C_EV_IRQ_Handler(pios_i2c_pressure_adapter_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PIOS_I2C_pressure_adapter_er_irq_handler(void)
|
||||||
|
{
|
||||||
|
/* Call into the generic code to handle the IRQ for this specific device */
|
||||||
|
PIOS_I2C_ER_IRQ_Handler(pios_i2c_pressure_adapter_id);
|
||||||
|
}
|
||||||
|
#endif /* PIOS_INCLUDE_I2C */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_RTC)
|
||||||
|
/*
|
||||||
|
* Realtime Clock (RTC)
|
||||||
|
*/
|
||||||
|
#include <pios_rtc_priv.h>
|
||||||
|
|
||||||
|
void PIOS_RTC_IRQ_Handler (void);
|
||||||
|
void RTC_WKUP_IRQHandler() __attribute__ ((alias ("PIOS_RTC_IRQ_Handler")));
|
||||||
|
static const struct pios_rtc_cfg pios_rtc_main_cfg = {
|
||||||
|
.clksrc = RCC_RTCCLKSource_HSE_Div16, // Divide 8 Mhz crystal down to 1
|
||||||
|
// For some reason it's acting like crystal is 16 Mhz. This clock is then divided
|
||||||
|
// by another 16 to give a nominal 62.5 khz clock
|
||||||
|
.prescaler = 100, // Every 100 cycles gives 625 Hz
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = RTC_WKUP_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
void PIOS_RTC_IRQ_Handler (void)
|
||||||
|
{
|
||||||
|
PIOS_RTC_irq_handler ();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "pios_tim_priv.h"
|
||||||
|
|
||||||
|
static const TIM_TimeBaseInitTypeDef tim_3_5_time_base = {
|
||||||
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
|
||||||
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
|
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
|
||||||
|
.TIM_RepetitionCounter = 0x0000,
|
||||||
|
};
|
||||||
|
static const TIM_TimeBaseInitTypeDef tim_9_10_11_time_base = {
|
||||||
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
|
||||||
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
|
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
|
||||||
|
.TIM_RepetitionCounter = 0x0000,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_3_cfg = {
|
||||||
|
.timer = TIM3,
|
||||||
|
.time_base_init = &tim_3_5_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM3_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_5_cfg = {
|
||||||
|
.timer = TIM5,
|
||||||
|
.time_base_init = &tim_3_5_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM5_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_9_cfg = {
|
||||||
|
.timer = TIM9,
|
||||||
|
.time_base_init = &tim_9_10_11_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_10_cfg = {
|
||||||
|
.timer = TIM10,
|
||||||
|
.time_base_init = &tim_9_10_11_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_11_cfg = {
|
||||||
|
.timer = TIM11,
|
||||||
|
.time_base_init = &tim_9_10_11_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM1_TRG_COM_TIM11_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set up timers that only have inputs on APB2
|
||||||
|
static const TIM_TimeBaseInitTypeDef tim_1_time_base = {
|
||||||
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
|
||||||
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
|
.TIM_Period = 0xFFFF,
|
||||||
|
.TIM_RepetitionCounter = 0x0000,
|
||||||
|
};
|
||||||
|
// Set up timers that only have inputs on APB2
|
||||||
|
static const TIM_TimeBaseInitTypeDef tim_4_time_base = {
|
||||||
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
|
||||||
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
|
.TIM_Period = 0xFFFF,
|
||||||
|
.TIM_RepetitionCounter = 0x0000,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_1_cfg = {
|
||||||
|
.timer = TIM1,
|
||||||
|
.time_base_init = &tim_1_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM1_CC_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct pios_tim_clock_cfg tim_4_cfg = {
|
||||||
|
.timer = TIM4,
|
||||||
|
.time_base_init = &tim_4_time_base,
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = TIM4_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID,
|
||||||
|
.NVIC_IRQChannelSubPriority = 0,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pios servo configuration structures
|
||||||
|
*/
|
||||||
|
#include <pios_servo_priv.h>
|
||||||
|
static const struct pios_tim_channel pios_tim_servoport_all_pins[] = {
|
||||||
|
{
|
||||||
|
.timer = TIM9,
|
||||||
|
.timer_chan = TIM_Channel_1,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_5,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource5,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM9,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM9,
|
||||||
|
.timer_chan = TIM_Channel_2,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_6,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource6,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM9,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM11,
|
||||||
|
.timer_chan = TIM_Channel_1,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_9,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource9,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM11,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM10,
|
||||||
|
.timer_chan = TIM_Channel_1,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_8,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource8,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM10,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM5,
|
||||||
|
.timer_chan = TIM_Channel_3,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_2,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource2,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM5,
|
||||||
|
.timer_chan = TIM_Channel_4,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOA,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_3,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource3,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM3,
|
||||||
|
.timer_chan = TIM_Channel_3,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_0,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource0,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM3,
|
||||||
|
.timer_chan = TIM_Channel_4,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOB,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_1,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource1,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM3,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct pios_servo_cfg pios_servo_cfg = {
|
||||||
|
.tim_oc_init = {
|
||||||
|
.TIM_OCMode = TIM_OCMode_PWM1,
|
||||||
|
.TIM_OutputState = TIM_OutputState_Enable,
|
||||||
|
.TIM_OutputNState = TIM_OutputNState_Disable,
|
||||||
|
.TIM_Pulse = PIOS_SERVOS_INITIAL_POSITION,
|
||||||
|
.TIM_OCPolarity = TIM_OCPolarity_High,
|
||||||
|
.TIM_OCNPolarity = TIM_OCPolarity_High,
|
||||||
|
.TIM_OCIdleState = TIM_OCIdleState_Reset,
|
||||||
|
.TIM_OCNIdleState = TIM_OCNIdleState_Reset,
|
||||||
|
},
|
||||||
|
.channels = pios_tim_servoport_all_pins,
|
||||||
|
.num_channels = NELEMENTS(pios_tim_servoport_all_pins),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PWM Inputs
|
||||||
|
*/
|
||||||
|
#if defined(PIOS_INCLUDE_PWM) || defined(PIOS_INCLUDE_PPM)
|
||||||
|
#include <pios_pwm_priv.h>
|
||||||
|
static const struct pios_tim_channel pios_tim_rcvrport_all_channels[] = {
|
||||||
|
{
|
||||||
|
.timer = TIM4,
|
||||||
|
.timer_chan = TIM_Channel_4,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_15,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource15,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM4,
|
||||||
|
.timer_chan = TIM_Channel_3,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_14,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource14,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM4,
|
||||||
|
.timer_chan = TIM_Channel_2,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_13,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource13,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM4,
|
||||||
|
.timer_chan = TIM_Channel_1,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_12,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource12,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM1,
|
||||||
|
.timer_chan = TIM_Channel_4,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_14,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource14,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM1,
|
||||||
|
.timer_chan = TIM_Channel_3,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_13,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource13,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM1,
|
||||||
|
.timer_chan = TIM_Channel_2,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource11,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.timer = TIM1,
|
||||||
|
.timer_chan = TIM_Channel_1,
|
||||||
|
.pin = {
|
||||||
|
.gpio = GPIOE,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_9,
|
||||||
|
.GPIO_Speed = GPIO_Speed_2MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_AF,
|
||||||
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
|
},
|
||||||
|
.pin_source = GPIO_PinSource9,
|
||||||
|
},
|
||||||
|
.remap = GPIO_AF_TIM1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct pios_pwm_cfg pios_pwm_cfg = {
|
||||||
|
.tim_ic_init = {
|
||||||
|
.TIM_ICPolarity = TIM_ICPolarity_Rising,
|
||||||
|
.TIM_ICSelection = TIM_ICSelection_DirectTI,
|
||||||
|
.TIM_ICPrescaler = TIM_ICPSC_DIV1,
|
||||||
|
.TIM_ICFilter = 0x0,
|
||||||
|
},
|
||||||
|
.channels = pios_tim_rcvrport_all_channels,
|
||||||
|
.num_channels = NELEMENTS(pios_tim_rcvrport_all_channels),
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PPM Input
|
||||||
|
*/
|
||||||
|
#if defined(PIOS_INCLUDE_PPM)
|
||||||
|
#include <pios_ppm_priv.h>
|
||||||
|
static const struct pios_ppm_cfg pios_ppm_cfg = {
|
||||||
|
.tim_ic_init = {
|
||||||
|
.TIM_ICPolarity = TIM_ICPolarity_Rising,
|
||||||
|
.TIM_ICSelection = TIM_ICSelection_DirectTI,
|
||||||
|
.TIM_ICPrescaler = TIM_ICPSC_DIV1,
|
||||||
|
.TIM_ICFilter = 0x0,
|
||||||
|
.TIM_Channel = TIM_Channel_2,
|
||||||
|
},
|
||||||
|
/* Use only the first channel for ppm */
|
||||||
|
.channels = &pios_tim_rcvrport_all_channels[0],
|
||||||
|
.num_channels = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //PPM
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_GCSRCVR)
|
||||||
|
#include "pios_gcsrcvr_priv.h"
|
||||||
|
#endif /* PIOS_INCLUDE_GCSRCVR */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_RCVR)
|
||||||
|
#include "pios_rcvr_priv.h"
|
||||||
|
#endif /* PIOS_INCLUDE_RCVR */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB)
|
||||||
|
#include "pios_usb_priv.h"
|
||||||
|
|
||||||
|
static const struct pios_usb_cfg pios_usb_main_cfg = {
|
||||||
|
.irq = {
|
||||||
|
.init = {
|
||||||
|
.NVIC_IRQChannel = OTG_FS_IRQn,
|
||||||
|
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_LOW,
|
||||||
|
.NVIC_IRQChannelSubPriority = 3,
|
||||||
|
.NVIC_IRQChannelCmd = ENABLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.vsense = {
|
||||||
|
.gpio = GPIOD,
|
||||||
|
.init = {
|
||||||
|
.GPIO_Pin = GPIO_Pin_11,
|
||||||
|
.GPIO_Speed = GPIO_Speed_25MHz,
|
||||||
|
.GPIO_Mode = GPIO_Mode_IN,
|
||||||
|
.GPIO_OType = GPIO_OType_OD,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "pios_usb_board_data_priv.h"
|
||||||
|
#include "pios_usb_desc_hid_cdc_priv.h"
|
||||||
|
#include "pios_usb_desc_hid_only_priv.h"
|
||||||
|
#include "pios_usbhook.h"
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_USB */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_COM_MSG)
|
||||||
|
|
||||||
|
#include <pios_com_msg_priv.h>
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_COM_MSG */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB_HID)
|
||||||
|
#include <pios_usb_hid_priv.h>
|
||||||
|
|
||||||
|
const struct pios_usb_hid_cfg pios_usb_hid_cfg = {
|
||||||
|
.data_if = 0,
|
||||||
|
.data_rx_ep = 1,
|
||||||
|
.data_tx_ep = 1,
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_USB_HID */
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||||
|
#include <pios_usb_cdc_priv.h>
|
||||||
|
|
||||||
|
const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = {
|
||||||
|
.ctrl_if = 1,
|
||||||
|
.ctrl_tx_ep = 2,
|
||||||
|
|
||||||
|
.data_if = 2,
|
||||||
|
.data_rx_ep = 3,
|
||||||
|
.data_tx_ep = 3,
|
||||||
|
};
|
||||||
|
#endif /* PIOS_INCLUDE_USB_CDC */
|
Loading…
x
Reference in New Issue
Block a user