Skip to content

Commit 171d751

Browse files
meirarmondpgeorge
authored andcommitted
esp32/modesp32: Make wake_on_ext1 available only on SoCs supporting it.
The `esp32.wake_on_ext1()` method should only be available on boards that have SOC_PM_SUPPORT_EXT1_WAKEUP=y. And update docs to reflect this. Signed-off-by: Meir Armon <[email protected]>
1 parent 4697a06 commit 171d751

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

docs/library/esp32.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Functions
4141
or a tuple/list of valid Pin objects. *level* should be ``esp32.WAKEUP_ALL_LOW``
4242
or ``esp32.WAKEUP_ANY_HIGH``.
4343

44+
.. note:: This is only available for boards that have ext1 support.
45+
4446
.. function:: gpio_deep_sleep_hold(enable)
4547

4648
Configure whether non-RTC GPIO pin configuration is retained during

ports/esp32/machine_rtc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ _USER_MEM_ATTR uint8_t rtc_user_mem_data[MICROPY_HW_RTC_USER_MEM_MAX];
8282
static const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
8383

8484
machine_rtc_config_t machine_rtc_config = {
85+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
8586
.ext1_pins = 0,
87+
#endif
8688
#if SOC_PM_SUPPORT_EXT0_WAKEUP
8789
.ext0_pin = -1
8890
#endif

ports/esp32/machine_rtc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "modmachine.h"
3232

3333
typedef struct {
34+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
3435
uint64_t ext1_pins; // set bit == pin#
36+
#endif
3537
#if SOC_PM_SUPPORT_EXT0_WAKEUP
3638
int8_t ext0_pin; // just the pin#, -1 == None
3739
#endif
@@ -45,7 +47,9 @@ typedef struct {
4547
bool ext0_level : 1;
4648
wake_type_t ext0_wake_types;
4749
#endif
50+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
4851
bool ext1_level : 1;
52+
#endif
4953
} machine_rtc_config_t;
5054

5155
extern machine_rtc_config_t machine_rtc_config;

ports/esp32/modesp32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static mp_obj_t esp32_wake_on_ext0(size_t n_args, const mp_obj_t *pos_args, mp_m
9797
static MP_DEFINE_CONST_FUN_OBJ_KW(esp32_wake_on_ext0_obj, 0, esp32_wake_on_ext0);
9898
#endif
9999

100+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
100101
static mp_obj_t esp32_wake_on_ext1(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
101102
enum {ARG_pins, ARG_level};
102103
const mp_arg_t allowed_args[] = {
@@ -132,6 +133,7 @@ static mp_obj_t esp32_wake_on_ext1(size_t n_args, const mp_obj_t *pos_args, mp_m
132133
return mp_const_none;
133134
}
134135
static MP_DEFINE_CONST_FUN_OBJ_KW(esp32_wake_on_ext1_obj, 0, esp32_wake_on_ext1);
136+
#endif
135137

136138
#if SOC_ULP_SUPPORTED
137139
static mp_obj_t esp32_wake_on_ulp(const mp_obj_t wake) {
@@ -272,7 +274,9 @@ static const mp_rom_map_elem_t esp32_module_globals_table[] = {
272274
#if SOC_PM_SUPPORT_EXT0_WAKEUP
273275
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext0), MP_ROM_PTR(&esp32_wake_on_ext0_obj) },
274276
#endif
277+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
275278
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext1), MP_ROM_PTR(&esp32_wake_on_ext1_obj) },
279+
#endif
276280
#if SOC_ULP_SUPPORTED
277281
{ MP_ROM_QSTR(MP_QSTR_wake_on_ulp), MP_ROM_PTR(&esp32_wake_on_ulp_obj) },
278282
#endif

0 commit comments

Comments
 (0)