@@ -65,9 +65,9 @@ void rtc_init(void)
65
65
HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct );
66
66
rtc_freq = LSE_VALUE ;
67
67
} else {
68
- error ("Cannot initialize RTC with LSE\n" );
68
+ error ("Cannot initialize RTC with LSE\n" );
69
69
}
70
- #else
70
+ #else
71
71
// Enable Power clock
72
72
__HAL_RCC_PWR_CLK_ENABLE ();
73
73
@@ -78,22 +78,22 @@ void rtc_init(void)
78
78
__HAL_RCC_BACKUPRESET_FORCE ();
79
79
__HAL_RCC_BACKUPRESET_RELEASE ();
80
80
81
- // Enable LSI clock
82
- RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE ;
83
- RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // Mandatory, otherwise the PLL is reconfigured!
84
- RCC_OscInitStruct .LSEState = RCC_LSE_OFF ;
85
- RCC_OscInitStruct .LSIState = RCC_LSI_ON ;
86
- if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) != HAL_OK ) {
87
- error ("Cannot initialize RTC with LSI\n" );
88
- }
89
- // Connect LSI to RTC
90
- PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_RTC ;
91
- PeriphClkInitStruct .RTCClockSelection = RCC_RTCCLKSOURCE_LSI ;
92
- if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
93
- error ("Cannot initialize RTC with LSI\n" );
94
- }
95
- // This value is LSI typical value. To be measured precisely using a timer input capture for example.
96
- rtc_freq = 40000 ;
81
+ // Enable LSI clock
82
+ RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE ;
83
+ RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // Mandatory, otherwise the PLL is reconfigured!
84
+ RCC_OscInitStruct .LSEState = RCC_LSE_OFF ;
85
+ RCC_OscInitStruct .LSIState = RCC_LSI_ON ;
86
+ if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) != HAL_OK ) {
87
+ error ("Cannot initialize RTC with LSI\n" );
88
+ }
89
+ // Connect LSI to RTC
90
+ PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_RTC ;
91
+ PeriphClkInitStruct .RTCClockSelection = RCC_RTCCLKSOURCE_LSI ;
92
+ if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
93
+ error ("Cannot initialize RTC with LSI\n" );
94
+ }
95
+ // This value is LSI typical value (see device datasheet)
96
+ rtc_freq = 32000 ;
97
97
#endif
98
98
99
99
// Check if RTC is already initialized
@@ -141,7 +141,7 @@ void rtc_free(void)
141
141
142
142
#if DEVICE_RTC_LSI
143
143
rtc_inited = 0 ;
144
- #endif
144
+ #endif
145
145
}
146
146
147
147
int rtc_isenabled (void )
0 commit comments