Skip to content

Commit

Permalink
stm32/powerctrl: Disable RTC write protection before changing flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
iabdalkader authored and dpgeorge committed Dec 7, 2020
1 parent 463a275 commit 8add94e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ports/stm32/powerctrl.c
Expand Up @@ -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;

Expand All @@ -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"
Expand Down

0 comments on commit 8add94e

Please sign in to comment.