stm32/rtc: Fix rtc_info flags when LSE fails and falls back to LSI.

Previously, if LSE is selected but fails and the RTC falls back to LSI,
then the rtc_info flags would incorrectly state that LSE is used.  This
patch fixes that by setting the bit in rtc_info only after the clock is
ready.
This commit is contained in:
Damien George 2018-02-05 14:40:06 +11:00
parent 20f5de9b39
commit 5a62f0faa6
1 changed files with 4 additions and 1 deletions

View File

@ -162,7 +162,7 @@ void rtc_init_finalise() {
return;
}
rtc_info = 0x20000000 | (rtc_use_lse << 28);
rtc_info = 0x20000000;
if (PYB_RTC_Init(&RTCHandle) != HAL_OK) {
if (rtc_use_lse) {
// fall back to LSI...
@ -182,6 +182,9 @@ void rtc_init_finalise() {
}
}
// record if LSE or LSI is used
rtc_info |= (rtc_use_lse << 28);
// record how long it took for the RTC to start up
rtc_info |= (HAL_GetTick() - rtc_startup_tick) & 0xffff;