Skip to content

Commit 35216e3

Browse files
CopilotBernardXiong
andcommitted
[dfs_v1][elmfat] Add new mutex API functions for R0.16 compatibility
Co-authored-by: BernardXiong <[email protected]>
1 parent eea8902 commit 35216e3

File tree

1 file changed

+39
-0
lines changed
  • components/dfs/dfs_v1/filesystems/elmfat

1 file changed

+39
-0
lines changed

components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ DWORD get_fattime(void)
999999
}
10001000

10011001
#if FF_FS_REENTRANT
1002+
/* Old FatFs API (R0.14b and earlier) */
10021003
int ff_cre_syncobj(BYTE drv, FF_SYNC_t *m)
10031004
{
10041005
char name[8];
@@ -1036,6 +1037,44 @@ void ff_rel_grant(FF_SYNC_t m)
10361037
rt_mutex_release(m);
10371038
}
10381039

1040+
/* New FatFs API (R0.15 and later) */
1041+
static rt_mutex_t Mutex[FF_VOLUMES + 1];
1042+
1043+
int ff_mutex_create (int vol)
1044+
{
1045+
char name[8];
1046+
rt_mutex_t mutex;
1047+
1048+
rt_snprintf(name, sizeof(name), "fat%d", vol);
1049+
mutex = rt_mutex_create(name, RT_IPC_FLAG_PRIO);
1050+
if (mutex != RT_NULL)
1051+
{
1052+
Mutex[vol] = mutex;
1053+
return RT_TRUE;
1054+
}
1055+
1056+
return RT_FALSE;
1057+
}
1058+
1059+
void ff_mutex_delete (int vol)
1060+
{
1061+
if (Mutex[vol] != RT_NULL)
1062+
rt_mutex_delete(Mutex[vol]);
1063+
}
1064+
1065+
int ff_mutex_take (int vol)
1066+
{
1067+
if (rt_mutex_take(Mutex[vol], FF_FS_TIMEOUT) == RT_EOK)
1068+
return RT_TRUE;
1069+
1070+
return RT_FALSE;
1071+
}
1072+
1073+
void ff_mutex_give (int vol)
1074+
{
1075+
rt_mutex_release(Mutex[vol]);
1076+
}
1077+
10391078
#endif
10401079

10411080
/* Memory functions */

0 commit comments

Comments
 (0)