Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SoM] Runtime power management IC detection #1733

Merged
merged 5 commits into from Mar 26, 2019

Conversation

@avtolstoy
Copy link
Member

commented Mar 19, 2019

Problem

SoMs may function with or without PMIC / FuelGauge. Currently power management subsystem is enabled only in compile time and is disabled for SoM platforms completely.

Solution

This PR adds support for runtime presence detection of PMIC and FuelGauge enabling system power management.

This functionality is enabled via a persistent system flag, and by default will be enabled in tinker shipped with manufactured devices, making this feature opt-out.

NOTE: Current development boards for SoMs do not have PMIC interrupt line connected to the MCU, which prevents power management subsystem from functioning correctly

This PR also fixes a race condition that causes system power manager to re-enable charging every second instead of every 60 seconds.

Steps to Test

Use the example app below with enabled and disabled SYSTEM_FLAG_PM_DETECTION. Observe the log on Serial1.

Example App

STARTUP(System.enable(SYSTEM_FLAG_PM_DETECTION));
// STARTUP(System.disable(SYSTEM_FLAG_PM_DETECTION));

Serial1LogHandler dbg(115200, LOG_LEVEL_NONE, {
    {"sys.power", LOG_LEVEL_ALL}
});

References

N/A


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • 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)

  • [Feature] [SoM] Runtime power management IC detection #1733

@avtolstoy avtolstoy added this to the 1.1.0-rc.1 milestone Mar 19, 2019

@avtolstoy avtolstoy requested review from sergeuz and technobly Mar 19, 2019

@technobly technobly force-pushed the feature/runtime-pm-detection branch from 5365970 to b52f33c Mar 19, 2019

@technobly

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

BSoM PMIC connected

0000000013 [sys.power] INFO: Power Management Initializing.
0000000015 [sys.power] INFO: PMIC present, version 23
0000000018 [sys.power] INFO: FuelGauge present, version 0003
0000000027 [sys.power] INFO: State of Charge: 2.10  %
0000000028 [sys.power] INFO: Battery Voltage: 4.11V
0000000029 [system] TRACE: Hello from Particle!

BSoM PMIC disconnected

0000000131 [sys.power] INFO: Power Management Initializing.
0000000133 [sys.power] WARN: PMIC not present
0000000134 [sys.power] WARN: Disabling system power manager
0000000137 [system] TRACE: Hello from Particle!
@technobly

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

PMIC detection disabled

0000000267 [sys.power] INFO: Power Management Initializing.
0000000269 [sys.power] INFO: Runtime PMIC/FuelGauge detection is not enabled
0000000270 [sys.power] WARN: Disabling system power manager
0000000279 [system] TRACE: Hello from Particle!
@technobly
Copy link
Member

left a comment

By itself this looks good. Are we going to merge the important parts of #1726 into this one though and close #1726?

@avtolstoy

This comment has been minimized.

Copy link
Member Author

commented Mar 25, 2019

@technobly I've already moved the necessary power management changes here from #1726 (see 6eab568). We can merge this one, #1726 is still in progress as I am waiting to have Cat M1 connectivity here.

@avtolstoy avtolstoy merged commit 857e105 into develop Mar 26, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@avtolstoy avtolstoy deleted the feature/runtime-pm-detection branch Mar 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.