summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDaniƫl van de Giessen <daniel@dvdgiessen.nl>2024-12-03 11:08:13 +0100
committerDamien George <damien@micropython.org>2024-12-10 11:20:15 +1100
commit5fb846df67189363904dcbb9c2bc93d0f287ccd6 (patch)
tree60ccbea0dfd10ecefb762dfabb57ec3b91e0a0eb
parent5564f3042ca850e363e6644b3df0b006785fcf2d (diff)
downloadmicropython-5fb846df67189363904dcbb9c2bc93d0f287ccd6.tar.gz
micropython-5fb846df67189363904dcbb9c2bc93d0f287ccd6.zip
esp32: Fix machine_touchpad compiling on IDFv5.3.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/esp32/machine_touchpad.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/ports/esp32/machine_touchpad.c b/ports/esp32/machine_touchpad.c
index 48250280ba..299c489f5a 100644
--- a/ports/esp32/machine_touchpad.c
+++ b/ports/esp32/machine_touchpad.c
@@ -31,9 +31,17 @@
#if SOC_TOUCH_SENSOR_SUPPORTED
-#if SOC_TOUCH_VERSION_1 // ESP32 only
+#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
+#if SOC_TOUCH_VERSION_1
+#define SOC_TOUCH_SENSOR_VERSION (1)
+#elif SOC_TOUCH_VERSION_2
+#define SOC_TOUCH_SENSOR_VERSION (2)
+#endif
+#endif
+
+#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32 only
#include "driver/touch_pad.h"
-#elif SOC_TOUCH_VERSION_2 // All other SoCs with touch, to date
+#elif SOC_TOUCH_SENSOR_VERSION == 2 // All other SoCs with touch, to date
#include "driver/touch_sensor.h"
#else
#error "Unknown touch hardware version"
@@ -98,13 +106,13 @@ static mp_obj_t mtp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
initialized = 1;
}
- #if SOC_TOUCH_VERSION_1
+ #if SOC_TOUCH_SENSOR_VERSION == 1
esp_err_t err = touch_pad_config(self->touchpad_id, 0);
- #elif SOC_TOUCH_VERSION_2
+ #elif SOC_TOUCH_SENSOR_VERSION == 2
esp_err_t err = touch_pad_config(self->touchpad_id);
#endif
if (err == ESP_OK) {
- #if SOC_TOUCH_VERSION_2
+ #if SOC_TOUCH_SENSOR_VERSION == 2
touch_pad_fsm_start();
#endif
@@ -115,10 +123,10 @@ static mp_obj_t mtp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
static mp_obj_t mtp_config(mp_obj_t self_in, mp_obj_t value_in) {
mtp_obj_t *self = self_in;
- #if SOC_TOUCH_VERSION_1
+ #if SOC_TOUCH_SENSOR_VERSION == 1
uint16_t value = mp_obj_get_int(value_in);
esp_err_t err = touch_pad_config(self->touchpad_id, value);
- #elif SOC_TOUCH_VERSION_2
+ #elif SOC_TOUCH_SENSOR_VERSION == 2
esp_err_t err = touch_pad_config(self->touchpad_id);
#endif
if (err == ESP_OK) {
@@ -130,10 +138,10 @@ MP_DEFINE_CONST_FUN_OBJ_2(mtp_config_obj, mtp_config);
static mp_obj_t mtp_read(mp_obj_t self_in) {
mtp_obj_t *self = self_in;
- #if SOC_TOUCH_VERSION_1
+ #if SOC_TOUCH_SENSOR_VERSION == 1
uint16_t value;
esp_err_t err = touch_pad_read(self->touchpad_id, &value);
- #elif SOC_TOUCH_VERSION_2
+ #elif SOC_TOUCH_SENSOR_VERSION == 2
uint32_t value;
esp_err_t err = touch_pad_read_raw_data(self->touchpad_id, &value);
#endif