我也分享下我的实现方法:
[mw_shl_code=c,true]//获得时间
//User defined function to give a current time to fatfs module */
//31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
//15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
DWORD get_fattime (void)
{
u32 time=0;
calendar_get_date(&calendar);
calendar_get_time(&calendar);
if(calendar.w_year<1980)calendar.w_year=1980;
time=(calendar.w_year-1980)<<25;//年份
time|=(calendar.w_month)<<21; //月份
time|=(calendar.w_date)<<16; //日期
time|=(calendar.hour)<<11; //时
time|=(calendar.min)<<5; //分
time|=(calendar.sec/2); //秒
return time;
} [/mw_shl_code]
|