Skip to content

Commit 41975a2

Browse files
committed
Workaround to fix RTC-reset issue on the EFM32GG11_STK3701
1 parent 2367482 commit 41975a2

File tree

1 file changed

+12
-6
lines changed
  • targets/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+12
-6
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/rtcc.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,24 @@ void rtc_init(void)
5252

5353
/* Set up the RTCC and let it run, Forrest, run */
5454

55-
//Save time if it has been set.
55+
/* Save time if it has been set */
5656
time_t t = 0;
57-
if (RTCC->RET[1].REG == 0) t = rtc_read();
57+
if (RTCC->RET[1].REG == 0) {
58+
t = rtc_read();
59+
}
5860

5961
RTCC_Reset();
6062
RTCC_Init_TypeDef rtcc_init = RTCC_INIT_DEFAULT;
6163
rtcc_init.presc = rtccCntPresc_32768;
6264
RTCC_Init(&rtcc_init);
6365
RTCC_Enable(true);
6466

65-
//Update time
66-
if (RTCC->RET[1].REG == 0) rtc_write(t);
67-
else RTCC->RET[0].REG = 0;
67+
/* Update time */
68+
if (RTCC->RET[1].REG == 0) {
69+
rtc_write(t);
70+
} else {
71+
RTCC->RET[0].REG = 0;
72+
}
6873
}
6974

7075
void rtc_free(void)
@@ -87,7 +92,8 @@ void rtc_write(time_t t)
8792
{
8893
core_util_critical_section_enter();
8994
RTCC->RET[0].REG = t - RTCC_CounterGet();
90-
//Record that the time has been set
95+
96+
/* Record that the time has been set */
9197
RTCC->RET[1].REG = 0;
9298
core_util_critical_section_exit();
9399
}

0 commit comments

Comments
 (0)