8000 stm32/powerctrl: Save and restore EWUP state when configuring standby. · micropython/micropython@0facd89 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0facd89

Browse files
peterhinchdpgeorge
authored andcommitted
stm32/powerctrl: Save and restore EWUP state when configuring standby.
This allows the user to enable wake-up sources using the EWUP bits, on F7 MCUs. Disabling the wake-up sources while clearing the wake-up flags follows the reference manual and ST examples.
1 parent 85ea4ac commit 0facd89

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/stm32/powerctrl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,14 @@ void powerctrl_enter_standby_mode(void) {
712712
RTC->ISR &= ~ISR_BITS;
713713

714714
#if defined(STM32F7)
715+
// Save EWUP state
716+
uint32_t csr2_ewup = PWR->CSR2 & (PWR_CSR2_EWUP6 | PWR_CSR2_EWUP5 | PWR_CSR2_EWUP4 | PWR_CSR2_EWUP3 | PWR_CSR2_EWUP2 | PWR_CSR2_EWUP1);
715717
// disable wake-up flags
716718
PWR->CSR2 &= ~(PWR_CSR2_EWUP6 | PWR_CSR2_EWUP5 | PWR_CSR2_EWUP4 | PWR_CSR2_EWUP3 | PWR_CSR2_EWUP2 | PWR_CSR2_EWUP1);
717719
// clear global wake-up flag
718720
PWR->CR2 |= PWR_CR2_CWUPF6 | PWR_CR2_CWUPF5 | PWR_CR2_CWUPF4 | PWR_CR2_CWUPF3 | PWR_CR2_CWUPF2 | PWR_CR2_CWUPF1;
721+
// Restore EWUP state
722+
PWR->CSR2 |= csr2_ewup;
719723
#elif defined(STM32H7)
720724
EXTI_D1->PR1 = 0x3fffff;
721725
PWR->WKUPCR |= PWR_WAKEUP_FLAG1 | PWR_WAKEUP_FLAG2 | PWR_WAKEUP_FLAG3 | PWR_WAKEUP_FLAG4 | PWR_WAKEUP_FLAG5 | PWR_WAKEUP_FLAG6;

0 commit comments

Comments
 (0)
0