diff --git a/.gitignore b/.gitignore index e5b66fc..3fd083c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,11 @@ Output/ **/MDK-ARM/Build_Output.txt **/MDK-ARM/JLinkLog.txt +# Keil RTE 自动生成头(勿改;打开工程会再生成) +**/MDK-ARM/RTE/ + +# 注意:*.uvprojx 必须入库,不能 ignore(Keil 工程文件) + # DebugConfig/*.dbgconf 建议保留入库(芯片调试配置,团队可共享) # ── 中间文件扩展名(散落于工程目录时兜底)────────────────────────────────── diff --git a/App/Inc/application.h b/App/Inc/application.h index 6e3ef9d..1cbbbe2 100644 --- a/App/Inc/application.h +++ b/App/Inc/application.h @@ -3,12 +3,10 @@ #include "main.h" - - -// DEMO是项目编号,1.0.0是软件大版本,009是软件小版本 -#define __VERSION__ "DEMO_1.0.0" -#define __DEVELOPER__ "WuChuYuan" -#define __EMAIL__ "1917507415@qq.com" +/* 项目代号(固件文件名用);软件版本见 jb_product.h 的 JB_MCU_SW_VERSION_* */ +#define __PROJECT_CODE__ "DEMO" +#define __DEVELOPER__ "WuChuYuan" +#define __EMAIL__ "1917507415@qq.com" typedef enum { diff --git a/App/OutputHex.bat b/App/OutputHex.bat index 898a604..506391d 100644 --- a/App/OutputHex.bat +++ b/App/OutputHex.bat @@ -16,11 +16,10 @@ set HEX_PATH=%cd%\MDK-ARM\Objects @REM Custom output directory set OUTPUT_PATH=%cd%\Output -@REM Software version header -set VERSION_FILE_PATH=%cd%\Inc\application.h - -@REM Software version string format -set SOFTWARE_VERSION="#define __VERSION__" +@REM Project code: application.h __PROJECT_CODE__ +@REM Soft version: jb_product.h JB_MCU_SW_VERSION_* (single source of truth) +set APP_H=%cd%\Inc\application.h +set PRODUCT_H=%cd%\Protocol\jb_product.h @REM Optional arg1: Keil root ($K) passed by AfterMake set "KEIL_ROOT=%~1" @@ -31,14 +30,23 @@ set "KEIL_ROOT=%~1" for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyMMdd_HHmmss"') do set CURRENT_DATE=%%i @REM ------------------------------------------------------------ -@REM Read software version from application.h +@REM Compose name: PROJECT_MAJOR.MINOR.PATCH @REM ------------------------------------------------------------ -set SW_Ver=unknown -for /f "tokens=3 delims= " %%i in ('findstr /C:%SOFTWARE_VERSION% "%VERSION_FILE_PATH%"') do set SW_Ver=%%i -if defined SW_Ver set SW_Ver=%SW_Ver:"=% +set PROJECT_CODE=DEMO +set VER_MAJOR=0 +set VER_MINOR=0 +set VER_PATCH=0 -@REM Custom output file name +for /f "tokens=3 delims= " %%i in ('findstr /C:"#define __PROJECT_CODE__" "%APP_H%"') do set PROJECT_CODE=%%i +if defined PROJECT_CODE set PROJECT_CODE=%PROJECT_CODE:"=% + +for /f "tokens=3 delims= " %%i in ('findstr /C:"#define JB_MCU_SW_VERSION_MAJOR" "%PRODUCT_H%"') do set VER_MAJOR=%%i +for /f "tokens=3 delims= " %%i in ('findstr /C:"#define JB_MCU_SW_VERSION_MINOR" "%PRODUCT_H%"') do set VER_MINOR=%%i +for /f "tokens=3 delims= " %%i in ('findstr /C:"#define JB_MCU_SW_VERSION_PATCH" "%PRODUCT_H%"') do set VER_PATCH=%%i + +set SW_Ver=%PROJECT_CODE%_%VER_MAJOR%.%VER_MINOR%.%VER_PATCH% set output_file_name=%SW_Ver%_%CURRENT_DATE% +echo Firmware version: %SW_Ver% if not exist "%OUTPUT_PATH%" mkdir "%OUTPUT_PATH%" diff --git a/App/Protocol/jb_product.h b/App/Protocol/jb_product.h index 8d5d800..046f2a7 100644 --- a/App/Protocol/jb_product.h +++ b/App/Protocol/jb_product.h @@ -23,7 +23,7 @@ /* MCU software version: Vmajor.minor.patch */ #define JB_MCU_SW_VERSION_MAJOR 1 #define JB_MCU_SW_VERSION_MINOR 0 -#define JB_MCU_SW_VERSION_PATCH 0 +#define JB_MCU_SW_VERSION_PATCH 1 /* MCU hardware version: Vmajor.minor.patch */ #define JB_MCU_HW_VERSION_MAJOR 1 diff --git a/App/Src/application.c b/App/Src/application.c index 24022c7..b2b84f4 100644 --- a/App/Src/application.c +++ b/App/Src/application.c @@ -14,7 +14,15 @@ void version_printf(void) { appPrintf(LOG_NOTIC, "Developer:%s\r\n", __DEVELOPER__); appPrintf(LOG_NOTIC, "Email:%s\r\n", __EMAIL__); - appPrintf(LOG_NOTIC, "Version:%s\r\n", __VERSION__); + appPrintf(LOG_NOTIC, "Project:%s\r\n", __PROJECT_CODE__); + appPrintf(LOG_NOTIC, "SW Version:%u.%u.%u\r\n", + (unsigned)JB_MCU_SW_VERSION_MAJOR, + (unsigned)JB_MCU_SW_VERSION_MINOR, + (unsigned)JB_MCU_SW_VERSION_PATCH); + appPrintf(LOG_NOTIC, "HW Version:%u.%u.%u\r\n", + (unsigned)JB_MCU_HW_VERSION_MAJOR, + (unsigned)JB_MCU_HW_VERSION_MINOR, + (unsigned)JB_MCU_HW_VERSION_PATCH); appPrintf(LOG_NOTIC, "Compiler Date:%s\r\n", __DATE__); appPrintf(LOG_NOTIC, "Compiler Time:%s\r\n", __TIME__); } diff --git a/Bootloader/MDK-ARM/RTE/_Project/RTE_Components.h b/Bootloader/MDK-ARM/RTE/_Project/RTE_Components.h deleted file mode 100644 index 17fcce3..0000000 --- a/Bootloader/MDK-ARM/RTE/_Project/RTE_Components.h +++ /dev/null @@ -1,21 +0,0 @@ - -/* - * Auto generated Run-Time-Environment Configuration File - * *** Do not modify ! *** - * - * Project: 'Bootloader' - * Target: 'Project' - */ - -#ifndef RTE_COMPONENTS_H -#define RTE_COMPONENTS_H - - -/* - * Define the Device Header File: - */ -#define CMSIS_device_header "py32f0xx.h" - - - -#endif /* RTE_COMPONENTS_H */