Skip to content

Commit cec2eb2

Browse files
committed
fixup! fixup! cpu/stm32/periph/rtc: don't stop RTC for every lock
1 parent e3946b7 commit cec2eb2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

cpu/stm32/periph/rtc_all.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,29 +275,33 @@ void rtc_init(void)
275275
RTC->BKP0R = MAGIC_CLCK_NUMBER; /* Store the new magic number */
276276
}
277277
#endif
278-
stmclk_dbp_lock();
279-
280-
if (!(RTC_REG_ISR & RTC_ISR_INITS))
281-
{
282-
/* enable low frequency clock */
283-
stmclk_enable_lfclk();
278+
/* enable low frequency clock */
279+
stmclk_enable_lfclk();
284280

285-
/* select input clock and enable the RTC */
286-
stmclk_dbp_unlock();
281+
/* select input clock and enable the RTC */
282+
stmclk_dbp_unlock();
287283
#if defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32WL)
288-
periph_clk_en(APB1, RCC_APB1ENR1_RTCAPBEN);
284+
periph_clk_en(APB1, RCC_APB1ENR1_RTCAPBEN);
289285
#elif defined(CPU_FAM_STM32G0)
290-
periph_clk_en(APB1, RCC_APBENR1_RTCAPBEN);
286+
periph_clk_en(APB1, RCC_APBENR1_RTCAPBEN);
291287
#elif defined(CPU_FAM_STM32U5)
292-
periph_clk_en(APB3, RCC_APB3ENR_RTCAPBEN);
288+
periph_clk_en(APB3, RCC_APB3ENR_RTCAPBEN);
293289
#endif
294-
EN_REG &= ~(CLKSEL_MASK);
290+
295291
#if IS_ACTIVE(CONFIG_BOARD_HAS_LSE)
292+
if ((EN_REG & (CLKSEL_MASK | EN_BIT)) != (CLKSEL_LSE | EN_BIT)) {
293+
EN_REG &= ~(CLKSEL_MASK);
296294
EN_REG |= (CLKSEL_LSE | EN_BIT);
295+
}
297296
#else
297+
if ((EN_REG & (CLKSEL_MASK | EN_BIT)) != (CLKSEL_LSI | EN_BIT)) {
298+
EN_REG &= ~(CLKSEL_MASK);
298299
EN_REG |= (CLKSEL_LSI | EN_BIT);
300+
}
299301
#endif
300302

303+
if (!(RTC_REG_ISR & RTC_ISR_INITS))
304+
{
301305
rtc_unlock();
302306
/* reset configuration */
303307
RTC->CR = 0;

0 commit comments

Comments
 (0)