Skip to content

Commit cb315bb

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

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

docs/library/esp32.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Functions
1818
Configure whether or not a touch will wake the device from sleep.
1919
*wake* should be a boolean value.
2020

21+
.. note:: This is only available for boards that have touch sensor support.
22+
2123
.. function:: wake_on_ulp(wake)
2224

2325
Configure whether or not the Ultra-Low-Power co-processor can wake the

ports/esp32/machine_pin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,11 @@ static mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_
325325
mp_raise_ValueError(MP_ERROR_TEXT("bad wake value"));
326326
}
327327

328+
#if SOC_TOUCH_SENSOR_SUPPORTED
328329
if (machine_rtc_config.wake_on_touch) { // not compatible
329330
mp_raise_ValueError(MP_ERROR_TEXT("no resources"));
330331
}
332+
#endif
331333

332334
if (!RTC_IS_VALID_EXT_PIN(index)) {
333335
mp_raise_ValueError(MP_ERROR_TEXT("invalid pin for wake"));

ports/esp32/machine_rtc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
typedef struct {
3434
uint64_t ext1_pins; // set bit == pin#
3535
int8_t ext0_pin; // just the pin#, -1 == None
36+
#if SOC_TOUCH_SENSOR_SUPPORTED
3637
bool wake_on_touch : 1;
38+
#endif
3739
#if SOC_ULP_SUPPORTED
3840
bool wake_on_ulp : 1;
3941
#endif

ports/esp32/modesp32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "../multi_heap_platform.h"
4848
#include "../heap_private.h"
4949

50+
#if SOC_TOUCH_SENSOR_SUPPORTED
5051
static mp_obj_t esp32_wake_on_touch(const mp_obj_t wake) {
5152

5253
if (machine_rtc_config.ext0_pin != -1) {
@@ -57,12 +58,16 @@ static mp_obj_t esp32_wake_on_touch(const mp_obj_t wake) {
5758
return mp_const_none;
5859
}
5960
static MP_DEFINE_CONST_FUN_OBJ_1(esp32_wake_on_touch_obj, esp32_wake_on_touch);
61+
#endif
6062

6163
static mp_obj_t esp32_wake_on_ext0(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
6264

65+
#if SOC_TOUCH_SENSOR_SUPPORTED
6366
if (machine_rtc_config.wake_on_touch) {
6467
mp_raise_ValueError(MP_ERROR_TEXT("no resources"));
6568
}
69+
#endif
70+
6671
enum {ARG_pin, ARG_level};
6772
const mp_arg_t allowed_args[] = {
6873
{ MP_QSTR_pin, MP_ARG_OBJ, {.u_obj = mp_obj_new_int(machine_rtc_config.ext0_pin)} },
@@ -259,7 +264,9 @@ static MP_DEFINE_CONST_FUN_OBJ_0(esp32_idf_task_info_obj, esp32_idf_task_info);
259264
static const mp_rom_map_elem_t esp32_module_globals_table[] = {
260265
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_esp32) },
261266

267+
#if SOC_TOUCH_SENSOR_SUPPORTED
262268
{ MP_ROM_QSTR(MP_QSTR_wake_on_touch), MP_ROM_PTR(&esp32_wake_on_touch_obj) },
269+
#endif
263270
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext0), MP_ROM_PTR(&esp32_wake_on_ext0_obj) },
264271
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext1), MP_ROM_PTR(&esp32_wake_on_ext1_obj) },
265272
#if SOC_ULP_SUPPORTED

0 commit comments

Comments
 (0)