From 5221e2a8ca85ae82f712073d266fb8918851f51f Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Mon, 8 Jun 2026 11:03:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=B8=BB=E7=BA=BF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=A5=E6=94=AF=E6=8C=81=E5=8A=A8=E6=80=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E8=A3=81=E5=89=AA=E5=AE=8F=E5=A4=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakePresets.json | 12 ++++- Core/Inc/bsp_config.h | 65 --------------------------- robot/bspMCU/My_Lwip.c | 2 +- robot/bspMCU/My_freeRTOS.c | 2 +- robot/bspMCU/My_print.c | 4 +- robot/bspMCU/include/bsp_CAN.h | 2 +- robot/bspMCU/include/bsp_cap.h | 2 +- robot/bspMCU/include/bsp_i2c.h | 2 +- robot/bspMCU/include/bsp_uart.h | 2 +- robot/bspMCU/include/bsp_usb.h | 2 +- robot/bspMCU/include/drv_interface.h | 2 +- robot/bspMCU/include/stmflash.h | 2 +- robot/bspMCU/l_can.c | 4 +- robot/bspMCU/l_stm32.c | 2 +- robot/bspMCU/l_uart.c | 2 +- robot/library/common/CMakeLists.txt | 12 ++++- robot/library/common/common_cfg.h.in | 41 +++++++++++++++++ robot/library/common/include/common.h | 2 + 18 files changed, 80 insertions(+), 82 deletions(-) delete mode 100644 Core/Inc/bsp_config.h create mode 100644 robot/library/common/common_cfg.h.in diff --git a/CMakePresets.json b/CMakePresets.json index 35b450e..fca2b81 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -29,14 +29,22 @@ "BUILD_PERIPHERAL": "ON", "BUILD_LIST": "ON", "BUILD_BSPMCU": "ON", - "MY_MEMPOOL_SIZE": "46 * 1024" + "MY_MEMPOOL_SIZE": "46*1024", + "IOC_100PIN": true, + "USE_LUA_ST": true, + "USE_LUA_ST_CAN": true, + "USE_UART": true, + "USE_CAN": true, + "USE_FREERTOS": true } }, { "name": "robot", "inherits": "Spool-end", "cacheVariables": { - "BUILD_OPTIONAL": "ON" + "BUILD_OPTIONAL": "ON", + "USE_TALNET": true, + "USE_LWIP": true } } ] diff --git a/Core/Inc/bsp_config.h b/Core/Inc/bsp_config.h deleted file mode 100644 index 2edeecc..0000000 --- a/Core/Inc/bsp_config.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __BSP_CONFIG_H__ -#define __BSP_CONFIG_H__ - - -#ifdef __cplusplus -#if __cplusplus -extern "C"{ -#endif -#endif /* __cplusplus */ - -/* 打印串口配置 */ - -#define IOC_100PIN // 100引脚芯片 - - -#define USE_TALNET -/* 编译My_print.c */ -// #define USE_PRINT - -// #define PRINT_ID 1 // 串口打印映射的串口号,对应g_ptUartTab全局 - // 如果还需要getchar需要将Myprint_IRQHandler放置到对应的中断服务中 - // 如果注释掉该全局则表示使用usb的cdc来作为打印串口 - -// #define LUACOM_ID 2 //这里是Lua的COM模块初始化1或2使用的串口,确保不要和PRINT_ID一致即可 - -/* 编译l_stm32.c */ -#define USE_LUA_ST -/* 编译l_can.c */ -#define USE_LUA_ST_CAN -/* 编译l_uart.c */ -// #define USE_LUA_ST_UART - -/* 编译bsp_cap.c */ -// #define USE_TIMER - -/* 编译bsp_uart.c */ -#define USE_UART -/* 默认使用空闲中断DMA方式,注释掉后使用传统字节中断 */ -//#define CONFIG_UART_IT_IDLEDMA - -/* 编译bsp_usb.c */ -// #define USE_USB - -/* 编译bsp_i2c.c */ -// #define USE_I2C - -/* 编译stmflash.c */ -// #define USE_ONCHIP_FLASH - -#define USE_CAN - -#define CONFIG_CAN_BUFFER_SIZE 128 - -#define USE_FREERTOS - -#define USE_LWIP - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif /* __cplusplus */ - - -#endif /* __L_STM32_H__ */ diff --git a/robot/bspMCU/My_Lwip.c b/robot/bspMCU/My_Lwip.c index 8990451..d65b761 100644 --- a/robot/bspMCU/My_Lwip.c +++ b/robot/bspMCU/My_Lwip.c @@ -16,7 +16,7 @@ 修改内容 : 创建文件 ******************************************************************************/ -#include "bsp_config.h" +#include "common.h" #ifdef USE_LWIP #include "lwip/sockets.h" #include "lwip/netdb.h" diff --git a/robot/bspMCU/My_freeRTOS.c b/robot/bspMCU/My_freeRTOS.c index 5d3bea9..be94cf3 100644 --- a/robot/bspMCU/My_freeRTOS.c +++ b/robot/bspMCU/My_freeRTOS.c @@ -16,7 +16,7 @@ 修改内容 : 创建文件 ******************************************************************************/ -#include "bsp_config.h" +#include "common.h" #ifdef USE_FREERTOS #include "cmsis_os.h" #include "FreeRTOS.h" diff --git a/robot/bspMCU/My_print.c b/robot/bspMCU/My_print.c index dbda681..170442c 100644 --- a/robot/bspMCU/My_print.c +++ b/robot/bspMCU/My_print.c @@ -1,4 +1,4 @@ -#include "bsp_config.h" +#include "common.h" #ifdef USE_PRINT #include #include @@ -8,7 +8,7 @@ #include "main.h" #include "bsp_uart.h" #include "rd_time.h" -#include "bsp_config.h" +#include "common.h" #ifdef USE_FREERTOS #include "cmsis_os.h" #endif diff --git a/robot/bspMCU/include/bsp_CAN.h b/robot/bspMCU/include/bsp_CAN.h index bc3d39d..c76e60d 100644 --- a/robot/bspMCU/include/bsp_CAN.h +++ b/robot/bspMCU/include/bsp_CAN.h @@ -59,7 +59,7 @@ extern "C"{ /*==============================================* * include header files * *----------------------------------------------*/ -#include "bsp_config.h" +#include "common.h" #ifdef USE_CAN #include "main.h" #include "com.h" diff --git a/robot/bspMCU/include/bsp_cap.h b/robot/bspMCU/include/bsp_cap.h index fd2fad9..f098ac4 100644 --- a/robot/bspMCU/include/bsp_cap.h +++ b/robot/bspMCU/include/bsp_cap.h @@ -12,7 +12,7 @@ #ifndef __BSP_CAP_H #define __BSP_CAP_H -#include "bsp_config.h" +#include "common.h" #ifdef USE_TIMER #include "tim.h" #include "stdbool.h" diff --git a/robot/bspMCU/include/bsp_i2c.h b/robot/bspMCU/include/bsp_i2c.h index dd45fdd..dfaf996 100644 --- a/robot/bspMCU/include/bsp_i2c.h +++ b/robot/bspMCU/include/bsp_i2c.h @@ -2,7 +2,7 @@ #define BSP_I2C_H -#include "bsp_config.h" +#include "common.h" #ifdef USE_I2C #include "main.h" #include diff --git a/robot/bspMCU/include/bsp_uart.h b/robot/bspMCU/include/bsp_uart.h index df043f1..bd28bb9 100644 --- a/robot/bspMCU/include/bsp_uart.h +++ b/robot/bspMCU/include/bsp_uart.h @@ -2,7 +2,7 @@ #define BSP_UART_H -#include "bsp_config.h" +#include "common.h" #ifdef USE_UART #include "com.h" #include "usart.h" diff --git a/robot/bspMCU/include/bsp_usb.h b/robot/bspMCU/include/bsp_usb.h index f82640d..fa558eb 100644 --- a/robot/bspMCU/include/bsp_usb.h +++ b/robot/bspMCU/include/bsp_usb.h @@ -59,7 +59,7 @@ extern "C"{ /*==============================================* * include header files * *----------------------------------------------*/ -#include "bsp_config.h" +#include "common.h" #ifdef USE_USB #include "com.h" diff --git a/robot/bspMCU/include/drv_interface.h b/robot/bspMCU/include/drv_interface.h index 79f6157..1257857 100644 --- a/robot/bspMCU/include/drv_interface.h +++ b/robot/bspMCU/include/drv_interface.h @@ -59,7 +59,7 @@ extern "C"{ /*==============================================* * include header files * *----------------------------------------------*/ -#include "bsp_config.h" +#include "common.h" #include "main.h" #include "bsp_uart.h" #include "bsp_CAN.h" diff --git a/robot/bspMCU/include/stmflash.h b/robot/bspMCU/include/stmflash.h index 40f9965..0ce6726 100644 --- a/robot/bspMCU/include/stmflash.h +++ b/robot/bspMCU/include/stmflash.h @@ -59,7 +59,7 @@ extern "C"{ /*==============================================* * include header files * *----------------------------------------------*/ -#include "bsp_config.h" +#include "common.h" #ifdef USE_ONCHIP_FLASH #include #include "main.h" diff --git a/robot/bspMCU/l_can.c b/robot/bspMCU/l_can.c index bd464c5..89d251f 100644 --- a/robot/bspMCU/l_can.c +++ b/robot/bspMCU/l_can.c @@ -1,9 +1,11 @@ -#include "bsp_config.h" +#include "common.h" #ifdef USE_LUA_ST_CAN #include "lua_base.h" #include "fdcan.h" #include "bsp_can.h" +#define CONFIG_CAN_BUFFER_SIZE 128 + typedef struct { TComCtrl *m_ptComCtrl; diff --git a/robot/bspMCU/l_stm32.c b/robot/bspMCU/l_stm32.c index 563c1a6..575d418 100644 --- a/robot/bspMCU/l_stm32.c +++ b/robot/bspMCU/l_stm32.c @@ -1,4 +1,4 @@ -#include "bsp_config.h" +#include "common.h" #ifdef USE_LUA_ST #include #include "lua_base.h" diff --git a/robot/bspMCU/l_uart.c b/robot/bspMCU/l_uart.c index 92fa96b..6d16ada 100644 --- a/robot/bspMCU/l_uart.c +++ b/robot/bspMCU/l_uart.c @@ -1,4 +1,4 @@ -#include "bsp_config.h" +#include "common.h" #ifdef USE_LUA_ST_UART #include "lua_base.h" #include "bsp_uart.h" diff --git a/robot/library/common/CMakeLists.txt b/robot/library/common/CMakeLists.txt index 67589fd..6de5db6 100644 --- a/robot/library/common/CMakeLists.txt +++ b/robot/library/common/CMakeLists.txt @@ -6,4 +6,14 @@ if(EXISTS ${COMMON_CMAKE_PATH}) include(${COMMON_CMAKE_PATH}) else() message(FATAL_ERROR "Cannot find common build logic at ${COMMON_CMAKE_PATH}") -endif() \ No newline at end of file +endif() + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/common_cfg.h.in + ${CMAKE_CURRENT_BINARY_DIR}/common_cfg.h + @ONLY +) + +target_include_directories(common PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} +) \ No newline at end of file diff --git a/robot/library/common/common_cfg.h.in b/robot/library/common/common_cfg.h.in new file mode 100644 index 0000000..3528e4b --- /dev/null +++ b/robot/library/common/common_cfg.h.in @@ -0,0 +1,41 @@ +// TEMPLATE FILE: Copy this file and rename the extension to .h before use. +// DO NOT edit this file directly. +#ifndef __COMMON_CFG_H__ +#define __COMMON_CFG_H__ + + +#ifdef __cplusplus +#if __cplusplus +extern "C"{ +#endif +#endif /* __cplusplus */ + +#cmakedefine MEM_POOL_TOTAL_SIZE @MEM_POOL_TOTAL_SIZE@ + +#cmakedefine IOC_100PIN +#cmakedefine USE_TALNET +#cmakedefine USE_LUA_ST +#cmakedefine USE_UART +#cmakedefine CONFIG_UART_IT_IDLEDMA +#cmakedefine USE_LUA_ST_UART +#cmakedefine USE_PRINT +#cmakedefine USE_TIMER +#cmakedefine USE_USB +#cmakedefine USE_I2C +#cmakedefine USE_ONCHIP_FLASH +#cmakedefine USE_CAN +#cmakedefine USE_LUA_ST_CAN +#cmakedefine USE_FREERTOS +#cmakedefine USE_LWIP + +#cmakedefine LUACOM_ID @LUACOM_ID@ +#cmakedefine PRINT_ID @PRINT_ID@ + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* __cplusplus */ + + +#endif /* __L_STM32_H__ */ diff --git a/robot/library/common/include/common.h b/robot/library/common/include/common.h index 47a1d6e..205e5f3 100644 --- a/robot/library/common/include/common.h +++ b/robot/library/common/include/common.h @@ -2,6 +2,8 @@ #define COMMON_H +#include "common_cfg.h" + #define rd_inline static __inline #define RD_SUCCESS 0 //成功