Skip to content

Commit b61cf8d

Browse files
committed
samd: Use RTC to set file timestamp
Use RTC to set file timestamp for file operations done on the board.
1 parent 39ee12d commit b61cf8d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ports/atmel-samd/fatfs_port.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828
#include "py/runtime.h"
2929
#include "lib/oofatfs/ff.h" /* FatFs lower layer API */
3030
#include "lib/oofatfs/diskio.h" /* FatFs lower layer API */
31+
#include "lib/timeutils/timeutils.h"
32+
#include "shared-bindings/rtc/RTC.h"
3133

3234
DWORD get_fattime(void) {
33-
// TODO(tannewt): Support the RTC.
34-
return ((2016 - 1980) << 25) | ((9) << 21) | ((1) << 16) | ((16) << 11) | ((43) << 5) | (35 / 2);
35+
timeutils_struct_time_t tm;
36+
common_hal_rtc_get_time(&tm);
37+
38+
return ((tm.tm_year - 1980) << 25) | (tm.tm_mon << 21) | (tm.tm_mday << 16) |
39+
(tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec >> 1);
3540
}

0 commit comments

Comments
 (0)