SMT32打印固件版本信息
文章目录
SMT32打印固件版本信息源码举例手动添加头文件absacc.h(选)测试结果总结宏定义__attribute__分析
源码
#define VERINFO_ADDR_BASE (0x8009F00)
const char Hardware_Ver
[] __attribute__((at(VERINFO_ADDR_BASE
+ 0x00))) = "Hardware: 1.0.0";
const char Firmware_Ver
[] __attribute__((at(VERINFO_ADDR_BASE
+ 0x20))) = "Firmware: 1.0.0";
const char Compiler_Date
[] __attribute__((at(VERINFO_ADDR_BASE
+ 0x40))) = "Date: "__DATE__;
const char Compiler_Time
[] __attribute__((at(VERINFO_ADDR_BASE
+ 0x60))) = "Time: "__TIME__;
举例
法一
printf("Hardware_Ver=%s\r\nFirmware_Ver=%s\r\nCompiler_Date=%s\r\n Compiler_Time=%s\r\n",Hardware_Ver
,Firmware_Ver
,Compiler_Date
,Compiler_Time
);
法二
unsigned char Verision_info
[40];
sprintf(Verision_info
,"Hardware_Ver=%s\r\nFirmware_Ver=%s\r\nCompiler_Date=%s\r\nCompiler_Time=%s\r\n",Hardware_Ver
,Firmware_Ver
,Compiler_Date
,Compiler_Time
);
printf(Verision_info
);
LCD_ShowString( ....参数
... , Verision_info
);
手动添加头文件absacc.h(选)
#ifndef __at
#define __at(_addr) __attribute__ ((at(_addr)))
#endif
#ifndef __section
#define __section(_name) __attribute__ ((section(_name)))
#endif
测试结果
debug页面
实物调试
总结
宏定义
__FILE__**:记录文件的路径加名称
__LINE__:记录文件已经被编译的行数
__DATE__:记录文件的编译日期
__TIME__:记录文件的编译时间
__attribute__分析
STM32学习笔记之__attribute__ ((at())绝对定位分析_一颗偏执的心-博客