From feda048dfac7dd7cc24b9cb46a265a1b177a753a Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 17 Apr 2026 16:20:40 +0200 Subject: [PATCH] Fix missing X3 serial output --- lib/hal/HalGPIO.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/hal/HalGPIO.cpp b/lib/hal/HalGPIO.cpp index c1734b0e..911d5543 100644 --- a/lib/hal/HalGPIO.cpp +++ b/lib/hal/HalGPIO.cpp @@ -314,11 +314,15 @@ bool HalGPIO::isUsbConnected() const { for (uint8_t attempt = 0; attempt < 2; ++attempt) { int16_t currentMa = 0; if (X3GPIO::readBQ27220CurrentMA(¤tMa)) { - return currentMa > 0; + if (currentMa > 0) { + return true; + } + break; } delay(2); } - return false; + // Fall back to the same USB pin-level detection used by X4. + return digitalRead(UART0_RXD) == HIGH; } // U0RXD/GPIO20 reads HIGH when USB is connected return digitalRead(UART0_RXD) == HIGH;