Simplify and fix altitude processing for BF43COMPAT
[inav.git] / cmake / stm32f4.cmake
blob64fae1fe2f53f72e01ade49dd1b8c1c9b2252dbc
1 include(cortex-m4f)
2 include(stm32-stdperiph)
3 include(stm32f4-usb)
5 set(STM32F4_STDPERIPH_DIR "${MAIN_LIB_DIR}/main/STM32F4/Drivers/STM32F4xx_StdPeriph_Driver")
6 set(STM32F4_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx")
7 set(STM32F4_CMSIS_DRIVERS_DIR "${MAIN_LIB_DIR}/main/STM32F4/Drivers/CMSIS")
8 set(STM32F4_VCP_DIR "${MAIN_SRC_DIR}/vcpf4")
10 set(STM32F4_STDPERIPH_SRC_EXCLUDES
11     stm32f4xx_can.c
12     stm32f4xx_cec.c
13     stm32f4xx_crc.c
14     stm32f4xx_cryp.c
15     stm32f4xx_cryp_aes.c
16     stm32f4xx_cryp_des.c
17     stm32f4xx_cryp_tdes.c
18     stm32f4xx_dbgmcu.c
19     stm32f4xx_dsi.c
20     stm32f4xx_flash_ramfunc.c
21     stm32f4xx_fmpi2c.c
22     stm32f4xx_fmc.c
23     stm32f4xx_hash.c
24     stm32f4xx_hash_md5.c
25     stm32f4xx_hash_sha1.c
26     stm32f4xx_lptim.c
27     stm32f4xx_qspi.c
28     stm32f4xx_sai.c
29     stm32f4xx_spdifrx.c
32 set(STM32F4_STDPERIPH_SRC_DIR "${STM32F4_STDPERIPH_DIR}/src")
33 glob_except(STM32F4_STDPERIPH_SRC "${STM32F4_STDPERIPH_SRC_DIR}/*.c" "${STM32F4_STDPERIPH_SRC_EXCLUDES}")
35 main_sources(STM32F4_SRC
36     target/system_stm32f4xx.c
38     config/config_streamer_stm32f4.c
39     config/config_streamer_ram.c
40     config/config_streamer_extflash.c
42     drivers/adc_stm32f4xx.c
43     drivers/adc_stm32f4xx.c
44     drivers/bus_i2c_stm32f40x.c
45     drivers/serial_uart_stm32f4xx.c
46     drivers/system_stm32f4xx.c
47     drivers/timer.c
48     drivers/timer_impl_stdperiph.c
49     drivers/timer_stm32f4xx.c
50     drivers/uart_inverter.c
51     drivers/dma_stm32f4xx.c
52     drivers/sdcard/sdmmc_sdio_f4xx.c
55 set(STM32F4_VCP_SRC
56     stm32f4xx_it.c
57     usb_bsp.c
58     usbd_desc.c
59     usbd_usr.c
60     usbd_cdc_vcp.c
62 list(TRANSFORM STM32F4_VCP_SRC PREPEND "${STM32F4_VCP_DIR}/")
64 main_sources(STM32F4_MSC_SRC
65     drivers/usb_msc_f4xx.c
68 set(STM32F4_INCLUDE_DIRS
69     "${CMSIS_INCLUDE_DIR}"
70     "${CMSIS_DSP_INCLUDE_DIR}"
71     "${STM32F4_STDPERIPH_DIR}/inc"
72     "${STM32F4_CMSIS_DEVICE_DIR}"
73     "${STM32F4_CMSIS_DRIVERS_DIR}"
74     "${STM32F4_VCP_DIR}"
77 set(STM32F4_DEFINITIONS
78     ${CORTEX_M4F_DEFINITIONS}
79     STM32F4
80     USE_STDPERIPH_DRIVER
83 function(target_stm32f4xx)
84     target_stm32(
85         SOURCES ${STM32_STDPERIPH_SRC} ${STM32F4_SRC}
86         COMPILE_DEFINITIONS ${STM32F4_DEFINITIONS}
87         COMPILE_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_COMPILE_OPTIONS}
88         INCLUDE_DIRECTORIES ${STM32F4_INCLUDE_DIRS}
89         LINK_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_LINK_OPTIONS}
91         MSC_SOURCES ${STM32F4_USBMSC_SRC} ${STM32F4_MSC_SRC}
92         VCP_SOURCES ${STM32F4_USB_SRC} ${STM32F4_VCP_SRC}
93         VCP_INCLUDE_DIRECTORIES ${STM32F4_USB_INCLUDE_DIRS}
95         OPTIMIZATION -O2
97         OPENOCD_TARGET stm32f4x
99         ${ARGN}
100     )
101 endfunction()
103 set(STM32F405_COMPILE_DEFINITIONS
104     STM32F40_41xxx
105     STM32F405xx
106     MCU_FLASH_SIZE=1024
109 function(target_stm32f405xg name)
110     target_stm32f4xx(
111         NAME ${name}
112         STARTUP startup_stm32f40xx.s
113         SOURCES ${STM32F4_STDPERIPH_SRC}
114         COMPILE_DEFINITIONS ${STM32F405_COMPILE_DEFINITIONS}
115         LINKER_SCRIPT stm32_flash_f405xg
116         SVD STM32F405
117         BOOTLOADER
118         ${ARGN}
119     )
120 endfunction()
122 set(STM32F411_OR_F427_STDPERIPH_SRC ${STM32F4_STDPERIPH_SRC})
123 set(STM32F411_OR_F427_STDPERIPH_SRC_EXCLUDES "stm32f4xx_fsmc.c")
124 exclude_basenames(STM32F411_OR_F427_STDPERIPH_SRC ${STM32F411_OR_F427_STDPERIPH_SRC_EXCLUDES})
126 set(STM32F411_COMPILE_DEFINITIONS
127     STM32F411xE
128     MCU_FLASH_SIZE=512
129     OPTIMIZATION -Os
132 function(target_stm32f411xe name)
133     target_stm32f4xx(
134         NAME ${name}
135         STARTUP startup_stm32f411xe.s
136         SOURCES ${STM32F411_OR_F427_STDPERIPH_SRC}
137         COMPILE_DEFINITIONS ${STM32F411_COMPILE_DEFINITIONS}
138         LINKER_SCRIPT stm32_flash_f411xe
139         SVD STM32F411
140         ${ARGN}
141     )
142 endfunction()
144 set(STM32F427_COMPILE_DEFINITIONS
145     STM32F427_437xx
146     MCU_FLASH_SIZE=1024
148 function(target_stm32f427xg name)
149     target_stm32f4xx(
150         NAME ${name}
151         STARTUP startup_stm32f427xx.s
152         SOURCES ${STM32F411_OR_F427_STDPERIPH_SRC}
153         COMPILE_DEFINITIONS ${STM32F427_COMPILE_DEFINITIONS}
154         LINKER_SCRIPT stm32_flash_f427xg
155         SVD STM32F411
156         ${ARGN}
157     )
158 endfunction()