From 564659779f90eaa9648a77ae855821b238e21a3a Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Wed, 30 Aug 2023 08:52:59 +0200 Subject: [PATCH 1/3] lcd_touch_ft5x06: Fixed missing reset. --- .../esp_lcd_touch_ft5x06.c | 23 ++++++++++++++++++- .../esp_lcd_touch_ft5x06/idf_component.yml | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c index 33674e67..4fdb0613 100644 --- a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -88,6 +88,8 @@ static esp_err_t touch_ft5x06_i2c_read(esp_lcd_touch_handle_t tp, uint8_t reg, u /* FT5x06 init */ static esp_err_t touch_ft5x06_init(esp_lcd_touch_handle_t tp); +/* FT5x06 reset */ +static esp_err_t touch_ft5x06_reset(esp_lcd_touch_handle_t tp); /******************************************************************************* * Public API functions @@ -144,6 +146,10 @@ esp_err_t esp_lcd_touch_new_i2c_ft5x06(const esp_lcd_panel_io_handle_t io, const ESP_GOTO_ON_ERROR(ret, err, TAG, "GPIO config failed"); } + /* Reset controller */ + ret = touch_ft5x06_reset(esp_lcd_touch_ft5x06); + ESP_GOTO_ON_ERROR(ret, err, TAG, "FT5x06 reset failed"); + /* Init controller */ ret = touch_ft5x06_init(esp_lcd_touch_ft5x06); ESP_GOTO_ON_ERROR(ret, err, TAG, "FT5x06 init failed"); @@ -286,6 +292,21 @@ static esp_err_t touch_ft5x06_init(esp_lcd_touch_handle_t tp) return ret; } +/* Reset controller */ +static esp_err_t touch_ft5x06_reset(esp_lcd_touch_handle_t tp) +{ + assert(tp != NULL); + + if (tp->config.rst_gpio_num != GPIO_NUM_NC) { + ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level error!"); + vTaskDelay(pdMS_TO_TICKS(10)); + ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, !tp->config.levels.reset), TAG, "GPIO set level error!"); + vTaskDelay(pdMS_TO_TICKS(10)); + } + + return ESP_OK; +} + static esp_err_t touch_ft5x06_i2c_write(esp_lcd_touch_handle_t tp, uint8_t reg, uint8_t data) { assert(tp != NULL); diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml b/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml index ec0b92ca..bbd51fcb 100644 --- a/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.5~1" +version: "1.0.6" description: ESP LCD Touch FT5x06 - touch controller FT5x06 url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_ft5x06 dependencies: From d88c95a4647af4ccdadb17b1cd0e8aa11603b729 Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Tue, 5 Sep 2023 10:16:33 +0200 Subject: [PATCH 2/3] lcd_touch_xxx: Fixed interrupt level. --- .../lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c | 2 +- .../lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c | 2 +- .../lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c | 2 +- components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c | 2 +- .../lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c | 2 +- .../lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c b/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c index 464b0166..f1712edd 100644 --- a/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c +++ b/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c @@ -60,7 +60,7 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons if (cst816s->config.int_gpio_num != GPIO_NUM_NC) { const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_INPUT, - .intr_type = GPIO_INTR_NEGEDGE, + .intr_type = (cst816s->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), .pin_bit_mask = BIT64(cst816s->config.int_gpio_num) }; ESP_GOTO_ON_ERROR(gpio_config(&int_gpio_config), err, TAG, "GPIO intr config failed"); diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c index 4fdb0613..f8f0fb86 100644 --- a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c @@ -124,7 +124,7 @@ esp_err_t esp_lcd_touch_new_i2c_ft5x06(const esp_lcd_panel_io_handle_t io, const if (esp_lcd_touch_ft5x06->config.int_gpio_num != GPIO_NUM_NC) { const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_INPUT, - .intr_type = GPIO_INTR_NEGEDGE, + .intr_type = (esp_lcd_touch_ft5x06->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), .pin_bit_mask = BIT64(esp_lcd_touch_ft5x06->config.int_gpio_num) }; ret = gpio_config(&int_gpio_config); diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c b/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c index 82d1b834..bae4cc96 100644 --- a/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c +++ b/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c @@ -65,7 +65,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt1151(const esp_lcd_panel_io_handle_t io, const if (gt1151->config.int_gpio_num != GPIO_NUM_NC) { const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_INPUT, - .intr_type = GPIO_INTR_NEGEDGE, + .intr_type = (gt1151->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), .pin_bit_mask = BIT64(gt1151->config.int_gpio_num) }; ESP_GOTO_ON_ERROR(gpio_config(&int_gpio_config), err, TAG, "GPIO intr config failed"); diff --git a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c index 9b2d5525..f5bb546d 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c +++ b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c @@ -74,7 +74,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const if (esp_lcd_touch_gt911->config.int_gpio_num != GPIO_NUM_NC) { const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_INPUT, - .intr_type = GPIO_INTR_NEGEDGE, + .intr_type = (esp_lcd_touch_gt911->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), .pin_bit_mask = BIT64(esp_lcd_touch_gt911->config.int_gpio_num) }; ret = gpio_config(&int_gpio_config); diff --git a/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c b/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c index b2f05e47..35f0d008 100644 --- a/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c +++ b/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c @@ -113,7 +113,7 @@ esp_err_t esp_lcd_touch_new_spi_stmpe610(const esp_lcd_panel_io_handle_t io, con if (esp_lcd_touch_stmpe610->config.int_gpio_num != GPIO_NUM_NC) { const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_INPUT, - .intr_type = GPIO_INTR_NEGEDGE, + .intr_type = (esp_lcd_touch_stmpe610->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), .pin_bit_mask = BIT64(esp_lcd_touch_stmpe610->config.int_gpio_num) }; ret = gpio_config(&int_gpio_config); diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c b/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c index 74f81d57..afcedb25 100644 --- a/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c +++ b/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c @@ -79,7 +79,7 @@ esp_err_t esp_lcd_touch_new_i2c_tt21100(const esp_lcd_panel_io_handle_t io, cons if (esp_lcd_touch_tt21100->config.int_gpio_num != GPIO_NUM_NC) { const gpio_config_t int_gpio_config = { .mode = GPIO_MODE_INPUT, - .intr_type = GPIO_INTR_NEGEDGE, + .intr_type = (esp_lcd_touch_tt21100->config.levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE), .pin_bit_mask = BIT64(esp_lcd_touch_tt21100->config.int_gpio_num) }; ret = gpio_config(&int_gpio_config); From 7f3f266bb7ba0293920b165c1e840d6df6fdc6c8 Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Thu, 7 Sep 2023 08:48:23 +0200 Subject: [PATCH 3/3] lcd_touch_xxx: Added remove ISR handler to deinit. --- .../lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c | 3 +++ .../lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c | 3 +++ .../lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c | 3 +++ components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c | 3 +++ .../lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c | 3 +++ .../lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c | 3 +++ 6 files changed, 18 insertions(+) diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c b/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c index f1712edd..917e1028 100644 --- a/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c +++ b/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c @@ -146,6 +146,9 @@ static esp_err_t del(esp_lcd_touch_handle_t tp) /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } } if (tp->config.rst_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.rst_gpio_num); diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c index f8f0fb86..9c2daa80 100644 --- a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c @@ -242,6 +242,9 @@ static esp_err_t esp_lcd_touch_ft5x06_del(esp_lcd_touch_handle_t tp) /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } } /* Reset GPIO pin settings */ diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c b/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c index bae4cc96..583b75f7 100644 --- a/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c +++ b/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c @@ -178,6 +178,9 @@ static esp_err_t del(esp_lcd_touch_handle_t tp) /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } } if (tp->config.rst_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.rst_gpio_num); diff --git a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c index f5bb546d..f3b70789 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c +++ b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c @@ -205,6 +205,9 @@ static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp) /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } } /* Reset GPIO pin settings */ diff --git a/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c b/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c index 35f0d008..179ee4fe 100644 --- a/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c +++ b/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c @@ -246,6 +246,9 @@ static esp_err_t esp_lcd_touch_stmpe610_del(esp_lcd_touch_handle_t tp) /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } } /* Reset GPIO pin settings */ diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c b/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c index afcedb25..6d3eaa26 100644 --- a/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c +++ b/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c @@ -307,6 +307,9 @@ static esp_err_t esp_lcd_touch_tt21100_del(esp_lcd_touch_handle_t tp) /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { gpio_reset_pin(tp->config.int_gpio_num); + if (tp->config.interrupt_callback) { + gpio_isr_handler_remove(tp->config.int_gpio_num); + } } /* Reset GPIO pin settings */