Skip to content

Commit 26e3c61

Browse files
adustm0xc0170
authored andcommitted
[STM all] Fix #1480: change location of check for RTC already initialised
Need to keep PWR_CLK_ENABLE and LSE LSI oscillator configuration. Just skip the HAL_RTC_Init in case INITS flag is already set.
1 parent 42ceddf commit 26e3c61

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ void rtc_init(void) {
4545
rtc_inited = 1;
4646

4747
RtcHandle.Instance = RTC;
48-
49-
// Check if RTC is already initialized
50-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
5148

5249
// Enable Power clock
5350
__PWR_CLK_ENABLE();
@@ -82,6 +79,9 @@ void rtc_init(void) {
8279
rtc_freq = LSI_VALUE;
8380
}
8481

82+
// Check if RTC is already initialized
83+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
84+
8585
// Enable RTC
8686
__HAL_RCC_RTC_ENABLE();
8787

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void rtc_init(void)
4646
rtc_inited = 1;
4747

4848
RtcHandle.Instance = RTC;
49-
50-
// Check if RTC is already initialized
51-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
5249

5350
// Enable Power clock
5451
__PWR_CLK_ENABLE();
@@ -83,6 +80,9 @@ void rtc_init(void)
8380
rtc_freq = LSI_VALUE;
8481
}
8582

83+
// Check if RTC is already initialized
84+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
85+
8686
// Enable RTC
8787
__HAL_RCC_RTC_ENABLE();
8888

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void rtc_init(void)
4646
rtc_inited = 1;
4747

4848
RtcHandle.Instance = RTC;
49-
50-
// Check if RTC is already initialized
51-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
5249

5350
// Enable Power clock
5451
__PWR_CLK_ENABLE();
@@ -85,6 +82,9 @@ void rtc_init(void)
8582
rtc_freq = LSI_VALUE;
8683
}
8784

85+
// Check if RTC is already initialized
86+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
87+
8888
// Enable RTC
8989
__HAL_RCC_RTC_ENABLE();
9090

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ void rtc_init(void)
4040
RCC_OscInitTypeDef RCC_OscInitStruct;
4141
uint32_t rtc_freq = 0;
4242

43-
if((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value
44-
4543
RtcHandle.Instance = RTC;
4644

4745
// Enable Power clock
@@ -79,6 +77,8 @@ void rtc_init(void)
7977
rtc_freq = LSI_VALUE;
8078
}
8179

80+
if((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value
81+
8282
// Enable RTC
8383
__HAL_RCC_RTC_ENABLE();
8484

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ void rtc_init(void)
5454
rtc_inited = 1;
5555

5656
RtcHandle.Instance = RTC;
57-
58-
// Check if RTC is already initialized
59-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
6057

6158
// Enable Power clock
6259
__PWR_CLK_ENABLE();
@@ -97,6 +94,9 @@ void rtc_init(void)
9794
}
9895
#endif
9996

97+
// Check if RTC is already initialized
98+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
99+
100100
// Enable RTC
101101
__HAL_RCC_RTC_ENABLE();
102102

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void rtc_init(void)
4646
rtc_inited = 1;
4747

4848
RtcHandle.Instance = RTC;
49-
50-
// Check if RTC is already initialized
51-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
5249

5350
// Enable Power clock
5451
__PWR_CLK_ENABLE();
@@ -85,6 +82,9 @@ void rtc_init(void)
8582
rtc_freq = 32000;
8683
}
8784

85+
// Check if RTC is already initialized
86+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
87+
8888
// Enable RTC
8989
__HAL_RCC_RTC_ENABLE();
9090

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void rtc_init(void)
4646
rtc_inited = 1;
4747

4848
RtcHandle.Instance = RTC;
49-
50-
// Check if RTC is already initialized
51-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
5249

5350
// Enable Power clock
5451
__PWR_CLK_ENABLE();
@@ -85,6 +82,9 @@ void rtc_init(void)
8582
rtc_freq = 32000;
8683
}
8784

85+
// Check if RTC is already initialized
86+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
87+
8888
// Enable RTC
8989
__HAL_RCC_RTC_ENABLE();
9090

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ void rtc_init(void)
4646
rtc_inited = 1;
4747

4848
RtcHandle.Instance = RTC;
49-
50-
// Check if RTC is already initialized
51-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
5249

5350
// Enable Power clock
5451
__PWR_CLK_ENABLE();
@@ -85,6 +82,9 @@ void rtc_init(void)
8582
rtc_freq = 40000;
8683
}
8784

85+
// Check if RTC is already initialized
86+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
87+
8888
// Enable RTC
8989
__HAL_RCC_RTC_ENABLE();
9090

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ void rtc_init(void)
4848

4949
RtcHandle.Instance = RTC;
5050

51-
// Check if RTC is already initialized
52-
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
53-
5451
// Enable Power clock
5552
__HAL_RCC_PWR_CLK_ENABLE();
5653

@@ -91,6 +88,9 @@ void rtc_init(void)
9188
rtc_freq = 40000;
9289
}
9390

91+
// Check if RTC is already initialized
92+
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
93+
9494
// Enable RTC
9595
__HAL_RCC_RTC_ENABLE();
9696

0 commit comments

Comments
 (0)