Implement Stopwatch (#12623)
[betaflight.git] / make / source.mk
blob65434a6c8b1a376ad4c54db323710fef1b21475c
1 COMMON_SRC = \
2 build/build_config.c \
3 build/debug.c \
4 build/debug_pin.c \
5 build/version.c \
6 $(TARGET_DIR_SRC) \
7 main.c \
8 $(addprefix pg/, $(notdir $(wildcard $(SRC_DIR)/pg/*.c))) \
9 $(addprefix common/,$(notdir $(wildcard $(SRC_DIR)/common/*.c))) \
10 $(addprefix config/,$(notdir $(wildcard $(SRC_DIR)/config/*.c))) \
11 cli/cli.c \
12 cli/settings.c \
13 config/config.c \
14 drivers/adc.c \
15 drivers/dshot.c \
16 drivers/dshot_dpwm.c \
17 drivers/dshot_command.c \
18 drivers/buf_writer.c \
19 drivers/bus.c \
20 drivers/bus_i2c_config.c \
21 drivers/bus_i2c_busdev.c \
22 drivers/bus_i2c_soft.c \
23 drivers/bus_octospi.c \
24 drivers/bus_quadspi.c \
25 drivers/bus_spi.c \
26 drivers/bus_spi_config.c \
27 drivers/bus_spi_pinconfig.c \
28 drivers/buttons.c \
29 drivers/display.c \
30 drivers/display_canvas.c \
31 drivers/dma_common.c \
32 drivers/io.c \
33 drivers/light_led.c \
34 drivers/mco.c \
35 drivers/motor.c \
36 drivers/pinio.c \
37 drivers/pin_pull_up_down.c \
38 drivers/resource.c \
39 drivers/serial.c \
40 drivers/serial_pinconfig.c \
41 drivers/serial_uart.c \
42 drivers/serial_uart_pinconfig.c \
43 drivers/sound_beeper.c \
44 drivers/stack_check.c \
45 drivers/system.c \
46 drivers/timer_common.c \
47 drivers/transponder_ir_arcitimer.c \
48 drivers/transponder_ir_ilap.c \
49 drivers/transponder_ir_erlt.c \
50 fc/board_info.c \
51 fc/dispatch.c \
52 fc/hardfaults.c \
53 fc/tasks.c \
54 fc/runtime_config.c \
55 fc/stats.c \
56 io/beeper.c \
57 io/piniobox.c \
58 io/serial.c \
59 io/smartaudio_protocol.c \
60 io/statusindicator.c \
61 io/tramp_protocol.c \
62 io/transponder_ir.c \
63 io/usb_cdc_hid.c \
64 io/usb_msc.c \
65 msp/msp.c \
66 msp/msp_box.c \
67 msp/msp_serial.c \
68 scheduler/scheduler.c \
69 sensors/adcinternal.c \
70 sensors/battery.c \
71 sensors/current.c \
72 sensors/voltage.c \
73 target/config_helper.c \
74 fc/init.c \
75 fc/controlrate_profile.c \
76 drivers/camera_control.c \
77 drivers/accgyro/gyro_sync.c \
78 drivers/rx/rx_spi.c \
79 drivers/rx/rx_xn297.c \
80 drivers/rx/rx_pwm.c \
81 drivers/serial_softserial.c \
82 fc/core.c \
83 fc/rc.c \
84 fc/rc_adjustments.c \
85 fc/rc_controls.c \
86 fc/rc_modes.c \
87 flight/position.c \
88 flight/failsafe.c \
89 flight/gps_rescue.c \
90 flight/dyn_notch_filter.c \
91 flight/imu.c \
92 flight/feedforward.c \
93 flight/mixer.c \
94 flight/mixer_init.c \
95 flight/mixer_tricopter.c \
96 flight/pid.c \
97 flight/pid_init.c \
98 flight/rpm_filter.c \
99 flight/servos.c \
100 flight/servos_tricopter.c \
101 io/serial_4way.c \
102 io/serial_4way_avrootloader.c \
103 io/serial_4way_stk500v2.c \
104 rx/ibus.c \
105 rx/jetiexbus.c \
106 rx/msp.c \
107 rx/pwm.c \
108 rx/frsky_crc.c \
109 rx/rx.c \
110 rx/rx_bind.c \
111 rx/rx_spi.c \
112 rx/rx_spi_common.c \
113 rx/crsf.c \
114 rx/ghst.c \
115 rx/sbus.c \
116 rx/sbus_channels.c \
117 rx/spektrum.c \
118 rx/srxl2.c \
119 io/spektrum_vtx_control.c \
120 io/spektrum_rssi.c \
121 rx/sumd.c \
122 rx/sumh.c \
123 rx/xbus.c \
124 rx/fport.c \
125 rx/msp_override.c \
126 sensors/acceleration.c \
127 sensors/acceleration_init.c \
128 sensors/boardalignment.c \
129 sensors/compass.c \
130 sensors/gyro.c \
131 sensors/gyro_init.c \
132 sensors/initialisation.c \
133 blackbox/blackbox.c \
134 blackbox/blackbox_encoding.c \
135 blackbox/blackbox_io.c \
136 cms/cms.c \
137 cms/cms_menu_blackbox.c \
138 cms/cms_menu_failsafe.c \
139 cms/cms_menu_firmware.c \
140 cms/cms_menu_gps_rescue.c\
141 cms/cms_menu_imu.c \
142 cms/cms_menu_ledstrip.c \
143 cms/cms_menu_main.c \
144 cms/cms_menu_misc.c \
145 cms/cms_menu_osd.c \
146 cms/cms_menu_power.c \
147 cms/cms_menu_saveexit.c \
148 cms/cms_menu_vtx_common.c \
149 cms/cms_menu_vtx_rtc6705.c \
150 cms/cms_menu_vtx_smartaudio.c \
151 cms/cms_menu_vtx_tramp.c \
152 cms/cms_menu_persistent_stats.c \
153 drivers/display_ug2864hsweg01.c \
154 drivers/light_ws2811strip.c \
155 drivers/rangefinder/rangefinder_hcsr04.c \
156 drivers/rangefinder/rangefinder_lidartf.c \
157 drivers/serial_escserial.c \
158 drivers/vtx_common.c \
159 drivers/vtx_table.c \
160 io/dashboard.c \
161 io/displayport_frsky_osd.c \
162 io/displayport_max7456.c \
163 io/displayport_msp.c \
164 io/displayport_oled.c \
165 io/displayport_srxl.c \
166 io/displayport_crsf.c \
167 io/displayport_hott.c \
168 io/frsky_osd.c \
169 io/rcdevice_cam.c \
170 io/rcdevice.c \
171 io/gps.c \
172 io/ledstrip.c \
173 io/pidaudio.c \
174 osd/osd.c \
175 osd/osd_elements.c \
176 osd/osd_warnings.c \
177 sensors/barometer.c \
178 sensors/rangefinder.c \
179 telemetry/telemetry.c \
180 telemetry/crsf.c \
181 telemetry/ghst.c \
182 telemetry/srxl.c \
183 telemetry/frsky_hub.c \
184 telemetry/hott.c \
185 telemetry/jetiexbus.c \
186 telemetry/smartport.c \
187 telemetry/ltm.c \
188 telemetry/mavlink.c \
189 telemetry/msp_shared.c \
190 telemetry/ibus.c \
191 telemetry/ibus_shared.c \
192 sensors/esc_sensor.c \
193 io/vtx.c \
194 io/vtx_rtc6705.c \
195 io/vtx_smartaudio.c \
196 io/vtx_tramp.c \
197 io/vtx_control.c \
198 io/vtx_msp.c \
199 cms/cms_menu_vtx_msp.c
201 ifneq ($(SIMULATOR_BUILD),yes)
203 COMMON_SRC += \
204 $(addprefix drivers/accgyro/,$(notdir $(wildcard $(SRC_DIR)/drivers/accgyro/*.c))) \
205 $(ROOT)/lib/main/BoschSensortec/BMI270-Sensor-API/bmi270_maximum_fifo.c \
206 $(addprefix drivers/barometer/,$(notdir $(wildcard $(SRC_DIR)/drivers/barometer/*.c))) \
207 $(addprefix drivers/compass/,$(notdir $(wildcard $(SRC_DIR)/drivers/compass/*.c))) \
208 drivers/max7456.c \
209 drivers/vtx_rtc6705.c \
210 drivers/vtx_rtc6705_soft_spi.c
212 ifneq ($(CONFIG),)
214 GYRO_DEFINE := $(shell grep " USE_GYRO_" $(CONFIG_FILE) | awk '{print $$2}' )
215 LEGACY_GYRO_DEFINES := USE_GYRO_L3GD20
216 ifneq ($(findstring $(GYRO_DEFINE),$(LEGACY_GYRO_DEFINES)),)
218 COMMON_SRC += \
219 $(addprefix drivers/accgyro_legacy/,$(notdir $(wildcard $(SRC_DIR)/drivers/accgyro_legacy/*.c)))
221 endif
222 endif
224 RX_SRC = \
225 rx/cc2500_common.c \
226 rx/cc2500_frsky_shared.c \
227 rx/cc2500_frsky_d.c \
228 rx/cc2500_frsky_x.c \
229 rx/cc2500_sfhss.c \
230 rx/cc2500_redpine.c \
231 rx/a7105_flysky.c \
232 rx/cyrf6936_spektrum.c \
233 drivers/rx/expresslrs_driver.c \
234 rx/expresslrs.c \
235 rx/expresslrs_common.c \
236 rx/expresslrs_telemetry.c \
237 drivers/rx/rx_cc2500.c \
238 drivers/rx/rx_a7105.c \
239 drivers/rx/rx_cyrf6936.c \
240 drivers/rx/rx_sx127x.c \
241 drivers/rx/rx_sx1280.c
243 FLASH_SRC += \
244 drivers/flash.c \
245 drivers/flash_m25p16.c \
246 drivers/flash_w25n01g.c \
247 drivers/flash_w25q128fv.c \
248 drivers/flash_w25m.c \
249 io/flashfs.c
251 SDCARD_SRC += \
252 drivers/sdcard.c \
253 drivers/sdcard_spi.c \
254 drivers/sdcard_sdio_baremetal.c \
255 drivers/sdcard_standard.c \
256 io/asyncfatfs/asyncfatfs.c \
257 io/asyncfatfs/fat_standard.c
259 INCLUDE_DIRS := $(INCLUDE_DIRS) \
260 $(FATFS_DIR)
261 VPATH := $(VPATH):$(FATFS_DIR)
263 endif
265 COMMON_DEVICE_SRC = \
266 $(CMSIS_SRC) \
267 $(DEVICE_STDPERIPH_SRC)
269 COMMON_SRC := $(COMMON_SRC) $(COMMON_DEVICE_SRC) $(RX_SRC)
271 ifeq ($(EXST),yes)
272 TARGET_FLAGS := -DUSE_EXST $(TARGET_FLAGS)
273 endif
275 ifeq ($(RAM_BASED),yes)
276 TARGET_FLAGS := -DUSE_EXST -DCONFIG_IN_RAM -DRAMBASED $(TARGET_FLAGS)
277 endif
279 ifeq ($(SIMULATOR_BUILD),yes)
280 TARGET_FLAGS := -DSIMULATOR_BUILD $(TARGET_FLAGS)
281 endif
283 SPEED_OPTIMISED_SRC := ""
284 SIZE_OPTIMISED_SRC := ""
286 SPEED_OPTIMISED_SRC := $(SPEED_OPTIMISED_SRC) \
287 common/encoding.c \
288 common/filter.c \
289 common/maths.c \
290 common/sdft.c \
291 common/stopwatch.c \
292 common/typeconversion.c \
293 drivers/accgyro/accgyro_mpu.c \
294 drivers/accgyro/accgyro_mpu3050.c \
295 drivers/accgyro/accgyro_spi_bmi160.c \
296 drivers/accgyro/accgyro_spi_bmi270.c \
297 drivers/accgyro/accgyro_spi_lsm6dso.c \
298 drivers/accgyro_legacy/accgyro_adxl345.c \
299 drivers/accgyro_legacy/accgyro_bma280.c \
300 drivers/accgyro_legacy/accgyro_l3g4200d.c \
301 drivers/accgyro_legacy/accgyro_l3gd20.c \
302 drivers/accgyro_legacy/accgyro_lsm303dlhc.c \
303 drivers/accgyro_legacy/accgyro_mma845x.c \
304 drivers/adc.c \
305 drivers/buf_writer.c \
306 drivers/bus.c \
307 drivers/bus_quadspi.c \
308 drivers/bus_spi.c \
309 drivers/exti.c \
310 drivers/io.c \
311 drivers/pwm_output.c \
312 drivers/rcc.c \
313 drivers/serial.c \
314 drivers/serial_uart.c \
315 drivers/system.c \
316 drivers/timer.c \
317 fc/core.c \
318 fc/tasks.c \
319 fc/rc.c \
320 fc/rc_controls.c \
321 fc/runtime_config.c \
322 flight/dyn_notch_filter.c \
323 flight/imu.c \
324 flight/mixer.c \
325 flight/pid.c \
326 flight/rpm_filter.c \
327 rx/ibus.c \
328 rx/rx.c \
329 rx/rx_spi.c \
330 rx/crsf.c \
331 rx/frsky_crc.c \
332 rx/sbus.c \
333 rx/sbus_channels.c \
334 rx/spektrum.c \
335 rx/srxl2.c \
336 rx/sumd.c \
337 rx/xbus.c \
338 rx/fport.c \
339 scheduler/scheduler.c \
340 sensors/acceleration.c \
341 sensors/boardalignment.c \
342 sensors/gyro.c \
343 $(CMSIS_SRC) \
344 $(DEVICE_STDPERIPH_SRC) \
346 SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
347 $(shell find $(SRC_DIR) -name '*_init.c') \
348 bus_bst_stm32f30x.c \
349 cli/cli.c \
350 cli/settings.c \
351 drivers/accgyro/accgyro_fake.c \
352 drivers/barometer/barometer_bmp085.c \
353 drivers/barometer/barometer_bmp280.c \
354 drivers/barometer/barometer_fake.c \
355 drivers/barometer/barometer_ms5611.c \
356 drivers/barometer/barometer_lps.c \
357 drivers/barometer/barometer_qmp6988.c \
358 drivers/barometer/barometer_2smpb_02b.c \
359 drivers/bus_i2c_config.c \
360 drivers/bus_i2c_timing.c \
361 drivers/bus_spi_config.c \
362 drivers/bus_spi_pinconfig.c \
363 drivers/compass/compass_ak8963.c \
364 drivers/compass/compass_ak8975.c \
365 drivers/compass/compass_fake.c \
366 drivers/compass/compass_hmc5883l.c \
367 drivers/compass/compass_qmc5883l.c \
368 drivers/compass/compass_lis3mdl.c \
369 drivers/display_ug2864hsweg01.c \
370 drivers/inverter.c \
371 drivers/light_ws2811strip.c \
372 drivers/serial_escserial.c \
373 drivers/serial_pinconfig.c \
374 drivers/serial_tcp.c \
375 drivers/serial_uart_pinconfig.c \
376 drivers/serial_usb_vcp.c \
377 drivers/vtx_rtc6705_soft_spi.c \
378 drivers/vtx_rtc6705.c \
379 drivers/vtx_common.c \
380 fc/init.c \
381 fc/board_info.c \
382 config/config_eeprom.c \
383 config/feature.c \
384 config/config_streamer.c \
385 config/simplified_tuning.c \
386 i2c_bst.c \
387 io/dashboard.c \
388 io/serial.c \
389 io/serial_4way.c \
390 io/serial_4way_avrootloader.c \
391 io/serial_4way_stk500v2.c \
392 io/transponder_ir.c \
393 io/usb_cdc_hid.c \
394 msp/msp_serial.c \
395 cms/cms.c \
396 cms/cms_menu_blackbox.c \
397 cms/cms_menu_failsafe.c \
398 cms/cms_menu_firmware.c \
399 cms/cms_menu_gps_rescue.c\
400 cms/cms_menu_imu.c \
401 cms/cms_menu_ledstrip.c \
402 cms/cms_menu_main.c \
403 cms/cms_menu_misc.c \
404 cms/cms_menu_osd.c \
405 cms/cms_menu_power.c \
406 cms/cms_menu_saveexit.c \
407 cms/cms_menu_vtx_common.c \
408 cms/cms_menu_vtx_rtc6705.c \
409 cms/cms_menu_vtx_smartaudio.c \
410 cms/cms_menu_vtx_tramp.c \
411 cms/cms_menu_persistent_stats.c \
412 io/vtx.c \
413 io/vtx_rtc6705.c \
414 io/vtx_smartaudio.c \
415 io/vtx_tramp.c \
416 io/vtx_control.c \
417 io/spektrum_vtx_control.c \
418 osd/osd.c \
419 osd/osd_elements.c \
420 osd/osd_warnings.c \
421 rx/rx_bind.c \
422 io/vtx_msp.c \
423 cms/cms_menu_vtx_msp.c
425 # Gyro driver files that only contain initialization and configuration code - not runtime code
426 SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
427 drivers/accgyro/accgyro_mpu6050.c \
428 drivers/accgyro/accgyro_mpu6500.c \
429 drivers/accgyro/accgyro_spi_mpu6000.c \
430 drivers/accgyro/accgyro_spi_mpu6500.c \
431 drivers/accgyro/accgyro_spi_mpu9250.c \
432 drivers/accgyro/accgyro_spi_icm20689.c \
433 drivers/accgyro/accgyro_spi_icm426xx.c \
434 drivers/accgyro/accgyro_spi_lsm6dso_init.c
437 # F4 and F7 optimizations
438 SPEED_OPTIMISED_SRC := $(SPEED_OPTIMISED_SRC) \
439 drivers/bus_i2c_hal.c \
440 drivers/bus_spi_ll.c \
441 rx/frsky_crc.c \
442 drivers/max7456.c \
443 drivers/pwm_output_dshot.c \
444 drivers/pwm_output_dshot_shared.c \
445 drivers/pwm_output_dshot_hal.c
447 SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
448 drivers/bus_i2c_hal_init.c
450 # check if target.mk supplied
451 SRC := $(STARTUP_SRC) $(MCU_COMMON_SRC) $(TARGET_SRC) $(VARIANT_SRC)
453 # Files that should not be optimized, useful for debugging IMPRECISE cpu faults.
454 # Specify FULL PATH, e.g. "./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_sdmmc.c"
455 NOT_OPTIMISED_SRC := $(NOT_OPTIMISED_SRC) \
457 ifneq ($(DSP_LIB),)
459 INCLUDE_DIRS += $(DSP_LIB)/Include
460 SRC += $(wildcard $(DSP_LIB)/Source/*/*.S)
462 endif
464 SRC += $(FLASH_SRC) $(MSC_SRC) $(SDCARD_SRC) $(COMMON_SRC)
466 #excludes
467 SRC := $(filter-out $(MCU_EXCLUDES), $(SRC))
469 SRC += $(VCP_SRC)
471 # end target specific make file checks
473 # Search path and source files for the Open Location Code library
474 OLC_DIR = $(ROOT)/lib/main/google/olc
476 ifneq ($(OLC_DIR),)
477 INCLUDE_DIRS += $(OLC_DIR)
478 SRC += $(OLC_DIR)/olc.c
479 SIZE_OPTIMISED_SRC += $(OLC_DIR)/olc.c
480 endif