diff options
author | Damien George <damien.p.george@gmail.com> | 2019-07-03 01:04:25 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-07-03 01:27:33 +1000 |
commit | ea033bf25a08c26b8b43fc316c797ae6526a894f (patch) | |
tree | e856f3b1dfa5e31a34cdfc10758fbbb01be80834 | |
parent | 8cde5faedd63ea1b21b7adef87e50e6a036c7e5a (diff) |
stm32/powerctrl: Add hooks for a board to perform actions on sleep/wake.
-rw-r--r-- | ports/stm32/powerctrl.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ports/stm32/powerctrl.c b/ports/stm32/powerctrl.c index 2ad242600..e3ad20039 100644 --- a/ports/stm32/powerctrl.c +++ b/ports/stm32/powerctrl.c @@ -324,6 +324,10 @@ void powerctrl_enter_stop_mode(void) { // executed until after the clocks are reconfigured uint32_t irq_state = disable_irq(); + #if defined(MICROPY_BOARD_ENTER_STOP) + MICROPY_BOARD_ENTER_STOP + #endif + #if defined(STM32L4) // Configure the MSI as the clock source after waking up __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI); @@ -399,6 +403,10 @@ void powerctrl_enter_stop_mode(void) { #endif + #if defined(MICROPY_BOARD_LEAVE_STOP) + MICROPY_BOARD_LEAVE_STOP + #endif + // Enable IRQs now that all clocks are reconfigured enable_irq(irq_state); } @@ -406,6 +414,10 @@ void powerctrl_enter_stop_mode(void) { void powerctrl_enter_standby_mode(void) { rtc_init_finalise(); + #if defined(MICROPY_BOARD_ENTER_STANDBY) + MICROPY_BOARD_ENTER_STANDBY + #endif + // We need to clear the PWR wake-up-flag before entering standby, since // the flag may have been set by a previous wake-up event. Furthermore, // we need to disable the wake-up sources while clearing this flag, so |