File tree 1 file changed +12
-10
lines changed
libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32L0
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -51,16 +51,6 @@ void rtc_init(void)
51
51
52
52
RtcHandle .Instance = RTC ;
53
53
54
- // Enable Power clock
55
- __PWR_CLK_ENABLE ();
56
-
57
- // Enable access to Backup domain
58
- HAL_PWR_EnableBkUpAccess ();
59
-
60
- // Reset Backup domain
61
- __HAL_RCC_BACKUPRESET_FORCE ();
62
- __HAL_RCC_BACKUPRESET_RELEASE ();
63
-
64
54
#if !DEVICE_RTC_LSI
65
55
// Enable LSE Oscillator
66
56
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSE ;
@@ -75,6 +65,16 @@ void rtc_init(void)
75
65
error ("Cannot initialize RTC with LSE\n" );
76
66
}
77
67
#else
68
+ // Enable Power clock
69
+ __PWR_CLK_ENABLE ();
70
+
71
+ // Enable access to Backup domain
72
+ HAL_PWR_EnableBkUpAccess ();
73
+
74
+ // Reset Backup domain
75
+ __HAL_RCC_BACKUPRESET_FORCE ();
76
+ __HAL_RCC_BACKUPRESET_RELEASE ();
77
+
78
78
// Enable LSI clock
79
79
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE ;
80
80
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // Mandatory, otherwise the PLL is reconfigured!
@@ -107,6 +107,7 @@ void rtc_init(void)
107
107
108
108
void rtc_free (void )
109
109
{
110
+ #if DEVICE_RTC_LSI
110
111
// Enable Power clock
111
112
__PWR_CLK_ENABLE ();
112
113
@@ -119,6 +120,7 @@ void rtc_free(void)
119
120
120
121
// Disable access to Backup domain
121
122
HAL_PWR_DisableBkUpAccess ();
123
+ #endif
122
124
123
125
// Disable LSI and LSE clocks
124
126
RCC_OscInitTypeDef RCC_OscInitStruct ;
You can’t perform that action at this time.
0 commit comments