rak4631: let the serial GPS switch the WB_IO2 rail (opt-in)
On a RAK19007 the RAK12501's supply is 3V3_S, switched by WB_IO2, so gps off, periodic mode and shutdown left it powered. Pass WB_IO2 to the NMEA driver as peripheralPower under GPS_RAIL_POWER_CONTROL, set by the new RAK_4631_repeater_gps_power env. It is opt-in because the rail feeds every slot module, and refused with ETHERNET_ENABLED (RAK13800). The RAK12500 (I2C) driver keeps switching its own power pin, so this only applies on the NMEA path. RefCountedDigitalPin now sets OUTPUT on claim and release: WB_IO2 left as an input (as probeRak12500() leaves it after a failed probe) keeps 3V3_S in its last state, so writing the latch alone did not cut it. Measured with a KM003C, battery and panel out: gps off 40.5 -> 12.4 mA, shutdown 29.7 -> 1.30 mA.
This commit is contained in:
1 parent
b2e46335e5
commit
017005d1cf
4 files changed
+27
-2
No files matched your search
@@ -14,10 +14,13 @@ public:
|
||||
digitalWrite(_pin, !_active); // initial state
|
||||
}
|
||||
|
||||
// Both set the level, then make the pin an output again, since other code may have left it
|
||||
// an input. On a RAK19007 with a RAK12501, WB_IO2 left as an input keeps 3V3_S in its last state.
|
||||
void claim() {
|
||||
_claims++;
|
||||
if (_claims > 0) {
|
||||
digitalWrite(_pin, _active);
|
||||
pinMode(_pin, OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +30,7 @@ public:
|
||||
_claims--;
|
||||
if (_claims == 0) {
|
||||
digitalWrite(_pin, !_active);
|
||||
pinMode(_pin, OUTPUT);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -28,9 +28,11 @@ class RakLocationProvider : public LocationProvider {
|
||||
}
|
||||
|
||||
public:
|
||||
// serialPower, if given, switches the serial module's supply (WB_IO2 on WisBlock bases).
|
||||
RakLocationProvider(RakI2cGpsDriver& driver, mesh::RTCClock* clock = nullptr,
|
||||
UART_TYPE& serial = Serial1)
|
||||
: _driver(driver), _nmeaDriver(serial), _nmea(_nmeaDriver, clock) {}
|
||||
UART_TYPE& serial = Serial1, RefCountedDigitalPin* serialPower = nullptr)
|
||||
: _driver(driver), _nmeaDriver(serial, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN, serialPower),
|
||||
_nmea(_nmeaDriver, clock) {}
|
||||
|
||||
void syncTime() override {
|
||||
LocationProvider::syncTime();
|
||||
@@ -112,6 +114,8 @@ public:
|
||||
// the serial module is started first, then the I2C module is probed
|
||||
_nmeaDriver.begin();
|
||||
if (_driver.detect(timeout_ms)) {
|
||||
// The serial driver keeps its claim on serialPower, so the rail stays as it is without one.
|
||||
// The RAK12500 driver switches its own power pin, and serialPower is only used on the serial path.
|
||||
_useI2c = true;
|
||||
} else if (!_nmeaDriver.detect(0)) {
|
||||
_nmeaDriver.stop();
|
||||
|
||||
Reference in new issue
Block a user