File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
targets/TARGET_Silicon_Labs/TARGET_EFM32 Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,20 @@ 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 ) t = rtc_read ();
58
+
54
59
RTCC_Reset ();
55
60
RTCC_Init_TypeDef rtcc_init = RTCC_INIT_DEFAULT ;
56
61
rtcc_init .presc = rtccCntPresc_32768 ;
57
62
RTCC_Init (& rtcc_init );
58
63
RTCC_Enable (true);
59
- RTCC -> RET [0 ].REG = 0 ;
64
+
65
+ //Update time
66
+ if (RTCC -> RET [1 ].REG == 0 ) rtc_write (t );
67
+ else RTCC -> RET [0 ].REG = 0 ;
60
68
}
61
69
62
70
void rtc_free (void )
@@ -79,6 +87,8 @@ void rtc_write(time_t t)
79
87
{
80
88
core_util_critical_section_enter ();
81
89
RTCC -> RET [0 ].REG = t - RTCC_CounterGet ();
90
+ //Record that the time has been set
91
+ RTCC -> RET [1 ].REG = 0 ;
82
92
core_util_critical_section_exit ();
83
93
}
84
94
You can’t perform that action at this time.
0 commit comments