mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13907 from petroborys/master
Workaround to fix RTC-reset issue on the EFM32GG11_STK3701pull/13959/head
commit
3a71f314d6
|
@ -51,12 +51,25 @@ void rtc_init(void)
|
||||||
RMU_ResetControl(rmuResetPin, rmuResetModeFull);
|
RMU_ResetControl(rmuResetPin, rmuResetModeFull);
|
||||||
|
|
||||||
/* Set up the RTCC and let it run, Forrest, run */
|
/* Set up the RTCC and let it run, Forrest, run */
|
||||||
|
|
||||||
|
/* Save time if it has been set */
|
||||||
|
time_t t = 0;
|
||||||
|
if (RTCC->RET[1].REG == 0) {
|
||||||
|
t = rtc_read();
|
||||||
|
}
|
||||||
|
|
||||||
RTCC_Reset();
|
RTCC_Reset();
|
||||||
RTCC_Init_TypeDef rtcc_init = RTCC_INIT_DEFAULT;
|
RTCC_Init_TypeDef rtcc_init = RTCC_INIT_DEFAULT;
|
||||||
rtcc_init.presc = rtccCntPresc_32768;
|
rtcc_init.presc = rtccCntPresc_32768;
|
||||||
RTCC_Init(&rtcc_init);
|
RTCC_Init(&rtcc_init);
|
||||||
RTCC_Enable(true);
|
RTCC_Enable(true);
|
||||||
RTCC->RET[0].REG = 0;
|
|
||||||
|
/* Update time */
|
||||||
|
if (RTCC->RET[1].REG == 0) {
|
||||||
|
rtc_write(t);
|
||||||
|
} else {
|
||||||
|
RTCC->RET[0].REG = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtc_free(void)
|
void rtc_free(void)
|
||||||
|
@ -79,6 +92,9 @@ void rtc_write(time_t t)
|
||||||
{
|
{
|
||||||
core_util_critical_section_enter();
|
core_util_critical_section_enter();
|
||||||
RTCC->RET[0].REG = t - RTCC_CounterGet();
|
RTCC->RET[0].REG = t - RTCC_CounterGet();
|
||||||
|
|
||||||
|
/* Record that the time has been set */
|
||||||
|
RTCC->RET[1].REG = 0;
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue