stm32/powerctrl: Add support for standby mode on L4 MCUs.
This maps to machine.deepsleep() which is now supported.
This commit is contained in:
parent
a1c81761b1
commit
c6365ffb92
@ -330,11 +330,7 @@ STATIC mp_obj_t machine_sleep(void) {
|
|||||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_sleep_obj, machine_sleep);
|
MP_DEFINE_CONST_FUN_OBJ_0(machine_sleep_obj, machine_sleep);
|
||||||
|
|
||||||
STATIC mp_obj_t machine_deepsleep(void) {
|
STATIC mp_obj_t machine_deepsleep(void) {
|
||||||
#if defined(STM32L4)
|
|
||||||
printf("machine.deepsleep not supported yet\n");
|
|
||||||
#else
|
|
||||||
powerctrl_enter_standby_mode();
|
powerctrl_enter_standby_mode();
|
||||||
#endif
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_deepsleep_obj, machine_deepsleep);
|
MP_DEFINE_CONST_FUN_OBJ_0(machine_deepsleep_obj, machine_deepsleep);
|
||||||
|
@ -340,7 +340,6 @@ void powerctrl_enter_stop_mode(void) {
|
|||||||
enable_irq(irq_state);
|
enable_irq(irq_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(STM32L4)
|
|
||||||
void powerctrl_enter_standby_mode(void) {
|
void powerctrl_enter_standby_mode(void) {
|
||||||
rtc_init_finalise();
|
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;
|
PWR->CR2 |= PWR_CR2_CWUPF6 | PWR_CR2_CWUPF5 | PWR_CR2_CWUPF4 | PWR_CR2_CWUPF3 | PWR_CR2_CWUPF2 | PWR_CR2_CWUPF1;
|
||||||
#elif defined(STM32H7)
|
#elif defined(STM32H7)
|
||||||
// TODO
|
// 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
|
#else
|
||||||
// clear global wake-up flag
|
// clear global wake-up flag
|
||||||
PWR->CR |= PWR_CR_CWUF;
|
PWR->CR |= PWR_CR_CWUF;
|
||||||
@ -388,4 +391,3 @@ void powerctrl_enter_standby_mode(void) {
|
|||||||
HAL_PWR_EnterSTANDBYMode();
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
// we never return; MCU is reset on exit from standby
|
// we never return; MCU is reset on exit from standby
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user