@@ -57,13 +57,14 @@ static void RTC_IRQHandler(void);
57
57
58
58
void rtc_init (void )
59
59
{
60
- RCC_OscInitTypeDef RCC_OscInitStruct ;
61
- RCC_PeriphCLKInitTypeDef PeriphClkInitStruct ;
60
+ RCC_OscInitTypeDef RCC_OscInitStruct = { 0 } ;
61
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = { 0 } ;
62
62
63
63
// Enable access to Backup domain
64
64
HAL_PWR_EnableBkUpAccess ();
65
65
66
66
RtcHandle .Instance = RTC ;
67
+ RtcHandle .State = HAL_RTC_STATE_RESET ;
67
68
68
69
#if !RTC_LSI
69
70
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSE ;
@@ -162,7 +163,7 @@ void rtc_free(void)
162
163
#endif
163
164
164
165
// Disable LSI and LSE clocks
165
- RCC_OscInitTypeDef RCC_OscInitStruct ;
166
+ RCC_OscInitTypeDef RCC_OscInitStruct = { 0 } ;
166
167
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE ;
167
168
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ;
168
169
RCC_OscInitStruct .LSIState = RCC_LSI_OFF ;
@@ -217,8 +218,8 @@ It is then not a problem to not use shifts.
217
218
218
219
time_t rtc_read (void )
219
220
{
220
- RTC_DateTypeDef dateStruct ;
221
- RTC_TimeTypeDef timeStruct ;
221
+ RTC_DateTypeDef dateStruct = { 0 } ;
222
+ RTC_TimeTypeDef timeStruct = { 0 } ;
222
223
struct tm timeinfo ;
223
224
224
225
RtcHandle .Instance = RTC ;
@@ -247,8 +248,8 @@ time_t rtc_read(void)
247
248
248
249
void rtc_write (time_t t )
249
250
{
250
- RTC_DateTypeDef dateStruct ;
251
- RTC_TimeTypeDef timeStruct ;
251
+ RTC_DateTypeDef dateStruct = { 0 } ;
252
+ RTC_TimeTypeDef timeStruct = { 0 } ;
252
253
253
254
RtcHandle .Instance = RTC ;
254
255
0 commit comments