| 270 | } |
| 271 | |
| 272 | bool HalGPIO::isUsbConnected() const { |
| 273 | if (deviceIsX3()) { |
| 274 | // X3: infer USB/charging via BQ27220 Current() register (0x0C, signed mA). |
| 275 | // Positive current means charging. |
| 276 | for (uint8_t attempt = 0; attempt < 2; ++attempt) { |
| 277 | int16_t currentMa = 0; |
| 278 | if (X3GPIO::readBQ27220CurrentMA(¤tMa)) { |
| 279 | return currentMa > 0; |
| 280 | } |
| 281 | delay(2); |
| 282 | } |
| 283 | return false; |
| 284 | } |
| 285 | // U0RXD/GPIO20 reads HIGH when USB is connected |
| 286 | return digitalRead(UART0_RXD) == HIGH; |
| 287 | } |
| 288 | |
| 289 | HalGPIO::WakeupReason HalGPIO::getWakeupReason() const { |
| 290 | const auto wakeupCause = esp_sleep_get_wakeup_cause(); |
no test coverage detected