File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ STATIC void RTC_CalendarConfig(void);
161161
162162void rtc_init (void ) {
163163 RTCHandle .Instance = RTC ;
164+ RTC_DateTypeDef date ;
164165
165166 /* Configure RTC prescaler and RTC data registers */
166167 /* RTC configured as follow:
@@ -188,8 +189,8 @@ void rtc_init(void) {
188189 // record how long it took for the RTC to start up
189190 rtc_info = HAL_GetTick () - tick ;
190191
191- // check data stored in BackUp register0
192- if (HAL_RTCEx_BKUPRead ( & RTCHandle , RTC_BKP_DR0 ) != 0x32f2 ) {
192+ HAL_RTC_GetDate ( & RTCHandle , & date , FORMAT_BIN );
193+ if (date . Year == 0 && date . Month == 0 && date . Date == 0 ) {
193194 // fresh reset; configure RTC Calendar
194195 RTC_CalendarConfig ();
195196 } else {
@@ -233,9 +234,6 @@ STATIC void RTC_CalendarConfig(void) {
233234 // init error
234235 return ;
235236 }
236-
237- // write data to indicate the RTC has been set
238- HAL_RTCEx_BKUPWrite (& RTCHandle , RTC_BKP_DR0 , 0x32f2 );
239237}
240238
241239/*
You can’t perform that action at this time.
0 commit comments