summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2020-12-02 23:35:58 +0200
committerDamien George <damien@micropython.org>2020-12-07 17:00:21 +1100
commit8add94e94e906ecf6c46d49127a8a0590be308b8 (patch)
tree108970a51c1285744da215af129a5a862ab64805
parent463a275bc4e99a1d37d523a120fe45976ea021fe (diff)
stm32/powerctrl: Disable RTC write protection before changing flags.
-rw-r--r--ports/stm32/powerctrl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ports/stm32/powerctrl.c b/ports/stm32/powerctrl.c
index c36351e31..ce2f6e190 100644
--- a/ports/stm32/powerctrl.c
+++ b/ports/stm32/powerctrl.c
@@ -689,6 +689,10 @@ void powerctrl_enter_standby_mode(void) {
// save RTC interrupts
uint32_t save_irq_bits = RTC->CR & CR_BITS;
+ // disable register write protection
+ RTC->WPR = 0xca;
+ RTC->WPR = 0x53;
+
// disable RTC interrupts
RTC->CR &= ~CR_BITS;
@@ -714,6 +718,9 @@ void powerctrl_enter_standby_mode(void) {
// enable previously-enabled RTC interrupts
RTC->CR |= save_irq_bits;
+ // enable register write protection
+ RTC->WPR = 0xff;
+
#if defined(STM32F7)
// Enable the internal (eg RTC) wakeup sources
// See Errata 2.2.2 "Wakeup from Standby mode when the back-up SRAM regulator is enabled"