Skip to content

Commit 9d60138

Browse files
committed
[xxx_L476XG] remove erase of BkUpR in RTC API
the erase of back up regsiters are needed only when using RTC+LSI
1 parent e42e174 commit 9d60138

File tree

1 file changed

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

1 file changed

+12
-10
lines changed

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

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

5353
RtcHandle.Instance = RTC;
5454

55-
// Enable Power clock
56-
__HAL_RCC_PWR_CLK_ENABLE();
57-
58-
// Enable access to Backup domain
59-
HAL_PWR_EnableBkUpAccess();
60-
61-
// Reset Backup domain
62-
__HAL_RCC_BACKUPRESET_FORCE();
63-
__HAL_RCC_BACKUPRESET_RELEASE();
64-
6555
#if !DEVICE_RTC_LSI
6656
// Enable LSE Oscillator
6757
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
@@ -78,6 +68,16 @@ void rtc_init(void)
7868
error("Cannot initialize RTC with LSE\n");
7969
}
8070
#else
71+
// Enable Power clock
72+
__HAL_RCC_PWR_CLK_ENABLE();
73+
74+
// Enable access to Backup domain
75+
HAL_PWR_EnableBkUpAccess();
76+
77+
// Reset Backup domain
78+
__HAL_RCC_BACKUPRESET_FORCE();
79+
__HAL_RCC_BACKUPRESET_RELEASE();
80+
8181
// Enable LSI clock
8282
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
8383
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
@@ -116,6 +116,7 @@ void rtc_init(void)
116116

117117
void rtc_free(void)
118118
{
119+
#if DEVICE_RTC_LSI
119120
// Enable Power clock
120121
__HAL_RCC_PWR_CLK_ENABLE();
121122

@@ -128,6 +129,7 @@ void rtc_free(void)
128129

129130
// Disable access to Backup domain
130131
HAL_PWR_DisableBkUpAccess();
132+
#endif
131133

132134
// Disable LSI and LSE clocks
133135
RCC_OscInitTypeDef RCC_OscInitStruct;

0 commit comments

Comments
 (0)