Skip to content

Commit 85af6be

Browse files
committed
fixup! cpu/stm32/periph/rtc: fix issue #8746
1 parent 459c363 commit 85af6be

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

cpu/stm32/periph/rtc_all.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
# define RTC_ISR_RSF RTC_ICSR_RSF
6969
# define RTC_ISR_INIT RTC_ICSR_INIT
7070
# define RTC_ISR_INITF RTC_ICSR_INITF
71+
# define RTC_ISR_INITS RTC_ICSR_INITS
7172
# define RTC_ISR_ALRAWF RTC_ICSR_ALRAWF
7273
# define RTC_ISR_ALRAF RTC_SR_ALRAF
7374
#elif defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32WL)
@@ -77,13 +78,15 @@
7778
# define RTC_ISR_RSF RTC_ICSR_RSF
7879
# define RTC_ISR_INIT RTC_ICSR_INIT
7980
# define RTC_ISR_INITF RTC_ICSR_INITF
81+
# define RTC_ISR_INITS RTC_ICSR_INITS
8082
#elif defined(CPU_FAM_STM32U5)
8183
# define RTC_REG_ISR RTC->ICSR
8284
# define RTC_REG_SR RTC->SR
8385
# define RTC_REG_SCR RTC->SCR
8486
# define RTC_ISR_RSF RTC_ICSR_RSF
8587
# define RTC_ISR_INIT RTC_ICSR_INIT
8688
# define RTC_ISR_INITF RTC_ICSR_INITF
89+
# define RTC_ISR_INITS RTC_ICSR_INITS
8790
# define RTC_ISR_ALRAF RTC_SR_ALRAF
8891
#else
8992
# define RTC_REG_ISR RTC->ISR
@@ -251,7 +254,7 @@ static inline void rtc_exit_init_mode(void)
251254
while (RTC_REG_ISR & RTC_ISR_INITF) {}
252255
}
253256

254-
static inline void rtc_lock(void)
257+
void rtc_lock(void)
255258
{
256259
/* lock RTC device */
257260
RTC->WPR = 0xff;
@@ -339,17 +342,12 @@ int rtc_set_time(struct tm *time)
339342
int rtc_get_time(struct tm *time)
340343
{
341344
#if defined(CPU_FAM_STM32WL)
342-
stmclk_dbp_unlock();
343-
/* unlock RTC */
344-
RTC->WPR = WPK1;
345-
RTC->WPR = WPK2;
346-
345+
/* after waking up from standby, the RSF flag has to be manually cleared */
346+
rtc_unlock();
347347
RTC->ICSR &= ~RTC_ICSR_RSF;
348+
rtc_lock();
348349

349-
RTC->WPR = 0xff;
350-
stmclk_dbp_lock();
351-
352-
/* waiting for the RSF bit to be set again */
350+
/* waiting for the RSF bit to be set again before accessing the time */
353351
while (!(RTC_REG_ISR & RTC_ICSR_RSF)) {};
354352
#endif
355353

0 commit comments

Comments
 (0)