MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / isUsbConnected

Method isUsbConnected

lib/hal/HalGPIO.cpp:272–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272bool 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(&currentMa)) {
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
289HalGPIO::WakeupReason HalGPIO::getWakeupReason() const {
290 const auto wakeupCause = esp_sleep_get_wakeup_cause();

Callers 2

fillBatteryIconMethod · 0.80
fillBatteryIconMethod · 0.80

Calls 1

readBQ27220CurrentMAFunction · 0.85

Tested by

no test coverage detected