Skip to content

Commit f44f4df

Browse files
authored
Merge pull request #5099 from mysterywolf/fatfs
[fatfs] 修改互斥保护超时时间, 并将超时时间改为Kconfig可配置
2 parents 66ad092 + 1d00635 commit f44f4df

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

components/dfs/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ if RT_USING_DFS
122122
config RT_DFS_ELM_REENTRANT
123123
bool "Enable the reentrancy (thread safe) of the FatFs module"
124124
default y
125+
126+
config RT_DFS_ELM_MUTEX_TIMEOUT
127+
int "Timeout of thread-safe protection mutex"
128+
range 0 1000000
129+
default 3000
130+
depends on RT_DFS_ELM_REENTRANT
125131
endmenu
126132
endif
127133

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# files format check exclude path, please follow the instructions below to modify;
2+
3+
dir_path:
4+
- elmfat

components/dfs/filesystems/elmfat/dfs_elm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ DWORD get_fattime(void)
945945
{
946946
DWORD fat_time = 0;
947947

948-
#ifdef RT_LIBC_USING_TIME
948+
#if defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC)
949949
time_t now;
950950
struct tm *p_tm;
951951
struct tm tm_now;
@@ -968,7 +968,7 @@ DWORD get_fattime(void)
968968
(DWORD)tm_now.tm_hour << 11 |
969969
(DWORD)tm_now.tm_min << 5 |
970970
(DWORD)tm_now.tm_sec / 2 ;
971-
#endif /* RT_USING_LIBC */
971+
#endif /* defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) */
972972

973973
return fat_time;
974974
}

components/dfs/filesystems/elmfat/ffconf.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,16 @@
295295
/ lock control is independent of re-entrancy. */
296296

297297
/* #include <somertos.h> // O/S definitions */
298+
#include <rtdef.h>
298299
#ifdef RT_DFS_ELM_REENTRANT
299300
#define FF_FS_REENTRANT 1 /* 0 or 1 */
300301
#else
301302
#define FF_FS_REENTRANT 0 /* 0:Disable or 1:Enable */
302303
#endif
303-
#define FF_FS_TIMEOUT 1000
304+
#ifndef RT_DFS_ELM_MUTEX_TIMEOUT
305+
#define RT_DFS_ELM_MUTEX_TIMEOUT 3000
306+
#endif
307+
#define FF_FS_TIMEOUT RT_DFS_ELM_MUTEX_TIMEOUT
304308
#define FF_SYNC_t rt_mutex_t
305309
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
306310
/ module itself. Note that regardless of this option, file access to different

0 commit comments

Comments
 (0)