Skip to content

Commit e5daac9

Browse files
Merge pull request #509 from Lzw655/fix/lcd_touch_new_error_process
fix(lcd_touch): avoid assigning a value to handle after creation failure
2 parents d0b7610 + 03b1e67 commit e5daac9

File tree

8 files changed

+25
-17
lines changed

8 files changed

+25
-17
lines changed

components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ esp_err_t esp_lcd_touch_new_i2c_ft5x06(const esp_lcd_panel_io_handle_t io, const
153153
ret = touch_ft5x06_init(esp_lcd_touch_ft5x06);
154154
ESP_GOTO_ON_ERROR(ret, err, TAG, "FT5x06 init failed");
155155

156+
*out_touch = esp_lcd_touch_ft5x06;
157+
156158
err:
157159
if (ret != ESP_OK) {
158160
ESP_LOGE(TAG, "Error (0x%x)! Touch controller FT5x06 initialization failed!", ret);
@@ -161,8 +163,6 @@ esp_err_t esp_lcd_touch_new_i2c_ft5x06(const esp_lcd_panel_io_handle_t io, const
161163
}
162164
}
163165

164-
*out_touch = esp_lcd_touch_ft5x06;
165-
166166
return ret;
167167
}
168168

components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.6~1"
1+
version: "1.0.7"
22
description: ESP LCD Touch FT5x06 - touch controller FT5x06
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_ft5x06
44
dependencies:

components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const
158158
ret = touch_gt911_read_cfg(esp_lcd_touch_gt911);
159159
ESP_GOTO_ON_ERROR(ret, err, TAG, "GT911 init failed");
160160

161+
*out_touch = esp_lcd_touch_gt911;
162+
161163
err:
162164
if (ret != ESP_OK) {
163165
ESP_LOGE(TAG, "Error (0x%x)! Touch controller GT911 initialization failed!", ret);
@@ -166,8 +168,6 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const
166168
}
167169
}
168170

169-
*out_touch = esp_lcd_touch_gt911;
170-
171171
return ret;
172172
}
173173

components/lcd_touch/esp_lcd_touch_gt911/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.1~2"
1+
version: "1.1.2"
22
description: ESP LCD Touch GT911 - touch controller GT911
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_gt911
44
dependencies:

components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ esp_err_t esp_lcd_touch_new_spi_stmpe610(const esp_lcd_panel_io_handle_t io, con
143143
ret = touch_stmpe610_read_cfg(esp_lcd_touch_stmpe610);
144144
ESP_GOTO_ON_ERROR(ret, err, TAG, "STMPE610 init failed");
145145

146+
*out_touch = esp_lcd_touch_stmpe610;
147+
146148
err:
147149
if (ret != ESP_OK) {
148150
ESP_LOGE(TAG, "Error (0x%x)! Touch controller STMPE610 initialization failed!", ret);
@@ -151,8 +153,6 @@ esp_err_t esp_lcd_touch_new_spi_stmpe610(const esp_lcd_panel_io_handle_t io, con
151153
}
152154
}
153155

154-
*out_touch = esp_lcd_touch_stmpe610;
155-
156156
return ret;
157157
}
158158

components/lcd_touch/esp_lcd_touch_stmpe610/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.6"
1+
version: "1.0.7"
22
description: ESP LCD Touch STMPE610 - touch controller STMPE610
33
url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lcd_touch_stmpe610
44
dependencies:

components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -108,6 +108,8 @@ esp_err_t esp_lcd_touch_new_i2c_tt21100(const esp_lcd_panel_io_handle_t io, cons
108108
ret = esp_lcd_touch_tt21100_read_data(esp_lcd_touch_tt21100);
109109
ESP_GOTO_ON_ERROR(ret, err, TAG, "TT21100 init failed");
110110

111+
*out_touch = esp_lcd_touch_tt21100;
112+
111113
err:
112114
if (ret != ESP_OK) {
113115
ESP_LOGE(TAG, "Error (0x%x)! Touch controller TT21100 initialization failed!", ret);
@@ -116,8 +118,6 @@ esp_err_t esp_lcd_touch_new_i2c_tt21100(const esp_lcd_panel_io_handle_t io, cons
116118
}
117119
}
118120

119-
*out_touch = esp_lcd_touch_tt21100;
120-
121121
return ret;
122122
}
123123

@@ -201,20 +201,22 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp)
201201
touch_tt21100_i2c_read(tp, data, data_len);
202202
ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");
203203

204-
portENTER_CRITICAL(&tp->data.lock);
205-
206204
if (data_len == 14) {
207205
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
208206
/* Button event */
209207
p_btn_data = (button_record_struct_t *) data;
210208

209+
portENTER_CRITICAL(&tp->data.lock);
210+
211211
/* Buttons count */
212212
tp->data.buttons = (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS < 4 ? CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS : 4);
213213

214214
for (i = 0; i < tp->data.buttons; i++) {
215215
tp->data.button[i].status = p_btn_data->btn_signal[i];
216216
}
217217

218+
portEXIT_CRITICAL(&tp->data.lock);
219+
218220
ESP_LOGD(TAG, "Len : %04Xh. ID : %02Xh. Time : %5u. Val : [%u] - [%04X][%04X][%04X][%04X]",
219221
p_btn_data->length, p_btn_data->report_id, p_btn_data->time_stamp, p_btn_data->btn_val,
220222
p_btn_data->btn_signal[0], p_btn_data->btn_signal[1], p_btn_data->btn_signal[2], p_btn_data->btn_signal[3]);
@@ -226,6 +228,9 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp)
226228

227229
/* Number of touched points */
228230
tp_num = (tp_num > CONFIG_ESP_LCD_TOUCH_MAX_POINTS ? CONFIG_ESP_LCD_TOUCH_MAX_POINTS : tp_num);
231+
232+
portENTER_CRITICAL(&tp->data.lock);
233+
229234
tp->data.points = tp_num;
230235

231236
/* Fill all coordinates */
@@ -235,12 +240,15 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp)
235240
tp->data.coords[i].x = p_touch_data->x;
236241
tp->data.coords[i].y = p_touch_data->y;
237242
tp->data.coords[i].strength = p_touch_data->pressure;
243+
}
244+
245+
portEXIT_CRITICAL(&tp->data.lock);
238246

247+
for (i = 0; i < tp_num; i++) {
248+
p_touch_data = &p_report_data->touch_record[i];
239249
ESP_LOGD(TAG, "(%zu) [%3u][%3u]", i, p_touch_data->x, p_touch_data->y);
240250
}
241251
}
242-
243-
portEXIT_CRITICAL(&tp->data.lock);
244252
}
245253

246254
return ESP_OK;

components/lcd_touch/esp_lcd_touch_tt21100/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.0~1"
1+
version: "1.1.1"
22
description: ESP LCD Touch TT21100 - touch controller TT21100
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_tt21100
44
dependencies:

0 commit comments

Comments
 (0)