Add comments
[inav.git] / cmake / stm32h7.cmake
blob08e7686b8f48285b5e085184538d428321f76356
1 include(cortex-m7)
2 include(stm32h7-usb)
4 set(STM32H7_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/STM32H7/Drivers/CMSIS/Device/ST/STM32H7xx")
5 set(STM32H7_HAL_DIR "${MAIN_LIB_DIR}/main/STM32H7/Drivers/STM32H7xx_HAL_Driver")
7 set(STM32H7_HAL_SRC
8     stm32h7xx_hal.c
9     stm32h7xx_hal_adc.c
10     stm32h7xx_hal_adc_ex.c
11 #    stm32h7xx_hal_cec.c
12 #    stm32h7xx_hal_comp.c
13     stm32h7xx_hal_cortex.c
14 #    stm32h7xx_hal_crc.c
15 #    stm32h7xx_hal_crc_ex.c
16 #    stm32h7xx_hal_cryp.c
17 #    stm32h7xx_hal_cryp_ex.c
18     stm32h7xx_hal_dac.c
19     stm32h7xx_hal_dac_ex.c
20 #    stm32h7xx_hal_dcmi.c
21 #    stm32h7xx_hal_dfsdm.c
22 #    stm32h7xx_hal_dfsdm_ex.c
23     stm32h7xx_hal_dma.c
24 #    stm32h7xx_hal_dma2d.c
25     stm32h7xx_hal_dma_ex.c
26 #    stm32h7xx_hal_dsi.c
27     stm32h7xx_hal_dts.c
28 #    stm32h7xx_hal_eth.c
29 #    stm32h7xx_hal_eth_ex.c
30     stm32h7xx_hal_exti.c
31 #    stm32h7xx_hal_fdcan.c
32     stm32h7xx_hal_flash.c
33     stm32h7xx_hal_flash_ex.c
34     stm32h7xx_hal_gfxmmu.c
35     stm32h7xx_hal_gpio.c
36 #    stm32h7xx_hal_hash.c
37 #    stm32h7xx_hal_hash_ex.c
38 #    stm32h7xx_hal_hcd.c
39 #    stm32h7xx_hal_hrtim.c
40 #    stm32h7xx_hal_hsem.c
41     stm32h7xx_hal_i2c.c
42     stm32h7xx_hal_i2c_ex.c
43 #    stm32h7xx_hal_i2s.c
44 #    stm32h7xx_hal_i2s_ex.c
45 #    stm32h7xx_hal_irda.c
46 #    stm32h7xx_hal_iwdg.c
47 #    stm32h7xx_hal_jpeg.c
48 #    stm32h7xx_hal_lptim.c
49 #    stm32h7xx_hal_ltdc.c
50 #    stm32h7xx_hal_ltdc_ex.c
51 #    stm32h7xx_hal_mdios.c
52 #    stm32h7xx_hal_mdma.c
53 #    stm32h7xx_hal_mmc.c
54 #    stm32h7xx_hal_mmc_ex.c
55 #    stm32h7xx_hal_nand.c
56 #    stm32h7xx_hal_nor.c
57 #    stm32h7xx_hal_opamp.c
58 #    stm32h7xx_hal_opamp_ex.c
59     stm32h7xx_hal_ospi.c
60     stm32h7xx_hal_otfdec.c
61     stm32h7xx_hal_pcd.c
62     stm32h7xx_hal_pcd_ex.c
63     stm32h7xx_hal_pssi.c
64     stm32h7xx_hal_pwr.c
65     stm32h7xx_hal_pwr_ex.c
66     stm32h7xx_hal_qspi.c
67 #    stm32h7xx_hal_ramecc.c
68     stm32h7xx_hal_rcc.c
69     stm32h7xx_hal_rcc_ex.c
70 #    stm32h7xx_hal_rng.c
71 #    stm32h7xx_hal_rng_ex.c
72     stm32h7xx_hal_rtc.c
73     stm32h7xx_hal_rtc_ex.c
74 #    stm32h7xx_hal_sai.c
75 #    stm32h7xx_hal_sai_ex.c
76     stm32h7xx_hal_sd.c
77     stm32h7xx_hal_sd_ex.c
78 #    stm32h7xx_hal_sdram.c
79 #    stm32h7xx_hal_smartcard.c
80 #    stm32h7xx_hal_smartcard_ex.c
81 #    stm32h7xx_hal_smbus.c
82 #    stm32h7xx_hal_spdifrx.c
83     stm32h7xx_hal_spi.c
84     stm32h7xx_hal_spi_ex.c
85 #    stm32h7xx_hal_sram.c
86 #    stm32h7xx_hal_swpmi.c
87     stm32h7xx_hal_tim.c
88     stm32h7xx_hal_tim_ex.c
89     stm32h7xx_hal_uart.c
90     stm32h7xx_hal_uart_ex.c
91 #    stm32h7xx_hal_usart.c
92 #    stm32h7xx_hal_usart_ex.c
93 #    stm32h7xx_hal_wwdg.c
94 #    stm32h7xx_ll_adc.c
95 #    stm32h7xx_ll_bdma.c
96 #    stm32h7xx_ll_comp.c
97 #    stm32h7xx_ll_crc.c
98     stm32h7xx_ll_crs.c
99 #    stm32h7xx_ll_dac.c
100 #    stm32h7xx_ll_delayblock.c
101     stm32h7xx_ll_dma.c
102 #    stm32h7xx_ll_dma2d.c
103     stm32h7xx_ll_exti.c
104 #    stm32h7xx_ll_fmc.c
105 #    stm32h7xx_ll_gpio.c
106 #    stm32h7xx_ll_hrtim.c
107     stm32h7xx_ll_i2c.c
108 #    stm32h7xx_ll_lptim.c
109 #    stm32h7xx_ll_lpuart.c
110 #    stm32h7xx_ll_mdma.c
111 #    stm32h7xx_ll_opamp.c
112 #    stm32h7xx_ll_pwr.c
113 #    stm32h7xx_ll_rcc.c
114 #    stm32h7xx_ll_rng.c
115 #    stm32h7xx_ll_rtc.c
116     stm32h7xx_ll_sdmmc.c
117     stm32h7xx_ll_spi.c
118 #    stm32h7xx_ll_swpmi.c
119     stm32h7xx_ll_tim.c
120 #    stm32h7xx_ll_usart.c
121     stm32h7xx_ll_usb.c
122 #    stm32h7xx_ll_utils.c
125 list(TRANSFORM STM32H7_HAL_SRC PREPEND "${STM32H7_HAL_DIR}/Src/")
127 set(STM32H7_VCP_DIR "${MAIN_SRC_DIR}/vcp_hal")
129 set(STM32H7_VCP_SRC
130     usbd_desc.c
131     usbd_conf_stm32h7xx.c
132     usbd_cdc_interface.c
134 list(TRANSFORM STM32H7_VCP_SRC PREPEND "${STM32H7_VCP_DIR}/")
136 set(STM32H7_INCLUDE_DIRS
137     ${STM32H7_HAL_DIR}/Inc
138     ${STM32H7_CMSIS_DEVICE_DIR}/Include
141 main_sources(STM32H7_SRC
142     target/system_stm32h7xx.c
144     config/config_streamer_stm32h7.c
145     config/config_streamer_ram.c
146     config/config_streamer_extflash.c
148     drivers/adc_stm32h7xx.c
149     drivers/bus_i2c_hal.c
150     drivers/dma_stm32h7xx.c
151     drivers/bus_spi_hal_ll.c
152     drivers/bus_quadspi.c
153     drivers/bus_quadspi_hal.c
154     drivers/memprot.h
155     drivers/memprot_hal.c
156     drivers/memprot_stm32h7xx.c
157     drivers/timer.c
158     drivers/timer_impl_hal.c
159     drivers/timer_stm32h7xx.c
160     drivers/system_stm32h7xx.c
161     drivers/serial_uart_stm32h7xx.c
162     drivers/serial_uart_hal.c
163     drivers/sdio.h
164     drivers/sdcard/sdmmc_sdio_h7xx.c
167 main_sources(STM32H7_MSC_SRC
168     drivers/usb_msc_h7xx.c
171 set(STM32H7_DEFINITIONS
172     ${CORTEX_M7_DEFINITIONS}
173     USE_HAL_DRIVER
174     USE_FULL_LL_DRIVER
175     MAX_MPU_REGIONS=16
178 function(target_stm32h7xx)
179     target_stm32(
180         SOURCES ${STM32H7_HAL_SRC} ${STM32H7_SRC}
181         COMPILE_DEFINITIONS ${STM32H7_DEFINITIONS}
182         COMPILE_OPTIONS ${CORTEX_M7_COMMON_OPTIONS} ${CORTEX_M7_COMPILE_OPTIONS}
183         INCLUDE_DIRECTORIES ${STM32H7_INCLUDE_DIRS}
184         LINK_OPTIONS ${CORTEX_M7_COMMON_OPTIONS} ${CORTEX_M7_LINK_OPTIONS}
186         MSC_SOURCES ${STM32H7_USBMSC_SRC} ${STM32H7_MSC_SRC}
187         VCP_SOURCES ${STM32H7_USB_SRC} ${STM32H7_VCP_SRC}
188         VCP_INCLUDE_DIRECTORIES ${STM32H7_USB_INCLUDE_DIRS} ${STM32H7_VCP_DIR}
190         OPTIMIZATION -O2
192         OPENOCD_TARGET stm32h7x
194 #        BOOTLOADER
196         ${ARGN}
197     )
198 endfunction()
200 macro(define_target_stm32h7 subfamily size)
201     function(target_stm32h7${subfamily}x${size} name)
202         set(func_ARGV ARGV)
203         string(TOUPPER ${size} upper_size)
204         get_stm32_flash_size(flash_size ${size})
205         set(definitions
206             STM32H7
207             STM32H7${subfamily}xx
208             STM32H7${subfamily}x${upper_size}
209             # stm32h743xx.h defined FLASH_SIZE, used by HAL, but in bytes
210             # use MCU_FLASH_SIZE since we use KiB in our code
211             MCU_FLASH_SIZE=${flash_size}
212         )
213         target_stm32h7xx(
214             NAME ${name}
215             STARTUP startup_stm32h7${subfamily}xx.s
216             COMPILE_DEFINITIONS ${definitions}
217             LINKER_SCRIPT stm32_flash_h7${subfamily}x${size}
218             ${${func_ARGV}}
219         )
220     endfunction()
221 endmacro()
223 define_target_stm32h7(43 i)