1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
35
36
37
38
39
40
41
42
43
44
52
53
61
62
63
64
65
66
67
68
69
70
71
72
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
97
98
99
100
101
102
103
104
111
112
119
120
123
124
125
126
127
128
129
130
131
132
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
157
158
164
165
166
167
168
169
170
176
177
/* ... */
#include "../ff.h"
#if _FS_REENTRANT
/* ... */
int ff_cre_syncobj (
BYTE vol,
_SYNC_t *sobj
)
{
int ret;
#if _USE_MUTEX
#if (osCMSIS < 0x20000U)
osMutexDef(MTX);
*sobj = osMutexCreate(osMutex(MTX));/* ... */
#else
*sobj = osMutexNew(NULL);
#endif
/* ... */
#else
#if (osCMSIS < 0x20000U)
osSemaphoreDef(SEM);
*sobj = osSemaphoreCreate(osSemaphore(SEM), 1);/* ... */
#else
*sobj = osSemaphoreNew(1, 1, NULL);
#endif
/* ... */
#endif
ret = (*sobj != NULL);
return ret;
}ff_cre_syncobj (/* 1:Function succeeded, 0:Could not create the sync object */ BYTE vol, /* Corresponding volume (logical drive number) */ _SYNC_t *sobj /* Pointer to return the created sync object */) { ... }
/* ... */
int ff_del_syncobj (
_SYNC_t sobj
)
{
#if _USE_MUTEX
osMutexDelete (sobj);
#else
osSemaphoreDelete (sobj);
#endif
return 1;
}ff_del_syncobj (/* 1:Function succeeded, 0:Could not delete due to any error */ _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */) { ... }
/* ... */
int ff_req_grant (
_SYNC_t sobj
)
{
int ret = 0;
#if (osCMSIS < 0x20000U)
#if _USE_MUTEX
if(osMutexWait(sobj, _FS_TIMEOUT) == osOK)
#else
if(osSemaphoreWait(sobj, _FS_TIMEOUT) == osOK)
#endif
/* ... */
#else
#if _USE_MUTEX
if(osMutexAcquire(sobj, _FS_TIMEOUT) == osOK)
#else
if(osSemaphoreAcquire(sobj, _FS_TIMEOUT) == osOK)
#endif
/* ... */
#endif
{
ret = 1;
...}
return ret;
}ff_req_grant (/* 1:Got a grant to access the volume, 0:Could not get a grant */ _SYNC_t sobj /* Sync object to wait */) { ... }
/* ... */
void ff_rel_grant (
_SYNC_t sobj
)
{
#if _USE_MUTEX
osMutexRelease(sobj);
#else
osSemaphoreRelease(sobj);
#endif
}ff_rel_grant (_SYNC_t sobj /* Sync object to be signaled */) { ... }
/* ... */
#endif
#if _USE_LFN == 3
/* ... */
void* ff_memalloc (
UINT msize
)
{
return ff_malloc(msize);
}ff_memalloc (/* Returns pointer to the allocated memory block */ UINT msize /* Number of bytes to allocate */) { ... }
void ff_memfree (
void* mblock
)
{
ff_free(mblock);
}ff_memfree (void* mblock /* Pointer to the memory block to free */) { ... }
/* ... */
#endif