Skip to content

Commit 03b1e67

Browse files
Lzw655tore-espressif
authored andcommitted
fix(tt21100): Avoid logging debug messages inside portENTER_CRITICAL()
1 parent 2f17f43 commit 03b1e67

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c

Lines changed: 13 additions & 5 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
*/
@@ -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;

0 commit comments

Comments
 (0)