summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-09-26 06:57:26 +0800
committerGitHub <[email protected]>2021-09-26 06:57:26 +0800
commitf44f4dfd7462765b5f2273536ebdb2298457e494 (patch)
tree5a35ac27ee96a34dafdb0e7b58ae7da13c1e7e0d /components
parent66ad092f066db6251c86aa994620c118474aa7aa (diff)
parent1d00635ee92760b59e45e55b1d47199201c0a390 (diff)
Merge pull request #5099 from mysterywolf/fatfs
[fatfs] 修改互斥保护超时时间, 并将超时时间改为Kconfig可配置
Diffstat (limited to 'components')
-rw-r--r--components/dfs/Kconfig6
-rw-r--r--components/dfs/filesystems/.ignore_format.yml4
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c4
-rw-r--r--components/dfs/filesystems/elmfat/ffconf.h6
4 files changed, 17 insertions, 3 deletions
diff --git a/components/dfs/Kconfig b/components/dfs/Kconfig
index 442c3bb260..7a4fbb655d 100644
--- a/components/dfs/Kconfig
+++ b/components/dfs/Kconfig
@@ -122,6 +122,12 @@ if RT_USING_DFS
config RT_DFS_ELM_REENTRANT
bool "Enable the reentrancy (thread safe) of the FatFs module"
default y
+
+ config RT_DFS_ELM_MUTEX_TIMEOUT
+ int "Timeout of thread-safe protection mutex"
+ range 0 1000000
+ default 3000
+ depends on RT_DFS_ELM_REENTRANT
endmenu
endif
diff --git a/components/dfs/filesystems/.ignore_format.yml b/components/dfs/filesystems/.ignore_format.yml
new file mode 100644
index 0000000000..e72719df1d
--- /dev/null
+++ b/components/dfs/filesystems/.ignore_format.yml
@@ -0,0 +1,4 @@
+# files format check exclude path, please follow the instructions below to modify;
+
+dir_path:
+- elmfat
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index 41f99d7b62..01d303f71f 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -945,7 +945,7 @@ DWORD get_fattime(void)
{
DWORD fat_time = 0;
-#ifdef RT_LIBC_USING_TIME
+#if defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC)
time_t now;
struct tm *p_tm;
struct tm tm_now;
@@ -968,7 +968,7 @@ DWORD get_fattime(void)
(DWORD)tm_now.tm_hour << 11 |
(DWORD)tm_now.tm_min << 5 |
(DWORD)tm_now.tm_sec / 2 ;
-#endif /* RT_USING_LIBC */
+#endif /* defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) */
return fat_time;
}
diff --git a/components/dfs/filesystems/elmfat/ffconf.h b/components/dfs/filesystems/elmfat/ffconf.h
index a17a07d8ea..a6dcebe228 100644
--- a/components/dfs/filesystems/elmfat/ffconf.h
+++ b/components/dfs/filesystems/elmfat/ffconf.h
@@ -295,12 +295,16 @@
/ lock control is independent of re-entrancy. */
/* #include <somertos.h> // O/S definitions */
+#include <rtdef.h>
#ifdef RT_DFS_ELM_REENTRANT
#define FF_FS_REENTRANT 1 /* 0 or 1 */
#else
#define FF_FS_REENTRANT 0 /* 0:Disable or 1:Enable */
#endif
-#define FF_FS_TIMEOUT 1000
+#ifndef RT_DFS_ELM_MUTEX_TIMEOUT
+#define RT_DFS_ELM_MUTEX_TIMEOUT 3000
+#endif
+#define FF_FS_TIMEOUT RT_DFS_ELM_MUTEX_TIMEOUT
#define FF_SYNC_t rt_mutex_t
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/ module itself. Note that regardless of this option, file access to different