119 lines
2.5 KiB
C
119 lines
2.5 KiB
C
|
|
//-------------------------------------------------------------------------------
|
|||
|
|
// File Name: config.C
|
|||
|
|
// Brief:
|
|||
|
|
// Version: 1.1.0
|
|||
|
|
// Create Date: 2021/07/20
|
|||
|
|
// Create by: Marshal Lee
|
|||
|
|
// Copyright:
|
|||
|
|
// Copyright (c) 2021, Richpeace Co., LTD.
|
|||
|
|
// All rights reserved.
|
|||
|
|
//
|
|||
|
|
// Modify by: Marshal Lee
|
|||
|
|
// Modify Date: 2021/07/20
|
|||
|
|
//-------------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
|
|||
|
|
#define _IN_CONFIG_C
|
|||
|
|
|
|||
|
|
#include "config.h"
|
|||
|
|
|
|||
|
|
static const char VERSION_INFO[VERSION_LEN] =
|
|||
|
|
{
|
|||
|
|
VER_TYPE,
|
|||
|
|
'-',
|
|||
|
|
VER_PROD,
|
|||
|
|
' ',
|
|||
|
|
#if (CUR_VERSION == VERSION_DEBUG) // <20><><EFBFBD>汾
|
|||
|
|
'D',
|
|||
|
|
#elif (CUR_VERSION == VERSION_RELEASE) // <20><><EFBFBD><EFBFBD><EFBFBD>汾
|
|||
|
|
'R',
|
|||
|
|
#else
|
|||
|
|
'V',
|
|||
|
|
#endif
|
|||
|
|
VER_CODE_M,
|
|||
|
|
'.',
|
|||
|
|
VER_CODE_S,
|
|||
|
|
'.',
|
|||
|
|
VER_CODE_D,
|
|||
|
|
0xff, 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__; // ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
const char time[12] = __TIME__; // ȡ<><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
|
|||
|
|
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]Ϊ<><CEAA>λ<EFBFBD><CEBB><EFBFBD>ݣ<EFBFBD>Date[7]Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
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 ) // <20><>д<EFBFBD><D0B4><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
|||
|
|
{
|
|||
|
|
u32 wrAddr;
|
|||
|
|
char * vbuf = &(str[VERSION_LEN-12]);
|
|||
|
|
GetCompileDateTime(vbuf);
|
|||
|
|
wrAddr = (u32)VERSION_INFO;
|
|||
|
|
wrAddr += VERSION_LEN-12;
|
|||
|
|
|
|||
|
|
// STMFlashWrite(wrAddr, (u16*)vbuf, 12/2, 3); // д<><D0B4>flash<73><68>
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void GetBuildStr(char * str)
|
|||
|
|
{
|
|||
|
|
sprintf(str, "Build: %s %s\r\n", __DATE__, __TIME__);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|