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
:$(STDPERIPH_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
/drivers
/stm32 \
115 $(ROOT
)/src
/main
/drivers
/stm32
/vcp_hal
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
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.
133 $(error Unknown MCU for G4 target
)
135 DEVICE_FLAGS
+= -DHSE_VALUE
=$(HSE_VALUE
) -DSTM32
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 \
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
179 # G4's MSC use the same driver layer file with F7
181 drivers
/usb_msc_common.c \
182 drivers
/stm32
/usb_msc_f7xx.c \
184 msc
/usbd_storage_emfat.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