Skip to content

fix: initialize RTC variables even when RTC hardware is not reinitialized #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ bool RTC_init(hourFormat_t format, sourceClock_t source, bool reset)
BackupDate |= getBackupRegister(RTC_BKP_DATE + 1) & 0xFFFF;
if ((BackupDate == 0) || reset) {
/* Let HAL calculate the prescaler */
RtcHandle.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
RtcHandle.Init.AsynchPrediv = prediv;
RtcHandle.Init.OutPut = RTC_OUTPUTSOURCE_NONE;
HAL_RTC_Init(&RtcHandle);
// Default: saturday 1st of January 2001
Expand Down Expand Up @@ -395,6 +395,9 @@ bool RTC_init(hourFormat_t format, sourceClock_t source, bool reset)
// Note: year 2000 is invalid as it is the hardware reset value and doesn't raise INITS flag
RTC_SetDate(1, 1, 1, 6);
reinit = true;
} else {
// This initialize variables: predivAsync, redivSync and predivSync_bits
RTC_getPrediv(NULL, NULL);
}
#endif /* STM32F1xx */

Expand Down