2019-06-29 18:03:00 -07:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/* Sample Code of OS Dependent Functions for FatFs */
|
2024-03-12 06:16:18 -07:00
|
|
|
/* (C) ChaN, 2018 */
|
|
|
|
/* (C) CTCaer, 2018-2024 */
|
2019-06-29 18:03:00 -07:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2022-01-15 14:04:34 -08:00
|
|
|
#include <bdk.h>
|
2019-06-29 18:03:00 -07:00
|
|
|
|
2020-06-14 06:45:45 -07:00
|
|
|
#include <libs/fatfs/ff.h>
|
2019-06-29 18:03:00 -07: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 */
|
|
|
|
)
|
|
|
|
{
|
2024-03-12 06:43:44 -07:00
|
|
|
// Ensure size is aligned to SDMMC block size.
|
2024-03-12 06:47:14 -07:00
|
|
|
return malloc(ALIGN(msize, SDMMC_DAT_BLOCKSIZE)); /* Allocate a new memory block with POSIX API */
|
2019-06-29 18:03:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/* 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 05:04:52 -07:00
|
|
|
#if FF_FS_NORTC == 0
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/* Get real time clock */
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DWORD get_fattime (
|
|
|
|
void
|
|
|
|
)
|
|
|
|
{
|
|
|
|
rtc_time_t time;
|
|
|
|
|
2024-03-12 06:11:32 -07:00
|
|
|
max77620_rtc_get_time_adjusted(&time);
|
2020-04-30 05:04:52 -07:00
|
|
|
|
|
|
|
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
|