1
0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-05 11:27:09 +00:00

fatfs: Use RTC clock for date/time

This commit is contained in:
CTCaer 2020-04-30 15:04:52 +03:00
parent b6933013be
commit 2a8c27115c

View File

@ -6,9 +6,11 @@
#include "ff.h"
#include "../../config/config.h"
#include "../../mem/heap.h"
#include "../../rtc/max77620-rtc.h"
extern nyx_config n_cfg;
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
@ -37,3 +39,27 @@ void ff_memfree (
#endif
#if FF_FS_NORTC == 0
/*------------------------------------------------------------------------*/
/* Get real time clock */
/*------------------------------------------------------------------------*/
DWORD get_fattime (
void
)
{
rtc_time_t time;
max77620_rtc_get_time(&time);
if (n_cfg.timeoff)
{
u32 epoch = (u32)((s32)max77620_rtc_date_to_epoch(&time, true) + (s32)n_cfg.timeoff);
max77620_rtc_epoch_to_date(epoch, &time);
}
return (((DWORD)(time.year - 1980) << 25) | ((DWORD)time.month << 21) | ((DWORD)time.day << 16) |
((DWORD)time.hour << 11) | ((DWORD)time.min << 5) | (time.sec >> 1));
}
#endif