This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new bf87c1f05 stm32/hal_nvreg: Fix access for stm32u5xx devices
bf87c1f05 is described below
commit bf87c1f0599cd41f86b64dcf58ab11fa40ef78ad
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Mar 18 08:34:34 2026 +0100
stm32/hal_nvreg: Fix access for stm32u5xx devices
RTCAPB clock needs to be enable for hal_nvreg functionality.
Signed-off-by: Jerzy Kasenberg <[email protected]>
---
hw/mcu/stm/stm32_common/src/hal_nvreg.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/mcu/stm/stm32_common/src/hal_nvreg.c
b/hw/mcu/stm/stm32_common/src/hal_nvreg.c
index 5b3cdfb5f..af02de2df 100644
--- a/hw/mcu/stm/stm32_common/src/hal_nvreg.c
+++ b/hw/mcu/stm/stm32_common/src/hal_nvreg.c
@@ -55,6 +55,8 @@ hal_nvreg_write(unsigned int reg, uint32_t val)
#endif
#if defined(__HAL_RCC_BKP_CLK_ENABLE)
__HAL_RCC_BKP_CLK_ENABLE();
+#elif defined(__HAL_RCC_RTCAPB_CLK_ENABLE)
+ __HAL_RCC_RTCAPB_CLK_ENABLE();
#endif
HAL_PWR_EnableBkUpAccess();
HAL_RTCEx_BKUPWrite(&hrtc, reg + HAL_NVREG_START_INDEX, val);
@@ -78,6 +80,11 @@ hal_nvreg_read(unsigned int reg)
#if PWR_ENABLED
RTC_HandleTypeDef hrtc = { .Instance = RTC };
if (reg < HAL_NVREG_MAX) {
+#if defined(__HAL_RCC_BKP_CLK_ENABLE)
+ __HAL_RCC_BKP_CLK_ENABLE();
+#elif defined(__HAL_RCC_RTCAPB_CLK_ENABLE)
+ __HAL_RCC_RTCAPB_CLK_ENABLE();
+#endif
HAL_PWR_EnableBkUpAccess();
val = HAL_RTCEx_BKUPRead(&hrtc, reg + HAL_NVREG_START_INDEX);
HAL_PWR_DisableBkUpAccess();