From 619a5be5e3764629dc1a1189ebc518cf57bb4ce5 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Thu, 7 Nov 2024 22:52:15 +0100 Subject: [PATCH] Added check for rst_gpio_num == GPIO_NUM_NC --- boards | 2 +- src/esp_touch_cst816s.c | 10 +++++++++- src/esp_touch_gt911.c | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/boards b/boards index 4b2c054..35fd2d6 160000 --- a/boards +++ b/boards @@ -1 +1 @@ -Subproject commit 4b2c0540acea25c71a67ec1605c8111ecc6367e3 +Subproject commit 35fd2d6067e1ce49e4460dff2be6c84c432042f6 diff --git a/src/esp_touch_cst816s.c b/src/esp_touch_cst816s.c index 3432a2c..4d3ff8f 100644 --- a/src/esp_touch_cst816s.c +++ b/src/esp_touch_cst816s.c @@ -86,6 +86,12 @@ esp_err_t cst816s_reset(esp_lcd_touch_handle_t th) if (th == NULL) return ESP_ERR_INVALID_ARG; + if (th->config.rst_gpio_num == GPIO_NUM_NC) + { + log_w("No RST pin defined"); + return ESP_OK; + } + esp_err_t res; // Set RST active if ((res = gpio_set_level(th->config.rst_gpio_num, th->config.levels.reset)) != ESP_OK) @@ -293,7 +299,9 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons { if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK) { - gpio_reset_pin(th->config.int_gpio_num); + if (config->int_gpio_num != GPIO_NUM_NC) + gpio_reset_pin(th->config.int_gpio_num); + free(th); log_e("Registering interrupt callback failed"); return res; diff --git a/src/esp_touch_gt911.c b/src/esp_touch_gt911.c index 33322c8..7e15308 100644 --- a/src/esp_touch_gt911.c +++ b/src/esp_touch_gt911.c @@ -82,6 +82,12 @@ esp_err_t gt911_reset(esp_lcd_touch_handle_t th) if (th == NULL) return ESP_ERR_INVALID_ARG; + if (th->config.rst_gpio_num == GPIO_NUM_NC) + { + log_w("No RST pin defined"); + return ESP_OK; + } + esp_err_t res; // Set RST active if ((res = gpio_set_level(th->config.rst_gpio_num, th->config.levels.reset)) != ESP_OK)