diff options
author | Peter Hinch <peter@hinch.me.uk> | 2015-10-14 10:01:14 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-10-20 12:05:16 +0100 |
commit | b106532b32b7b92d62250ca6a9edea078e042597 (patch) | |
tree | f84ad75a7079b0b3951f3fea91033da8f6a8beef | |
parent | 8e6e9eaea575f2f9b7b3591c813002cd94ff45e3 (diff) | |
download | micropython-b106532b32b7b92d62250ca6a9edea078e042597.tar.gz micropython-b106532b32b7b92d62250ca6a9edea078e042597.zip |
stmhal/rtc: Init uses YMD rather than backup register to detect powerup.
-rw-r--r-- | stmhal/rtc.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/stmhal/rtc.c b/stmhal/rtc.c index 1be0b6e62b..679f586631 100644 --- a/stmhal/rtc.c +++ b/stmhal/rtc.c @@ -161,6 +161,7 @@ STATIC void RTC_CalendarConfig(void); void rtc_init(void) { RTCHandle.Instance = RTC; + RTC_DateTypeDef date; /* Configure RTC prescaler and RTC data registers */ /* RTC configured as follow: @@ -188,8 +189,8 @@ void rtc_init(void) { // record how long it took for the RTC to start up rtc_info = HAL_GetTick() - tick; - // check data stored in BackUp register0 - if (HAL_RTCEx_BKUPRead(&RTCHandle, RTC_BKP_DR0) != 0x32f2) { + HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN); + if (date.Year == 0 && date.Month ==0 && date.Date == 0) { // fresh reset; configure RTC Calendar RTC_CalendarConfig(); } else { @@ -233,9 +234,6 @@ STATIC void RTC_CalendarConfig(void) { // init error return; } - - // write data to indicate the RTC has been set - HAL_RTCEx_BKUPWrite(&RTCHandle, RTC_BKP_DR0, 0x32f2); } /* |