2019-06-30 02:03:00 +01:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/* Sample Code of OS Dependent Functions for FatFs */
|
|
|
|
/* (C) ChaN, 2018 */
|
|
|
|
/* (C) CTCaer, 2018 */
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "ff.h"
|
2020-04-30 13:04:52 +01:00
|
|
|
#include "../../config/config.h"
|
2019-06-30 02:03:00 +01:00
|
|
|
#include "../../mem/heap.h"
|
2020-04-30 13:04:52 +01:00
|
|
|
#include "../../rtc/max77620-rtc.h"
|
2019-06-30 02:03:00 +01:00
|
|
|
|
2020-04-30 13:04:52 +01:00
|
|
|
extern nyx_config n_cfg;
|
2019-06-30 02:03:00 +01:00
|
|
|
|
|
|
|
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/* Allocate a memory block */
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
|
|
|
UINT msize /* Number of bytes to allocate */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/* Free a memory block */
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void ff_memfree (
|
|
|
|
void* mblock /* Pointer to the memory block to free (nothing to do if null) */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
free(mblock); /* Free the memory block with POSIX API */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-04-30 13:04:52 +01:00
|
|
|
#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)
|
|
|
|
{
|
2020-05-05 17:16:16 +01:00
|
|
|
u32 epoch = (u32)((s32)max77620_rtc_date_to_epoch(&time) + (s32)n_cfg.timeoff);
|
2020-04-30 13:04:52 +01:00
|
|
|
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
|