mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 04:51:12 +02:00
esp32/modesp32: Make wake_on_ext0 available only on SoCs supporting it.
The `esp32.wake_on_ext0()` method should only be available on boards that have SOC_PM_SUPPORT_EXT0_WAKEUP=y. And update docs to reflect this. Signed-off-by: Meir Armon <meirarmon@gmail.com>
This commit is contained in:
committed by
Damien George
parent
cb315bb8e4
commit
4697a06fdb
@@ -33,6 +33,8 @@ Functions
|
||||
or a valid Pin object. *level* should be ``esp32.WAKEUP_ALL_LOW`` or
|
||||
``esp32.WAKEUP_ANY_HIGH``.
|
||||
|
||||
.. note:: This is only available for boards that have ext0 support.
|
||||
|
||||
.. function:: wake_on_ext1(pins, level)
|
||||
|
||||
Configure how EXT1 wakes the device from sleep. *pins* can be ``None``
|
||||
|
@@ -335,6 +335,7 @@ static mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("invalid pin for wake"));
|
||||
}
|
||||
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
if (machine_rtc_config.ext0_pin == -1) {
|
||||
machine_rtc_config.ext0_pin = index;
|
||||
} else if (machine_rtc_config.ext0_pin != index) {
|
||||
@@ -343,10 +344,13 @@ static mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
|
||||
machine_rtc_config.ext0_level = trigger == GPIO_INTR_LOW_LEVEL ? 0 : 1;
|
||||
machine_rtc_config.ext0_wake_types = wake;
|
||||
#endif
|
||||
} else {
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
if (machine_rtc_config.ext0_pin == index) {
|
||||
machine_rtc_config.ext0_pin = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (handler == mp_const_none) {
|
||||
handler = MP_OBJ_NULL;
|
||||
|
@@ -83,7 +83,9 @@ static const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
|
||||
|
||||
machine_rtc_config_t machine_rtc_config = {
|
||||
.ext1_pins = 0,
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
.ext0_pin = -1
|
||||
#endif
|
||||
};
|
||||
|
||||
static mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
|
@@ -32,15 +32,19 @@
|
||||
|
||||
typedef struct {
|
||||
uint64_t ext1_pins; // set bit == pin#
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
int8_t ext0_pin; // just the pin#, -1 == None
|
||||
#endif
|
||||
#if SOC_TOUCH_SENSOR_SUPPORTED
|
||||
bool wake_on_touch : 1;
|
||||
#endif
|
||||
#if SOC_ULP_SUPPORTED
|
||||
bool wake_on_ulp : 1;
|
||||
#endif
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
bool ext0_level : 1;
|
||||
wake_type_t ext0_wake_types;
|
||||
#endif
|
||||
bool ext1_level : 1;
|
||||
} machine_rtc_config_t;
|
||||
|
||||
|
@@ -60,6 +60,7 @@ static mp_obj_t esp32_wake_on_touch(const mp_obj_t wake) {
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(esp32_wake_on_touch_obj, esp32_wake_on_touch);
|
||||
#endif
|
||||
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
static mp_obj_t esp32_wake_on_ext0(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
||||
#if SOC_TOUCH_SENSOR_SUPPORTED
|
||||
@@ -94,6 +95,7 @@ static mp_obj_t esp32_wake_on_ext0(size_t n_args, const mp_obj_t *pos_args, mp_m
|
||||
return mp_const_none;
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(esp32_wake_on_ext0_obj, 0, esp32_wake_on_ext0);
|
||||
#endif
|
||||
|
||||
static mp_obj_t esp32_wake_on_ext1(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum {ARG_pins, ARG_level};
|
||||
@@ -267,7 +269,9 @@ static const mp_rom_map_elem_t esp32_module_globals_table[] = {
|
||||
#if SOC_TOUCH_SENSOR_SUPPORTED
|
||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_touch), MP_ROM_PTR(&esp32_wake_on_touch_obj) },
|
||||
#endif
|
||||
#if SOC_PM_SUPPORT_EXT0_WAKEUP
|
||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext0), MP_ROM_PTR(&esp32_wake_on_ext0_obj) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext1), MP_ROM_PTR(&esp32_wake_on_ext1_obj) },
|
||||
#if SOC_ULP_SUPPORTED
|
||||
{ MP_ROM_QSTR(MP_QSTR_wake_on_ulp), MP_ROM_PTR(&esp32_wake_on_ulp_obj) },
|
||||
|
Reference in New Issue
Block a user