Skip to content

Commit c90b7f8

Browse files
committed
Merge pull request ARMmbed#1648 from dbestm/dev_xxx_l0x3xx_rtc
[XXX_L0X3XX] Move erasing of BkUpR in RTC API
2 parents 2454dc5 + 50845e8 commit c90b7f8

File tree

1 file changed

+12
-10
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32L0

1 file changed

+12
-10
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32L0/rtc_api.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ void rtc_init(void)
5151

5252
RtcHandle.Instance = RTC;
5353

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-
6454
#if !DEVICE_RTC_LSI
6555
// Enable LSE Oscillator
6656
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
@@ -75,6 +65,16 @@ void rtc_init(void)
7565
error("Cannot initialize RTC with LSE\n");
7666
}
7767
#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+
7878
// Enable LSI clock
7979
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
8080
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
@@ -107,6 +107,7 @@ void rtc_init(void)
107107

108108
void rtc_free(void)
109109
{
110+
#if DEVICE_RTC_LSI
110111
// Enable Power clock
111112
__PWR_CLK_ENABLE();
112113

@@ -119,6 +120,7 @@ void rtc_free(void)
119120

120121
// Disable access to Backup domain
121122
HAL_PWR_DisableBkUpAccess();
123+
#endif
122124

123125
// Disable LSI and LSE clocks
124126
RCC_OscInitTypeDef RCC_OscInitStruct;

0 commit comments

Comments
 (0)