[board] support Matek F7 Wing

This commit is contained in:
Gautier Hattenberger
2020-12-10 17:32:37 +01:00
parent a64f5fbdd0
commit e37090e14e
14 changed files with 3961 additions and 2 deletions
@@ -0,0 +1,204 @@
<!DOCTYPE airframe SYSTEM "../../airframe.dtd">
<airframe name="Matek F765-WING Test File">
<firmware name="fixedwing">
<configure name="RTOS_DEBUG" value="0"/>
<!--configure name="CH_OPT" value="0 -g -ggdb3"/-->
<target name="ap" board="matek_f765_wing">
<configure name="PERIODIC_FREQUENCY" value="100"/>
<module name="radio_control" type="sbus"/>
</target>
<target name="nps" board="pc">
<configure name="PERIODIC_FREQUENCY" value="100"/>
<module name="radio_control" type="ppm"/>
<module name="fdm" type="jsbsim"/>
</target>
<target name="sim" board="pc">
<module name="radio_control" type="ppm"/>
</target>
<module name="board" type="matek_f765_wing"/>
<module name="gps" type="ublox">
<configure name="GPS_BAUD" value="B115200"/>
</module>
<module name="ahrs" type="float_dcm"/>
<module name="ins" type="alt_float"/>
<module name="air_data"/>
<module name="telemetry" type="xbee_api"/>
<module name="control" type="new"/>
<module name="navigation"/>
<!--configure name="SDLOG_USE_RTC" value="FALSE"/-->
<!--module name="tlsf"/>
<module name="pprzlog"/>
<module name="logger" type="sd_chibios"/>
<module name="flight_recorder"/-->
</firmware>
<!-- commands section -->
<servos>
<servo name="MOTOR" no="2" min="1040" neutral="1040" max="2000"/>
<servo name="AILEVON_RIGHT" no="3" max="1900" neutral="1416" min="1100"/>
<servo name="AILEVON_LEFT" no="4" max="1100" neutral="1586" min="1900"/>
</servos>
<commands>
<axis name="THROTTLE" failsafe_value="0"/>
<axis name="ROLL" failsafe_value="0"/>
<axis name="PITCH" failsafe_value="0"/>
</commands>
<rc_commands>
<set command="THROTTLE" value="@THROTTLE"/>
<set command="ROLL" value="@ROLL"/>
<set command="PITCH" value="@PITCH"/>
</rc_commands>
<section name="MIXER">
<define name="AILEVON_AILERON_RATE" value="0.75"/>
<define name="AILEVON_ELEVATOR_RATE" value="0.75"/>
<define name="AILERON_DIFF" value="0.5"/>
<define name="COMMAND_ROLL_TRIM" value="0"/>
<define name="COMMAND_PITCH_TRIM" value="0"/>
</section>
<command_laws>
<let var="aileron" value="@ROLL * AILEVON_AILERON_RATE"/>
<let var="elevator" value="@PITCH * AILEVON_ELEVATOR_RATE"/>
<set servo="MOTOR" value="@THROTTLE"/>
<set servo="AILEVON_LEFT" value="$elevator - ($aileron > 0 ? AILERON_DIFF : 1) * $aileron"/>
<set servo="AILEVON_RIGHT" value="$elevator + ($aileron > 0 ? 1 : AILERON_DIFF) * $aileron"/>
</command_laws>
<section name="AUTO1" prefix="AUTO1_">
<define name="MAX_ROLL" value="45." unit="deg"/>
<define name="MAX_PITCH" value="30." unit="deg"/>
</section>
<section name="IMU" prefix="IMU_">
<define name="GYRO_P_SIGN" value="1"/>
<define name="GYRO_Q_SIGN" value="1"/>
<define name="GYRO_R_SIGN" value="1"/>
<define name="ACCEL_X_SIGN" value="1"/>
<define name="ACCEL_Y_SIGN" value="1"/>
<define name="ACCEL_Z_SIGN" value="1"/>
<define name="ACCEL_X_NEUTRAL" value="-41"/>
<define name="ACCEL_Y_NEUTRAL" value="1"/>
<define name="ACCEL_Z_NEUTRAL" value="24"/>
<define name="ACCEL_X_SENS" value="2.45166329295" integer="16"/>
<define name="ACCEL_Y_SENS" value="2.45072320868" integer="16"/>
<define name="ACCEL_Z_SENS" value="2.44974997157" integer="16"/>
<define name="MAG_X_SIGN" value="1"/>
<define name="MAG_Y_SIGN" value="1"/>
<define name="MAG_Z_SIGN" value="1"/>
<define name="MAG_X_NEUTRAL" value="1984"/>
<define name="MAG_Y_NEUTRAL" value="-528"/>
<define name="MAG_Z_NEUTRAL" value="1055"/>
<define name="MAG_X_SENS" value="0.676644619376" integer="16"/>
<define name="MAG_Y_SENS" value="0.667566939093" integer="16"/>
<define name="MAG_Z_SENS" value="0.663687314941" integer="16"/>
<define name="BODY_TO_IMU_PHI" value="0" unit="deg"/>
<define name="BODY_TO_IMU_THETA" value="0." unit="deg"/>
<define name="BODY_TO_IMU_PSI" value="0" unit="deg"/>
</section>
<section name="INS" prefix="INS_">
<!--muret-->
<define name="H_X" value="0.5180"/>
<define name="H_Y" value="-0.0071"/>
<define name="H_Z" value="0.8554"/>
</section>
<section name="BAT">
<define name="CALIB_AMP_A" value="0.0045360"/>
<define name="CALIB_AMP_B" value="2.8136"/>
<define name="CATASTROPHIC_BAT_LEVEL" value="9.3" unit="V"/>
<!--define name="MilliAmpereOfAdc(_adc)" value="(_adc-620)*4.536"/-->
</section>
<section name="MISC">
<define name="NOMINAL_AIRSPEED" value="12." unit="m/s"/>
<define name="CARROT" value="5." unit="s"/>
<define name="KILL_MODE_DISTANCE" value="(1.5*MAX_DIST_FROM_HOME)"/>
<define name="DEFAULT_CIRCLE_RADIUS" value="80."/>
<define name="UNLOCKED_HOME_MODE" value="TRUE"/>
</section>
<section name="BUNGEE" prefix="BUNGEE_TAKEOFF_">
<define name="HEIGHT" value="15."/>
<define name="DISTANCE" value="-10."/>
<define name="MIN_SPEED" value="2"/>
<define name="PITCH" value="12" unit="deg"/>
<define name="THROTTLE" value="1."/>
</section>
<section name="VERTICAL CONTROL" prefix="V_CTL_">
<define name="POWER_CTL_BAT_NOMINAL" value="11.1" unit="volt"/>
<!-- outer loop proportional gain -->
<define name="ALTITUDE_PGAIN" value="0.06"/>
<!-- outer loop saturation -->
<define name="ALTITUDE_MAX_CLIMB" value="3."/>
<!-- auto throttle inner loop -->
<define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.5"/>
<define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE" value="0.25"/>
<define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE" value="0.85"/>
<define name="AUTO_THROTTLE_LOITER_TRIM" value="1000"/>
<define name="AUTO_THROTTLE_DASH_TRIM" value="-1200"/>
<define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.08" unit="%/(m/s)"/>
<define name="AUTO_THROTTLE_PGAIN" value="0.011"/>
<define name="AUTO_THROTTLE_IGAIN" value="0.006"/>
<define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN" value="0.13"/>
<define name="THROTTLE_SLEW" value="0.1"/>
<!-- TODO : CTRL_NEW "Climb loop (pitch)" -->
<define name="AUTO_PITCH_PGAIN" value="0.028"/>
<define name="AUTO_PITCH_DGAIN" value="0.013"/>
<define name="AUTO_PITCH_IGAIN" value="0.006"/>
<define name="AUTO_PITCH_MAX_PITCH" value="20" unit="deg"/>
<define name="AUTO_PITCH_MIN_PITCH" value="-20" unit="deg"/>
<define name="PITCH_TRIM" value="0." unit="deg"/>
</section>
<section name="HORIZONTAL CONTROL" prefix="H_CTL_">
<define name="COURSE_PGAIN" value="0.58"/>
<define name="ROLL_MAX_SETPOINT" value="45" unit="deg"/>
<define name="PITCH_MAX_SETPOINT" value="30." unit="deg"/>
<define name="PITCH_MIN_SETPOINT" value="-30." unit="deg"/>
<define name="ROLL_ATTITUDE_GAIN" value="10041"/>
<define name="ROLL_RATE_GAIN" value="1500"/>
<define name="PITCH_PGAIN" value="10672"/>
<define name="PITCH_DGAIN" value="1343"/>
<define name="AILERON_OF_THROTTLE" value="0.0"/>
<define name="PITCH_OF_ROLL" value="0.024"/>
</section>
<section name="FAILSAFE" prefix="FAILSAFE_">
<define name="DELAY_WITHOUT_GPS" value="2" unit="s"/>
<define name="DEFAULT_THROTTLE" value="0.3" unit="%"/>
<define name="DEFAULT_ROLL" value="0.17" unit="rad"/>
<define name="DEFAULT_PITCH" value="0.08" unit="rad"/>
<define name="HOME_RADIUS" value="100" unit="m"/>
</section>
<section name="SIMULATOR" prefix="NPS_">
<define name="JSBSIM_LAUNCHSPEED" value="15"/>
<define name="JSBSIM_MODEL" value="easystar" type="string"/>
<define name="SENSORS_PARAMS" value="nps_sensors_params_wind_estimator.h" type="string"/>
<define name="JS_AXIS_MODE" value="4"/>
</section>
</airframe>
@@ -29,7 +29,7 @@
<define name="USE_AHRS_GPS_ACCELERATIONS"/>
<!-- load standard internal sensors, then custom modules -->
<module name="board_matek_wing">
<module name="board_matek_f405_wing">
<define name="BMP280_SYNC_SEND"/>
</module>
+95
View File
@@ -0,0 +1,95 @@
# Hey Emacs, this is a -*- makefile -*-
#
# matek_f765_wing.makefile
#
# based on STM32F7
# only compatible with ChibiOS
#
BOARD=matek
BOARD_VERSION=F765-WING
BOARD_DIR=mateksys/$(BOARD_VERSION)
BOARD_CFG=\"boards/$(BOARD_DIR)/$(BOARD)$(BOARD_VERSION).h\"
ARCH=chibios
$(TARGET).ARCHDIR = $(ARCH)
RTOS=chibios
MCU=cortex-m7
## FPU on F7
USE_FPU=hard
USE_FPU_OPT= -mfpu=fpv5-d16
USE_LTO ?= yes
$(TARGET).CFLAGS += -DSTM32F7 -DPPRZLINK_ENABLE_FD -DUSE_HARD_FAULT_RECOVERY -DDSHOT_CHANNEL_FIRST_INDEX=1U
##############################################################################
# Architecture or project specific options
#
# Define project name here (target)
PROJECT = $(TARGET)
# Project specific files and paths (see Makefile.chibios for details)
CHIBIOS_BOARD_PLATFORM = STM32F7xx/platform.mk
CHIBIOS_BOARD_PORT = ARMCMx/STM32F7xx/port.mk
CHIBIOS_BOARD_LINKER = STM32F76xxI.ld
CHIBIOS_BOARD_STARTUP = startup_stm32f7xx.mk
# ITCM flash is a special flash that allow faster operations
# At the moment it is not possible to flash the code in this mode using dfu-util
# but it should work with the BlackMagicProbe or STLINK
# By default, normal flash is used
ifeq ($(USE_ITCM),1)
$(TARGET).CFLAGS += -DUSE_ITCM=1
DFU_ADDR = 0x00200000
else
$(TARGET).CFLAGS += -DUSE_ITCM=0
DFU_ADDR = 0x08000000
endif
##############################################################################
# Compiler settings
#
# default flash mode is via usb dfu bootloader
# possibilities: DFU-UTIL, SWD, STLINK
FLASH_MODE ?= DFU-UTIL
HAS_LUFTBOOT = FALSE
#
# default LED configuration
#
RADIO_CONTROL_LED ?= none
BARO_LED ?= none
AHRS_ALIGNER_LED ?= 2
GPS_LED ?= none
SYS_TIME_LED ?= 1
#
# default UART configuration (modem, gps, spektrum)
#
MODEM_PORT ?= UART7
MODEM_BAUD ?= B57600
GPS_PORT ?= UART2
GPS_BAUD ?= B57600
RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT ?= UART6
# single mode
SBUS_PORT ?= UART6
#
# default actuator configuration
#
# you can use different actuators by adding a configure option to your firmware section
# e.g. <configure name="ACTUATORS" value="actuators_ppm/>
# and by setting the correct "driver" attribute in servo section
# e.g. <servo driver="Ppm">
#
ACTUATORS ?= actuators_pwm
+3
View File
@@ -64,6 +64,7 @@
<board name="crazybee_f4_.*"/>
<board name="crazyflie_.*"/>
<board name="nucleo.*"/>
<board name="matek_.*"/>
</boards>
</mode>
<mode name="STLink (SWD)">
@@ -81,6 +82,7 @@
<board name="crazybee_f4_.*"/>
<board name="crazyflie_.*"/>
<board name="nucleo.*"/>
<board name="matek_.*"/>
</boards>
</mode>
<mode name="BlackMagic Probe (SWD)">
@@ -103,6 +105,7 @@
<board name="vms_ecu_.*"/>
<board name="crazyflie_.*"/>
<board name="nucleo.*"/>
<board name="matek_.*"/>
</boards>
</mode>
<mode name="BlackMagic Probe (SWD_NOPWR)">
@@ -1,6 +1,6 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="board_matek_wing" dir="boards">
<module name="board_matek_f405_wing" dir="boards">
<doc>
<description>
Autoload several onboard sensors and subsystems
+42
View File
@@ -0,0 +1,42 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="board_matek_f765_wing" dir="boards">
<doc>
<description>
Autoload several onboard sensors and subsystems
for the Matek F765 Wing board with proper configuration.
IMU ICM20602 (auto-detected from MPU6000 driver)
Baro (BMP280)
OSD
Normal back of the board is on the battery/ESC wires
Normal up of the board is on MCU side.
</description>
<configure name="BOARD_MATEK_ROTATED" value="FALSE|TRUE" description="if TRUE, the board is not using is default orientation and axis can be redefined by hand"/>
</doc>
<autoload name="imu" type="mpu6000"/>
<autoload name="spi" type="master"/>
<autoload name="osd_max7456"/>
<autoload name="baro_bmp280_i2c"/>
<autoload name="current_sensor"/>
<makefile target="!sim|nps|fbw">
<!-- IMU CONFIGURATION -->
<configure name="IMU_MPU_SPI_DEV" value="spi3" case="upper|lower"/>
<configure name="IMU_MPU_SPI_SLAVE_IDX" value="SPI_SLAVE4"/>
<define name="IMU_MPU_GYRO_RANGE" value="MPU60X0_GYRO_RANGE_1000"/>
<define name="IMU_MPU_ACCEL_RANGE" value="MPU60X0_ACCEL_RANGE_8G"/>
<define name="IMU_MPU_CHAN_X" value="1" cond="ifeq (,$(findstring $(BOARD_MATEK_ROTATED),1 TRUE))"/>
<define name="IMU_MPU_CHAN_Y" value="0" cond="ifeq (,$(findstring $(BOARD_MATEK_ROTATED),1 TRUE))"/>
<define name="IMU_MPU_X_SIGN" value="-1" cond="ifeq (,$(findstring $(BOARD_MATEK_ROTATED),1 TRUE))"/>
<!-- BAROMETER BMP280 CONFIGURATION -->
<configure name="BMP280_I2C_DEV" value="i2c2"/>
<!-- OSD CONFIGURATION -->
<configure name="MAX7456_SPI_DEV" value="spi2"/>
<configure name="MAX7456_SLAVE_IDX" value="SPI_SLAVE5"/>
<define name="USE_MATEK_TYPE_OSD_CHIP" value="true" />
<define name="USE_PAL_FOR_OSD_VIDEO" value="true" />
<define name="BARO_ALTITUDE_VAR" value="baro_alt" /> <!-- if non defined the default var is ''baro_alt'' -->
<!-- CURRENT SENSOR -->
<configure name="ADC_CURRENT_SENSOR" value="ADC_4"/>
</makefile>
</module>
@@ -0,0 +1,278 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* This file has been automatically generated using ChibiStudio board
* generator plugin. Do not edit manually.
*/
#include "hal.h"
#include "stm32_gpio.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/**
* @brief Type of STM32 GPIO port setup.
*/
typedef struct {
uint32_t moder;
uint32_t otyper;
uint32_t ospeedr;
uint32_t pupdr;
uint32_t odr;
uint32_t afrl;
uint32_t afrh;
} gpio_setup_t;
/**
* @brief Type of STM32 GPIO initialization data.
*/
typedef struct {
#if STM32_HAS_GPIOA || defined(__DOXYGEN__)
gpio_setup_t PAData;
#endif
#if STM32_HAS_GPIOB || defined(__DOXYGEN__)
gpio_setup_t PBData;
#endif
#if STM32_HAS_GPIOC || defined(__DOXYGEN__)
gpio_setup_t PCData;
#endif
#if STM32_HAS_GPIOD || defined(__DOXYGEN__)
gpio_setup_t PDData;
#endif
#if STM32_HAS_GPIOE || defined(__DOXYGEN__)
gpio_setup_t PEData;
#endif
#if STM32_HAS_GPIOF || defined(__DOXYGEN__)
gpio_setup_t PFData;
#endif
#if STM32_HAS_GPIOG || defined(__DOXYGEN__)
gpio_setup_t PGData;
#endif
#if STM32_HAS_GPIOH || defined(__DOXYGEN__)
gpio_setup_t PHData;
#endif
#if STM32_HAS_GPIOI || defined(__DOXYGEN__)
gpio_setup_t PIData;
#endif
#if STM32_HAS_GPIOJ || defined(__DOXYGEN__)
gpio_setup_t PJData;
#endif
#if STM32_HAS_GPIOK || defined(__DOXYGEN__)
gpio_setup_t PKData;
#endif
} gpio_config_t;
/**
* @brief STM32 GPIO static initialization data.
*/
static const gpio_config_t gpio_default_config = {
#if STM32_HAS_GPIOA
{VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
#endif
#if STM32_HAS_GPIOB
{VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
#endif
#if STM32_HAS_GPIOC
{VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
#endif
#if STM32_HAS_GPIOD
{VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
#endif
#if STM32_HAS_GPIOE
{VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
#endif
#if STM32_HAS_GPIOF
{VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
#endif
#if STM32_HAS_GPIOG
{VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
#endif
#if STM32_HAS_GPIOH
{VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
#endif
#if STM32_HAS_GPIOI
{VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH},
#endif
#if STM32_HAS_GPIOJ
{VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR,
VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH},
#endif
#if STM32_HAS_GPIOK
{VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR,
VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH}
#endif
};
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) {
gpiop->OTYPER = config->otyper;
gpiop->OSPEEDR = config->ospeedr;
gpiop->PUPDR = config->pupdr;
gpiop->ODR = config->odr;
gpiop->AFRL = config->afrl;
gpiop->AFRH = config->afrh;
gpiop->MODER = config->moder;
}
static void stm32_gpio_init(void) {
/* Enabling GPIO-related clocks, the mask comes from the
registry header file.*/
rccResetAHB1(STM32_GPIO_EN_MASK);
rccEnableAHB1(STM32_GPIO_EN_MASK, true);
/* Initializing all the defined GPIO ports.*/
#if STM32_HAS_GPIOA
gpio_init(GPIOA, &gpio_default_config.PAData);
#endif
#if STM32_HAS_GPIOB
gpio_init(GPIOB, &gpio_default_config.PBData);
#endif
#if STM32_HAS_GPIOC
gpio_init(GPIOC, &gpio_default_config.PCData);
#endif
#if STM32_HAS_GPIOD
gpio_init(GPIOD, &gpio_default_config.PDData);
#endif
#if STM32_HAS_GPIOE
gpio_init(GPIOE, &gpio_default_config.PEData);
#endif
#if STM32_HAS_GPIOF
gpio_init(GPIOF, &gpio_default_config.PFData);
#endif
#if STM32_HAS_GPIOG
gpio_init(GPIOG, &gpio_default_config.PGData);
#endif
#if STM32_HAS_GPIOH
gpio_init(GPIOH, &gpio_default_config.PHData);
#endif
#if STM32_HAS_GPIOI
gpio_init(GPIOI, &gpio_default_config.PIData);
#endif
#if STM32_HAS_GPIOJ
gpio_init(GPIOJ, &gpio_default_config.PJData);
#endif
#if STM32_HAS_GPIOK
gpio_init(GPIOK, &gpio_default_config.PKData);
#endif
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/**
* @brief Early initialization code.
* @details GPIO ports and system clocks are initialized before everything
* else.
*/
void __early_init(void) {
stm32_gpio_init();
stm32_clock_init();
}
#if HAL_USE_SDC || defined(__DOXYGEN__)
/**
* @brief SDC card detection.
*/
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
(void)sdcp;
/* assume card is inserted as there is no SD_DETECT pin
* actual detection will be done by the software
*/
return true;
}
/**
* @brief SDC card write protection detection.
*/
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
(void)sdcp;
return false;
}
#endif /* HAL_USE_SDC */
#if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
/**
* @brief MMC_SPI card detection.
*/
bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
(void)mmcp;
/* TODO: Fill the implementation.*/
return true;
}
/**
* @brief MMC_SPI card write protection detection.
*/
bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
(void)mmcp;
/* TODO: Fill the implementation.*/
return false;
}
#endif
/**
* @brief Board-specific initialization code.
* @todo Add your board-specific code, if any.
*/
void boardInit(void) {
}
/** Energy saving procedure for SD log closing
*/
void mcu_periph_energy_save(void)
{
palSetLineMode(LINE_LED1, PAL_MODE_INPUT);
palSetLineMode(LINE_LED2, PAL_MODE_INPUT);
palSetLineMode(LINE_OSD_CS, PAL_MODE_INPUT);
palSetLineMode(LINE_IMU1_CS, PAL_MODE_INPUT);
palSetLineMode(LINE_IMU2_CS, PAL_MODE_INPUT);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,20 @@
#
# ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Required include directories
BOARDINC = $(CHIBIOS_BOARD_DIR)
# List of all the board related files.
BOARDSRC = ${BOARDINC}/board.c
@@ -0,0 +1,270 @@
/* CHIBIOS FIX */
#include "ch.h"
/*---------------------------------------------------------------------------/
/ FatFs - FAT file system module configuration file
/---------------------------------------------------------------------------*/
#define FFCONF_DEF 87030 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Function Configurations
/---------------------------------------------------------------------------*/
#define FF_FS_READONLY 0
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
/ and optional writing functions as well. */
#define FF_FS_MINIMIZE 0
/* This option defines minimization level to remove some basic API functions.
/
/ 0: All basic functions are enabled.
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
/ are removed.
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
/ 3: f_lseek() function is removed in addition to 2. */
#define FF_USE_STRFUNC 0
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
/ f_printf().
/
/ 0: Disable string functions.
/ 1: Enable without LF-CRLF conversion.
/ 2: Enable with LF-CRLF conversion. */
#define FF_USE_FIND 1
/* This option switches filtered directory read functions, f_findfirst() and
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
#define FF_USE_MKFS 1
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
#define FF_USE_FASTSEEK 1
/* This option switches fast seek function. (0:Disable or 1:Enable) */
#define FF_USE_EXPAND 1
/* This option switches f_expand function. (0:Disable or 1:Enable) */
#define FF_USE_CHMOD 1
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
#define FF_USE_LABEL 1
/* This option switches volume label functions, f_getlabel() and f_setlabel().
/ (0:Disable or 1:Enable) */
#define FF_USE_FORWARD 1
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
/*---------------------------------------------------------------------------/
/ Locale and Namespace Configurations
/---------------------------------------------------------------------------*/
#define FF_CODE_PAGE 850
/* This option specifies the OEM code page to be used on the target system.
/ Incorrect setting of the code page can cause a file open failure.
/
/ 1 - ASCII (No extended character. Non-LFN cfg. only)
/ 437 - U.S.
/ 720 - Arabic
/ 737 - Greek
/ 771 - KBL
/ 775 - Baltic
/ 850 - Latin 1
/ 852 - Latin 2
/ 855 - Cyrillic
/ 857 - Turkish
/ 860 - Portuguese
/ 861 - Icelandic
/ 862 - Hebrew
/ 863 - Canadian French
/ 864 - Arabic
/ 865 - Nordic
/ 866 - Russian
/ 869 - Greek 2
/ 932 - Japanese (DBCS)
/ 936 - Simplified Chinese (DBCS)
/ 949 - Korean (DBCS)
/ 950 - Traditional Chinese (DBCS)
*/
#define FF_USE_LFN 3
#define FF_MAX_LFN 255
/* The FF_USE_LFN switches the support of long file name (LFN).
/
/ 0: Disable support of LFN. _MAX_LFN has no effect.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
/ 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP.
/
/ To enable the LFN, Unicode handling functions (option/unicode.c) must be added
/ to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and
/ additional 608 bytes at exFAT enabled. _MAX_LFN can be in range from 12 to 255.
/ It should be set 255 to support full featured LFN operations.
/ When use stack for the working buffer, take care on stack overflow. When use heap
/ memory for the working buffer, memory management functions, ff_memalloc() and
/ ff_memfree(), must be added to the project. */
#define FF_LFN_UNICODE 0
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:UTF-16)
/ To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1.
/ This option also affects behavior of string I/O functions. */
#define FF_STRF_ENCODE 3
/* When _LFN_UNICODE == 1, this option selects the character encoding ON THE FILE to
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
/
/ 0: ANSI/OEM
/ 1: UTF-16LE
/ 2: UTF-16BE
/ 3: UTF-8
/
/ This option has no effect when _LFN_UNICODE == 0. */
#define FF_FS_RPATH 1
/* This option configures support of relative path.
/
/ 0: Disable relative path and remove related functions.
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
/ 2: f_getcwd() function is available in addition to 1.
*/
/*---------------------------------------------------------------------------/
/ Drive/Volume Configurations
/---------------------------------------------------------------------------*/
#define FF_VOLUMES 1
/* Number of volumes (logical drives) to be used. */
#define FF_STR_VOLUME_ID 0
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
/* _STR_VOLUME_ID switches string support of volume ID.
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
/ the drive ID strings are: A-Z and 0-9. */
#define FF_MULTI_PARTITION 0
/* This option switches support of multi-partition on a physical drive.
/ By default (0), each logical drive number is bound to the same physical drive
/ number and only an FAT volume found on the physical drive will be mounted.
/ When multi-partition is enabled (1), each logical drive number can be bound to
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
/ funciton will be available. */
#define FF_MIN_SS 512
#define FF_MAX_SS 512
/* These options configure the range of sector size to be supported. (512, 1024,
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
/ harddisk. But a larger value may be required for on-board flash memory and some
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
/ disk_ioctl() function. */
#define FF_USE_TRIM 0
/* This option switches support of ATA-TRIM. (0:Disable or 1:Enable)
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
/ disk_ioctl() function. */
#define FF_FS_NOFSINFO 0
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/ option, and f_getfree() function at first time after volume mount will force
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
/
/ bit0=0: Use free cluster count in the FSINFO if available.
/ bit0=1: Do not trust free cluster count in the FSINFO.
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
*/
/*---------------------------------------------------------------------------/
/ System Configurations
/---------------------------------------------------------------------------*/
#define FF_FS_TINY 0
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
/ At the tiny configuration, size of file object (FIL) is reduced _MAX_SS bytes.
/ Instead of private sector buffer eliminated from the file object, common sector
/ buffer in the file system object (FATFS) is used for the file data transfer. */
#define FF_FS_EXFAT 1
/* This option switches support of exFAT file system. (0:Disable or 1:Enable)
/ When enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
/ Note that enabling exFAT discards C89 compatibility. */
#define FF_FS_NORTC 0
#define FF_NORTC_MON 1
#define FF_NORTC_MDAY 1
#define FF_NORTC_YEAR 2016
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
/ the timestamp function. All objects modified by FatFs will have a fixed timestamp
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time.
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
/ added to the project to get current time form real-time clock. _NORTC_MON,
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
/ These options have no effect at read-only configuration (FF_FS_READONLY = 1). */
#define FF_FS_LOCK 0
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
/ is 1.
/
/ 0: Disable file lock function. To avoid volume corruption, application program
/ should avoid illegal open, remove and rename to the open objects.
/ >0: Enable file lock function. The value defines how many files/sub-directories
/ can be opened simultaneously under file lock control. Note that the file
/ lock control is independent of re-entrancy. */
#define FF_FS_REENTRANT 1
#define FF_FS_TIMEOUT TIME_MS2I(1000)
#define FF_SYNC_t semaphore_t*
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/ module itself. Note that regardless of this option, file access to different
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
/ to the same volume is under control of this function.
/
/ 0: Disable re-entrancy. FF_FS_TIMEOUT and _SYNC_t have no effect.
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
/ function, must be added to the project. Samples are available in
/ option/syscall.c.
/
/ The FF_FS_TIMEOUT defines timeout period in unit of time tick.
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
/ included somewhere in the scope of ff.h. */
/* #include <windows.h> // O/S definitions */
/*--- End of configuration options ---*/
@@ -0,0 +1,144 @@
MCU_MODEL = STM32F765V(G-I)Tx
CHIBIOS_VERSION = 3.0
HEADER
/*
* Board identifier.
*/
#define BOARD_MATEKF765_WING
#define BOARD_NAME "MATEKSYS F765-WING"
/*
* Board oscillators-related settings.
*/
#if !defined(STM32_HSECLK)
#define STM32_HSECLK 8000000U
#endif
#if !defined(STM32_LSECLK)
#define STM32_LSECLK 32768U
#endif
#define STM32_LSEDRV (3U << 3U)
/*
* Board voltages.
* Required for performance limits calculation.
*/
#define STM32_VDD 300U
/*
* MCU type as defined in the ST header.
*/
#define STM32F767xx
CONFIG
# PIN NAME PERIPH_TYPE AF_NUMBER or
# PIN NAME FUNCTION PP_or_OPENDRAIN PIN_SPEED PULL_RESISTOR INITIAL_LEVEL AF_NUMBER
# SPEED : SPEED_VERYLOW, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH
#
# DEFAULT AND SYS
#
# 'SYS' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'ADC' => ['ANALOG', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_LOW'],
# 'PWM' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_LOW'],
# 'ICU' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'I2C' => ['ALTERNATE', 'OPENDRAIN', 'SPEED_HIGH', 'PULLUP', 'LEVEL_HIGH'],
# 'SPI' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'UART' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'PULLUP', 'LEVEL_HIGH'],
# 'OTG' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'ETH' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'FSMC' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'SDIO' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'PULLUP', 'LEVEL_HIGH'],
# 'SDIOCK' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'CAN' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'DCMI' => ['ALTERNATE', 'PUSHPULL', 'SPEED_HIGH', 'FLOATING', 'LEVEL_HIGH'],
# 'LED' => ['OUTPUT', 'PUSHPULL', 'SPEED_VERYLOW', 'FLOATING', 'LEVEL_LOW'],
# 'PASSIVE' => ['INPUT', 'PUSHPULL', 'SPEED_VERYLOW', 'FLOATING', 'LEVEL_LOW']);
#
# SYSTEM
A13 SWDIO SYS AF:SYS_JTMS-SWDIO
A14 SWCLK SYS AF:SYS_JTCK-SWCLK
C14 OSC32_IN SYS AF0
C15 OSC32_OUT SYS AF0
H00 OSC_IN SYS AF0
H01 OSC_OUT SYS AF0
#DEFAULT
DEFAULT INPUT PUSHPULL SPEED_VERYLOW PULLDOWN LEVEL_LOW AF0
# ACTIVE PINS
PA00 S1 PWM AF:TIM2_CH1 ()
PA01 S2 PWM AF:TIM2_CH2 ()
PA02 S3 PWM AF:TIM5_CH3 ()
PA03 S4 PWM AF:TIM5_CH4 ()
PA05 SPI1_SCK SPI AF:SPI1_SCK # MPU6000
PA06 SPI1_MISO SPI AF:SPI1_MISO # MPU6000
PA07 SPI1_MOSI SPI AF:SPI1_MOSI # MPU6000
PA08 LED_WS2812 PWM AF:TIM1_CH1 ()
PA09 UART1_TX UART AF:USART1_TX
PA10 UART1_RX UART AF:USART1_RX
PA11 OTG_FS_DM OTG AF:USB_OTG_FS_DM
PA12 OTG_FS_DP OTG AF:USB_OTG_FS_DP
PB00 S5 PWM AF:TIM8_CH2N ()
PB01 S6 PWM AF:TIM8_CH3N ()
PB03 SPI3_SCK SPI AF:SPI3_SCK # ICM20602
PB04 SPI3_MISO SPI AF:SPI3_MISO # ICM20602
PB05 SPI3_MOSI SPI AF:SPI3_MOSI # ICM20602
PB06 I2C1_SCL I2C AF:I2C1_SCL
PB07 I2C1_SDA I2C AF:I2C1_SDA
PB08 UART5_RX UART AF:UART5_RX # ESC telem
PB09 ALARM PWM AF:TIM11_CH1 ()
PB10 I2C2_SCL I2C AF:I2C2_SCL
PB11 I2C2_SDA I2C AF:I2C2_SDA
PB12 OSD_CS OUTPUT PUSHPULL SPEED_HIGH FLOATING LEVEL_HIGH # MAX7456
PB13 SPI2_SCK SPI AF:SPI2_SCK # MAX7456
PB14 SPI2_MISO SPI AF:SPI2_MISO # MAX7456
PB15 SPI2_MOSI SPI AF:SPI2_MOSI # MAX7456
PC00 AIRSPEED ADC ADC1_IN10 ()
PC01 RSSI ADC ADC1_IN11 ()
PC02 VBAT_MEAS ADC ADC1_IN12 ()
PC03 CURRENT_MEAS ADC ADC1_IN13 ()
PC04 IMU1_CS OUTPUT PUSHPULL SPEED_HIGH FLOATING LEVEL_HIGH # MPU6000
PC06 RC2 PASSIVE (AF:TIM8_CH1, AF:USART6_TX)
PC07 RC1 PASSIVE (AF:TIM3_CH2, AF:USART6_RX)
PC08 SDMMC1_D0 SDIO AF:SDMMC1_D0
PC09 SDMMC1_D1 SDIO AF:SDMMC1_D1
PC10 SDMMC1_D2 SDIO AF:SDMMC1_D2
PC11 SDMMC1_D3 SDIO AF:SDMMC1_D3
PC12 SDMMC1_CK SDIO AF:SDMMC1_CK
PD00 UART4_RX UART AF:UART4_RX (AF:CAN1_RX)
PD01 UART4_TX UART AF:UART4_TX (AF:CAN1_TX)
PD02 SDMMC1_CMD SDIO AF:SDMMC1_CMD
PD05 UART2_TX UART AF:USART2_TX
PD06 UART2_RX UART AF:USART2_RX
PD07 IMU2_CS OUTPUT PUSHPULL SPEED_HIGH FLOATING LEVEL_HIGH # ICM20602
PD08 UART3_TX UART AF:USART3_TX
PD09 UART3_RX UART AF:USART3_RX
PD10 LED1 LED # blue
PD11 LED2 LED # green
PD12 S7 PWM AF:TIM4_CH1 ()
PD13 S8 PWM AF:TIM4_CH2 ()
PD14 S9 PWM AF:TIM4_CH3 ()
PD15 S10 PWM AF:TIM4_CH4 ()
PE00 UART8_RX UART AF:UART8_RX
PE01 UART8_TX UART AF:UART8_TX
#PE04 PINIO1 Where is this pin ?
PE05 S11 PWM AF:TIM9_CH1 ()
PE06 S12 PWM AF:TIM9_CH2 ()
PE07 UART7_RX UART AF:UART7_RX
PE08 UART7_TX UART AF:UART7_TX
PE09 UART7_RTS UART AF:UART7_RTS
PE10 UART7_CTS UART AF:UART7_CTS
PE11 SPI4_CS OUTPUT PUSHPULL SPEED_HIGH FLOATING LEVEL_HIGH
PE12 SPI4_CLK SPI AF:SPI4_SCK
PE13 SPI4_MISO SPI AF:SPI4_MISO
PE14 SPI4_MOSI SPI AF:SPI4_MOSI
#PE15 PINIO2 Where is this pin ?
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+5
View File
@@ -88,6 +88,11 @@
#define STALL_AIRSPEED 10.0
#endif
#if !defined(MINIMUM_AIRSPEED)
#pragma message "MINIMUM_AIRSPEED not defined, 1.3 * STALL_SPEED will be used"
#define MINIMUM_AIRSPEED (1.3f * STALL_AIRSPEED)
#endif
#endif
#if !defined(IMU_MAG_X_SIGN)