-
Notifications
You must be signed in to change notification settings - Fork 0
Develop/nn #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Develop/nn #1
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4259f88
添加 STM32F407VGT6 作为测试
00lllooolll00 b4bef98
添加 F407VGT6测试
00lllooolll00 3ff1079
[fix]将编译脚本设置为可执行
0c0b2e6
[update]新增一层 层,用于存放一些资源文件
00lllooolll00 9455052
[update]新增一层 层,用于存放一些资源文件
00lllooolll00 1d9dea9
[update]添加文件占位符
00lllooolll00 cce4ba1
[fix]修复了 `ek_main` 无法被强定义使用的问题
00lllooolll00 e270778
[fix]修复了 `ek_main` 无法被强定义使用的问题
00lllooolll00 662af6a
[update]更新各个层级的readme
00lllooolll00 4737a8f
[change]减少构建系统中的注释
00lllooolll00 9a4c89c
[update]说明如何编写单独MCU的CMakeLists
00lllooolll00 1090d0a
[fix]修复CMake报错
00lllooolll00 9f2410f
[fix]修复 workflow 报错
00lllooolll00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| file(GLOB_RECURSE L0_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/*.c") | ||
|
|
||
| add_library(l0_assets STATIC ${L0_SRCS}) | ||
|
|
||
| target_link_libraries(l0_assets PUBLIC | ||
| global_macros | ||
| global_options | ||
| ) | ||
|
|
||
| target_include_directories(l0_assets PUBLIC inc) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # L0_Assets (资源文件层) | ||
|
|
||
| ## 1. 简介 | ||
| L0_Assets 是本项目的资源文件层,用于存放与固件一起打包的资源数据。 | ||
|
|
||
| 向上:为各层提供资源数据访问接口。 | ||
|
|
||
| 本层主要用于存储不需要编译的静态资源,如: | ||
| - 图标、图片数据 | ||
| - 字体文件 | ||
| - 配置数据 | ||
| - 其他二进制资源 | ||
|
|
||
| ## 2. 目录结构 | ||
| ```text | ||
| L0_Assets | ||
| ├── CMakeLists.txt # 构建脚本 | ||
| ├── inc/ # 头文件目录(资源声明) | ||
| │ └── assets.h | ||
| └── src/ # 源文件目录(资源定义) | ||
| └── assets.c | ||
| ``` | ||
|
|
||
| ## 3. 核心开发原则 | ||
|
|
||
| **静态资源管理**: | ||
|
|
||
| 本层主要存放编译到固件中的静态资源数据。 | ||
|
|
||
| 资源以 C 数组或 const 数据的形式提供,直接链接到最终固件。 | ||
|
|
||
| **无依赖设计**: | ||
|
|
||
| 本层不依赖任何其他层级(L1~L5),仅依赖 `global_macros` 和 `global_options`。 | ||
|
|
||
| 保持最底层的独立性,确保资源数据可被任何层访问。 | ||
|
|
||
| ## 4. 使用示例 | ||
|
|
||
| ### 添加图片资源 | ||
|
|
||
| ```c | ||
| // inc/logo.h | ||
| #ifndef LOGO_H | ||
| #define LOGO_H | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| // Logo 图片数据 (RGB565 格式) | ||
| extern const uint16_t logo_data[]; | ||
| extern const uint32_t logo_width; | ||
| extern const uint32_t logo_height; | ||
|
|
||
| #endif | ||
| ``` | ||
|
|
||
| ```c | ||
| // src/logo.c | ||
| #include "logo.h" | ||
|
|
||
| const uint16_t logo_data[] = { | ||
| 0xFFFF, 0xFFFF, 0x0000, // ... | ||
| }; | ||
|
|
||
| const uint32_t logo_width = 64; | ||
| const uint32_t logo_height = 64; | ||
| ``` | ||
|
|
||
| ### 在上层使用资源 | ||
|
|
||
| ```c | ||
| // L5_App 或 L4 组件中使用 | ||
| #include "assets.h" | ||
|
|
||
| void display_logo(void) | ||
| { | ||
| // 使用资源数据 | ||
| lcd_draw_bitmap(0, 0, logo_width, logo_height, logo_data); | ||
| } | ||
| ``` | ||
|
|
||
| ## 5. 常见问题 | ||
|
|
||
| **Q: 为什么需要单独的资源层?** | ||
|
|
||
| A: 将资源数据集中管理,便于维护和复用。同时,资源数据可以作为独立模块被任何层访问,符合分层架构的设计理念。 | ||
|
|
||
| **Q: 资源文件如何影响固件大小?** | ||
|
|
||
| A: 所有资源数据都会被链接到最终固件中,增加 FLASH 占用。建议使用压缩格式或优化资源大小。 | ||
|
|
||
| **Q: 能否支持外部资源文件?** | ||
|
|
||
| A: 本层仅支持编译时嵌入的静态资源。如需运行时加载外部文件(如 SD 卡),应在 L4_Components 中实现文件系统驱动。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // 这个文件夹放置一些资源文件 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,14 @@ | ||
| add_library(l1_mcu STATIC) | ||
|
|
||
| target_link_libraries(l1_mcu PUBLIC | ||
| global_macros | ||
| global_options | ||
| ) | ||
|
|
||
| target_link_libraries(l1_mcu PUBLIC l0_assets global_macros global_options) | ||
| target_include_directories(l1_mcu PUBLIC inc) | ||
|
|
||
| # 设置默认 MCU 型号,允许命令行 -DMCU_MODEL=xxx 覆盖 | ||
| # 选择 MCU 型号 | ||
| set(MCU_MODEL "STM32F429ZIT6_GCC" CACHE STRING "Select MCU Model") | ||
|
|
||
| message(STATUS "L1 Configuration: Integrating ${MCU_MODEL} into l1_mcu") | ||
|
|
||
| if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${MCU_MODEL}") | ||
| message(FATAL_ERROR "MCU directory not found: ${CMAKE_CURRENT_SOURCE_DIR}/${MCU_MODEL}") | ||
| endif() | ||
|
|
||
| # 添加 stub 源文件(提供 ek_main 的弱定义) | ||
| target_sources(l1_mcu PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/stub/ek_app_stub.c | ||
| ) | ||
|
|
||
| # 进入子目录。注意:此时 l1_mcu 目标已经存在,子目录可以向其添加文件 | ||
| add_subdirectory(${MCU_MODEL}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| [PreviousLibFiles] | ||
| LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dmamux.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dmamux.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/pmu_armv8.h;Drivers/CMSIS/Include/cachel1_armv7.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm55.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_starmc1.h;Drivers/CMSIS/Include/core_cm85.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/pac_armv81.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_armv81mml.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm0plus.h; | ||
|
|
||
| [PreviousUsedCMakes] | ||
| SourceFiles=Core/Src/main.c;Core/Src/gpio.c;Core/Src/usart.c;Core/Src/stm32f4xx_it.c;Core/Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Core/Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Core/Src/system_stm32f4xx.c;;; | ||
| HeaderPath=Drivers/STM32F4xx_HAL_Driver/Inc;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;Drivers/CMSIS/Device/ST/STM32F4xx/Include;Drivers/CMSIS/Include;Middlewares/ST/ARM/DSP/Inc;Core/Inc; | ||
| CDefines=USE_HAL_DRIVER;STM32F407xx;USE_HAL_DRIVER;USE_HAL_DRIVER; | ||
|
|
||
| [PreviousGenFiles] | ||
| AdvancedFolderStructure=true | ||
| HeaderFileListSize=5 | ||
| HeaderFiles#0=../Core/Inc/gpio.h | ||
| HeaderFiles#1=../Core/Inc/usart.h | ||
| HeaderFiles#2=../Core/Inc/stm32f4xx_it.h | ||
| HeaderFiles#3=../Core/Inc/stm32f4xx_hal_conf.h | ||
| HeaderFiles#4=../Core/Inc/main.h | ||
| HeaderFolderListSize=1 | ||
| HeaderPath#0=../Core/Inc | ||
| HeaderFiles=; | ||
| SourceFileListSize=5 | ||
| SourceFiles#0=../Core/Src/gpio.c | ||
| SourceFiles#1=../Core/Src/usart.c | ||
| SourceFiles#2=../Core/Src/stm32f4xx_it.c | ||
| SourceFiles#3=../Core/Src/stm32f4xx_hal_msp.c | ||
| SourceFiles#4=../Core/Src/main.c | ||
| SourceFolderListSize=1 | ||
| SourcePath#0=../Core/Src | ||
| SourceFiles=; | ||
|
|
||
| [ThirdPartyIp] | ||
| ThirdPartyIpNumber=1 | ||
| ThirdPartyIpName#0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0 | ||
|
|
||
| [ThirdPartyIp#STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0] | ||
| library=../Middlewares/ST/ARM/DSP/Lib/libarm_cortexM4lf_math.a; | ||
| header=../Middlewares/ST/ARM/DSP/Inc/arm_math.h; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # STM32 头文件路径 | ||
| set(MX_Include_Dirs | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Include | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Include | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/ARM/DSP/Inc | ||
| ) | ||
|
|
||
| # 收集源文件 | ||
| file(GLOB MX_Start_S ${CMAKE_CURRENT_SOURCE_DIR}/*.s) | ||
| aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Core/Src MX_Core_Src) | ||
| aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32F4xx_HAL_Driver/Src MX_Driver_Src) | ||
|
|
||
| # 创建 cubemx_hal OBJECT 库(不生成独立静态库,对象将被添加到 l1_mcu) | ||
| add_library(cubemx_hal OBJECT ${MX_Start_S} ${MX_Core_Src} ${MX_Driver_Src}) | ||
|
|
||
| # ARM DSP 数学库 - 作为源文件添加 | ||
| target_sources(cubemx_hal PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/ARM/DSP/Lib/libarm_cortexM4lf_math.a | ||
| ) | ||
|
|
||
| # 头文件路径 - PUBLIC(传递给使用者) | ||
| target_include_directories(cubemx_hal PUBLIC | ||
| ${MX_Include_Dirs} | ||
| ) | ||
|
|
||
| # STM32 宏定义 - PUBLIC(传递给使用者) | ||
| target_compile_definitions(cubemx_hal PUBLIC | ||
| USE_HAL_DRIVER | ||
| STM32F407xx | ||
| $<$<CONFIG:Debug>:DEBUG> | ||
| ) | ||
|
|
||
| # 链接全局配置 | ||
| target_link_libraries(cubemx_hal PUBLIC | ||
| global_macros | ||
| global_options | ||
| ) | ||
|
|
||
| # 将 cubemx_hal 的对象文件添加到 l1_mcu(整合到 l1_mcu 静态库中) | ||
| # 这样上层只需要链接 l1_mcu,不需要知道 cubemx_hal 的存在 | ||
| target_sources(l1_mcu PRIVATE | ||
| $<TARGET_OBJECTS:cubemx_hal> | ||
| ) | ||
|
|
||
| # 将 cubemx_hal 的头文件和宏定义传递给 l1_mcu 的使用者 | ||
| target_include_directories(l1_mcu PUBLIC | ||
| $<TARGET_PROPERTY:cubemx_hal,INTERFACE_INCLUDE_DIRECTORIES> | ||
| ) | ||
|
|
||
| target_compile_definitions(l1_mcu PUBLIC | ||
| $<TARGET_PROPERTY:cubemx_hal,INTERFACE_COMPILE_DEFINITIONS> | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment explaining why the --undefined flag is necessary for ek_main, as this is a non-standard linking requirement that forces symbol resolution across layers.