|
68 | 68 | # define RTC_ISR_RSF RTC_ICSR_RSF |
69 | 69 | # define RTC_ISR_INIT RTC_ICSR_INIT |
70 | 70 | # define RTC_ISR_INITF RTC_ICSR_INITF |
| 71 | +# define RTC_ISR_INITS RTC_ICSR_INITS |
71 | 72 | # define RTC_ISR_ALRAWF RTC_ICSR_ALRAWF |
72 | 73 | # define RTC_ISR_ALRAF RTC_SR_ALRAF |
73 | 74 | #elif defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32WL) |
|
77 | 78 | # define RTC_ISR_RSF RTC_ICSR_RSF |
78 | 79 | # define RTC_ISR_INIT RTC_ICSR_INIT |
79 | 80 | # define RTC_ISR_INITF RTC_ICSR_INITF |
| 81 | +# define RTC_ISR_INITS RTC_ICSR_INITS |
80 | 82 | #elif defined(CPU_FAM_STM32U5) |
81 | 83 | # define RTC_REG_ISR RTC->ICSR |
82 | 84 | # define RTC_REG_SR RTC->SR |
83 | 85 | # define RTC_REG_SCR RTC->SCR |
84 | 86 | # define RTC_ISR_RSF RTC_ICSR_RSF |
85 | 87 | # define RTC_ISR_INIT RTC_ICSR_INIT |
86 | 88 | # define RTC_ISR_INITF RTC_ICSR_INITF |
| 89 | +# define RTC_ISR_INITS RTC_ICSR_INITS |
87 | 90 | # define RTC_ISR_ALRAF RTC_SR_ALRAF |
88 | 91 | #else |
89 | 92 | # define RTC_REG_ISR RTC->ISR |
@@ -251,7 +254,7 @@ static inline void rtc_exit_init_mode(void) |
251 | 254 | while (RTC_REG_ISR & RTC_ISR_INITF) {} |
252 | 255 | } |
253 | 256 |
|
254 | | -static inline void rtc_lock(void) |
| 257 | +void rtc_lock(void) |
255 | 258 | { |
256 | 259 | /* lock RTC device */ |
257 | 260 | RTC->WPR = 0xff; |
@@ -339,17 +342,12 @@ int rtc_set_time(struct tm *time) |
339 | 342 | int rtc_get_time(struct tm *time) |
340 | 343 | { |
341 | 344 | #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(); |
347 | 347 | RTC->ICSR &= ~RTC_ICSR_RSF; |
| 348 | + rtc_lock(); |
348 | 349 |
|
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 */ |
353 | 351 | while (!(RTC_REG_ISR & RTC_ICSR_RSF)) {}; |
354 | 352 | #endif |
355 | 353 |
|
|
0 commit comments