OSD RTC time seconds display option
[inav.git] / cmake / stm32f4.cmake
blob37fd1cdad5c78fbe0be54f4ff78cf0ac204ba22a
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
40     drivers/adc_stm32f4xx.c
41     drivers/adc_stm32f4xx.c
42     drivers/bus_i2c_stm32f40x.c
43     drivers/serial_uart_stm32f4xx.c
44     drivers/system_stm32f4xx.c
45     drivers/timer.c
46     drivers/timer_impl_stdperiph.c
47     drivers/timer_stm32f4xx.c
48     drivers/uart_inverter.c
49     drivers/dma_stm32f4xx.c
50     drivers/sdcard/sdmmc_sdio_f4xx.c
53 set(STM32F4_VCP_SRC
54     stm32f4xx_it.c
55     usb_bsp.c
56     usbd_desc.c
57     usbd_usr.c
58     usbd_cdc_vcp.c
60 list(TRANSFORM STM32F4_VCP_SRC PREPEND "${STM32F4_VCP_DIR}/")
62 main_sources(STM32F4_MSC_SRC
63     drivers/usb_msc_f4xx.c
66 set(STM32F4_INCLUDE_DIRS
67     "${CMSIS_INCLUDE_DIR}"
68     "${CMSIS_DSP_INCLUDE_DIR}"
69     "${STM32F4_STDPERIPH_DIR}/inc"
70     "${STM32F4_CMSIS_DEVICE_DIR}"
71     "${STM32F4_CMSIS_DRIVERS_DIR}"
72     "${STM32F4_VCP_DIR}"
75 set(STM32F4_DEFINITIONS
76     ${CORTEX_M4F_DEFINITIONS}
77     STM32F4
78     USE_STDPERIPH_DRIVER
81 function(target_stm32f4xx)
82     target_stm32(
83         SOURCES ${STM32_STDPERIPH_SRC} ${STM32F4_SRC}
84         COMPILE_DEFINITIONS ${STM32F4_DEFINITIONS}
85         COMPILE_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_COMPILE_OPTIONS}
86         INCLUDE_DIRECTORIES ${STM32F4_INCLUDE_DIRS}
87         LINK_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_LINK_OPTIONS}
89         MSC_SOURCES ${STM32F4_USBMSC_SRC} ${STM32F4_MSC_SRC}
90         VCP_SOURCES ${STM32F4_USB_SRC} ${STM32F4_VCP_SRC}
91         VCP_INCLUDE_DIRECTORIES ${STM32F4_USB_INCLUDE_DIRS}
93         OPTIMIZATION -O2
95         OPENOCD_TARGET stm32f4x
97         ${ARGN}
98     )
99 endfunction()
101 set(STM32F405_COMPILE_DEFINITIONS
102     STM32F40_41xxx
103     STM32F405xx
104     MCU_FLASH_SIZE=1024
107 function(target_stm32f405xg name)
108     target_stm32f4xx(
109         NAME ${name}
110         STARTUP startup_stm32f40xx.s
111         SOURCES ${STM32F4_STDPERIPH_SRC}
112         COMPILE_DEFINITIONS ${STM32F405_COMPILE_DEFINITIONS}
113         LINKER_SCRIPT stm32_flash_f405xg
114         SVD STM32F405
115         BOOTLOADER
116         ${ARGN}
117     )
118 endfunction()
120 set(STM32F411_OR_F427_STDPERIPH_SRC ${STM32F4_STDPERIPH_SRC})
121 set(STM32F411_OR_F427_STDPERIPH_SRC_EXCLUDES "stm32f4xx_fsmc.c")
122 exclude_basenames(STM32F411_OR_F427_STDPERIPH_SRC ${STM32F411_OR_F427_STDPERIPH_SRC_EXCLUDES})
124 set(STM32F411_COMPILE_DEFINITIONS
125     STM32F411xE
126     MCU_FLASH_SIZE=512
129 function(target_stm32f411xe name)
130     target_stm32f4xx(
131         NAME ${name}
132         STARTUP startup_stm32f411xe.s
133         SOURCES ${STM32F411_OR_F427_STDPERIPH_SRC}
134         COMPILE_DEFINITIONS ${STM32F411_COMPILE_DEFINITIONS}
135         LINKER_SCRIPT stm32_flash_f411xe
136         SVD STM32F411
137         ${ARGN}
138     )
139 endfunction()
141 set(STM32F427_COMPILE_DEFINITIONS
142     STM32F427_437xx
143     MCU_FLASH_SIZE=1024
145 function(target_stm32f427xg name)
146     target_stm32f4xx(
147         NAME ${name}
148         STARTUP startup_stm32f427xx.s
149         SOURCES ${STM32F411_OR_F427_STDPERIPH_SRC}
150         COMPILE_DEFINITIONS ${STM32F427_COMPILE_DEFINITIONS}
151         LINKER_SCRIPT stm32_flash_f427xg
152         SVD STM32F411
153         ${ARGN}
154     )
155 endfunction()