Skip to content

Commit dc41c67

Browse files
CaTeIMjgriffiths
authored andcommitted
Fix: Waveshare S3 Touch LCD 2 Windows connectivity & USB detection
Disable native hardware USB JTAG interface in favor of TinyUSB CDC stack to resolve driver enumeration issues on Windows hosts. Updates: - configs/sdkconfig_display_waveshares3_touch_lcd2.defaults: Switch USB stack - main/power/wslcdtouch2.inc: Use TinyUSB tud_mounted() for reliable power detection
1 parent c5ad31d commit dc41c67

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

configs/sdkconfig_display_waveshares3_touch_lcd2.defaults

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ CONFIG_COMPILER_WARN_WRITE_STRINGS=y
2727
CONFIG_DEBUG_MODE=y
2828
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
2929
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
30-
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
30+
CONFIG_ESP_CONSOLE_NONE=y
31+
CONFIG_ESP_CONSOLE_SECONDARY_NONE=y
3132
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
3233
CONFIG_ESP_ERR_TO_NAME_LOOKUP=n
3334
CONFIG_ESP_MAIN_TASK_STACK_SIZE=12288
@@ -51,7 +52,6 @@ CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=3
5152
CONFIG_GC032A_SUPPORT=n
5253
CONFIG_GC2145_SUPPORT=n
5354
CONFIG_IDF_TARGET="esp32s3"
54-
CONFIG_JADE_USE_USB_JTAG_SERIAL=y
5555
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
5656
CONFIG_MBEDTLS_ECP_RESTARTABLE=y
5757
CONFIG_NEWLIB_NANO_FORMAT=y

main/power/wslcdtouch2.inc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Waveshare LCD Touch 2 implmentation
1+
// Waveshare LCD Touch 2 implementation
22
//
33
#include <driver/gpio.h>
44
#include <driver/ledc.h>
@@ -14,6 +14,7 @@
1414
#include "iot_button.h"
1515
#include "power.h"
1616
#include "soc/gpio_num.h"
17+
#include "tusb.h"
1718

1819
#define BATTERY_ADC_CHANNEL ADC_CHANNEL_4
1920
#define BATTERY_ADC_ATTEN ADC_ATTEN_DB_12
@@ -205,5 +206,18 @@ uint16_t power_get_temp(void) { return 0; }
205206
void disable_usb_host(void) {}
206207
void enable_usb_host(void) {}
207208

208-
// This is only a guess by the ADC voltage when the USB is plugged in
209-
bool usb_is_powered(void) { return power_get_vbat() > 1350; }
209+
bool usb_is_powered(void)
210+
{
211+
// Check if USB is mounted and not suspended (active connection)
212+
if (tud_mounted() && !tud_suspended()) {
213+
return true;
214+
}
215+
216+
// Fallback: If voltage is near zero (<1V) but chip is on,
217+
// we must be running on USB power without a battery.
218+
if (power_get_vbat() < 1000) {
219+
return true;
220+
}
221+
222+
return false;
223+
}

0 commit comments

Comments
 (0)