summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/diskio.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-19 02:17:30 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-19 02:17:30 +0100
commit6e44381cce102bbb4b0c45aacb927a565cab41c9 (patch)
treec7da7854df9c5a7b583182ae114f082b008a0eb8 /stmhal/diskio.c
parented5117f6a8d0659b8a9a3a985d8b7e36644e39d5 (diff)
downloadmicropython-6e44381cce102bbb4b0c45aacb927a565cab41c9.tar.gz
micropython-6e44381cce102bbb4b0c45aacb927a565cab41c9.zip
stmhal: Improve RTC class; make fatfs use RTC for time stamping files.
Diffstat (limited to 'stmhal/diskio.c')
-rw-r--r--stmhal/diskio.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/stmhal/diskio.c b/stmhal/diskio.c
index 4ac3a35aa2..69a6432418 100644
--- a/stmhal/diskio.c
+++ b/stmhal/diskio.c
@@ -9,11 +9,19 @@
#include <stdint.h>
#include <stdio.h>
-#include "ff.h" /* FatFs lower layer API */
-#include "diskio.h" /* FatFs lower layer API */
+
+#include "stm32f4xx_hal.h"
+
#include "misc.h"
+#include "mpconfig.h"
+#include "qstr.h"
+#include "obj.h"
+#include "systick.h"
+#include "rtc.h"
#include "storage.h"
#include "sdcard.h"
+#include "ff.h" /* FatFs lower layer API */
+#include "diskio.h" /* FatFs lower layer API */
const PARTITION VolToPart[] = {
{0, 1}, // Logical drive 0 ==> Physical drive 0, 1st partition
@@ -190,12 +198,9 @@ DWORD get_fattime (
void
)
{
- // TODO replace with call to RTC
- int year = 2013;
- int month = 10;
- int day = 12;
- int hour = 21;
- int minute = 42;
- int second = 13;
- return ((year - 1980) << 25) | ((month) << 21) | ((day) << 16) | ((hour) << 11) | ((minute) << 5) | (second / 2);
+ RTC_TimeTypeDef time;
+ RTC_DateTypeDef date;
+ HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN);
+ HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN);
+ return ((2000 + date.Year - 1980) << 25) | ((date.Month) << 21) | ((date.Date) << 16) | ((time.Hours) << 11) | ((time.Minutes) << 5) | (time.Seconds / 2);
}