Skip to content

Commit

Permalink
Merge pull request espressif#216 from espressif/fix/lcd_touch_ft5x06_…
Browse files Browse the repository at this point in the history
…reset

lcd_touch_ft5x06: Fixed missing reset.
  • Loading branch information
espzav authored Sep 8, 2023
2 parents 3fdc94b + 7f3f266 commit ceb77a4
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
28 changes: 26 additions & 2 deletions components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -122,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);
Expand All @@ -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");
Expand Down Expand Up @@ -236,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 */
Expand Down Expand Up @@ -286,6 +295,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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit ceb77a4

Please sign in to comment.