FLYWOOF411_V2 based on target files from vendor (#6495)
[inav.git] / cmake / stm32f3.cmake
blob2d0ef507044ae4662db7cb44f2dbb49d666d2805
1 include(cortex-m4f)
2 include(stm32-stdperiph)
3 include(stm32f3-usb)
5 set(STM32F3_STDPERIPH_DIR "${MAIN_LIB_DIR}/main/STM32F3/Drivers/STM32F30x_StdPeriph_Driver")
6 set(STM32F3_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/STM32F3/Drivers/CMSIS/Device/ST/STM32F30x")
7 set(STM32F3_CMSIS_DRIVERS_DIR "${MAIN_LIB_DIR}/main/STM32F3/Drivers/CMSIS")
8 set(STM32F3_VCP_DIR "${MAIN_SRC_DIR}/vcp")
10 set(STM32F3_STDPERIPH_SRC_EXCLUDES
11     stm32f30x_crc.c
12     stm32f30x_can.c
14 set(STM32F3_STDPERIPH_SRC_DIR "${STM32F3_STDPERIPH_DIR}/src")
15 glob_except(STM32F3_STDPERIPH_SRC "${STM32F3_STDPERIPH_SRC_DIR}/*.c" "${STM32F3_STDPERIPH_SRC_EXCLUDES}")
18 main_sources(STM32F3_SRC
19     target/system_stm32f30x.c
21     config/config_streamer_stm32f3.c
23     drivers/adc_stm32f30x.c
24     drivers/bus_i2c_stm32f30x.c
25     drivers/dma_stm32f3xx.c
26     drivers/serial_uart_stm32f30x.c
27     drivers/system_stm32f30x.c
28     drivers/timer_impl_stdperiph.c
29     drivers/timer_stm32f30x.c
32 set(STM32F3_VCP_SRC
33     hw_config.c
34     stm32_it.c
35     usb_desc.c
36     usb_endp.c
37     usb_istr.c
38     usb_prop.c
39     usb_pwr.c
41 list(TRANSFORM STM32F3_VCP_SRC PREPEND "${STM32F3_VCP_DIR}/")
43 set(STM32F3_INCLUDE_DIRS
44     "${CMSIS_INCLUDE_DIR}"
45     "${CMSIS_DSP_INCLUDE_DIR}"
46     "${STM32F3_STDPERIPH_DIR}/inc"
47     "${STM32F3_CMSIS_DEVICE_DIR}"
48     "${STM32F3_CMSIS_DRIVERS_DIR}"
49     "${STM32F3_VCP_DIR}"
52 set(STM32F3_DEFINITIONS
53     ${CORTEX_M4F_DEFINITIONS}
54     STM32F3
55     USE_STDPERIPH_DRIVER
58 set(STM32F303CC_DEFINITIONS
59     STM32F303
60     STM32F303xC
61     MCU_FLASH_SIZE=256
64 function(target_stm32f3xx)
65     # F3 targets don't support MSC and use -Os instead of -O2 to save size
66     target_stm32(
67         SOURCES ${STM32_STDPERIPH_SRC} ${STM32F3_STDPERIPH_SRC} ${STM32F3_SRC}
68         COMPILE_DEFINITIONS ${STM32F3_DEFINITIONS}
69         COMPILE_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_COMPILE_OPTIONS}
70         INCLUDE_DIRECTORIES ${STM32F3_INCLUDE_DIRS}
71         LINK_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_LINK_OPTIONS}
73         VCP_SOURCES ${STM32F3_USB_SRC} ${STM32F3_VCP_SRC}
74         VCP_INCLUDE_DIRECTORIES ${STM32F3_USB_INCLUDE_DIRS}
76         DISABLE_MSC
78         OPTIMIZATION -Os
80         OPENOCD_TARGET stm32f3x
82         ${ARGN}
83     )
84 endfunction()
86 function(target_stm32f303xc name)
87     target_stm32f3xx(
88         NAME ${name}
89         STARTUP startup_stm32f30x_md_gcc.S
90         COMPILE_DEFINITIONS ${STM32F303CC_DEFINITIONS}
91         LINKER_SCRIPT stm32_flash_f303xc
92         SVD STM32F303
93         ${ARGN}
94     )
95 endfunction()