mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-14 01:21:57 +00:00
fix(wio-tracker-l2): USB power detection works - charge bolt, Power row, GPS hint
- The AW35615 USB-C controller (FUSB302-style registers, ID 0x91) only reports VBUSOK with its measure block on; POWER resets to bandgap only, so isExternalPowered() was always false. Board init turns it on - Status bar shows a charge bolt on the cable, Diagnostics > Live has a Power row, the GPS screen notes that charging disturbs GPS, and the low-battery warning is skipped on USB as intended - Roadmap: USB detection closed; GPS indoors still worse than the L1 even on battery, left open for later Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,20 @@ void WioTrackerL2Board::begin() {
|
||||
|
||||
Wire.beginTransmission(0x22);
|
||||
aw_ok = Wire.endTransmission() == 0;
|
||||
if (aw_ok) {
|
||||
// AW35615 = FUSB302-style register map. VBUSOK (STATUS0 bit 7) only
|
||||
// works with the measure block powered: POWER (0x0B) resets to 0x01
|
||||
// (bandgap only), which reads "no USB" forever. Add the receiver /
|
||||
// current references and the measure block (PWR[1..2]).
|
||||
// Verified on hardware: device ID 0x91; STATUS0 0x01 -> 0x80 on USB.
|
||||
int pw = awRead(0x0B);
|
||||
if (pw >= 0) {
|
||||
Wire.beginTransmission(0x22);
|
||||
Wire.write((uint8_t)0x0B);
|
||||
Wire.write((uint8_t)(pw | 0x07));
|
||||
Wire.endTransmission();
|
||||
}
|
||||
}
|
||||
MESH_DEBUG_PRINTLN("WioTrackerL2Board: init done");
|
||||
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
@@ -156,13 +170,18 @@ int WioTrackerL2Board::expReadInputs() {
|
||||
return lo | (hi << 8);
|
||||
}
|
||||
|
||||
bool WioTrackerL2Board::isExternalPowered() {
|
||||
if (!aw_ok) return false;
|
||||
int WioTrackerL2Board::awRead(uint8_t reg) {
|
||||
if (!aw_ok) return -1;
|
||||
Wire.beginTransmission(0x22);
|
||||
Wire.write((uint8_t)0x40); // STATUS0
|
||||
if (Wire.endTransmission() != 0) return false;
|
||||
if (Wire.requestFrom(0x22, 1) != 1) return false;
|
||||
return (Wire.read() & 0x80) != 0; // VBUSOK bit
|
||||
Wire.write(reg);
|
||||
if (Wire.endTransmission() != 0) return -1;
|
||||
if (Wire.requestFrom(0x22, 1) != 1) return -1;
|
||||
return Wire.read();
|
||||
}
|
||||
|
||||
bool WioTrackerL2Board::isExternalPowered() {
|
||||
int st0 = awRead(0x40); // STATUS0
|
||||
return st0 >= 0 && (st0 & 0x80) != 0; // VBUSOK
|
||||
}
|
||||
|
||||
bool WioTrackerL2Board::readWakeButton() {
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
|
||||
// VBUS presence via the AW35615 USB-C controller (I2C 0x22)
|
||||
bool isExternalPowered() override;
|
||||
int awRead(uint8_t reg); // AW35615 register, -1 on error
|
||||
|
||||
bool expanderOK() const { return expander_ok; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user