Skip to content

Commit e2cb35e

Browse files
dbestm0xc0170
authored andcommitted
[XXX_F746XG] Move erasing of BkUpR in RTC API
The erasing of back up register is only needed when using LSI in RTC API
1 parent b3e2dc9 commit e2cb35e

File tree

1 file changed

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

1 file changed

+12
-10
lines changed

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

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

4747
RtcHandle.Instance = RTC;
4848

49-
// Enable Power clock
50-
__PWR_CLK_ENABLE();
51-
52-
// Enable access to Backup domain
53-
HAL_PWR_EnableBkUpAccess();
54-
55-
// Reset Backup domain
56-
__HAL_RCC_BACKUPRESET_FORCE();
57-
__HAL_RCC_BACKUPRESET_RELEASE();
58-
5949
#if !DEVICE_RTC_LSI
6050
// Enable LSE Oscillator
6151
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
@@ -71,6 +61,16 @@ void rtc_init(void)
7161
error("Cannot initialize RTC with LSE\n");
7262
}
7363
#else
64+
// Enable Power clock
65+
__PWR_CLK_ENABLE();
66+
67+
// Enable access to Backup domain
68+
HAL_PWR_EnableBkUpAccess();
69+
70+
// Reset Backup domain
71+
__HAL_RCC_BACKUPRESET_FORCE();
72+
__HAL_RCC_BACKUPRESET_RELEASE();
73+
7474
// Enable LSI clock
7575
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
7676
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
@@ -103,6 +103,7 @@ void rtc_init(void)
103103

104104
void rtc_free(void)
105105
{
106+
#if DEVICE_RTC_LSI
106107
// Enable Power clock
107108
__PWR_CLK_ENABLE();
108109

@@ -115,6 +116,7 @@ void rtc_free(void)
115116

116117
// Disable access to Backup domain
117118
HAL_PWR_DisableBkUpAccess();
119+
#endif
118120

119121
// Disable LSI and LSE clocks
120122
RCC_OscInitTypeDef RCC_OscInitStruct;

0 commit comments

Comments
 (0)