u32 bsp_get_time(void){
const u8 Month_Table[12][3]= {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
u8 i;
u8 *_date;
u8 *_time;
u8 mon,day;
u8 hour,minute;
u16 year;
_date = __DATE__;
_time = __TIME__;
hour = (_time[0] - '0') * 10 + (_time[1] - '0');
if(_time[2] == ':'){
minute = (_time[3] - '0') * 10 + (_time[4] - '0');
}
for(i=0; i<12; i++){
if((Month_Table
[0] == _date[0]) && (Month_Table[1] == _date[1]) && (Month_Table[2] == _date[2]))
mon = i+1;
}
if(_date[4]==' '){
day=_date[5]-'0';
}
else{
day=10*(_date[4]-'0')+_date[5]-'0';
}
year=10*(_date[9]-'0')+_date[10]-'0';
return (year*100000000 + mon*1000000 + day*10000 + hour * 100 + minute);
}
调用该函数,直接返回以当前日期组合而成的整数值,举个栗子:
1908191500,即2019年8月19日15点0分
将函数 u32 bsp_get_time(void) 所在的c文件设置为总是编译
u32 bsp_get_time(void){
const u8 Month_Table[12][3]= {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
u8 i;
u8 *_date;
u8 *_time;
u8 mon,day;
u8 hour,minute;
u16 year;
_date = __DATE__;
_time = __TIME__;
hour = (_time[0] - '0') * 10 + (_time[1] - '0');
if(_time[2] == ':'){
minute = (_time[3] - '0') * 10 + (_time[4] - '0');
}
for(i=0; i<12; i++){
if((Month_Table
[0] == _date[0]) && (Month_Table[1] == _date[1]) && (Month_Table[2] == _date[2]))
mon = i+1;
}
if(_date[4]==' '){
day=_date[5]-'0';
}
else{
day=10*(_date[4]-'0')+_date[5]-'0';
}
year=10*(_date[9]-'0')+_date[10]-'0';
return (year*100000000 + mon*1000000 + day*10000 + hour * 100 + minute);
}
调用该函数,直接返回以当前日期组合而成的整数值,举个栗子:
1908191500,即2019年8月19日15点0分
将函数 u32 bsp_get_time(void) 所在的c文件设置为总是编译
举报