File tree 1 file changed +12
-10
lines changed
libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32L1
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_LSI | RCC_OSCILLATORTYPE_LSE ;
@@ -76,6 +66,16 @@ void rtc_init(void)
76
66
error ("Cannot initialize RTC with LSE\n" );
77
67
}
78
68
#else
69
+ // Enable Power clock
70
+ __PWR_CLK_ENABLE ();
71
+
72
+ // Enable access to Backup domain
73
+ HAL_PWR_EnableBkUpAccess ();
74
+
75
+ // Reset Backup domain
76
+ __HAL_RCC_BACKUPRESET_FORCE ();
77
+ __HAL_RCC_BACKUPRESET_RELEASE ();
78
+
79
79
// Enable LSI clock
80
80
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE ;
81
81
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // Mandatory, otherwise the PLL is reconfigured!
@@ -114,6 +114,7 @@ void rtc_init(void)
114
114
115
115
void rtc_free (void )
116
116
{
117
+ #if DEVICE_RTC_LSI
117
118
// Enable Power clock
118
119
__PWR_CLK_ENABLE ();
119
120
@@ -126,6 +127,7 @@ void rtc_free(void)
126
127
127
128
// Disable access to Backup domain
128
129
HAL_PWR_DisableBkUpAccess ();
130
+ #endif
129
131
130
132
// Disable LSI and LSE clocks
131
133
RCC_OscInitTypeDef RCC_OscInitStruct ;
You can’t perform that action at this time.
0 commit comments