mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
fatfs: Use RTC clock for date/time
This commit is contained in:
parent
b6933013be
commit
2a8c27115c
1 changed files with 27 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue