device-os icon indicating copy to clipboard operation
device-os copied to clipboard

[system] battery state might be wrong when it is detached

Open XuGuohui opened this issue 1 year ago • 0 comments

NOTE: this PR is targeting the feature/muon-som-evb branch

Problem

Under some circumstances, battery state remains not charging even if the battery is detached. For instance, on the M.2 breakout board, when it is powered through DC jack only.

Solution

When power is good and battery is in not charging state and VBAT < VSYSMIN (i.e. in VSYSMIN regulation), we assume that the battery is disconnected.

Steps to Test

  1. Build and run the attached test app on a SoM module that is installed on M.2 breakout board
  2. Power the M.2 breakout board through the DC jack only.

Example App

#include "application.h"

SYSTEM_MODE(MANUAL);

SerialLogHandler logHandler(LOG_LEVEL_ALL);

void setup() {
}

void loop() {
    static system_tick_t lastTime = 0;
    if (millis() - lastTime > 3000) {
        lastTime = millis();
        PMIC power;
        Log.info("Bat state: %d, Charge enabled: %d, isHot: %d, status: %d, fault: %d",
                 System.batteryState(), power.isChargingEnabled(), power.isHot(), power.getSystemStatus(), power.getFault());
    }
}

References

N/A


Completeness

  • [x] User is totes amazing for contributing!
  • [x] Contributor has signed CLA (Info here)
  • [x] Problem and Solution clearly stated
  • [ ] Run unit/integration/application tests on device
  • [ ] Added documentation
  • [ ] Added to CHANGELOG.md after merging (add links to docs and issues)

XuGuohui avatar Jun 27 '24 18:06 XuGuohui