Browse Source

stm32/powerctrl: Add support for standby mode on L4 MCUs.

This maps to machine.deepsleep() which is now supported.
pull/4088/head
Damien George 6 years ago
parent
commit
c6365ffb92
  1. 4
      ports/stm32/modmachine.c
  2. 6
      ports/stm32/powerctrl.c

4
ports/stm32/modmachine.c

@ -330,11 +330,7 @@ STATIC mp_obj_t machine_sleep(void) {
MP_DEFINE_CONST_FUN_OBJ_0(machine_sleep_obj, machine_sleep);
STATIC mp_obj_t machine_deepsleep(void) {
#if defined(STM32L4)
printf("machine.deepsleep not supported yet\n");
#else
powerctrl_enter_standby_mode();
#endif
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_deepsleep_obj, machine_deepsleep);

6
ports/stm32/powerctrl.c

@ -340,7 +340,6 @@ void powerctrl_enter_stop_mode(void) {
enable_irq(irq_state);
}
#if !defined(STM32L4)
void powerctrl_enter_standby_mode(void) {
rtc_init_finalise();
@ -376,6 +375,10 @@ void powerctrl_enter_standby_mode(void) {
PWR->CR2 |= PWR_CR2_CWUPF6 | PWR_CR2_CWUPF5 | PWR_CR2_CWUPF4 | PWR_CR2_CWUPF3 | PWR_CR2_CWUPF2 | PWR_CR2_CWUPF1;
#elif defined(STM32H7)
// TODO
#elif defined(STM32L4)
// clear all wake-up flags
PWR->SCR |= PWR_SCR_CWUF5 | PWR_SCR_CWUF4 | PWR_SCR_CWUF3 | PWR_SCR_CWUF2 | PWR_SCR_CWUF1;
// TODO
#else
// clear global wake-up flag
PWR->CR |= PWR_CR_CWUF;
@ -388,4 +391,3 @@ void powerctrl_enter_standby_mode(void) {
HAL_PWR_EnterSTANDBYMode();
// we never return; MCU is reset on exit from standby
}
#endif

Loading…
Cancel
Save