You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@mynewt.apache.org by "kasjer (via GitHub)" <gi...@apache.org> on 2025/11/05 17:34:23 UTC
[PR] mcu/stm32: Fix hal_nvreg for STM32F1 [mynewt-core]
kasjer opened a new pull request, #3538:
URL: https://github.com/apache/mynewt-core/pull/3538
This fixes 3 issues for hal_nvreg for STM32F1 devices.
- STM32F1 registers are 16 bits not 32 like in other series.
- Backup registers for ST HAL for STM32F1 start from 1 not 0.
- PWR clock needs to be turned on if it was not before
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] mcu/stm32: Fix hal_nvreg for STM32F1 [mynewt-core]
Posted by "sjanc (via GitHub)" <gi...@apache.org>.
sjanc commented on code in PR #3538:
URL: https://github.com/apache/mynewt-core/pull/3538#discussion_r2536808541
##########
hw/mcu/stm/stm32_common/src/hal_nvreg.c:
##########
@@ -30,23 +32,38 @@
#define HAL_NVREG_MAX (0)
#endif
+#if MYNEWT_VAL_MCU_STM32F1
+#define HAL_NVREG_WIDTH_BYTES 2
+#define HAL_NVREG_START_INDEX 1
+#else
/* RTC backup registers are 32-bits wide */
#define HAL_NVREG_WIDTH_BYTES (4)
+#define HAL_NVREG_START_INDEX 0
+#endif
void
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_PWR_IS_CLK_ENABLED)
+ bool disable_pwr = __HAL_RCC_PWR_IS_CLK_ENABLED();
Review Comment:
this looks like there is `!` missing in condition, ie to disable only if it wasn't already enabled
also, for parity I'd put both enable() and disable() calls under same condition
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] mcu/stm32: Fix hal_nvreg for STM32F1 [mynewt-core]
Posted by "kasjer (via GitHub)" <gi...@apache.org>.
kasjer commented on code in PR #3538:
URL: https://github.com/apache/mynewt-core/pull/3538#discussion_r2539533302
##########
hw/mcu/stm/stm32_common/src/hal_nvreg.c:
##########
@@ -30,23 +32,38 @@
#define HAL_NVREG_MAX (0)
#endif
+#if MYNEWT_VAL_MCU_STM32F1
+#define HAL_NVREG_WIDTH_BYTES 2
+#define HAL_NVREG_START_INDEX 1
+#else
/* RTC backup registers are 32-bits wide */
#define HAL_NVREG_WIDTH_BYTES (4)
+#define HAL_NVREG_START_INDEX 0
+#endif
void
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_PWR_IS_CLK_ENABLED)
+ bool disable_pwr = __HAL_RCC_PWR_IS_CLK_ENABLED();
Review Comment:
changed to be consistent and corrected, thanks you for noticing this mistake
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] mcu/stm32: Fix hal_nvreg for STM32F1 [mynewt-core]
Posted by "kasjer (via GitHub)" <gi...@apache.org>.
kasjer merged PR #3538:
URL: https://github.com/apache/mynewt-core/pull/3538
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org