first commit

This commit is contained in:
SkyLi
2026-05-18 19:58:03 +08:00
commit c33c019924
96 changed files with 52560 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_CXX_COMPILER_FORCED TRUE)
set(CMAKE_C_COMPILER_ID GNU)
set(CMAKE_CXX_COMPILER_ID GNU)
# Some default GCC settings
# arm-none-eabi- must be part of path environment
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# MCU specific flags
set(TARGET_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -fdata-sections -ffunction-sections")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g3")
endif()
if(CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -g0")
endif()
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -MMD -MP")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -fno-threadsafe-statics")
set(CMAKE_C_LINK_FLAGS "${TARGET_FLAGS}")
#LINKER_SCRIPT
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -T \"${CMAKE_SOURCE_DIR}/STM32F103C8TX_FLASH.ld\"")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --specs=nano.specs")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group -lc -lm -Wl,--end-group")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--print-memory-usage")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group -lstdc++ -lsupc++ -Wl,--end-group")
+66
View File
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.22)
project(stm32base)
add_library(stm32base INTERFACE)
# Enable CMake support for ASM and C languages
enable_language(C ASM)
target_compile_definitions(stm32base INTERFACE
STM32F10X_HD
$<$<CONFIG:Debug>:DEBUG>
)
target_include_directories(stm32base INTERFACE
../../Libraries/CMSIS/CM3/CoreSupport
../../Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x
../../Libraries/STM32F10x_StdPeriph_Driver/inc
../../USER/inc
)
target_sources(stm32base INTERFACE
../../USER/src/sys.c
../../USER/src/main.c
../../USER/src/stm32f10x_it.c
../../USER/src/system_stm32f10x.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/misc.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_adc.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_can.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_cec.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_crc.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dac.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_pwr.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_spi.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c
../../Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c
../../Libraries/CMSIS/CM3/CoreSupport/core_cm3.c
../../Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_md.s
)
target_link_directories(stm32base INTERFACE
)
target_link_libraries(stm32base INTERFACE
)
# Validate that stm32base code is compatible with C standard
if(CMAKE_C_STANDARD LESS 11)
message(ERROR "Generated code requires C11 or higher")
endif()