Removing Timer Usage Flags (#12862)
[betaflight.git] / make / mcu / STM32G4.mk
blob72f5724fb6ce6d85dceaaffc60790ea742387e07
2 # G4 Make file include
5 ifeq ($(DEBUG_HARDFAULTS),G4)
6 CFLAGS += -DDEBUG_HARDFAULTS
7 endif
9 #CMSIS
10 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
12 #STDPERIPH
13 STDPERIPH_DIR = $(ROOT)/lib/main/STM32G4/Drivers/STM32G4xx_HAL_Driver
14 STDPERIPH_SRC = $(notdir $(wildcard $(STDPERIPH_DIR)/Src/*.c))
15 EXCLUDES = \
16 stm32g4xx_hal_comp.c \
17 stm32g4xx_hal_crc.c \
18 stm32g4xx_hal_crc_ex.c \
19 stm32g4xx_hal_cryp.c \
20 stm32g4xx_hal_cryp_ex.c \
21 stm32g4xx_hal_dac.c \
22 stm32g4xx_hal_dac_ex.c \
23 stm32g4xx_hal_dma_ex.c \
24 stm32g4xx_hal_flash_ramfunc.c \
25 stm33g4xx_hal_fmac.c \
26 stm32g4xx_hal_hrtim.c \
27 stm32g4xx_hal_i2s.c \
28 stm32g4xx_hal_irda.c \
29 stm32g4xx_hal_iwdg.c \
30 stm32g4xx_hal_lptim.c \
31 stm32g4xx_hal_msp_template.c \
32 stm32g4xx_hal_nand.c \
33 stm32g4xx_hal_nor.c \
34 stm32g4xx_hal_opamp.c \
35 stm32g4xx_hal_opamp_ex.c \
36 stm32g4xx_hal_qspi.c \
37 stm32g4xx_hal_rng.c \
38 stm32g4xx_hal_sai.c \
39 stm32g4xx_hal_sai_ex.c \
40 stm32g4xx_hal_smartcard.c \
41 stm32g4xx_hal_smartcard_ex.c \
42 stm32g4xx_hal_smbus.c \
43 stm32g4xx_hal_spi.c \
44 stm32g4xx_hal_spi_ex.c \
45 stm32g4xx_hal_sram.c \
46 stm32g4xx_hal_timebase_tim_template.c \
47 stm32g4xx_hal_usart.c \
48 stm32g4xx_hal_usart_ex.c \
49 stm32g4xx_hal_wwdg.c \
50 stm32g4xx_ll_adc.c \
51 stm32g4xx_ll_comp.c \
52 stm32g4xx_ll_cordic.c \
53 stm32g4xx_ll_crc.c \
54 stm32g4xx_ll_crs.c \
55 stm32g4xx_ll_dac.c \
56 stm32g4xx_ll_exti.c \
57 stm32g4xx_ll_fmac.c \
58 stm32g4xx_ll_fmc.c \
59 stm32g4xx_ll_gpio.c \
60 stm32g4xx_ll_hrtim.c \
61 stm32g4xx_ll_i2c.c \
62 stm32g4xx_ll_lptim.c \
63 stm32g4xx_ll_lpuart.c \
64 stm32g4xx_ll_opamp.c \
65 stm32g4xx_ll_pwr.c \
66 stm32g4xx_ll_rcc.c \
67 stm32g4xx_ll_rng.c \
68 stm32g4xx_ll_rtc.c \
69 stm32g4xx_ll_ucpd.c \
70 stm32g4xx_ll_usart.c \
71 stm32g4xx_ll_utils.c
73 STDPERIPH_SRC := $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC))
75 #USB
76 USBCORE_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Core
77 USBCORE_SRC = $(notdir $(wildcard $(USBCORE_DIR)/Src/*.c))
78 EXCLUDES = usbd_conf_template.c
79 USBCORE_SRC := $(filter-out ${EXCLUDES}, $(USBCORE_SRC))
81 USBCDC_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC
82 USBCDC_SRC = $(notdir $(wildcard $(USBCDC_DIR)/Src/*.c))
83 EXCLUDES = usbd_cdc_if_template.c
84 USBCDC_SRC := $(filter-out ${EXCLUDES}, $(USBCDC_SRC))
86 USBHID_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Class/HID
87 USBHID_SRC = $(notdir $(wildcard $(USBHID_DIR)/Src/*.c))
89 USBMSC_DIR = $(ROOT)/lib/main/STM32G4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC
90 USBMSC_SRC = $(notdir $(wildcard $(USBMSC_DIR)/Src/*.c))
91 EXCLUDES = usbd_msc_storage_template.c
92 USBMSC_SRC := $(filter-out ${EXCLUDES}, $(USBMSC_SRC))
94 VPATH := $(VPATH):$(USBCDC_DIR)/Src:$(USBCORE_DIR)/Src:$(USBHID_DIR)/Src:$(USBMSC_DIR)/Src:$(STDPERIPH_DIR)/src
96 DEVICE_STDPERIPH_SRC := $(STDPERIPH_SRC) \
97 $(USBCORE_SRC) \
98 $(USBCDC_SRC) \
99 $(USBHID_SRC) \
100 $(USBMSC_SRC)
102 #CMSIS
103 VPATH := $(VPATH):$(CMSIS_DIR)/Include:$(CMSIS_DIR)/Device/ST/STM32G4xx
104 VPATH := $(VPATH):$(STDPERIPH_DIR)/Src
105 CMSIS_SRC :=
106 INCLUDE_DIRS := $(INCLUDE_DIRS) \
107 $(STDPERIPH_DIR)/Inc \
108 $(USBCORE_DIR)/Inc \
109 $(USBCDC_DIR)/Inc \
110 $(USBHID_DIR)/Inc \
111 $(USBMSC_DIR)/Inc \
112 $(CMSIS_DIR)/Core/Include \
113 $(ROOT)/lib/main/STM32G4/Drivers/CMSIS/Device/ST/STM32G4xx/Include \
114 $(ROOT)/src/main/drivers/stm32 \
115 $(ROOT)/src/main/drivers/stm32/vcp_hal
117 #Flags
118 ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
120 DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DUSE_DMA_RAM -DMAX_MPU_REGIONS=16
122 # G47X_TARGETS includes G47{3,4}{RE,CE,CEU}
124 ifeq ($(TARGET_MCU),STM32G474xx)
125 DEVICE_FLAGS += -DSTM32G474xx
126 LD_SCRIPT = $(LINKER_DIR)/stm32_flash_g474.ld
127 STARTUP_SRC = startup_stm32g474xx.s
128 MCU_FLASH_SIZE = 512
129 # Override the OPTIMISE_SPEED compiler setting to save flash space on these 512KB targets.
130 # Performance is only slightly affected but around 50 kB of flash are saved.
131 OPTIMISE_SPEED = -O2
132 else
133 $(error Unknown MCU for G4 target)
134 endif
135 DEVICE_FLAGS += -DHSE_VALUE=$(HSE_VALUE) -DSTM32
137 VCP_SRC = \
138 drivers/stm32/vcp_hal/usbd_desc.c \
139 drivers/stm32/vcp_hal/usbd_conf_stm32g4xx.c \
140 drivers/stm32/vcp_hal/usbd_cdc_hid.c \
141 drivers/stm32/vcp_hal/usbd_cdc_interface.c \
142 drivers/stm32/serial_usb_vcp.c \
143 drivers/usb_io.c
145 MCU_COMMON_SRC = \
146 drivers/accgyro/accgyro_mpu.c \
147 drivers/bus_i2c_timing.c \
148 drivers/dshot_bitbang_decode.c \
149 drivers/pwm_output_dshot_shared.c \
150 drivers/stm32/adc_stm32g4xx.c \
151 drivers/stm32/bus_i2c_hal_init.c \
152 drivers/stm32/bus_i2c_hal.c \
153 drivers/stm32/bus_spi_ll.c \
154 drivers/stm32/debug.c \
155 drivers/stm32/dma_reqmap_mcu.c \
156 drivers/stm32/dma_stm32g4xx.c \
157 drivers/stm32/dshot_bitbang_ll.c \
158 drivers/stm32/dshot_bitbang.c \
159 drivers/stm32/exti.c \
160 drivers/stm32/io_stm32.c \
161 drivers/stm32/light_ws2811strip_hal.c \
162 drivers/stm32/memprot_hal.c \
163 drivers/stm32/memprot_stm32g4xx.c \
164 drivers/stm32/persistent.c \
165 drivers/stm32/pwm_output.c \
166 drivers/stm32/pwm_output_dshot_hal.c \
167 drivers/stm32/rcc_stm32.c \
168 drivers/stm32/serial_uart_hal.c \
169 drivers/stm32/serial_uart_stm32g4xx.c \
170 drivers/stm32/system_stm32g4xx.c \
171 drivers/stm32/timer_hal.c \
172 drivers/stm32/timer_stm32g4xx.c \
173 drivers/stm32/transponder_ir_io_hal.c \
174 startup/system_stm32g4xx.c
176 MCU_EXCLUDES = \
177 drivers/bus_i2c.c
179 # G4's MSC use the same driver layer file with F7
180 MSC_SRC = \
181 drivers/usb_msc_common.c \
182 drivers/stm32/usb_msc_f7xx.c \
183 msc/usbd_storage.c \
184 msc/usbd_storage_emfat.c \
185 msc/emfat.c \
186 msc/emfat_file.c \
187 msc/usbd_storage_sdio.c \
188 msc/usbd_storage_sd_spi.c
190 DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP
191 DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM4