Optimise DSHOT cache management loops (#12672)
[betaflight.git] / make / mcu / STM32F4.mk
blobe95af2e40fe0bfe4fb3eb0c38a45f509693af396
2 # F4 Make file include
5 #CMSIS
6 ifeq ($(PERIPH_DRIVER), HAL)
7 CMSIS_DIR := $(ROOT)/lib/main/STM32F4/Drivers/CMSIS
8 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4/Drivers/STM32F4xx_HAL_Driver
9 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
10 EXCLUDES =
12 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
14 else
15 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
16 STDPERIPH_DIR = $(ROOT)/lib/main/STM32F4/Drivers/STM32F4xx_StdPeriph_Driver
17 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/src/*.c))
18 EXCLUDES = stm32f4xx_crc.c \
19 stm32f4xx_can.c \
20 stm32f4xx_fmc.c \
21 stm32f4xx_sai.c \
22 stm32f4xx_cec.c \
23 stm32f4xx_dsi.c \
24 stm32f4xx_flash_ramfunc.c \
25 stm32f4xx_fmpi2c.c \
26 stm32f4xx_lptim.c \
27 stm32f4xx_qspi.c \
28 stm32f4xx_spdifrx.c \
29 stm32f4xx_cryp.c \
30 stm32f4xx_cryp_aes.c \
31 stm32f4xx_hash_md5.c \
32 stm32f4xx_cryp_des.c \
33 stm32f4xx_hash.c \
34 stm32f4xx_dbgmcu.c \
35 stm32f4xx_cryp_tdes.c \
36 stm32f4xx_hash_sha1.c
38 VPATH := $(VPATH):$(STDPERIPH_DIR)/src
39 endif
41 ifeq ($(TARGET_MCU),$(filter $(TARGET_MCU),STM32F411xE STM32F446xx))
42 EXCLUDES += stm32f4xx_fsmc.c
43 endif
45 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
47 ifeq ($(PERIPH_DRIVER), HAL)
48 #USB
49 USBCORE_DIR = $(ROOT)/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Core
50 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
51 EXCLUDES = usbd_conf_template.c
52 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
54 USBCDC_DIR = $(ROOT)/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
55 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
56 EXCLUDES = usbd_cdc_if_template.c
57 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
59 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src
61 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
62 $(USBCORE_SRC) \
63 $(USBCDC_SRC)
64 else
65 USBCORE_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Core
66 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/src/*.c))
67 USBOTG_DIR = $(ROOT)/lib/main/STM32_USB_OTG_Driver
68 USBOTG_SRC = $(notdir $(wildcard $(USBOTG_DIR)/src/*.c))
69 EXCLUDES = usb_bsp_template.c \
70 usb_conf_template.c \
71 usb_hcd_int.c \
72 usb_hcd.c \
73 usb_otg.c
75 USBOTG_SRC := $(filter-out ${EXCLUDES}, $(USBOTG_SRC))
76 USBCDC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/cdc
77 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/src/*.c))
78 EXCLUDES = usbd_cdc_if_template.c
79 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
80 USBMSC_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/msc
81 USBMSC_SRC = $(notdir $(wildcard $(USBMSC_DIR)/src/*.c))
82 EXCLUDES = usbd_storage_template.c
83 USBMSC_SRC := $(filter-out ${EXCLUDES}, $(USBMSC_SRC))
84 USBHID_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/hid
85 USBHID_SRC = $(notdir $(wildcard $(USBHID_DIR)/src/*.c))
86 USBWRAPPER_DIR = $(ROOT)/lib/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper
87 USBWRAPPER_SRC = $(notdir $(wildcard $(USBWRAPPER_DIR)/src/*.c))
88 VPATH := $(VPATH):$(USBOTG_DIR)/src:$(USBCORE_DIR)/src:$(USBCDC_DIR)/src:$(USBMSC_DIR)/src:$(USBHID_DIR)/src:$(USBWRAPPER_DIR)/src
90 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
91 $(USBOTG_SRC) \
92 $(USBCORE_SRC) \
93 $(USBCDC_SRC) \
94 $(USBHID_SRC) \
95 $(USBWRAPPER_SRC) \
96 $(USBMSC_SRC)
97 endif
99 #CMSIS
100 VPATH := $(VPATH):$(CMSIS_DIR)/Core/Include:$(ROOT)/lib/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx
102 INCLUDE_DIRS := $(INCLUDE_DIRS) \
103 $(ROOT)/src/main/drivers/stm32
105 ifeq ($(PERIPH_DRIVER), HAL)
106 CMSIS_SRC :=
107 INCLUDE_DIRS := $(INCLUDE_DIRS) \
108 $(STDPERIPH_DIR)/Inc \
109 $(USBCORE_DIR)/Inc \
110 $(USBCDC_DIR)/Inc \
111 $(CMSIS_DIR)/Include \
112 $(CMSIS_DIR)/Device/ST/STM32F4xx/Include \
113 $(ROOT)/src/main/drivers/stm32/vcp_hal
114 else
115 CMSIS_SRC := $(notdir $(wildcard $(CMSIS_DIR)/CoreSupport/*.c \
116 $(ROOT)/lib/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx/*.c))
117 INCLUDE_DIRS := $(INCLUDE_DIRS) \
118 $(STDPERIPH_DIR)/inc \
119 $(USBOTG_DIR)/inc \
120 $(USBCORE_DIR)/inc \
121 $(USBCDC_DIR)/inc \
122 $(USBHID_DIR)/inc \
123 $(USBWRAPPER_DIR)/inc \
124 $(USBMSC_DIR)/inc \
125 $(CMSIS_DIR)/Core/Include \
126 $(ROOT)/lib/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx \
127 $(ROOT)/src/main/drivers/stm32/vcpf4
128 endif
130 #Flags
131 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
133 ifeq ($(TARGET_MCU),STM32F411xE)
134 DEVICE_FLAGS = -DSTM32F411xE -finline-limit=20
135 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld
136 STARTUP_SRC = startup_stm32f411xe.s
137 MCU_FLASH_SIZE := 512
139 else ifeq ($(TARGET_MCU),STM32F405xx)
140 DEVICE_FLAGS = -DSTM32F40_41xxx -DSTM32F405xx
141 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f405.ld
142 STARTUP_SRC = startup_stm32f40xx.s
143 MCU_FLASH_SIZE := 1024
145 else ifeq ($(TARGET_MCU),STM32F446xx)
146 DEVICE_FLAGS = -DSTM32F446xx
147 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f446.ld
148 STARTUP_SRC = startup_stm32f446xx.s
149 MCU_FLASH_SIZE := 512
151 else
152 $(error Unknown MCU for F4 target)
153 endif
154 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE) -DSTM32
156 MCU_COMMON_SRC = \
157 drivers/accgyro/accgyro_mpu.c \
158 drivers/dshot_bitbang_decode.c \
159 drivers/inverter.c \
160 drivers/pwm_output_dshot_shared.c \
161 drivers/stm32/pwm_output_dshot.c \
162 drivers/stm32/adc_stm32f4xx.c \
163 drivers/stm32/bus_i2c_stm32f4xx.c \
164 drivers/stm32/bus_spi_stdperiph.c \
165 drivers/stm32/debug.c \
166 drivers/stm32/dma_reqmap_mcu.c \
167 drivers/stm32/dma_stm32f4xx.c \
168 drivers/stm32/dshot_bitbang.c \
169 drivers/stm32/dshot_bitbang_stdperiph.c \
170 drivers/stm32/exti.c \
171 drivers/stm32/io_stm32.c \
172 drivers/stm32/light_ws2811strip_stdperiph.c \
173 drivers/stm32/persistent.c \
174 drivers/stm32/pwm_output.c \
175 drivers/stm32/rcc_stm32.c \
176 drivers/stm32/sdio_f4xx.c \
177 drivers/stm32/serial_uart_stdperiph.c \
178 drivers/stm32/serial_uart_stm32f4xx.c \
179 drivers/stm32/system_stm32f4xx.c \
180 drivers/stm32/timer_stdperiph.c \
181 drivers/stm32/timer_stm32f4xx.c \
182 drivers/stm32/transponder_ir_io_stdperiph.c \
183 drivers/stm32/usbd_msc_desc.c \
184 startup/system_stm32f4xx.c
186 ifeq ($(PERIPH_DRIVER), HAL)
187 VCP_SRC = \
188 drivers/stm32/vcp_hal/usbd_desc.c \
189 drivers/stm32/vcp_hal/usbd_conf.c \
190 drivers/stm32/vcp_hal/usbd_cdc_interface.c \
191 drivers/stm32/serial_usb_vcp.c \
192 drivers/usb_io.c
193 else
194 VCP_SRC = \
195 drivers/stm32/vcpf4/stm32f4xx_it.c \
196 drivers/stm32/vcpf4/usb_bsp.c \
197 drivers/stm32/vcpf4/usbd_desc.c \
198 drivers/stm32/vcpf4/usbd_usr.c \
199 drivers/stm32/vcpf4/usbd_cdc_vcp.c \
200 drivers/stm32/vcpf4/usb_cdc_hid.c \
201 drivers/stm32/serial_usb_vcp.c \
202 drivers/usb_io.c
203 endif
205 MSC_SRC = \
206 drivers/usb_msc_common.c \
207 drivers/stm32/usb_msc_f4xx.c \
208 msc/usbd_storage.c \
209 msc/usbd_storage_emfat.c \
210 msc/emfat.c \
211 msc/emfat_file.c \
212 msc/usbd_storage_sd_spi.c \
213 msc/usbd_storage_sdio.c
215 DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP
216 DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM4