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 5477f8fed mcu/stm32: Fix hal_nvreg_write for STM32F1
5477f8fed is described below

commit 5477f8fed4ffe0e1fb7efa5aaa13bbead6824b2e
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Sat Jun 8 16:46:14 2024 +0200

    mcu/stm32: Fix hal_nvreg_write for STM32F1
    
    Writing to backup registers requires enabling BPK_CLK.
    For read it does not seem to be needed.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/mcu/stm/stm32_common/src/hal_nvreg.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/mcu/stm/stm32_common/src/hal_nvreg.c 
b/hw/mcu/stm/stm32_common/src/hal_nvreg.c
index c2953aa21..82b210745 100644
--- a/hw/mcu/stm/stm32_common/src/hal_nvreg.c
+++ b/hw/mcu/stm/stm32_common/src/hal_nvreg.c
@@ -39,9 +39,15 @@ hal_nvreg_write(unsigned int reg, uint32_t val)
 #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();
+#endif
         HAL_PWR_EnableBkUpAccess();
         HAL_RTCEx_BKUPWrite(&hrtc, reg, val);
         HAL_PWR_DisableBkUpAccess();
+#if defined(__HAL_RCC_BKP_CLK_DISABLE)
+        __HAL_RCC_BKP_CLK_DISABLE();
+#endif
     }
 #endif
 }

Reply via email to