Merge pull request #9300 from iNavFlight/dzikuvx-drop-output_mode
[inav.git] / cmake / at32f4.cmake
blob3fb407827bf770a8f74b98fe93a6834de7a00c77
1 include(cortex-m4f)
2 include(at32-stdperiph)
3 include(at32f4-usb)
5 set(AT32F4_STDPERIPH_DIR "${MAIN_LIB_DIR}/main/AT32F43x/Drivers/AT32F43x_StdPeriph_Driver")
6 set(AT32F4_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/AT32F43x/Drivers/CMSIS/Device/ST/AT32F43x")
7 set(AT32F4_CMSIS_DRIVERS_DIR "${MAIN_LIB_DIR}/main/AT32F43x/Drivers/CMSIS")
9   
10 set(AT32F4_STDPERIPH_SRC_EXCLUDES
11         at32f435_437_can.c
12         at32f435_437_dvp.c
13         at32f435_437_emac
14         at32f435_437_xmc.c
17 set(AT32F4_STDPERIPH_SRC_DIR "${AT32F4_STDPERIPH_DIR}/src")
18 glob_except(AT32F4_STDPERIPH_SRC "${AT32F4_STDPERIPH_SRC_DIR}/*.c" "${AT32F4_STDPERIPH_SRC_EXCLUDES}")
20 list(APPEND AT32F4_STDPERIPH_SRC "${AT32F4_CMSIS_DEVICE_DIR}/at32f435_437_clock.c" )
22 main_sources(AT32F4_SRC
23     target/system_at32f435_437.c
24     config/config_streamer_at32f43x.c
25     config/config_streamer_ram.c
26     config/config_streamer_extflash.c 
27     drivers/adc_at32f43x.c
28     drivers/i2c_application.c
29     drivers/bus_i2c_at32f43x.c
30     drivers/bus_spi_at32f43x
31     drivers/serial_uart_hal_at32f43x.c
32     drivers/serial_uart_at32f43x.c
34     drivers/system_at32f43x.c
35     drivers/timer.c
36     drivers/timer_impl_stdperiph_at32.c
37     drivers/timer_at32f43x.c
38     drivers/uart_inverter.c
39     drivers/dma_at32f43x.c
42 set(AT32F4_INCLUDE_DIRS
43     ${CMSIS_INCLUDE_DIR}
44     ${CMSIS_DSP_INCLUDE_DIR}
45     ${AT32F4_CMSIS_DRIVERS_DIR}
46     ${AT32F4_STDPERIPH_DIR}/inc
47     ${AT32F4_CMSIS_DEVICE_DIR}
48     #"${AT32F4_I2C_DIR}"
51 set(AT32F4_DEFINITIONS
52     ${CORTEX_M4F_DEFINITIONS}
53     AT32F43x
54     USE_STDPERIPH_DRIVER
57 function(target_at32f43x)
58     target_at32(
59         SOURCES ${AT32_STDPERIPH_SRC} ${AT32F4_SRC}
60         COMPILE_DEFINITIONS ${AT32F4_DEFINITIONS}
61         COMPILE_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_COMPILE_OPTIONS}
62         INCLUDE_DIRECTORIES ${AT32F4_INCLUDE_DIRS}
63         LINK_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_LINK_OPTIONS}
65         MSC_SOURCES ${AT32F4_USBMSC_SRC} ${AT32F4_MSC_SRC}
66         VCP_SOURCES ${AT32F4_USB_SRC} ${AT32F4_VCP_SRC}
67         VCP_INCLUDE_DIRECTORIES ${AT32F4_USB_INCLUDE_DIRS}
69         OPTIMIZATION -O2
71         OPENOCD_TARGET at32f437xx
73         ${ARGN}
74     )
75 endfunction()
77 #target_at32f43x_xMT7
78 #target_at32f43x_xGT7
80 set(at32f43x_xMT7_COMPILE_DEFINITIONS
81     AT32F437VMT7
82     MCU_FLASH_SIZE=4032
85 function(target_at32f43x_xMT7 name)
86     target_at32f43x(
87         NAME ${name}
88         STARTUP startup_at32f435_437.s
89         SOURCES ${AT32F4_STDPERIPH_SRC}
90         COMPILE_DEFINITIONS ${at32f43x_xMT7_COMPILE_DEFINITIONS}
91         LINKER_SCRIPT at32_flash_f43xM
92         #BOOTLOADER
93         SVD at32f43x_xMT7
94         ${ARGN}
95     )
96 endfunction()
98 set(at32f43x_xGT7_COMPILE_DEFINITIONS
99     AT32F435RGT7
100     MCU_FLASH_SIZE=1024
103 function(target_at32f43x_xGT7 name)
104     target_at32f43x(
105         NAME ${name}
106         STARTUP startup_at32f435_437.s
107         SOURCES ${AT32F4_STDPERIPH_SRC}
108         COMPILE_DEFINITIONS ${at32f43x_xGT7_COMPILE_DEFINITIONS}
109         LINKER_SCRIPT at32_flash_f43xG
110         #BOOTLOADER
111         SVD at32f43x_xGT7
112         ${ARGN}
113     )
114 endfunction()