Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
b106532b
Commit
b106532b
authored
Oct 14, 2015
by
Peter Hinch
Committed by
Damien George
Oct 20, 2015
Browse files
stmhal/rtc: Init uses YMD rather than backup register to detect powerup.
parent
8e6e9eae
Changes
1
Hide whitespace changes
Inline
Side-by-side
stmhal/rtc.c
View file @
b106532b
...
...
@@ -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
);
}
/*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment