Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/fatfs/ffsystem.c
1476 views
1
/*------------------------------------------------------------------------*/
2
/* Sample Code of OS Dependent Functions for FatFs */
3
/* (C) ChaN, 2018 */
4
/* (C) CTCaer, 2018-2024 */
5
/*------------------------------------------------------------------------*/
6
7
#include <bdk.h>
8
9
#include <libs/fatfs/ff.h>
10
11
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
12
13
/*------------------------------------------------------------------------*/
14
/* Allocate a memory block */
15
/*------------------------------------------------------------------------*/
16
17
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
18
UINT msize /* Number of bytes to allocate */
19
)
20
{
21
// Ensure size is aligned to SDMMC block size.
22
return malloc(ALIGN(msize, SDMMC_DAT_BLOCKSIZE)); /* Allocate a new memory block with POSIX API */
23
}
24
25
26
/*------------------------------------------------------------------------*/
27
/* Free a memory block */
28
/*------------------------------------------------------------------------*/
29
30
void ff_memfree (
31
void* mblock /* Pointer to the memory block to free (nothing to do if null) */
32
)
33
{
34
free(mblock); /* Free the memory block with POSIX API */
35
}
36
37
#endif
38
39
#if FF_FS_NORTC == 0
40
41
/*------------------------------------------------------------------------*/
42
/* Get real time clock */
43
/*------------------------------------------------------------------------*/
44
45
DWORD get_fattime (
46
void
47
)
48
{
49
rtc_time_t time;
50
51
max77620_rtc_get_time_adjusted(&time);
52
53
return (((DWORD)(time.year - 1980) << 25) | ((DWORD)time.month << 21) | ((DWORD)time.day << 16) |
54
((DWORD)time.hour << 11) | ((DWORD)time.min << 5) | (time.sec >> 1));
55
}
56
57
#endif
58
59