drivers: rtc: Fix RTC alarm when using both CONFIG_COUNTER and CONFIG_PM
It is found that when we use CONFIG_COUNTER and CONFIG_PM concurrently, the RTC alarm callback can be used only once (in some cases, it just won't work at all, e.g., using CONFIG_BT). By set the DBP bit on PWR control register 1 via LL_PWR_EnableBkUpAccess function to temporarily disable write protection every time we assign RTC alarm, we can register alarm callback correctly. Tested on Nucleo WB55RG. Fixes: #68673 Signed-off-by: Krisna Resi <krisna_resi@ymail.com>
This commit is contained in:
parent
0907aff2ae
commit
7dd7175336
|
@ -240,6 +240,12 @@ tick_t rtc_stm32_read(const struct device *dev)
|
|||
#endif /* CONFIG_COUNTER_RTC_STM32_SUBSECONDS */
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
/* Enable Backup access */
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || \
|
||||
defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
/* Read time and date registers. Make sure value of the previous register
|
||||
* hasn't been changed while reading the next one.
|
||||
*/
|
||||
|
@ -295,6 +301,12 @@ tick_t rtc_stm32_read(const struct device *dev)
|
|||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
/* Enable Backup access */
|
||||
#if defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || \
|
||||
defined(PWR_DBPCR_DBP) || defined(PWR_DBPR_DBP)
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
#endif /* PWR_CR_DBP || PWR_CR1_DBP || PWR_DBPR_DBP */
|
||||
|
||||
rtc_time = LL_RTC_TIME_Get(RTC);
|
||||
|
||||
ticks = rtc_time;
|
||||
|
|
Loading…
Reference in a new issue