stmhal/rtc: Init uses YMD rather than backup register to detect powerup.

This commit is contained in:
Peter Hinch 2015-10-14 10:01:14 +01:00 committed by Damien George
parent 8e6e9eaea5
commit b106532b32
1 changed files with 3 additions and 5 deletions

View File

@ -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);
}
/*