optical/EMBOS/Users/Config/config.c
2025-09-04 09:45:08 +08:00

106 lines
2.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#define _IN_CONFIG_C
#include "config.h"
static const char VERSION_INFO[VERSION_LEN] =
{
#if (CUR_UPFL == GAUF_PMB1)
'P','0','-','0','1',
#elif (CUR_UPFL == GAUF_EMB1)
'E','0','-','0','1',
#else
'0','0','0','0','0',
#endif
'-',
VER_TYPE,
'-',
VER_PROD,
' ',
'V',
VER_CODE_M,
'.',
VER_CODE_S,
'.',
VER_CODE_D,
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
void GetCompileDateTime(char * datetime)
{
u8 i;
int month, year, day;
int hour, min, second;
const char *pMonth[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
const char Date[12] = __DATE__; // 取编译日期
const char time[12] = __TIME__; // 取编译时间
month = 1;
for (i = 0; i < 12; i++)
{
if (memcmp(Date, pMonth[i], 3) == 0)
{
month = i + 1;
break;
}
}
year = (uint8_t)atoi(Date + 9); // Date[9]为位年份Date[7]为完整年份
day = (uint8_t)atoi(Date + 4);
hour = (uint8_t)atoi(time + 0);
min = (uint8_t)atoi(time + 3);
second = (uint8_t)atoi(time + 6);
if (datetime != NULL)
{
sprintf(datetime, "%02d%02d%02d%02d%02d%02d", year, month, day, hour, min, second);
}
}
void GetVersionStr(char * str)
{
if (str != NULL)
{
memcpy(str, VERSION_INFO, VERSION_LEN);
str[VERSION_LEN-1] = 0;
if (str[0] == 0xff)
{
str[0] = 0;
}
else
{
if (
str[VERSION_LEN-12] == 0xff &&
str[VERSION_LEN-11] == 0xff &&
str[VERSION_LEN-10] == 0xff &&
str[VERSION_LEN-9] == 0xff &&
str[VERSION_LEN-8] == 0xff &&
str[VERSION_LEN-7] == 0xff &&
str[VERSION_LEN-6] == 0xff &&
str[VERSION_LEN-5] == 0xff &&
str[VERSION_LEN-4] == 0xff &&
str[VERSION_LEN-3] == 0xff &&
str[VERSION_LEN-2] == 0xff &&
// str[VERSION_LEN-1] == 0xff &&
1 ) // 新写入的程序
{
u32 wrAddr;
char * vbuf = &(str[VERSION_LEN-12]);
GetCompileDateTime(vbuf);
wrAddr = (u32)VERSION_INFO;
wrAddr += VERSION_LEN-23;
// STMFlashWrite(wrAddr, (u16*)vbuf, 12/2, 3); // 写入flash中
}
}
}
}
void GetBuildStr(char * str)
{
sprintf(str, "Build: %s %s\r\n", __DATE__, __TIME__);
}