Skip to content

Commit b311265

Browse files
Eric Bersetheberseth
Eric Berseth
authored andcommitted
Fix locking issues with the power manager and model gauge
1 parent 3092c2f commit b311265

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/tracker.cpp

+19-16
Original file line numberDiff line numberDiff line change
@@ -347,26 +347,29 @@ void Tracker::initBatteryMonitor() {
347347
// In order to disable charging safely we want to enable the PMIC watchdog so that
348348
// if anything happens during the procedure that the circuit can return to
349349
// normal operation in the event the MCU doesn't complete.
350-
PMIC pmic(true);
351-
FuelGauge fuelGauge;
352-
353-
pmic.setWatchdog(0x1); // 40 seconds
354-
pmic.disableCharging();
355-
// Delay so that the bulk capacitance and battery can equalize
356-
delay(_commonCfgData.postChargeSettleTime);
357350

358351
TrackerFuelGauge::instance().init();
359352

360-
fuelGauge.quickStart();
361-
// Must delay at least 175ms after quickstart, before calling
362-
// getSoC(), or reading will not have updated yet.
363-
delay(200);
364-
365-
_forceDisableCharging = _deviceConfig.disableCharging();
366-
if (_batterySafeToCharge && !_forceDisableCharging) {
367-
pmic.enableCharging();
353+
{
354+
PMIC pmic(true);
355+
FuelGauge fuelGauge;
356+
357+
pmic.setWatchdog(0x1); // 40 seconds
358+
pmic.disableCharging();
359+
// Delay so that the bulk capacitance and battery can equalize
360+
delay(_commonCfgData.postChargeSettleTime);
361+
362+
fuelGauge.quickStart();
363+
// Must delay at least 175ms after quickstart, before calling
364+
// getSoC(), or reading will not have updated yet.
365+
delay(200);
366+
367+
_forceDisableCharging = _deviceConfig.disableCharging();
368+
if (_batterySafeToCharge && !_forceDisableCharging) {
369+
pmic.enableCharging();
370+
}
371+
pmic.disableWatchdog();
368372
}
369-
pmic.disableWatchdog();
370373
}
371374

372375
bool Tracker::getChargeEnabled() {

0 commit comments

Comments
 (0)