diff options
| author | Noralf Trønnes <noralf@tronnes.org> | 2018-08-25 18:11:29 +0200 |
|---|---|---|
| committer | Noralf Trønnes <noralf@tronnes.org> | 2018-08-25 20:43:09 +0200 |
| commit | b61cf8d81f6f5c59175de9e7508752b0f27d7fcd (patch) | |
| tree | 4cdbc2b73bdda5ba5133af788d510c44eefa5fab | |
| parent | 39ee12d1ac6ffb105f6ac0994f6169a7bb327cbd (diff) | |
samd: Use RTC to set file timestamp
Use RTC to set file timestamp for file operations done on the board.
| -rw-r--r-- | ports/atmel-samd/fatfs_port.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ports/atmel-samd/fatfs_port.c b/ports/atmel-samd/fatfs_port.c index e1eba350a..67c6c9d35 100644 --- a/ports/atmel-samd/fatfs_port.c +++ b/ports/atmel-samd/fatfs_port.c @@ -28,8 +28,13 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" /* FatFs lower layer API */ #include "lib/oofatfs/diskio.h" /* FatFs lower layer API */ +#include "lib/timeutils/timeutils.h" +#include "shared-bindings/rtc/RTC.h" DWORD get_fattime(void) { - // TODO(tannewt): Support the RTC. - return ((2016 - 1980) << 25) | ((9) << 21) | ((1) << 16) | ((16) << 11) | ((43) << 5) | (35 / 2); + timeutils_struct_time_t tm; + common_hal_rtc_get_time(&tm); + + return ((tm.tm_year - 1980) << 25) | (tm.tm_mon << 21) | (tm.tm_mday << 16) | + (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec >> 1); } |
