@@ -53,7 +53,11 @@ void rtc_init(void)
53
53
__HAL_RCC_PWR_CLK_ENABLE ();
54
54
HAL_PWR_EnableBkUpAccess ();
55
55
56
+ #if DEVICE_LOWPOWERTIMER
57
+ if ( (rtc_isenabled ()) && ((RTC -> PRER & RTC_PRER_PREDIV_S ) == PREDIV_S_VALUE ) ) {
58
+ #else /* DEVICE_LOWPOWERTIMER */
56
59
if (rtc_isenabled ()) {
60
+ #endif /* DEVICE_LOWPOWERTIMER */
57
61
return ;
58
62
}
59
63
@@ -107,19 +111,8 @@ void rtc_init(void)
107
111
RtcHandle .Init .AsynchPrediv = RTC_AUTO_1_SECOND ;
108
112
#else /* TARGET_STM32F1 */
109
113
RtcHandle .Init .HourFormat = RTC_HOURFORMAT_24 ;
110
-
111
- /* PREDIV_A : 7-bit asynchronous prescaler */
112
- #if DEVICE_LOWPOWERTIMER && !MBED_CONF_TARGET_LOWPOWERTIMER_LPTIM
113
- /* PREDIV_A is set to a small value to improve the SubSeconds resolution */
114
- /* with a 32768Hz clock, PREDIV_A=7 gives a precision of 244us */
115
- RtcHandle .Init .AsynchPrediv = 7 ;
116
- #else
117
- /* PREDIV_A is set to the maximum value to improve the consumption */
118
- RtcHandle .Init .AsynchPrediv = 0x007F ;
119
- #endif
120
- /* PREDIV_S : 15-bit synchronous prescaler */
121
- /* PREDIV_S is set in order to get a 1 Hz clock */
122
- RtcHandle .Init .SynchPrediv = RTC_CLOCK / (RtcHandle .Init .AsynchPrediv + 1 ) - 1 ;
114
+ RtcHandle .Init .AsynchPrediv = PREDIV_A_VALUE ;
115
+ RtcHandle .Init .SynchPrediv = PREDIV_S_VALUE ;
123
116
RtcHandle .Init .OutPut = RTC_OUTPUT_DISABLE ;
124
117
RtcHandle .Init .OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH ;
125
118
RtcHandle .Init .OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN ;
0 commit comments