File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
targets/TARGET_Silicon_Labs/TARGET_EFM32 Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,25 @@ void rtc_init(void)
51
51
RMU_ResetControl (rmuResetPin , rmuResetModeFull );
52
52
53
53
/* Set up the RTCC and let it run, Forrest, run */
54
+
55
+ /* Save time if it has been set */
56
+ time_t t = 0 ;
57
+ if (RTCC -> RET [1 ].REG == 0 ) {
58
+ t = rtc_read ();
59
+ }
60
+
54
61
RTCC_Reset ();
55
62
RTCC_Init_TypeDef rtcc_init = RTCC_INIT_DEFAULT ;
56
63
rtcc_init .presc = rtccCntPresc_32768 ;
57
64
RTCC_Init (& rtcc_init );
58
65
RTCC_Enable (true);
59
- RTCC -> RET [0 ].REG = 0 ;
66
+
67
+ /* Update time */
68
+ if (RTCC -> RET [1 ].REG == 0 ) {
69
+ rtc_write (t );
70
+ } else {
71
+ RTCC -> RET [0 ].REG = 0 ;
72
+ }
60
73
}
61
74
62
75
void rtc_free (void )
@@ -79,6 +92,9 @@ void rtc_write(time_t t)
79
92
{
80
93
core_util_critical_section_enter ();
81
94
RTCC -> RET [0 ].REG = t - RTCC_CounterGet ();
95
+
96
+ /* Record that the time has been set */
97
+ RTCC -> RET [1 ].REG = 0 ;
82
98
core_util_critical_section_exit ();
83
99
}
84
100
You can’t perform that action at this time.
0 commit comments