esp32/modesp32: Add wake_on_ulp() so ULP can wake CPU from deepsleep.
Add esp32.wake_on_ulp() to give access to esp_sleep_enable_ulp_wakeup(), which is needed to allow the ULP co-processor to wake the main CPU from deep sleep.
This commit is contained in:
parent
cf550ad9d1
commit
ba21f76f89
@ -18,6 +18,11 @@ Functions
|
|||||||
Configure whether or not a touch will wake the device from sleep.
|
Configure whether or not a touch will wake the device from sleep.
|
||||||
*wake* should be a boolean value.
|
*wake* should be a boolean value.
|
||||||
|
|
||||||
|
.. function:: wake_on_ulp(wake)
|
||||||
|
|
||||||
|
Configure whether or not the Ultra-Low-Power co-processor can wake the
|
||||||
|
device from sleep. *wake* should be a boolean value.
|
||||||
|
|
||||||
.. function:: wake_on_ext0(pin, level)
|
.. function:: wake_on_ext0(pin, level)
|
||||||
|
|
||||||
Configure how EXT0 wakes the device from sleep. *pin* can be ``None``
|
Configure how EXT0 wakes the device from sleep. *pin* can be ``None``
|
||||||
|
@ -34,6 +34,7 @@ typedef struct {
|
|||||||
uint64_t ext1_pins; // set bit == pin#
|
uint64_t ext1_pins; // set bit == pin#
|
||||||
int8_t ext0_pin; // just the pin#, -1 == None
|
int8_t ext0_pin; // just the pin#, -1 == None
|
||||||
bool wake_on_touch : 1;
|
bool wake_on_touch : 1;
|
||||||
|
bool wake_on_ulp : 1;
|
||||||
bool ext0_level : 1;
|
bool ext0_level : 1;
|
||||||
wake_type_t ext0_wake_types;
|
wake_type_t ext0_wake_types;
|
||||||
bool ext1_level : 1;
|
bool ext1_level : 1;
|
||||||
|
@ -131,6 +131,15 @@ STATIC mp_obj_t esp32_wake_on_ext1(size_t n_args, const mp_obj_t *pos_args, mp_m
|
|||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp32_wake_on_ext1_obj, 0, esp32_wake_on_ext1);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp32_wake_on_ext1_obj, 0, esp32_wake_on_ext1);
|
||||||
|
|
||||||
|
STATIC mp_obj_t esp32_wake_on_ulp(const mp_obj_t wake) {
|
||||||
|
if (machine_rtc_config.ext0_pin != -1) {
|
||||||
|
mp_raise_ValueError(MP_ERROR_TEXT("no resources"));
|
||||||
|
}
|
||||||
|
machine_rtc_config.wake_on_ulp = mp_obj_is_true(wake);
|
||||||
|
return mp_const_none;
|
||||||
|
}
|
||||||
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp32_wake_on_ulp_obj, esp32_wake_on_ulp);
|
||||||
|
|
||||||
STATIC mp_obj_t esp32_gpio_deep_sleep_hold(const mp_obj_t enable) {
|
STATIC mp_obj_t esp32_gpio_deep_sleep_hold(const mp_obj_t enable) {
|
||||||
if (mp_obj_is_true(enable)) {
|
if (mp_obj_is_true(enable)) {
|
||||||
gpio_deep_sleep_hold_en();
|
gpio_deep_sleep_hold_en();
|
||||||
@ -197,6 +206,7 @@ STATIC const mp_rom_map_elem_t esp32_module_globals_table[] = {
|
|||||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_touch), MP_ROM_PTR(&esp32_wake_on_touch_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_wake_on_touch), MP_ROM_PTR(&esp32_wake_on_touch_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext0), MP_ROM_PTR(&esp32_wake_on_ext0_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext0), MP_ROM_PTR(&esp32_wake_on_ext0_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext1), MP_ROM_PTR(&esp32_wake_on_ext1_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext1), MP_ROM_PTR(&esp32_wake_on_ext1_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_wake_on_ulp), MP_ROM_PTR(&esp32_wake_on_ulp_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_gpio_deep_sleep_hold), MP_ROM_PTR(&esp32_gpio_deep_sleep_hold_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_gpio_deep_sleep_hold), MP_ROM_PTR(&esp32_gpio_deep_sleep_hold_obj) },
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
{ MP_ROM_QSTR(MP_QSTR_raw_temperature), MP_ROM_PTR(&esp32_raw_temperature_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_raw_temperature), MP_ROM_PTR(&esp32_raw_temperature_obj) },
|
||||||
|
@ -144,6 +144,12 @@ STATIC mp_obj_t machine_sleep_helper(wake_type_t wake_type, size_t n_args, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (machine_rtc_config.wake_on_ulp) {
|
||||||
|
if (esp_sleep_enable_ulp_wakeup() != ESP_OK) {
|
||||||
|
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("esp_sleep_enable_ulp_wakeup() failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (wake_type) {
|
switch (wake_type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user