Merge pull request #5099 from mysterywolf/fatfs

[fatfs] 修改互斥保护超时时间, 并将超时时间改为Kconfig可配置
This commit is contained in:
Bernard Xiong 2021-09-26 06:57:26 +08:00 committed by GitHub
commit f44f4dfd74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

View File

@ -122,6 +122,12 @@ if RT_USING_DFS
config RT_DFS_ELM_REENTRANT config RT_DFS_ELM_REENTRANT
bool "Enable the reentrancy (thread safe) of the FatFs module" bool "Enable the reentrancy (thread safe) of the FatFs module"
default y 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 endmenu
endif endif

View File

@ -0,0 +1,4 @@
# files format check exclude path, please follow the instructions below to modify;
dir_path:
- elmfat

View File

@ -945,7 +945,7 @@ DWORD get_fattime(void)
{ {
DWORD fat_time = 0; DWORD fat_time = 0;
#ifdef RT_LIBC_USING_TIME #if defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC)
time_t now; time_t now;
struct tm *p_tm; struct tm *p_tm;
struct tm tm_now; struct tm tm_now;
@ -968,7 +968,7 @@ DWORD get_fattime(void)
(DWORD)tm_now.tm_hour << 11 | (DWORD)tm_now.tm_hour << 11 |
(DWORD)tm_now.tm_min << 5 | (DWORD)tm_now.tm_min << 5 |
(DWORD)tm_now.tm_sec / 2 ; (DWORD)tm_now.tm_sec / 2 ;
#endif /* RT_USING_LIBC */ #endif /* defined(RT_LIBC_USING_TIME) || defined(RT_USING_LIBC) */
return fat_time; return fat_time;
} }

View File

@ -295,12 +295,16 @@
/ lock control is independent of re-entrancy. */ / lock control is independent of re-entrancy. */
/* #include <somertos.h> // O/S definitions */ /* #include <somertos.h> // O/S definitions */
#include <rtdef.h>
#ifdef RT_DFS_ELM_REENTRANT #ifdef RT_DFS_ELM_REENTRANT
#define FF_FS_REENTRANT 1 /* 0 or 1 */ #define FF_FS_REENTRANT 1 /* 0 or 1 */
#else #else
#define FF_FS_REENTRANT 0 /* 0:Disable or 1:Enable */ #define FF_FS_REENTRANT 0 /* 0:Disable or 1:Enable */
#endif #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 #define FF_SYNC_t rt_mutex_t
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs /* 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 / module itself. Note that regardless of this option, file access to different