fatfs 时间函数实现

 

时钟源由STM32的RTC来实现

 

 1 /**
 2 * @brief Gets Time from RTC 
 3 * @param None
 4 * @retval Time in DWORD
 5 */
 6 DWORD get_fattime(void)
 7 {
 8 /* USER CODE BEGIN get_fattime */
 9 uint32_t retValue = 0;
10 uint8_t year = 0,month = 0,day = 0,hour = 0,minuite = 0,second = 0;
11 year = 2000 + sdatestructureget.Year - 1980;
12 month = sdatestructureget.Month;
13 day = sdatestructureget.Date;
14 hour = stimestructureget.Hours;
15 minuite = stimestructureget.Minutes;
16 second = stimestructureget.Seconds/2;
17 retValue = (uint32_t)year<<25 | (uint32_t)month<<21 | (uint32_t)day<<16 | (uint32_t)hour<<11 | (uint32_t)minuite<<5 | second;
18 return retValue;
19 /* USER CODE END get_fattime */ 
20 }

 

posted @ 2016-04-08 15:35  杰克纬伯  阅读(2480)  评论(0编辑  收藏  举报