summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/common/dir.c3
-rw-r--r--firmware/common/dircache.c2
-rw-r--r--firmware/common/timefuncs.c14
-rw-r--r--firmware/drivers/fat.c14
-rw-r--r--firmware/export/fat.h1
-rw-r--r--firmware/include/timefuncs.h2
6 files changed, 19 insertions, 17 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c
index f89129ae34..245947b134 100644
--- a/firmware/common/dir.c
+++ b/firmware/common/dir.c
@@ -26,6 +26,7 @@
26#include "debug.h" 26#include "debug.h"
27#include "dir.h" 27#include "dir.h"
28#include "pathfuncs.h" 28#include "pathfuncs.h"
29#include "timefuncs.h"
29#include "fileobj_mgr.h" 30#include "fileobj_mgr.h"
30#include "dircache_redirect.h" 31#include "dircache_redirect.h"
31 32
@@ -406,7 +407,7 @@ struct dirinfo dir_get_info(DIR *dirp, struct dirent *entry)
406 { 407 {
407 .attribute = entry->info.attr, 408 .attribute = entry->info.attr,
408 .size = entry->info.size, 409 .size = entry->info.size,
409 .mtime = fattime_mktime(entry->info.wrtdate, entry->info.wrttime), 410 .mtime = dostime_mktime(entry->info.wrtdate, entry->info.wrttime),
410 }; 411 };
411 412
412file_error: 413file_error:
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 589986911c..3b880d3382 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -2956,7 +2956,7 @@ void dircache_dump(void)
2956 FOR_EACH_CACHE_ENTRY(ce) 2956 FOR_EACH_CACHE_ENTRY(ce)
2957 { 2957 {
2958 #ifdef DIRCACHE_NATIVE 2958 #ifdef DIRCACHE_NATIVE
2959 time_t mtime = fattime_mktime(ce->wrtdate, ce->wrttime); 2959 time_t mtime = dostime_mktime(ce->wrtdate, ce->wrttime);
2960 #else 2960 #else
2961 time_t mtime = ce->mtime; 2961 time_t mtime = ce->mtime;
2962 #endif 2962 #endif
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index 108431753a..d87e6b67f2 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -32,6 +32,20 @@
32 32
33static struct tm tm; 33static struct tm tm;
34 34
35time_t dostime_mktime(uint16_t dosdate, uint16_t dostime)
36{
37 /* this knows our mktime() only uses these struct tm fields */
38 struct tm tm;
39 tm.tm_sec = ((dostime ) & 0x1f) * 2;
40 tm.tm_min = ((dostime >> 5) & 0x3f);
41 tm.tm_hour = ((dostime >> 11) );
42 tm.tm_mday = ((dosdate ) & 0x1f);
43 tm.tm_mon = ((dosdate >> 5) & 0x0f) - 1;
44 tm.tm_year = ((dosdate >> 9) ) + 80;
45
46 return mktime(&tm);
47}
48
35#if !CONFIG_RTC 49#if !CONFIG_RTC
36static inline bool rtc_dirty(void) 50static inline bool rtc_dirty(void)
37{ 51{
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 337e29a1bc..cc9735d0f7 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -2954,20 +2954,6 @@ void fat_empty_fat_direntry(struct fat_direntry *entry)
2954 entry->firstcluster = 0; 2954 entry->firstcluster = 0;
2955} 2955}
2956 2956
2957time_t fattime_mktime(uint16_t fatdate, uint16_t fattime)
2958{
2959 /* this knows our mktime() only uses these struct tm fields */
2960 struct tm tm;
2961 tm.tm_sec = ((fattime ) & 0x1f) * 2;
2962 tm.tm_min = ((fattime >> 5) & 0x3f);
2963 tm.tm_hour = ((fattime >> 11) );
2964 tm.tm_mday = ((fatdate ) & 0x1f);
2965 tm.tm_mon = ((fatdate >> 5) & 0x0f) - 1;
2966 tm.tm_year = ((fatdate >> 9) ) + 80;
2967
2968 return mktime(&tm);
2969}
2970
2971void fat_init(void) 2957void fat_init(void)
2972{ 2958{
2973 dc_lock_cache(); 2959 dc_lock_cache();
diff --git a/firmware/export/fat.h b/firmware/export/fat.h
index b8092290e6..27c2a161f6 100644
--- a/firmware/export/fat.h
+++ b/firmware/export/fat.h
@@ -174,7 +174,6 @@ void fat_recalc_free(IF_MV_NONVOID(int volume));
174bool fat_size(IF_MV(int volume,) unsigned long *size, unsigned long *free); 174bool fat_size(IF_MV(int volume,) unsigned long *size, unsigned long *free);
175 175
176/** Misc. **/ 176/** Misc. **/
177time_t fattime_mktime(uint16_t fatdate, uint16_t fattime);
178void fat_empty_fat_direntry(struct fat_direntry *entry); 177void fat_empty_fat_direntry(struct fat_direntry *entry);
179void fat_init(void); 178void fat_init(void);
180 179
diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h
index c72508e862..2e8ef01ca6 100644
--- a/firmware/include/timefuncs.h
+++ b/firmware/include/timefuncs.h
@@ -24,8 +24,10 @@
24 24
25#include "config.h" 25#include "config.h"
26#include <stdbool.h> 26#include <stdbool.h>
27#include <stdint.h>
27#include "time.h" 28#include "time.h"
28 29
30time_t dostime_mktime(uint16_t dosdate, uint16_t dostime);
29struct tm *get_time(void); 31struct tm *get_time(void);
30int set_time(const struct tm *tm); 32int set_time(const struct tm *tm);
31#if CONFIG_RTC 33#if CONFIG_RTC