diff options
author | Damien George <damien.p.george@gmail.com> | 2018-02-05 14:40:06 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-02-05 14:40:06 +1100 |
commit | 5a62f0faa62751af94a795428eddab43f7e60518 (patch) | |
tree | caad93937bb0c53c00eb98a7cdf49aa9bab6bc95 | |
parent | 20f5de9b397e9b9dac7070598685f24e8e9636a2 (diff) |
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.
-rw-r--r-- | ports/stm32/rtc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ports/stm32/rtc.c b/ports/stm32/rtc.c index 73272d363..029da5fc0 100644 --- a/ports/stm32/rtc.c +++ b/ports/stm32/rtc.c @@ -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; |