diff --git a/Makefile b/Makefile index 7c998b2d37..73b20f8c94 100644 --- a/Makefile +++ b/Makefile @@ -682,6 +682,7 @@ COMMON_SRC = \ drivers/serial.c \ drivers/serial_pinconfig.c \ drivers/serial_uart.c \ + drivers/serial_uart_pinconfig.c \ drivers/sound_beeper.c \ drivers/stack_check.c \ drivers/system.c \ @@ -897,6 +898,7 @@ SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \ config/config_streamer.c \ drivers/serial_pinconfig.c \ drivers/serial_uart_init.c \ + drivers/serial_uart_pinconfig.c \ io/serial_4way.c \ io/serial_4way_avrootloader.c \ io/serial_4way_stk500v2.c \ @@ -1013,8 +1015,10 @@ SITLEXCLUDES = \ drivers/light_led.c \ drivers/system.c \ drivers/rcc.c \ - drivers/serial_uart.c \ drivers/serial_pinconfig.c \ + drivers/serial_uart.c \ + drivers/serial_uart_init.c \ + drivers/serial_uart_pinconfig.c \ drivers/rx_xn297.c \ drivers/display_ug2864hsweg01.c \ telemetry/crsf.c \ diff --git a/Makefile.orig b/Makefile.orig deleted file mode 100644 index 21ac357f44..0000000000 --- a/Makefile.orig +++ /dev/null @@ -1,1439 +0,0 @@ -############################################################################### -# "THE BEER-WARE LICENSE" (Revision 42): -# wrote this file. As long as you retain this notice you -# can do whatever you want with this stuff. If we meet some day, and you think -# this stuff is worth it, you can buy me a beer in return -############################################################################### -# -# Makefile for building the betaflight firmware. -# -# Invoke this with 'make help' to see the list of supported targets. -# -############################################################################### - - -# Things that the user might override on the commandline -# - -# The target to build, see VALID_TARGETS below -TARGET ?= NAZE - -# Compile-time options -OPTIONS ?= - -# compile for OpenPilot BootLoader support -OPBL ?= no - -# Debugger optons, must be empty or GDB -DEBUG ?= - -# Insert the debugging hardfault debugger -# releases should not be built with this flag as it does not disable pwm output -DEBUG_HARDFAULTS ?= - -# Serial port/Device for flashing -SERIAL_DEVICE ?= $(firstword $(wildcard /dev/ttyUSB*) no-port-found) - -# Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override. -FLASH_SIZE ?= - - -############################################################################### -# Things that need to be maintained as the source changes -# - -FORKNAME = betaflight - -# Working directories -ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -SRC_DIR = $(ROOT)/src/main -OBJECT_DIR = $(ROOT)/obj/main -BIN_DIR = $(ROOT)/obj -CMSIS_DIR = $(ROOT)/lib/main/CMSIS -INCLUDE_DIRS = $(SRC_DIR) \ - $(ROOT)/src/main/target -LINKER_DIR = $(ROOT)/src/main/target/link - -## V : Set verbosity level based on the V= parameter -## V=0 Low -## V=1 High -include $(ROOT)/make/build_verbosity.mk - -# Build tools, so we all share the same versions -# import macros common to all supported build systems -include $(ROOT)/make/system-id.mk - -# developer preferences, edit these at will, they'll be gitignored --include $(ROOT)/make/local.mk - -# configure some directories that are relative to wherever ROOT_DIR is located -ifndef TOOLS_DIR -TOOLS_DIR := $(ROOT)/tools -endif -BUILD_DIR := $(ROOT)/build -DL_DIR := $(ROOT)/downloads - -export RM := rm - -# import macros that are OS specific -include $(ROOT)/make/$(OSFAMILY).mk - -# include the tools makefile -include $(ROOT)/make/tools.mk - -# default xtal value for F4 targets -HSE_VALUE ?= 8000000 - -# used for turning on features like VCP and SDCARD -FEATURES = - -OFFICIAL_TARGETS = ALIENFLIGHTF3 ALIENFLIGHTF4 ANYFCF7 BETAFLIGHTF3 BLUEJAYF4 CC3D FURYF4 NAZE REVO SIRINFPV SPARKY SPRACINGF3 SPRACINGF3EVO SPRACINGF3NEO SPRACINGF4EVO STM32F3DISCOVERY -ALT_TARGETS = $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/*/*.mk))))) -OPBL_TARGETS = $(filter %_OPBL, $(ALT_TARGETS)) -OSD_SLAVE_TARGETS = SPRACINGF3OSD - -VALID_TARGETS = $(dir $(wildcard $(ROOT)/src/main/target/*/target.mk)) -VALID_TARGETS := $(subst /,, $(subst ./src/main/target/,, $(VALID_TARGETS))) -VALID_TARGETS := $(VALID_TARGETS) $(ALT_TARGETS) -VALID_TARGETS := $(sort $(VALID_TARGETS)) - -GROUP_1_TARGETS := \ - AFROMINI \ - AIORACERF3 \ - AIR32 \ - AIRBOTF4 \ - AIRBOTF4SD \ - AIRHEROF3 \ - ALIENFLIGHTF1 \ - ALIENFLIGHTF3 \ - ALIENFLIGHTF4 \ - ALIENFLIGHTNGF7 \ - ANYFCF7 \ - BEEBRAIN \ - BEEROTORF4 \ - BETAFLIGHTF3 \ - BLUEJAYF4 \ - CC3D \ - CC3D_OPBL \ - -GROUP_2_TARGETS := \ - CHEBUZZF3 \ - CJMCU \ - CL_RACINGF4 \ - COLIBRI \ - COLIBRI_OPBL \ - COLIBRI_RACE \ - DOGE \ - ELLE0 \ - F4BY \ - FISHDRONEF4 \ - FLIP32F3OSD \ - FURYF3 \ - FURYF4 \ - FURYF7 \ - IMPULSERCF3 \ - IRCFUSIONF3 \ - ISHAPEDF3 \ - -GROUP_3_TARGETS := \ - KAKUTEF4 \ - KISSCC \ - KIWIF4 \ - LUX_RACE \ - LUXV2_RACE \ - MICROSCISKY \ - MOTOLAB \ - MULTIFLITEPICO \ - NAZE \ - NERO \ - NUCLEOF7 \ - OMNIBUS \ - OMNIBUSF4 \ - OMNIBUSF4SD \ - PIKOBLX \ - PLUMF4 \ - PODIUMF4 \ - -GROUP_4_TARGETS := \ - RCEXPLORERF3 \ - REVO \ - REVO_OPBL \ - REVOLT \ - REVONANO \ - RMDO \ - SINGULARITY \ - SIRINFPV \ - SOULF4 \ - SPARKY \ - SPARKY2 \ - SPRACINGF3 \ - SPRACINGF3EVO \ - SPRACINGF3MINI \ - SPRACINGF3NEO \ - SPRACINGF3OSD \ - SPRACINGF4EVO \ - STM32F3DISCOVERY \ - TINYBEEF3 \ - -GROUP_OTHER_TARGETS := $(filter-out $(GROUP_1_TARGETS) $(GROUP_2_TARGETS) $(GROUP_3_TARGETS) $(GROUP_4_TARGETS), $(VALID_TARGETS)) - - -ifeq ($(filter $(TARGET),$(ALT_TARGETS)), $(TARGET)) -BASE_TARGET := $(firstword $(subst /,, $(subst ./src/main/target/,, $(dir $(wildcard $(ROOT)/src/main/target/*/$(TARGET).mk))))) --include $(ROOT)/src/main/target/$(BASE_TARGET)/$(TARGET).mk -else -BASE_TARGET := $(TARGET) -endif - -ifeq ($(filter $(TARGET),$(OPBL_TARGETS)), $(TARGET)) -OPBL = yes -endif - -ifeq ($(filter $(TARGET),$(OSD_SLAVE_TARGETS)), $(TARGET)) -# build an OSD SLAVE -OSD_SLAVE = yes -else -# build an FC -FC = yes -endif - - -# silently ignore if the file is not present. Allows for target specific. --include $(ROOT)/src/main/target/$(BASE_TARGET)/target.mk - -F4_TARGETS = $(F405_TARGETS) $(F411_TARGETS) $(F446_TARGETS) -F7_TARGETS = $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS) - -ifeq ($(filter $(TARGET),$(VALID_TARGETS)),) -$(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have you prepared a valid target.mk?) -endif - -ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS) $(SITL_TARGETS)),) -$(error Target '$(TARGET)' has not specified a valid STM group, must be one of F1, F3, F405, F411 or F7x5. Have you prepared a valid target.mk?) -endif - -128K_TARGETS = $(F1_TARGETS) -256K_TARGETS = $(F3_TARGETS) -512K_TARGETS = $(F411_TARGETS) $(F446_TARGETS) $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) -1024K_TARGETS = $(F405_TARGETS) $(F7X5XG_TARGETS) $(F7X6XG_TARGETS) -2048K_TARGETS = $(F7X5XI_TARGETS) $(SITL_TARGETS) - -# Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already. -ifeq ($(FLASH_SIZE),) -ifeq ($(TARGET),$(filter $(TARGET),$(2048K_TARGETS))) -FLASH_SIZE = 2048 -else ifeq ($(TARGET),$(filter $(TARGET),$(1024K_TARGETS))) -FLASH_SIZE = 1024 -else ifeq ($(TARGET),$(filter $(TARGET),$(512K_TARGETS))) -FLASH_SIZE = 512 -else ifeq ($(TARGET),$(filter $(TARGET),$(256K_TARGETS))) -FLASH_SIZE = 256 -else ifeq ($(TARGET),$(filter $(TARGET),$(128K_TARGETS))) -FLASH_SIZE = 128 -else -$(error FLASH_SIZE not configured for target $(TARGET)) -endif -endif - -# note that there is no hardfault debugging startup file assembly handler for other platforms -ifeq ($(DEBUG_HARDFAULTS),F3) -CFLAGS += -DDEBUG_HARDFAULTS -STM32F30x_COMMON_SRC = startup_stm32f3_debug_hardfault_handler.S -else -STM32F30x_COMMON_SRC = startup_stm32f30x_md_gcc.S -endif - -ifeq ($(DEBUG_HARDFAULTS),F7) -CFLAGS += -DDEBUG_HARDFAULTS -endif - -REVISION := $(shell git log -1 --format="%h") - -FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' ) -FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' ) -FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' ) - -FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH) - -# Search path for sources -VPATH := $(SRC_DIR):$(SRC_DIR)/startup -USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver -USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c)) -FATFS_DIR = $(ROOT)/lib/main/FatFS -FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c)) - -CSOURCES := $(shell find $(SRC_DIR) -name '*.c') - -ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS))) -# F3 TARGETS - -STDPERIPH_DIR = $(ROOT)/lib/main/STM32F30x_StdPeriph_Driver -STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c)) -EXCLUDES = stm32f30x_crc.c \ - stm32f30x_can.c -STARTUP_SRC = startup_stm32f30x_md_gcc.S - -STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC)) -DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC) - -VPATH := $(VPATH):$(CMSIS_DIR)/CM4/CoreSupport:$(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F30x -CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM4/CoreSupport/*.c \ - $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F30x/*.c)) - -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(STDPERIPH_DIR)/inc \ - $(CMSIS_DIR)/CM4/CoreSupport \ - $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F30x - -ifneq ($(filter VCP, $(FEATURES)),) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(USBFS_DIR)/inc \ - $(ROOT)/src/main/vcp - -VPATH := $(VPATH):$(USBFS_DIR)/src - -DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC)\ - $(USBPERIPH_SRC) -endif - -ifneq ($(filter SDCARD, $(FEATURES)),) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(FATFS_DIR) \ - -VPATH := $(VPATH):$(FATFS_DIR) -endif - -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k.ld - -ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion -DEVICE_FLAGS = -DSTM32F303xC -DSTM32F303 -# End F3 targets -# -# Start F4 targets -else ifeq ($(TARGET),$(filter $(TARGET), $(F4_TARGETS))) - -#STDPERIPH -STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4xx_StdPeriph_Driver -STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c)) -EXCLUDES = stm32f4xx_crc.c \ - stm32f4xx_can.c \ - stm32f4xx_fmc.c \ - stm32f4xx_sai.c \ - stm32f4xx_cec.c \ - stm32f4xx_dsi.c \ - stm32f4xx_flash_ramfunc.c \ - stm32f4xx_fmpi2c.c \ - stm32f4xx_lptim.c \ - stm32f4xx_qspi.c \ - stm32f4xx_spdifrx.c \ - stm32f4xx_cryp.c \ - stm32f4xx_cryp_aes.c \ - stm32f4xx_hash_md5.c \ - stm32f4xx_cryp_des.c \ - stm32f4xx_rtc.c \ - stm32f4xx_hash.c \ - stm32f4xx_dbgmcu.c \ - stm32f4xx_cryp_tdes.c \ - stm32f4xx_hash_sha1.c - -ifeq ($(TARGET),$(filter $(TARGET), $(F411_TARGETS))) -EXCLUDES += stm32f4xx_fsmc.c -endif - -ifeq ($(TARGET),$(filter $(TARGET), $(F446_TARGETS))) -EXCLUDES += stm32f4xx_fsmc.c -endif - -STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC)) - -#USB -USBCORE_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Core -USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/src/*.c)) -USBOTG_DIR = $(ROOT)/lib/main/STM32_USB_OTG_Driver -USBOTG_SRC = $(notdir $(wildcard $(USBOTG_DIR)/src/*.c)) -EXCLUDES = usb_bsp_template.c \ - usb_conf_template.c \ - usb_hcd_int.c \ - usb_hcd.c \ - usb_otg.c - -USBOTG_SRC := $(filter-out ${EXCLUDES}, $(USBOTG_SRC)) -USBCDC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/cdc -USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/src/*.c)) -EXCLUDES = usbd_cdc_if_template.c -USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC)) -VPATH := $(VPATH):$(USBOTG_DIR)/src:$(USBCORE_DIR)/src:$(USBCDC_DIR)/src - -DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \ - $(USBOTG_SRC) \ - $(USBCORE_SRC) \ - $(USBCDC_SRC) - -#CMSIS -VPATH := $(VPATH):$(CMSIS_DIR)/CM4/CoreSupport:$(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx -CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM4/CoreSupport/*.c \ - $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx/*.c)) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(STDPERIPH_DIR)/inc \ - $(USBOTG_DIR)/inc \ - $(USBCORE_DIR)/inc \ - $(USBCDC_DIR)/inc \ - $(USBFS_DIR)/inc \ - $(CMSIS_DIR)/CM4/CoreSupport \ - $(CMSIS_DIR)/CM4/DeviceSupport/ST/STM32F4xx \ - $(ROOT)/src/main/vcpf4 - -ifneq ($(filter SDCARD,$(FEATURES)),) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(FATFS_DIR) -VPATH := $(VPATH):$(FATFS_DIR) -endif - -#Flags -ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion - -ifeq ($(TARGET),$(filter $(TARGET),$(F411_TARGETS))) -DEVICE_FLAGS = -DSTM32F411xE -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld -STARTUP_SRC = startup_stm32f411xe.s -else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS))) -DEVICE_FLAGS = -DSTM32F40_41xxx -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405.ld -STARTUP_SRC = startup_stm32f40xx.s -else ifeq ($(TARGET),$(filter $(TARGET),$(F446_TARGETS))) -DEVICE_FLAGS = -DSTM32F446xx -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f446.ld -STARTUP_SRC = startup_stm32f446xx.s -else -$(error Unknown MCU for F4 target) -endif -DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE) - -# End F4 targets -# -# Start F7 targets -else ifeq ($(TARGET),$(filter $(TARGET), $(F7_TARGETS))) - -#STDPERIPH -STDPERIPH_DIR = $(ROOT)/lib/main/STM32F7xx_HAL_Driver -STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c)) -EXCLUDES = stm32f7xx_hal_can.c \ - stm32f7xx_hal_cec.c \ - stm32f7xx_hal_crc.c \ - stm32f7xx_hal_crc_ex.c \ - stm32f7xx_hal_cryp.c \ - stm32f7xx_hal_cryp_ex.c \ - stm32f7xx_hal_dac.c \ - stm32f7xx_hal_dac_ex.c \ - stm32f7xx_hal_dcmi.c \ - stm32f7xx_hal_dcmi_ex.c \ - stm32f7xx_hal_dfsdm.c \ - stm32f7xx_hal_dma2d.c \ - stm32f7xx_hal_dsi.c \ - stm32f7xx_hal_eth.c \ - stm32f7xx_hal_hash.c \ - stm32f7xx_hal_hash_ex.c \ - stm32f7xx_hal_hcd.c \ - stm32f7xx_hal_i2s.c \ - stm32f7xx_hal_irda.c \ - stm32f7xx_hal_iwdg.c \ - stm32f7xx_hal_jpeg.c \ - stm32f7xx_hal_lptim.c \ - stm32f7xx_hal_ltdc.c \ - stm32f7xx_hal_ltdc_ex.c \ - stm32f7xx_hal_mdios.c \ - stm32f7xx_hal_mmc.c \ - stm32f7xx_hal_msp_template.c \ - stm32f7xx_hal_nand.c \ - stm32f7xx_hal_nor.c \ - stm32f7xx_hal_qspi.c \ - stm32f7xx_hal_rng.c \ - stm32f7xx_hal_rtc.c \ - stm32f7xx_hal_rtc_ex.c \ - stm32f7xx_hal_sai.c \ - stm32f7xx_hal_sai_ex.c \ - stm32f7xx_hal_sd.c \ - stm32f7xx_hal_sdram.c \ - stm32f7xx_hal_smartcard.c \ - stm32f7xx_hal_smartcard_ex.c \ - stm32f7xx_hal_smbus.c \ - stm32f7xx_hal_spdifrx.c \ - stm32f7xx_hal_sram.c \ - stm32f7xx_hal_timebase_rtc_alarm_template.c \ - stm32f7xx_hal_timebase_rtc_wakeup_template.c \ - stm32f7xx_hal_timebase_tim_template.c \ - stm32f7xx_hal_wwdg.c \ - stm32f7xx_ll_adc.c \ - stm32f7xx_ll_crc.c \ - stm32f7xx_ll_dac.c \ - stm32f7xx_ll_dma.c \ - stm32f7xx_ll_dma2d.c \ - stm32f7xx_ll_exti.c \ - stm32f7xx_ll_fmc.c \ - stm32f7xx_ll_gpio.c \ - stm32f7xx_ll_i2c.c \ - stm32f7xx_ll_lptim.c \ - stm32f7xx_ll_pwr.c \ - stm32f7xx_ll_rcc.c \ - stm32f7xx_ll_rng.c \ - stm32f7xx_ll_rtc.c \ - stm32f7xx_ll_sdmmc.c \ - stm32f7xx_ll_spi.c \ - stm32f7xx_ll_tim.c \ - stm32f7xx_ll_usart.c \ - stm32f7xx_ll_utils.c - -STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC)) - -#USB -USBCORE_DIR = $(ROOT)/lib/main/Middlewares/ST/STM32_USB_Device_Library/Core -USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c)) -EXCLUDES = usbd_conf_template.c -USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC)) - -USBCDC_DIR = $(ROOT)/lib/main/Middlewares/ST/STM32_USB_Device_Library/Class/CDC -USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c)) -EXCLUDES = usbd_cdc_if_template.c -USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC)) - -VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src - -DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \ - $(USBCORE_SRC) \ - $(USBCDC_SRC) - -#CMSIS -VPATH := $(VPATH):$(CMSIS_DIR)/CM7/Include:$(CMSIS_DIR)/CM7/Device/ST/STM32F7xx -VPATH := $(VPATH):$(STDPERIPH_DIR)/Src -CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM7/Include/*.c \ - $(CMSIS_DIR)/CM7/Device/ST/STM32F7xx/*.c)) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(STDPERIPH_DIR)/Inc \ - $(USBCORE_DIR)/Inc \ - $(USBCDC_DIR)/Inc \ - $(CMSIS_DIR)/CM7/Include \ - $(CMSIS_DIR)/CM7/Device/ST/STM32F7xx/Include \ - $(ROOT)/src/main/vcp_hal - -ifneq ($(filter SDCARD,$(FEATURES)),) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(FATFS_DIR) -VPATH := $(VPATH):$(FATFS_DIR) -endif - -#Flags -ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant -Wdouble-promotion - -ifeq ($(TARGET),$(filter $(TARGET),$(F7X5XG_TARGETS))) -DEVICE_FLAGS = -DSTM32F745xx -DUSE_HAL_DRIVER -D__FPU_PRESENT -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f745.ld -STARTUP_SRC = startup_stm32f745xx.s -else ifeq ($(TARGET),$(filter $(TARGET),$(F7X6XG_TARGETS))) -DEVICE_FLAGS = -DSTM32F746xx -DUSE_HAL_DRIVER -D__FPU_PRESENT -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f746.ld -STARTUP_SRC = startup_stm32f746xx.s -else ifeq ($(TARGET),$(filter $(TARGET),$(F7X2RE_TARGETS))) -DEVICE_FLAGS = -DSTM32F722xx -DUSE_HAL_DRIVER -D__FPU_PRESENT -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f722.ld -STARTUP_SRC = startup_stm32f722xx.s -else -$(error Unknown MCU for F7 target) -endif -DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE) - -TARGET_FLAGS = -D$(TARGET) - -# End F7 targets -# -# Start SITL targets -else ifeq ($(TARGET),$(filter $(TARGET), $(SITL_TARGETS))) - -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(ROOT)/lib/main/dyad - -SITL_SRC := $(ROOT)/lib/main/dyad/dyad.c - -#Flags -ARCH_FLAGS = -DEVICE_FLAGS = -LD_SCRIPT = src/main/target/SITL/parameter_group.ld -STARTUP_SRC = - -TARGET_FLAGS = -D$(TARGET) - -ARM_SDK_PREFIX = - -# End SITL targets -# -# Start F1 targets -else - -STDPERIPH_DIR = $(ROOT)/lib/main/STM32F10x_StdPeriph_Driver -STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c)) -EXCLUDES = stm32f10x_crc.c \ - stm32f10x_cec.c \ - stm32f10x_can.c -STARTUP_SRC = startup_stm32f10x_md_gcc.S -STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC)) - -# Search path and source files for the CMSIS sources -VPATH := $(VPATH):$(CMSIS_DIR)/CM3/CoreSupport:$(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x -CMSIS_SRC = $(notdir $(wildcard $(CMSIS_DIR)/CM3/CoreSupport/*.c \ - $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x/*.c)) - -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(STDPERIPH_DIR)/inc \ - $(CMSIS_DIR)/CM3/CoreSupport \ - $(CMSIS_DIR)/CM3/DeviceSupport/ST/STM32F10x - -DEVICE_STDPERIPH_SRC = $(STDPERIPH_SRC) - -ifneq ($(filter VCP, $(FEATURES)),) -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(USBFS_DIR)/inc \ - $(ROOT)/src/main/vcp - -VPATH := $(VPATH):$(USBFS_DIR)/src - -DEVICE_STDPERIPH_SRC := $(DEVICE_STDPERIPH_SRC) \ - $(USBPERIPH_SRC) - -endif - -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k.ld -ARCH_FLAGS = -mthumb -mcpu=cortex-m3 - -ifeq ($(DEVICE_FLAGS),) -DEVICE_FLAGS = -DSTM32F10X_MD -endif -DEVICE_FLAGS += -DSTM32F10X - -endif -# -# End F1 targets -# -ifneq ($(BASE_TARGET), $(TARGET)) -TARGET_FLAGS := $(TARGET_FLAGS) -D$(BASE_TARGET) -endif - -ifneq ($(FLASH_SIZE),) -DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE) -endif - -ifneq ($(HSE_VALUE),) -DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE) -endif - -TARGET_DIR = $(ROOT)/src/main/target/$(BASE_TARGET) -TARGET_DIR_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c)) - -ifeq ($(OPBL),yes) -TARGET_FLAGS := -DOPBL $(TARGET_FLAGS) -ifeq ($(TARGET), $(filter $(TARGET),$(F405_TARGETS))) -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405_opbl.ld -else ifeq ($(TARGET), $(filter $(TARGET),$(F411_TARGETS))) -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411_opbl.ld -else ifeq ($(TARGET), $(filter $(TARGET),$(F3_TARGETS))) -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f303_$(FLASH_SIZE)k_opbl.ld -else ifeq ($(TARGET), $(filter $(TARGET),$(F1_TARGETS))) -LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f103_$(FLASH_SIZE)k_opbl.ld -endif -.DEFAULT_GOAL := binary -else -.DEFAULT_GOAL := hex -endif - -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(ROOT)/lib/main/MAVLink - -INCLUDE_DIRS := $(INCLUDE_DIRS) \ - $(TARGET_DIR) - -VPATH := $(VPATH):$(TARGET_DIR) - -COMMON_SRC = \ - build/build_config.c \ - build/debug.c \ - build/version.c \ - $(TARGET_DIR_SRC) \ - main.c \ - common/encoding.c \ - common/filter.c \ - common/maths.c \ - common/printf.c \ - common/streambuf.c \ - common/typeconversion.c \ - config/config_eeprom.c \ - config/feature.c \ - config/parameter_group.c \ - config/config_streamer.c \ - drivers/adc.c \ - drivers/buf_writer.c \ - drivers/bus_i2c_soft.c \ - drivers/bus_spi.c \ - drivers/bus_spi_soft.c \ - drivers/buttons.c \ - drivers/display.c \ - drivers/exti.c \ - drivers/io.c \ - drivers/light_led.c \ - drivers/resource.c \ - drivers/rcc.c \ - drivers/serial.c \ - drivers/serial_pinconfig.c \ - drivers/serial_uart.c \ - drivers/sound_beeper.c \ - drivers/stack_check.c \ - drivers/system.c \ - drivers/timer.c \ - drivers/transponder_ir.c \ - fc/config.c \ - fc/fc_dispatch.c \ - fc/fc_hardfaults.c \ - fc/fc_msp.c \ - fc/fc_tasks.c \ - fc/runtime_config.c \ - io/beeper.c \ - io/serial.c \ - io/statusindicator.c \ - io/transponder_ir.c \ - msp/msp_serial.c \ - scheduler/scheduler.c \ - sensors/battery.c \ - sensors/current.c \ - sensors/voltage.c \ - -OSD_SLAVE_SRC = \ - io/displayport_max7456.c \ - osd_slave/osd_slave_init.c \ - io/osd_slave.c - -FC_SRC = \ - fc/fc_init.c \ - fc/controlrate_profile.c \ - drivers/gyro_sync.c \ - drivers/rx_nrf24l01.c \ - drivers/rx_spi.c \ - drivers/rx_xn297.c \ - drivers/pwm_esc_detect.c \ - drivers/pwm_output.c \ - drivers/rx_pwm.c \ - drivers/serial_softserial.c \ - fc/fc_core.c \ - fc/fc_rc.c \ - fc/rc_adjustments.c \ - fc/rc_controls.c \ - fc/cli.c \ - fc/settings.c \ - flight/altitude.c \ - flight/failsafe.c \ - flight/imu.c \ - flight/mixer.c \ - flight/pid.c \ - flight/servos.c \ - io/serial_4way.c \ - io/serial_4way_avrootloader.c \ - io/serial_4way_stk500v2.c \ - rx/ibus.c \ - rx/jetiexbus.c \ - rx/msp.c \ - rx/nrf24_cx10.c \ - rx/nrf24_inav.c \ - rx/nrf24_h8_3d.c \ - rx/nrf24_syma.c \ - rx/nrf24_v202.c \ - rx/pwm.c \ - rx/rx.c \ - rx/rx_spi.c \ - rx/crsf.c \ - rx/sbus.c \ - rx/spektrum.c \ - rx/sumd.c \ - rx/sumh.c \ - rx/xbus.c \ - sensors/acceleration.c \ - sensors/boardalignment.c \ - sensors/compass.c \ - sensors/gyro.c \ - sensors/gyroanalyse.c \ - sensors/initialisation.c \ - blackbox/blackbox.c \ - blackbox/blackbox_encoding.c \ - blackbox/blackbox_io.c \ - cms/cms.c \ - cms/cms_menu_blackbox.c \ - cms/cms_menu_builtin.c \ - cms/cms_menu_imu.c \ - cms/cms_menu_ledstrip.c \ - cms/cms_menu_misc.c \ - cms/cms_menu_osd.c \ - common/colorconversion.c \ - common/gps_conversion.c \ - drivers/display_ug2864hsweg01.c \ - drivers/light_ws2811strip.c \ - drivers/serial_escserial.c \ - drivers/sonar_hcsr04.c \ - drivers/vtx_common.c \ - drivers/transponder_ir.c \ - flight/navigation.c \ - io/dashboard.c \ - io/displayport_max7456.c \ - io/displayport_msp.c \ - io/displayport_oled.c \ - io/gps.c \ - io/ledstrip.c \ - io/osd.c \ - sensors/sonar.c \ - sensors/barometer.c \ - telemetry/telemetry.c \ - telemetry/crsf.c \ - telemetry/srxl.c \ - telemetry/frsky.c \ - telemetry/hott.c \ - telemetry/smartport.c \ - telemetry/ltm.c \ - telemetry/mavlink.c \ - telemetry/ibus.c \ - telemetry/ibus_shared.c \ - sensors/esc_sensor.c \ - io/vtx_string.c \ - io/vtx_rtc6705.c \ - io/vtx_smartaudio.c \ - io/vtx_tramp.c \ - io/vtx_control.c - -COMMON_DEVICE_SRC = \ - $(CMSIS_SRC) \ - $(DEVICE_STDPERIPH_SRC) - -ifeq ($(OSD_SLAVE),yes) -TARGET_FLAGS := -DUSE_OSD_SLAVE $(TARGET_FLAGS) -COMMON_SRC := $(COMMON_SRC) $(OSD_SLAVE_SRC) $(COMMON_DEVICE_SRC) -else -COMMON_SRC := $(COMMON_SRC) $(FC_SRC) $(COMMON_DEVICE_SRC) -endif - - -SPEED_OPTIMISED_SRC := "" -SIZE_OPTIMISED_SRC := "" - -ifneq ($(TARGET),$(filter $(TARGET),$(F1_TARGETS))) -SPEED_OPTIMISED_SRC := $(SPEED_OPTIMISED_SRC) \ - common/encoding.c \ - common/filter.c \ - common/maths.c \ - common/typeconversion.c \ - drivers/adc.c \ - drivers/buf_writer.c \ - drivers/bus_i2c_soft.c \ - drivers/bus_spi.c \ - drivers/bus_spi_soft.c \ - drivers/exti.c \ - drivers/gyro_sync.c \ - drivers/io.c \ - drivers/light_led.c \ - drivers/resource.c \ - drivers/rx_nrf24l01.c \ - drivers/rx_spi.c \ - drivers/rx_xn297.c \ - drivers/pwm_output.c \ - drivers/rcc.c \ - drivers/rx_pwm.c \ - drivers/serial.c \ - drivers/serial_uart.c \ - drivers/sound_beeper.c \ - drivers/system.c \ - drivers/timer.c \ - fc/fc_core.c \ - fc/fc_tasks.c \ - fc/fc_rc.c \ - fc/rc_controls.c \ - fc/runtime_config.c \ - flight/imu.c \ - flight/mixer.c \ - flight/pid.c \ - flight/servos.c \ - io/serial.c \ - rx/ibus.c \ - rx/jetiexbus.c \ - rx/nrf24_cx10.c \ - rx/nrf24_inav.c \ - rx/nrf24_h8_3d.c \ - rx/nrf24_syma.c \ - rx/nrf24_v202.c \ - rx/pwm.c \ - rx/rx.c \ - rx/rx_spi.c \ - rx/crsf.c \ - rx/sbus.c \ - rx/spektrum.c \ - rx/sumd.c \ - rx/sumh.c \ - rx/xbus.c \ - scheduler/scheduler.c \ - sensors/acceleration.c \ - sensors/boardalignment.c \ - sensors/gyro.c \ - sensors/gyroanalyse.c \ - $(CMSIS_SRC) \ - $(DEVICE_STDPERIPH_SRC) \ - drivers/display_ug2864hsweg01.c \ - drivers/light_ws2811strip.c \ - drivers/serial_softserial.c \ - io/dashboard.c \ - io/displayport_max7456.c \ - io/osd.c \ - io/osd_slave.c - -SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \ - drivers/serial_escserial.c \ - drivers/vtx_common.c \ - fc/fc_init.c \ - fc/cli.c \ - fc/settings.c \ - config/config_eeprom.c \ - config/feature.c \ - config/parameter_group.c \ - config/config_streamer.c \ - drivers/serial_pinconfig.c \ - drivers/serial_uart_init.c \ - io/serial_4way.c \ - io/serial_4way_avrootloader.c \ - io/serial_4way_stk500v2.c \ - msp/msp_serial.c \ - cms/cms.c \ - cms/cms_menu_blackbox.c \ - cms/cms_menu_builtin.c \ - cms/cms_menu_imu.c \ - cms/cms_menu_ledstrip.c \ - cms/cms_menu_misc.c \ - cms/cms_menu_osd.c \ - io/vtx_rtc6705.c \ - io/vtx_smartaudio.c \ - io/vtx_tramp.c -endif #!F1 - -ifeq ($(TARGET),$(filter $(TARGET),$(F4_TARGETS))) -VCP_SRC = \ - vcpf4/stm32f4xx_it.c \ - vcpf4/usb_bsp.c \ - vcpf4/usbd_desc.c \ - vcpf4/usbd_usr.c \ - vcpf4/usbd_cdc_vcp.c \ - drivers/serial_usb_vcp.c \ - drivers/usb_io.c -else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS))) -VCP_SRC = \ - vcp_hal/usbd_desc.c \ - vcp_hal/usbd_conf.c \ - vcp_hal/usbd_cdc_interface.c \ - drivers/serial_usb_vcp.c \ - drivers/usb_io.c -else -VCP_SRC = \ - vcp/hw_config.c \ - vcp/stm32_it.c \ - vcp/usb_desc.c \ - vcp/usb_endp.c \ - vcp/usb_istr.c \ - vcp/usb_prop.c \ - vcp/usb_pwr.c \ - drivers/serial_usb_vcp.c \ - drivers/usb_io.c -endif - -STM32F10x_COMMON_SRC = \ - drivers/adc_stm32f10x.c \ - drivers/bus_i2c_stm32f10x.c \ - drivers/dma.c \ - drivers/gpio_stm32f10x.c \ - drivers/inverter.c \ - drivers/light_ws2811strip_stdperiph.c \ - drivers/serial_uart_init.c \ - drivers/serial_uart_stm32f10x.c \ - drivers/system_stm32f10x.c \ - drivers/timer_stm32f10x.c - -STM32F30x_COMMON_SRC = \ - target/system_stm32f30x.c \ - drivers/adc_stm32f30x.c \ - drivers/bus_i2c_stm32f30x.c \ - drivers/dma.c \ - drivers/gpio_stm32f30x.c \ - drivers/light_ws2811strip_stdperiph.c \ - drivers/pwm_output_dshot.c \ - drivers/serial_uart_init.c \ - drivers/serial_uart_stm32f30x.c \ - drivers/system_stm32f30x.c \ - drivers/timer_stm32f30x.c - -STM32F4xx_COMMON_SRC = \ - target/system_stm32f4xx.c \ - drivers/accgyro/accgyro_mpu.c \ - drivers/adc_stm32f4xx.c \ - drivers/bus_i2c_stm32f10x.c \ - drivers/dma_stm32f4xx.c \ - drivers/gpio_stm32f4xx.c \ - drivers/inverter.c \ - drivers/light_ws2811strip_stdperiph.c \ - drivers/pwm_output_dshot.c \ - drivers/serial_uart_init.c \ - drivers/serial_uart_stm32f4xx.c \ - drivers/system_stm32f4xx.c \ - drivers/timer_stm32f4xx.c - -STM32F7xx_COMMON_SRC = \ - target/system_stm32f7xx.c \ - drivers/accgyro/accgyro_mpu.c \ - drivers/adc_stm32f7xx.c \ - drivers/bus_i2c_hal.c \ - drivers/dma_stm32f7xx.c \ - drivers/gpio_stm32f7xx.c \ - drivers/light_ws2811strip_hal.c \ - drivers/bus_spi_hal.c \ - drivers/pwm_output_dshot_hal.c \ - drivers/timer_hal.c \ - drivers/timer_stm32f7xx.c \ - drivers/system_stm32f7xx.c \ - drivers/serial_uart_stm32f7xx.c \ - drivers/serial_uart_hal.c - -F7EXCLUDES = drivers/bus_spi.c \ - drivers/bus_i2c.c \ - drivers/timer.c \ - drivers/serial_uart.c - -SITLEXCLUDES = \ - drivers/adc.c \ - drivers/bus_spi.c \ - drivers/bus_i2c.c \ - drivers/dma.c \ - drivers/pwm_output.c \ - drivers/timer.c \ - drivers/light_led.c \ - drivers/system.c \ - drivers/rcc.c \ - drivers/serial_uart.c \ -<<<<<<< HEAD - drivers/serial_pinconfig.c \ -======= - drivers/rx_xn297.c \ - drivers/display_ug2864hsweg01.c \ - telemetry/crsf.c \ - telemetry/srxl.c \ - io/displayport_oled.c ->>>>>>> betaflight/master - - -# check if target.mk supplied -ifeq ($(TARGET),$(filter $(TARGET),$(F4_TARGETS))) -SRC := $(STARTUP_SRC) $(STM32F4xx_COMMON_SRC) $(TARGET_SRC) $(VARIANT_SRC) -else ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS))) -SRC := $(STARTUP_SRC) $(STM32F7xx_COMMON_SRC) $(TARGET_SRC) $(VARIANT_SRC) -else ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS))) -SRC := $(STARTUP_SRC) $(STM32F30x_COMMON_SRC) $(TARGET_SRC) $(VARIANT_SRC) -else ifeq ($(TARGET),$(filter $(TARGET),$(F1_TARGETS))) -SRC := $(STARTUP_SRC) $(STM32F10x_COMMON_SRC) $(TARGET_SRC) $(VARIANT_SRC) -else ifeq ($(TARGET),$(filter $(TARGET),$(SITL_TARGETS))) -SRC := $(TARGET_SRC) $(SITL_SRC) $(VARIANT_SRC) -endif - -ifneq ($(filter $(TARGET),$(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS)),) -DSPLIB := $(ROOT)/lib/main/DSP_Lib -DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE - -ifneq ($(filter $(TARGET),$(F3_TARGETS)) $(F4_TARGETS)),) -DEVICE_FLAGS += -DARM_MATH_CM4 -endif -ifneq ($(filter $(TARGET),$(F7_TARGETS)),) -DEVICE_FLAGS += -DARM_MATH_CM7 -endif - -INCLUDE_DIRS += $(DSPLIB)/Include - -SRC += $(DSPLIB)/Source/BasicMathFunctions/arm_mult_f32.c -SRC += $(DSPLIB)/Source/TransformFunctions/arm_rfft_fast_f32.c -SRC += $(DSPLIB)/Source/TransformFunctions/arm_cfft_f32.c -SRC += $(DSPLIB)/Source/TransformFunctions/arm_rfft_fast_init_f32.c -SRC += $(DSPLIB)/Source/TransformFunctions/arm_cfft_radix8_f32.c -SRC += $(DSPLIB)/Source/CommonTables/arm_common_tables.c - -SRC += $(DSPLIB)/Source/ComplexMathFunctions/arm_cmplx_mag_f32.c -SRC += $(DSPLIB)/Source/StatisticsFunctions/arm_max_f32.c - -SRC += $(wildcard $(DSPLIB)/Source/*/*.S) - -endif - - -ifneq ($(filter ONBOARDFLASH,$(FEATURES)),) -SRC += \ - drivers/flash_m25p16.c \ - io/flashfs.c -endif - -SRC += $(COMMON_SRC) - -#excludes -ifeq ($(TARGET),$(filter $(TARGET),$(F7_TARGETS))) -SRC := $(filter-out ${F7EXCLUDES}, $(SRC)) -endif - -#SITL excludes -ifeq ($(TARGET),$(filter $(TARGET),$(SITL_TARGETS))) -SRC := $(filter-out ${SITLEXCLUDES}, $(SRC)) -endif - -ifneq ($(filter SDCARD,$(FEATURES)),) -SRC += \ - drivers/sdcard.c \ - drivers/sdcard_standard.c \ - io/asyncfatfs/asyncfatfs.c \ - io/asyncfatfs/fat_standard.c -endif - -ifneq ($(filter VCP,$(FEATURES)),) -SRC += $(VCP_SRC) -endif -# end target specific make file checks - - -# Search path and source files for the ST stdperiph library -VPATH := $(VPATH):$(STDPERIPH_DIR)/src - -############################################################################### -# Things that might need changing to use different tools -# - -# Find out if ccache is installed on the system -CCACHE := ccache -RESULT = $(shell (which $(CCACHE) > /dev/null 2>&1; echo $$?) ) -ifneq ($(RESULT),0) -CCACHE := -endif - -# Tool names -CROSS_CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc -CROSS_CXX := $(CCACHE) $(ARM_SDK_PREFIX)g++ -OBJCOPY := $(ARM_SDK_PREFIX)objcopy -SIZE := $(ARM_SDK_PREFIX)size - -# -# Tool options. -# - -ifneq ($(DEBUG),GDB) -OPTIMISATION_BASE := -flto -fuse-linker-plugin -ffast-math -OPTIMISE_SPEED := "" -OPTIMISE_SIZE := "" - -ifeq ($(TARGET),$(filter $(TARGET),$(F1_TARGETS))) -OPTIMISE_DEFAULT := -Os - -LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT) - -else ifeq ($(TARGET),$(filter $(TARGET),$(SITL_TARGETS))) -OPTIMISE_DEFAULT := -Ofast -OPTIMISE_SPEED := -Ofast -OPTIMISE_SIZE := -Os - -LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED) - -else -OPTIMISE_DEFAULT := -O2 -OPTIMISE_SPEED := -Ofast -OPTIMISE_SIZE := -Os - -LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED) - -endif #TARGETS - -CC_DEFAULT_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT) -CC_SPEED_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED) -CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE) - -else #DEBUG -OPTIMISE_DEFAULT := -Og - -CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT) - -LTO_FLAGS := $(OPTIMISE_DEFAULT) -endif #DEBUG - -DEBUG_FLAGS = -ggdb3 -DDEBUG - -CFLAGS += $(ARCH_FLAGS) \ - $(addprefix -D,$(OPTIONS)) \ - $(addprefix -I,$(INCLUDE_DIRS)) \ - $(DEBUG_FLAGS) \ - -std=gnu99 \ - -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \ - -ffunction-sections \ - -fdata-sections \ - -pedantic \ - $(DEVICE_FLAGS) \ - -DUSE_STDPERIPH_DRIVER \ - -D$(TARGET) \ - $(TARGET_FLAGS) \ - -D'__FORKNAME__="$(FORKNAME)"' \ - -D'__TARGET__="$(TARGET)"' \ - -D'__REVISION__="$(REVISION)"' \ - -save-temps=obj \ - -MMD -MP - -ASFLAGS = $(ARCH_FLAGS) \ - -x assembler-with-cpp \ - $(addprefix -I,$(INCLUDE_DIRS)) \ - -MMD -MP - -LDFLAGS = -lm \ - -nostartfiles \ - --specs=nano.specs \ - -lc \ - -lnosys \ - $(ARCH_FLAGS) \ - $(LTO_FLAGS) \ - $(DEBUG_FLAGS) \ - -static \ - -Wl,-gc-sections,-Map,$(TARGET_MAP) \ - -Wl,-L$(LINKER_DIR) \ - -Wl,--cref \ - -Wl,--no-wchar-size-warning \ - -T$(LD_SCRIPT) - -#SITL compile -ifeq ($(TARGET),$(filter $(TARGET),$(SITL_TARGETS))) -LDFLAGS = \ - -lm \ - -lpthread \ - -lc \ - -lrt \ - $(ARCH_FLAGS) \ - $(LTO_FLAGS) \ - $(DEBUG_FLAGS) \ - -Wl,-gc-sections,-Map,$(TARGET_MAP) \ - -Wl,-L$(LINKER_DIR) \ - -Wl,--cref \ - -T$(LD_SCRIPT) - -ifneq ($(filter SITL_STATIC,$(OPTIONS)),) -LDFLAGS += \ - -static \ - -static-libgcc -endif -endif - -############################################################################### -# No user-serviceable parts below -############################################################################### - -CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \ - --std=c99 --inline-suppr --quiet --force \ - $(addprefix -I,$(INCLUDE_DIRS)) \ - -I/usr/include -I/usr/include/linux - -# -# Things we will build -# -TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).bin -TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).hex -TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf -TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(SRC)))) -TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(SRC)))) -TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map - - -CLEAN_ARTIFACTS := $(TARGET_BIN) -CLEAN_ARTIFACTS += $(TARGET_HEX) -CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP) - -# Make sure build date and revision is updated on every incremental build -$(OBJECT_DIR)/$(TARGET)/build/version.o : $(SRC) - -# List of buildable ELF files and their object dependencies. -# It would be nice to compute these lists, but that seems to be just beyond make. - -$(TARGET_HEX): $(TARGET_ELF) - $(V0) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@ - -$(TARGET_BIN): $(TARGET_ELF) - $(V0) $(OBJCOPY) -O binary $< $@ - -$(TARGET_ELF): $(TARGET_OBJS) - $(V1) echo Linking $(TARGET) - $(V1) $(CROSS_CC) -o $@ $^ $(LDFLAGS) - $(V0) $(SIZE) $(TARGET_ELF) - -# Compile -ifneq ($(DEBUG),GDB) -$(OBJECT_DIR)/$(TARGET)/%.o: %.c - $(V1) mkdir -p $(dir $@) - $(V1) $(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \ - echo "%% (speed optimised) $(notdir $<)" "$(STDOUT)" && \ - $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SPEED_OPTIMISATION) $<, \ - $(if $(findstring $(subst ./src/main/,,$<),$(SIZE_OPTIMISED_SRC)), \ - echo "%% (size optimised) $(notdir $<)" "$(STDOUT)" && \ - $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SIZE_OPTIMISATION) $<, \ - echo "%% $(notdir $<)" "$(STDOUT)" && \ - $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEFAULT_OPTIMISATION) $<)) -else -$(OBJECT_DIR)/$(TARGET)/%.o: %.c - $(V1) mkdir -p $(dir $@) - $(V1) echo "%% $(notdir $<)" "$(STDOUT)" && \ - $(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEBUG_OPTIMISATION) $< -endif - -# Assemble -$(OBJECT_DIR)/$(TARGET)/%.o: %.s - $(V1) mkdir -p $(dir $@) - $(V1) echo "%% $(notdir $<)" "$(STDOUT)" - $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $< - -$(OBJECT_DIR)/$(TARGET)/%.o: %.S - $(V1) mkdir -p $(dir $@) - $(V1) echo "%% $(notdir $<)" "$(STDOUT)" - $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $< - - -## all : Build all valid targets -all: $(VALID_TARGETS) - -## official : Build all official (travis) targets -official: $(OFFICIAL_TARGETS) - -## targets-group-1 : build some targets -targets-group-1: $(GROUP_1_TARGETS) - -## targets-group-2 : build some targets -targets-group-2: $(GROUP_2_TARGETS) - -## targets-group-3 : build some targets -targets-group-3: $(GROUP_3_TARGETS) - -## targets-group-3 : build some targets -targets-group-4: $(GROUP_4_TARGETS) - -## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3) -targets-group-rest: $(GROUP_OTHER_TARGETS) - - -$(VALID_TARGETS): - $(V0) echo "" && \ - echo "Building $@" && \ - time $(MAKE) binary hex TARGET=$@ && \ - echo "Building $@ succeeded." - - - -CLEAN_TARGETS = $(addprefix clean_,$(VALID_TARGETS) ) -TARGETS_CLEAN = $(addsuffix _clean,$(VALID_TARGETS) ) - -## clean : clean up temporary / machine-generated files -clean: - $(V0) echo "Cleaning $(TARGET)" - $(V0) rm -f $(CLEAN_ARTIFACTS) - $(V0) rm -rf $(OBJECT_DIR)/$(TARGET) - $(V0) echo "Cleaning $(TARGET) succeeded." - -## clean_test : clean up temporary / machine-generated files (tests) -clean_test: - $(V0) cd src/test && $(MAKE) clean || true - -## clean_ : clean up one specific target -$(CLEAN_TARGETS) : - $(V0) $(MAKE) -j TARGET=$(subst clean_,,$@) clean - -## _clean : clean up one specific target (alias for above) -$(TARGETS_CLEAN) : - $(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean - -## clean_all : clean all valid targets -clean_all:$(CLEAN_TARGETS) - -## all_clean : clean all valid targets (alias for above) -all_clean:$(TARGETS_CLEAN) - - -flash_$(TARGET): $(TARGET_HEX) - $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon - $(V0) echo -n 'R' >$(SERIAL_DEVICE) - $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE) - -## flash : flash firmware (.hex) onto flight controller -flash: flash_$(TARGET) - -st-flash_$(TARGET): $(TARGET_BIN) - $(V0) st-flash --reset write $< 0x08000000 - -## st-flash : flash firmware (.bin) onto flight controller -st-flash: st-flash_$(TARGET) - -binary: - $(V0) $(MAKE) -j $(TARGET_BIN) - -hex: - $(V0) $(MAKE) -j $(TARGET_HEX) - -unbrick_$(TARGET): $(TARGET_HEX) - $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon - $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE) - -## unbrick : unbrick flight controller -unbrick: unbrick_$(TARGET) - -## cppcheck : run static analysis on C source code -cppcheck: $(CSOURCES) - $(V0) $(CPPCHECK) - -cppcheck-result.xml: $(CSOURCES) - $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml - -# mkdirs -$(DL_DIR): - mkdir -p $@ - -$(TOOLS_DIR): - mkdir -p $@ - -$(BUILD_DIR): - mkdir -p $@ - -## version : print firmware version -version: - @echo $(FC_VER) - -## help : print this help message and exit -help: Makefile make/tools.mk - $(V0) @echo "" - $(V0) @echo "Makefile for the $(FORKNAME) firmware" - $(V0) @echo "" - $(V0) @echo "Usage:" - $(V0) @echo " make [V=] [TARGET=] [OPTIONS=\"\"]" - $(V0) @echo "Or:" - $(V0) @echo " make [V=] [OPTIONS=\"\"]" - $(V0) @echo "" - $(V0) @echo "Valid TARGET values are: $(VALID_TARGETS)" - $(V0) @echo "" - $(V0) @sed -n 's/^## //p' $? - -## targets : print a list of all valid target platforms (for consumption by scripts) -targets: - $(V0) @echo "Valid targets: $(VALID_TARGETS)" - $(V0) @echo "Target: $(TARGET)" - $(V0) @echo "Base target: $(BASE_TARGET)" - $(V0) @echo "targets-group-1: $(GROUP_1_TARGETS)" - $(V0) @echo "targets-group-2: $(GROUP_2_TARGETS)" - $(V0) @echo "targets-group-3: $(GROUP_3_TARGETS)" - $(V0) @echo "targets-group-4: $(GROUP_4_TARGETS)" - $(V0) @echo "targets-group-rest: $(GROUP_OTHER_TARGETS)" - -## test : run the cleanflight test suite -## junittest : run the cleanflight test suite, producing Junit XML result files. -test junittest: - $(V0) cd src/test && $(MAKE) $@ - -# rebuild everything when makefile changes -$(TARGET_OBJS) : Makefile - -# include auto-generated dependencies --include $(TARGET_DEPS) diff --git a/src/main/drivers/serial_uart_hal.c b/src/main/drivers/serial_uart_hal.c index c9d84000ec..58a7d38e3b 100644 --- a/src/main/drivers/serial_uart_hal.c +++ b/src/main/drivers/serial_uart_hal.c @@ -40,33 +40,6 @@ #include "drivers/serial_uart.h" #include "drivers/serial_uart_impl.h" -uartDevice_t uartDevice[UARTDEV_COUNT]; // Only configured in target.h -uartDevice_t *uartDevmap[UARTDEV_COUNT_MAX]; // Full array - -void uartPinConfigure(const serialPinConfig_t *pSerialPinConfig) -{ - uartDevice_t *uartdev = uartDevice; - - for (size_t hindex = 0 ; hindex < UARTDEV_COUNT ; hindex++) { - - const uartHardware_t *hardware = &uartHardware[hindex]; - UARTDevice device = hardware->device; - - for (int pair = 0 ; pair < UARTHARDWARE_PINPAIR_COUNT ; pair++) { - if (hardware->pinPair[pair].rx == pSerialPinConfig->ioTagRx[device] - && hardware->pinPair[pair].tx == pSerialPinConfig->ioTagTx[device]) { - // Matching pin pair found - - uartdev->hardware = hardware; - uartdev->rx = hardware->pinPair[pair].rx; - uartdev->tx = hardware->pinPair[pair].tx; - uartDevmap[device] = uartdev++; - break; - } - } - } -} - static void usartConfigurePinInversion(uartPort_t *uartPort) { bool inverted = uartPort->port.options & SERIAL_INVERTED; diff --git a/src/main/drivers/serial_uart_impl.h b/src/main/drivers/serial_uart_impl.h index 82df2bd39c..48cef851f2 100644 --- a/src/main/drivers/serial_uart_impl.h +++ b/src/main/drivers/serial_uart_impl.h @@ -21,7 +21,7 @@ #if defined(STM32F1) #define UARTDEV_COUNT_MAX 3 -#define UARTHARDWARE_PINPAIR_COUNT 3 +#define UARTHARDWARE_MAX_PINS 3 #ifndef UART_RX_BUFFER_SIZE #define UART_RX_BUFFER_SIZE 256 #endif @@ -30,7 +30,7 @@ #endif #elif defined(STM32F3) #define UARTDEV_COUNT_MAX 5 -#define UARTHARDWARE_PINPAIR_COUNT 4 +#define UARTHARDWARE_MAX_PINS 4 #ifndef UART_RX_BUFFER_SIZE #define UART_RX_BUFFER_SIZE 256 #endif @@ -39,7 +39,7 @@ #endif #elif defined(STM32F4) #define UARTDEV_COUNT_MAX 6 -#define UARTHARDWARE_PINPAIR_COUNT 4 +#define UARTHARDWARE_MAX_PINS 4 #ifndef UART_RX_BUFFER_SIZE #define UART_RX_BUFFER_SIZE 512 #endif @@ -48,7 +48,7 @@ #endif #elif defined(STM32F7) #define UARTDEV_COUNT_MAX 8 -#define UARTHARDWARE_PINPAIR_COUNT 3 +#define UARTHARDWARE_MAX_PINS 3 #ifndef UART_RX_BUFFER_SIZE #define UART_RX_BUFFER_SIZE 512 #endif @@ -111,11 +111,6 @@ #define UARTDEV_COUNT (UARTDEV_COUNT_1 + UARTDEV_COUNT_2 + UARTDEV_COUNT_3 + UARTDEV_COUNT_4 + UARTDEV_COUNT_5 + UARTDEV_COUNT_6 + UARTDEV_COUNT_7 + UARTDEV_COUNT_8) -typedef struct uartPinPair_s { - ioTag_t rx; - ioTag_t tx; -} uartPinPair_t; - typedef struct uartHardware_s { UARTDevice device; // XXX Not required for full allocation USART_TypeDef* reg; @@ -127,7 +122,8 @@ typedef struct uartHardware_s { DMA_Stream_TypeDef *txDMAStream; DMA_Stream_TypeDef *rxDMAStream; #endif - uartPinPair_t pinPair[UARTHARDWARE_PINPAIR_COUNT]; + ioTag_t rxPins[UARTHARDWARE_MAX_PINS]; + ioTag_t txPins[UARTHARDWARE_MAX_PINS]; #if defined(STM32F7) uint32_t rcc_ahb1; rccPeriphTag_t rcc_apb2; diff --git a/src/main/drivers/serial_uart_init.c b/src/main/drivers/serial_uart_init.c index 1390b11343..96f4ec25ed 100644 --- a/src/main/drivers/serial_uart_init.c +++ b/src/main/drivers/serial_uart_init.c @@ -42,33 +42,6 @@ #include "drivers/serial_uart.h" #include "drivers/serial_uart_impl.h" -uartDevice_t uartDevice[UARTDEV_COUNT]; // Only those configured in target.h -uartDevice_t *uartDevmap[UARTDEV_COUNT_MAX]; // Full array - -void uartPinConfigure(const serialPinConfig_t *pSerialPinConfig) -{ - uartDevice_t *uartdev = uartDevice; - - for (size_t hindex = 0; hindex < UARTDEV_COUNT_MAX; hindex++) { - - const uartHardware_t *hardware = &uartHardware[hindex]; - UARTDevice device = hardware->device; - - for (int pair = 0 ; pair < UARTHARDWARE_PINPAIR_COUNT ; pair++) { - if (hardware->pinPair[pair].rx == pSerialPinConfig->ioTagRx[device] - && hardware->pinPair[pair].tx == pSerialPinConfig->ioTagTx[device]) { - // Matching pin pair found - - uartdev->hardware = hardware; - uartdev->rx = hardware->pinPair[pair].rx; - uartdev->tx = hardware->pinPair[pair].tx; - uartDevmap[device] = uartdev++; - break; - } - } - } -} - static void usartConfigurePinInversion(uartPort_t *uartPort) { #if !defined(USE_INVERTER) && !defined(STM32F303xC) UNUSED(uartPort); diff --git a/src/main/drivers/serial_uart_pinconfig.c b/src/main/drivers/serial_uart_pinconfig.c new file mode 100644 index 0000000000..b16f5fb872 --- /dev/null +++ b/src/main/drivers/serial_uart_pinconfig.c @@ -0,0 +1,64 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight 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. + * + * Cleanflight 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 Cleanflight. If not, see . + */ + +/* + * UART pin configuration common to all MCUs. + */ + +/* + * Authors: + * jflyper - Created as a part of configurable UART/refactoring. +*/ + +#include +#include + +#include "platform.h" + +#include "build/build_config.h" + +#include "drivers/rcc.h" +#include "drivers/serial.h" +#include "drivers/serial_uart.h" +#include "drivers/serial_uart_impl.h" + +uartDevice_t uartDevice[UARTDEV_COUNT]; // Only those configured in target.h +uartDevice_t *uartDevmap[UARTDEV_COUNT_MAX]; // Full array + +void uartPinConfigure(const serialPinConfig_t *pSerialPinConfig) +{ + uartDevice_t *uartdev = uartDevice; + + for (size_t hindex = 0; hindex < UARTDEV_COUNT_MAX; hindex++) { + + const uartHardware_t *hardware = &uartHardware[hindex]; + UARTDevice device = hardware->device; + + for (int pindex = 0 ; pindex < UARTHARDWARE_MAX_PINS ; pindex++) { + if (hardware->rxPins[pindex] && (hardware->rxPins[pindex] == pSerialPinConfig->ioTagRx[device])) + uartdev->rx = pSerialPinConfig->ioTagRx[device]; + + if (hardware->txPins[pindex] && (hardware->txPins[pindex] == pSerialPinConfig->ioTagTx[device])) + uartdev->tx = pSerialPinConfig->ioTagTx[device]; + } + + if (uartdev->rx || uartdev->tx) { + uartdev->hardware = hardware; + uartDevmap[device] = uartdev++; + } + } +} diff --git a/src/main/drivers/serial_uart_stm32f10x.c b/src/main/drivers/serial_uart_stm32f10x.c index edb83e924a..f6ecd7e560 100644 --- a/src/main/drivers/serial_uart_stm32f10x.c +++ b/src/main/drivers/serial_uart_stm32f10x.c @@ -64,10 +64,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = USART1, .rxDMAChannel = UART1_RX_DMA_CHANNEL, .txDMAChannel = UART1_TX_DMA_CHANNEL, - .pinPair = { - { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PA9) }, - { DEFIO_TAG_E(PB7), DEFIO_TAG_E(PB6) }, - }, + .rxPins = { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PB7), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA9), DEFIO_TAG_E(PB6), IO_TAG_NONE }, //.af = GPIO_AF_USART1, .rcc = RCC_APB2(USART1), .irqn = USART1_IRQn, @@ -81,10 +79,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = USART2, .rxDMAChannel = UART2_RX_DMA_CHANNEL, .txDMAChannel = UART2_TX_DMA_CHANNEL, - .pinPair = { - { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PA2) }, - { DEFIO_TAG_E(PD6), DEFIO_TAG_E(PD5) }, - }, + .rxPins = { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PD6), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA2), DEFIO_TAG_E(PD5), IO_TAG_NONE }, //.af = GPIO_AF_USART2, .rcc = RCC_APB1(USART2), .irqn = USART2_IRQn, @@ -98,11 +94,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = USART3, .rxDMAChannel = UART3_RX_DMA_CHANNEL, .txDMAChannel = UART3_TX_DMA_CHANNEL, - .pinPair = { - { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PB10) }, - { DEFIO_TAG_E(PD9), DEFIO_TAG_E(PD8) }, - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - }, + .rxPins = { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PD9), DEFIO_TAG_E(PC11) }, + .txPins = { DEFIO_TAG_E(PB10), DEFIO_TAG_E(PD8), DEFIO_TAG_E(PC10) }, //.af = GPIO_AF_USART3, .rcc = RCC_APB1(USART3), .irqn = USART3_IRQn, diff --git a/src/main/drivers/serial_uart_stm32f30x.c b/src/main/drivers/serial_uart_stm32f30x.c index 093f8db8a9..8dd877c940 100644 --- a/src/main/drivers/serial_uart_stm32f30x.c +++ b/src/main/drivers/serial_uart_stm32f30x.c @@ -87,12 +87,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = USART1, .rxDMAChannel = UART1_RX_DMA, .txDMAChannel = UART1_TX_DMA, - .pinPair = { - { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PA9) }, - { DEFIO_TAG_E(PB7), DEFIO_TAG_E(PB6) }, - { DEFIO_TAG_E(PC5), DEFIO_TAG_E(PC4) }, - { DEFIO_TAG_E(PE1), DEFIO_TAG_E(PE0) }, - }, + .rxPins = { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PB7), DEFIO_TAG_E(PC5), DEFIO_TAG_E(PE1) }, + .txPins = { DEFIO_TAG_E(PA9), DEFIO_TAG_E(PB6), DEFIO_TAG_E(PC4), DEFIO_TAG_E(PE0) }, .rcc = RCC_APB2(USART1), .af = GPIO_AF_7, .irqn = USART1_IRQn, @@ -107,12 +103,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = USART2, .rxDMAChannel = UART2_RX_DMA, .txDMAChannel = UART2_TX_DMA, - .pinPair = { - { DEFIO_TAG_E(PA15), DEFIO_TAG_E(PA14) }, - { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PA2) }, - { DEFIO_TAG_E(PB4), DEFIO_TAG_E(PB3) }, - { DEFIO_TAG_E(PD6), DEFIO_TAG_E(PD5) }, - }, + .rxPins = { DEFIO_TAG_E(PA15), DEFIO_TAG_E(PA3), DEFIO_TAG_E(PB4), DEFIO_TAG_E(PD6) }, + .txPins = { DEFIO_TAG_E(PA14), DEFIO_TAG_E(PA2), DEFIO_TAG_E(PB3), DEFIO_TAG_E(PD5) }, .rcc = RCC_APB1(USART2), .af = GPIO_AF_7, .irqn = USART2_IRQn, @@ -127,11 +119,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = USART3, .rxDMAChannel = UART3_RX_DMA, .txDMAChannel = UART3_TX_DMA, - .pinPair = { - { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PB10) }, - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - { DEFIO_TAG_E(PD9), DEFIO_TAG_E(PD8) }, - }, + .rxPins = { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PC11), DEFIO_TAG_E(PD9), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PB10), DEFIO_TAG_E(PC10), DEFIO_TAG_E(PD8), IO_TAG_NONE }, .rcc = RCC_APB1(USART3), .af = GPIO_AF_7, .irqn = USART3_IRQn, @@ -147,9 +136,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = UART4, .rxDMAChannel = 0, // XXX UART4_RX_DMA !? .txDMAChannel = 0, // XXX UART4_TX_DMA !? - .pinPair = { - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - }, + .rxPins = { DEFIO_TAG_E(PC11), IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PC10), IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE }, .rcc = RCC_APB1(UART4), .af = GPIO_AF_5, .irqn = UART4_IRQn, @@ -165,9 +153,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .reg = UART5, .rxDMAChannel = 0, .txDMAChannel = 0, - .pinPair = { - { DEFIO_TAG_E(PD2), DEFIO_TAG_E(PC12) }, - }, + .rxPins = { DEFIO_TAG_E(PD2), IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PC12), IO_TAG_NONE, IO_TAG_NONE, IO_TAG_NONE }, .rcc = RCC_APB1(UART5), .af = GPIO_AF_5, .irqn = UART5_IRQn, diff --git a/src/main/drivers/serial_uart_stm32f4xx.c b/src/main/drivers/serial_uart_stm32f4xx.c index 9cdc2f00a3..89904d8c44 100644 --- a/src/main/drivers/serial_uart_stm32f4xx.c +++ b/src/main/drivers/serial_uart_stm32f4xx.c @@ -48,10 +48,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { #ifdef USE_UART1_TX_DMA .txDMAStream = DMA2_Stream7, #endif - .pinPair = { - { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PA9) }, - { DEFIO_TAG_E(PB7), DEFIO_TAG_E(PB6) }, - }, + .rxPins = { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PB7), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA9), DEFIO_TAG_E(PB6), IO_TAG_NONE }, .af = GPIO_AF_USART1, .rcc = RCC_APB2(USART1), .irqn = USART1_IRQn, @@ -71,10 +69,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { #ifdef USE_UART2_TX_DMA .txDMAStream = DMA1_Stream6, #endif - .pinPair = { - { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PA2) }, - { DEFIO_TAG_E(PD6), DEFIO_TAG_E(PD5) }, - }, + .rxPins = { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PD6), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA2), DEFIO_TAG_E(PD5), IO_TAG_NONE }, .af = GPIO_AF_USART2, .rcc = RCC_APB1(USART2), .irqn = USART2_IRQn, @@ -94,11 +90,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { #ifdef USE_UART3_TX_DMA .txDMAStream = DMA1_Stream3, #endif - .pinPair = { - { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PB10) }, - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - { DEFIO_TAG_E(PD9), DEFIO_TAG_E(PD8) } - }, + .rxPins = { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PC11), DEFIO_TAG_E(PD9) }, + .txPins = { DEFIO_TAG_E(PB10), DEFIO_TAG_E(PC10), DEFIO_TAG_E(PD8) }, .af = GPIO_AF_USART3, .rcc = RCC_APB1(USART3), .irqn = USART3_IRQn, @@ -118,10 +111,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { #ifdef USE_UART4_TX_DMA .txDMAStream = DMA1_Stream4, #endif - .pinPair = { - { DEFIO_TAG_E(PA1), DEFIO_TAG_E(PA0) }, - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - }, + .rxPins = { DEFIO_TAG_E(PA1), DEFIO_TAG_E(PC11), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA0), DEFIO_TAG_E(PC10), IO_TAG_NONE }, .af = GPIO_AF_UART4, .rcc = RCC_APB1(UART4), .irqn = UART4_IRQn, @@ -141,9 +132,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { #ifdef USE_UART5_TX_DMA .txDMAStream = DMA1_Stream7, #endif - .pinPair = { - { DEFIO_TAG_E(PD2), DEFIO_TAG_E(PC12) }, - }, + .rxPins = { DEFIO_TAG_E(PD2), IO_TAG_NONE, IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PC12), IO_TAG_NONE, IO_TAG_NONE }, .af = GPIO_AF_UART5, .rcc = RCC_APB1(UART5), .irqn = UART5_IRQn, @@ -163,10 +153,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { #ifdef USE_UART6_TX_DMA .txDMAStream = DMA2_Stream6, #endif - .pinPair = { - { DEFIO_TAG_E(PC7), DEFIO_TAG_E(PC6) }, - { DEFIO_TAG_E(PG9), DEFIO_TAG_E(PG14) }, - }, + .rxPins = { DEFIO_TAG_E(PC7), DEFIO_TAG_E(PG9), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PC6), DEFIO_TAG_E(PG14), IO_TAG_NONE }, .af = GPIO_AF_USART6, .rcc = RCC_APB2(USART6), .irqn = USART6_IRQn, diff --git a/src/main/drivers/serial_uart_stm32f7xx.c b/src/main/drivers/serial_uart_stm32f7xx.c index 1fd15044e6..7bde2a94cd 100644 --- a/src/main/drivers/serial_uart_stm32f7xx.c +++ b/src/main/drivers/serial_uart_stm32f7xx.c @@ -48,10 +48,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA2_Stream5, #endif .txDMAStream = DMA2_Stream7, - .pinPair = { - { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PA9) }, - { DEFIO_TAG_E(PB7), DEFIO_TAG_E(PB6) }, - }, + .rxPins = { DEFIO_TAG_E(PA10), DEFIO_TAG_E(PB7), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA9), DEFIO_TAG_E(PB6), IO_TAG_NONE }, .af = GPIO_AF7_USART1, #ifdef UART1_AHB1_PERIPHERALS .rcc_ahb1 = UART1_AHB1_PERIPHERALS, @@ -73,10 +71,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA1_Stream5, #endif .txDMAStream = DMA1_Stream6, - .pinPair = { - { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PA2) }, - { DEFIO_TAG_E(PD6), DEFIO_TAG_E(PD5) }, - }, + .rxPins = { DEFIO_TAG_E(PA3), DEFIO_TAG_E(PD6), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA2), DEFIO_TAG_E(PD5), IO_TAG_NONE }, .af = GPIO_AF7_USART2, #ifdef UART2_AHB1_PERIPHERALS .rcc_ahb1 = UART2_AHB1_PERIPHERALS, @@ -98,11 +94,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA1_Stream1, #endif .txDMAStream = DMA1_Stream3, - .pinPair = { - { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PB10) }, - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - { DEFIO_TAG_E(PD9), DEFIO_TAG_E(PD8) }, - }, + .rxPins = { DEFIO_TAG_E(PB11), DEFIO_TAG_E(PC11), DEFIO_TAG_E(PD9) }, + .txPins = { DEFIO_TAG_E(PB10), DEFIO_TAG_E(PC10), DEFIO_TAG_E(PD8) }, .af = GPIO_AF7_USART3, #ifdef UART3_AHB1_PERIPHERALS .rcc_ahb1 = UART3_AHB1_PERIPHERALS, @@ -124,10 +117,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA1_Stream2, #endif .txDMAStream = DMA1_Stream4, - .pinPair = { - { DEFIO_TAG_E(PA1), DEFIO_TAG_E(PA0) }, - { DEFIO_TAG_E(PC11), DEFIO_TAG_E(PC10) }, - }, + .rxPins = { DEFIO_TAG_E(PA1), DEFIO_TAG_E(PC11), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PA0), DEFIO_TAG_E(PC10), IO_TAG_NONE }, .af = GPIO_AF8_UART4, #ifdef UART4_AHB1_PERIPHERALS .rcc_ahb1 = UART4_AHB1_PERIPHERALS, @@ -149,9 +140,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA1_Stream0, #endif .txDMAStream = DMA1_Stream7, - .pinPair = { - { DEFIO_TAG_E(PD2), DEFIO_TAG_E(PC12) }, - }, + .rxPins = { DEFIO_TAG_E(PD2), IO_TAG_NONE, IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PC12), IO_TAG_NONE, IO_TAG_NONE }, .af = GPIO_AF8_UART5, #ifdef UART5_AHB1_PERIPHERALS .rcc_ahb1 = UART5_AHB1_PERIPHERALS, @@ -173,10 +163,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA2_Stream1, #endif .txDMAStream = DMA2_Stream6, - .pinPair = { - { DEFIO_TAG_E(PC7), DEFIO_TAG_E(PC6) }, - { DEFIO_TAG_E(PG9), DEFIO_TAG_E(PG14) }, - }, + .rxPins = { DEFIO_TAG_E(PC7), DEFIO_TAG_E(PG9), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PC6), DEFIO_TAG_E(PG14), IO_TAG_NONE }, .af = GPIO_AF8_USART6, #ifdef UART6_AHB1_PERIPHERALS .rcc_ahb1 = UART6_AHB1_PERIPHERALS, @@ -198,10 +186,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA1_Stream3, #endif .txDMAStream = DMA1_Stream1, - .pinPair = { - { DEFIO_TAG_E(PE7), DEFIO_TAG_E(PE8) }, - { DEFIO_TAG_E(PF6), DEFIO_TAG_E(PF7) }, - }, + .rxPins = { DEFIO_TAG_E(PE7), DEFIO_TAG_E(PF6), IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PE8), DEFIO_TAG_E(PF7), IO_TAG_NONE }, .af = GPIO_AF8_UART7, #ifdef UART7_AHB1_PERIPHERALS .rcc_ahb1 = UART7_AHB1_PERIPHERALS, @@ -223,9 +209,8 @@ const uartHardware_t uartHardware[UARTDEV_COUNT] = { .rxDMAStream = DMA1_Stream6, #endif .txDMAStream = DMA1_Stream0, - .pinPair = { - { DEFIO_TAG_E(PE0), DEFIO_TAG_E(PE1) }, - }, + .rxPins = { DEFIO_TAG_E(PE0), IO_TAG_NONE, IO_TAG_NONE }, + .txPins = { DEFIO_TAG_E(PE1), IO_TAG_NONE, IO_TAG_NONE }, .af = GPIO_AF8_UART8, #ifdef UART8_AHB1_PERIPHERALS .rcc_ahb1 = UART8_AHB1_PERIPHERALS, diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index f8422f242d..d79f3ec970 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -281,7 +281,7 @@ void init(void) busSwitchInit(); #endif -#ifdef USE_UART +#if defined(USE_UART) && !defined(SITL) uartPinConfigure(serialPinConfig()); #endif @@ -342,7 +342,7 @@ void init(void) beeperInit(beeperDevConfig()); #endif /* temp until PGs are implemented. */ -#ifdef USE_INVERTER +#if defined(USE_INVERTER) && !defined(SITL) initInverters(serialPinConfig()); #endif diff --git a/src/main/target/NUCLEOF7/target.h b/src/main/target/NUCLEOF7/target.h index ef50b450f7..e683c82c3c 100644 --- a/src/main/target/NUCLEOF7/target.h +++ b/src/main/target/NUCLEOF7/target.h @@ -151,5 +151,6 @@ #define TARGET_IO_PORTD 0xffff #define TARGET_IO_PORTE 0xffff #define TARGET_IO_PORTF 0xffff +#define TARGET_IO_PORTG 0xffff #define USED_TIMERS ( TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(5) | TIM_N(12) | TIM_N(8) | TIM_N(9) | TIM_N(10) | TIM_N(11)) diff --git a/src/main/target/SITL/target.h b/src/main/target/SITL/target.h index 053c74bf87..dc811d9246 100644 --- a/src/main/target/SITL/target.h +++ b/src/main/target/SITL/target.h @@ -59,14 +59,14 @@ #define USABLE_TIMER_CHANNEL_COUNT 0 -//#define USE_UART1 -//#define USE_UART2 -//#define USE_UART3 -//#define USE_UART4 -//#define USE_UART5 -//#define USE_UART6 -//#define USE_UART7 -//#define USE_UART8 +#define USE_UART1 +#define USE_UART2 +#define USE_UART3 +#define USE_UART4 +#define USE_UART5 +#define USE_UART6 +#define USE_UART7 +#define USE_UART8 //#define USE_SOFTSERIAL1 //#define USE_SOFTSERIAL2