f7: use hal for sdio
[inav.git] / cmake / stm32f7.cmake
blob62819928d56daa1bdb97332c5484b5605ae126ab
1 include(cortex-m7)
2 include(stm32f7-usb)
4 set(STM32F7_HAL_DIR "${MAIN_LIB_DIR}/main/STM32F7/Drivers/STM32F7xx_HAL_Driver")
6 set(STM32F7_HAL_SRC
7     stm32f7xx_hal.c
8     stm32f7xx_hal_adc.c
9     stm32f7xx_hal_adc_ex.c
10     stm32f7xx_hal_cortex.c
11     stm32f7xx_hal_dac.c
12     stm32f7xx_hal_dac_ex.c
13     stm32f7xx_hal_dma.c
14     stm32f7xx_hal_dma_ex.c
15     stm32f7xx_hal_flash.c
16     stm32f7xx_hal_flash_ex.c
17     stm32f7xx_hal_gpio.c
18     stm32f7xx_hal_i2c.c
19     stm32f7xx_hal_i2c_ex.c
20     stm32f7xx_hal_pcd.c
21     stm32f7xx_hal_pcd_ex.c
22     stm32f7xx_hal_pwr.c
23     stm32f7xx_hal_pwr_ex.c
24     stm32f7xx_hal_rcc.c
25     stm32f7xx_hal_rcc_ex.c
26     stm32f7xx_hal_rtc.c
27     stm32f7xx_hal_rtc_ex.c
28     stm32f7xx_hal_spi.c
29     stm32f7xx_hal_tim.c
30     stm32f7xx_hal_tim_ex.c
31     stm32f7xx_hal_uart.c
32     stm32f7xx_hal_usart.c
33     stm32f7xx_ll_dma.c
34     stm32f7xx_ll_dma2d.c
35     stm32f7xx_ll_gpio.c
36     stm32f7xx_ll_rcc.c
37     stm32f7xx_ll_spi.c
38     stm32f7xx_ll_tim.c
39     stm32f7xx_ll_usb.c
40     stm32f7xx_ll_utils.c
41     stm32f7xx_hal_sd.c
42     stm32f7xx_ll_sdmmc.c
44 list(TRANSFORM STM32F7_HAL_SRC PREPEND "${STM32F7_HAL_DIR}/Src/")
46 set(STM32F7_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/STM32F7/Drivers/CMSIS/Device/ST/STM32F7xx")
48 set(STM32F7_VCP_DIR "${MAIN_SRC_DIR}/vcp_hal")
50 set(STM32F7_VCP_SRC
51     usbd_desc.c
52     usbd_conf_stm32f7xx.c
53     usbd_cdc_interface.c
55 list(TRANSFORM STM32F7_VCP_SRC PREPEND "${STM32F7_VCP_DIR}/")
57 set(STM32F7_INCLUDE_DIRS
58     ${STM32F7_HAL_DIR}/Inc
59     ${STM32F7_CMSIS_DEVICE_DIR}/Include
62 main_sources(STM32F7_SRC
63     target/system_stm32f7xx.c
65     config/config_streamer_stm32f7.c
66     config/config_streamer_ram.c
67     config/config_streamer_extflash.c
69     drivers/adc_stm32f7xx.c
70     drivers/bus_i2c_hal.c
71     drivers/dma_stm32f7xx.c
72     drivers/bus_spi_hal_ll.c
73     drivers/timer.c
74     drivers/timer_impl_hal.c
75     drivers/timer_stm32f7xx.c
76     drivers/system_stm32f7xx.c
77     drivers/serial_uart_stm32f7xx.c
78     drivers/serial_uart_hal.c
79     drivers/sdcard/sdmmc_sdio_hal.c
82 main_sources(STM32F7_MSC_SRC
83     drivers/usb_msc_f7xx.c
86 set(STM32F7_DEFINITIONS
87     ${CORTEX_M7_DEFINITIONS}
88     USE_HAL_DRIVER
89     USE_FULL_LL_DRIVER
92 function(target_stm32f7xx)
93     target_stm32(
94         SOURCES ${STM32F7_HAL_SRC} ${STM32F7_SRC}
95         COMPILE_DEFINITIONS ${STM32F7_DEFINITIONS}
96         COMPILE_OPTIONS ${CORTEX_M7_COMMON_OPTIONS} ${CORTEX_M7_COMPILE_OPTIONS}
97         INCLUDE_DIRECTORIES ${STM32F7_INCLUDE_DIRS}
98         LINK_OPTIONS ${CORTEX_M7_COMMON_OPTIONS} ${CORTEX_M7_LINK_OPTIONS}
100         MSC_SOURCES ${STM32F7_USBMSC_SRC} ${STM32F7_MSC_SRC}
101         VCP_SOURCES ${STM32F7_USB_SRC} ${STM32F7_VCP_SRC}
102         VCP_INCLUDE_DIRECTORIES ${STM32F7_USB_INCLUDE_DIRS} ${STM32F7_VCP_DIR}
104         OPENOCD_TARGET stm32f7x
106         BOOTLOADER
108         ${ARGN}
109     )
110 endfunction()
112 macro(define_target_stm32f7 subfamily size)
113     function(target_stm32f7${subfamily}x${size} name)
114         set(func_ARGV ARGV)
115         string(TOUPPER ${size} upper_size)
116         get_stm32_flash_size(flash_size ${size})
117         if(flash_size GREATER 512)
118             set(opt -O2)
119         else()
120             set(opt -Os)
121         endif()
122         set(definitions
123             STM32F7
124             STM32F7${subfamily}xx
125             STM32F7${subfamily}x${upper_size}
126             MCU_FLASH_SIZE=${flash_size}
127         )
128         target_stm32f7xx(
129             NAME ${name}
130             STARTUP startup_stm32f7${subfamily}xx.s
131             COMPILE_DEFINITIONS ${definitions}
132             LINKER_SCRIPT stm32_flash_f7${subfamily}x${size}
133             OPTIMIZATION ${opt}
135             ${${func_ARGV}}
136         )
137     endfunction()
138 endmacro()
140 define_target_stm32f7(22 e)
141 define_target_stm32f7(45 g)
142 define_target_stm32f7(46 g)
143 define_target_stm32f7(65 g)
144 define_target_stm32f7(65 i)