5 ifeq ($(DEBUG_HARDFAULTS
),G4
)
6 CFLAGS
+= -DDEBUG_HARDFAULTS
10 CMSIS_DIR
:= $(ROOT
)/lib
/main
/CMSIS
13 STDPERIPH_DIR
= $(ROOT
)/lib
/main
/STM32G4
/Drivers
/STM32G4xx_HAL_Driver
14 STDPERIPH_SRC
= $(notdir $(wildcard $(STDPERIPH_DIR
)/Src
/*.c
))
16 stm32g4xx_hal_comp.c \
18 stm32g4xx_hal_crc_ex.c \
19 stm32g4xx_hal_cryp.c \
20 stm32g4xx_hal_cryp_ex.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 \
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 \
34 stm32g4xx_hal_opamp.c \
35 stm32g4xx_hal_opamp_ex.c \
36 stm32g4xx_hal_qspi.c \
39 stm32g4xx_hal_sai_ex.c \
40 stm32g4xx_hal_smartcard.c \
41 stm32g4xx_hal_smartcard_ex.c \
42 stm32g4xx_hal_smbus.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 \
52 stm32g4xx_ll_cordic.c \
60 stm32g4xx_ll_hrtim.c \
62 stm32g4xx_ll_lptim.c \
63 stm32g4xx_ll_lpuart.c \
64 stm32g4xx_ll_opamp.c \
70 stm32g4xx_ll_usart.c \
73 STDPERIPH_SRC
:= $(filter-out ${EXCLUDES}, $(STDPERIPH_SRC
))
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
96 DEVICE_STDPERIPH_SRC
:= $(STDPERIPH_SRC
) \
103 VPATH
:= $(VPATH
):$(CMSIS_DIR
)/Include
:$(CMSIS_DIR
)/Device
/ST
/STM32G4xx
104 VPATH
:= $(VPATH
):$(STDPERIPH_DIR
)/Src
106 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
107 $(STDPERIPH_DIR
)/Inc \
112 $(CMSIS_DIR
)/Core
/Include \
113 $(ROOT
)/lib
/main
/STM32G4
/Drivers
/CMSIS
/Device
/ST
/STM32G4xx
/Include \
114 $(ROOT
)/src
/main
/vcp_hal
116 ifneq ($(filter SDCARD_SPI
,$(FEATURES
)),)
117 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
119 VPATH
:= $(VPATH
):$(FATFS_DIR
)
122 ifneq ($(filter SDCARD_SDIO
,$(FEATURES
)),)
123 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
125 VPATH
:= $(VPATH
):$(FATFS_DIR
)
129 ARCH_FLAGS
= -mthumb
-mcpu
=cortex-m4
-march
=armv7e-m
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16
-fsingle-precision-constant
131 DEVICE_FLAGS
= -DUSE_HAL_DRIVER
-DUSE_FULL_LL_DRIVER
-DUSE_DMA_RAM
-DMAX_MPU_REGIONS
=16
133 # G47X_TARGETS includes G47{3,4}{RE,CE,CEU}
135 ifeq ($(TARGET
),$(filter $(TARGET
),$(G47X_TARGETS
)))
136 DEVICE_FLAGS
+= -DSTM32G474xx
137 LD_SCRIPT
= $(LINKER_DIR
)/stm32_flash_g474.
ld
138 STARTUP_SRC
= startup_stm32g474xx.s
140 # Override the OPTIMISE_SPEED compiler setting to save flash space on these 512KB targets.
141 # Performance is only slightly affected but around 50 kB of flash are saved.
144 $(error Unknown MCU for G4 target
)
146 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
)
148 TARGET_FLAGS
= -D
$(TARGET
)
151 vcp_hal
/usbd_desc.c \
152 vcp_hal
/usbd_conf_stm32g4xx.c \
153 vcp_hal
/usbd_cdc_hid.c \
154 vcp_hal
/usbd_cdc_interface.c \
155 drivers
/serial_usb_vcp.c \
159 drivers
/accgyro
/accgyro_mpu.c \
160 drivers
/adc_stm32g4xx.c \
161 drivers
/bus_i2c_hal.c \
162 drivers
/bus_i2c_hal_init.c \
163 drivers
/bus_i2c_timing.c \
164 drivers
/bus_spi_ll.c \
165 drivers
/dma_stm32g4xx.c \
166 drivers
/dshot_bitbang.c \
167 drivers
/dshot_bitbang_decode.c \
168 drivers
/dshot_bitbang_ll.c \
169 drivers
/light_ws2811strip_hal.c \
170 drivers
/memprot_hal.c \
171 drivers
/memprot_stm32g4xx.c \
172 drivers
/persistent.c \
173 drivers
/pwm_output_dshot_shared.c \
174 drivers
/pwm_output_dshot_hal.c \
175 drivers
/timer_hal.c \
176 drivers
/timer_stm32g4xx.c \
177 drivers
/transponder_ir_io_hal.c \
178 drivers
/system_stm32g4xx.c \
179 drivers
/serial_uart_stm32g4xx.c \
180 drivers
/serial_uart_hal.c \
181 startup
/system_stm32g4xx.c
187 # G4's MSC use the same driver layer file with F7
189 drivers
/usb_msc_common.c \
190 drivers
/usb_msc_f7xx.c \
193 ifneq ($(filter SDCARD_SDIO
,$(FEATURES
)),)
197 msc
/usbd_storage_sdio.c
200 ifneq ($(filter SDCARD_SPI
,$(FEATURES
)),)
202 msc
/usbd_storage_sd_spi.c
205 ifneq ($(filter ONBOARDFLASH
,$(FEATURES
)),)
207 msc
/usbd_storage_emfat.c \
212 DSP_LIB
:= $(ROOT
)/lib
/main
/CMSIS
/DSP
213 DEVICE_FLAGS
+= -DARM_MATH_MATRIX_CHECK
-DARM_MATH_ROUNDING
-D__FPU_PRESENT
=1 -DUNALIGNED_SUPPORT_DISABLE
-DARM_MATH_CM4