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

Set pin mode for PMIC and fuel gauge interrupts #2207

Merged
merged 1 commit into from Oct 2, 2020

Conversation

eberseth
Copy link
Contributor

@eberseth eberseth commented Oct 2, 2020

Problem

Interrupts for the fuel gauge device were not firing after attaching handlers, mainly on the tracker platform. An MCP23S17 GPIO expander is used to receive the input from the fuel gauge and it's defaults were not set for the interrupt pins to accept inputs with pullup.

Solution

The PMIC and fuel gauge interrupt pins were explicitly configured for input source with pullups.

Steps to Test

  1. A battery with charge greater than 10% should be powering the device.
  2. Flash the application
  3. Unplug any cabled power sources (VIN or USB)
  4. Allow the battery to discharge
  5. Check if the handler print statement prints when the SOC (not normalized) value decreases and crosses 8%.

Example App

void lowBatteryHandler(system_event_t event, int data) {
  Serial1.println("Battery charge low handler");
}

void setup() {
  Serial1.begin(115200);
  FuelGauge().setAlertThreshold(8); // percent
  FuelGauge().clearAlert();
  delay(100);
  System.on(low_battery, lowBatteryHandler);
}

void loop() {
  static unsigned int loopCount = 0;
  if (System.uptime() - loopCount >= 10) {
    loopCount = System.uptime();
    Serial1.printlnf("voltage = %0.3f, normal SOC = %0.3f%%, SOC = %0.3f%%, state = %d, source = %d",
      FuelGauge().getVCell(),
      FuelGauge().getNormalizedSoC(),
      FuelGauge().getSoC(),
      System.batteryState(),
      System.powerSource());
  }
}

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)

@eberseth eberseth added this to the 2.0.0 milestone Oct 2, 2020
@eberseth eberseth changed the title [system] power: set pin mode for PMIC and fuel gauge interrupts Set pin mode for PMIC and fuel gauge interrupts Oct 2, 2020
@avtolstoy avtolstoy merged commit b76295a into develop Oct 2, 2020
@avtolstoy avtolstoy deleted the fix/pin-modes-for-interrupts branch October 2, 2020 12:21
@avtolstoy avtolstoy added ready to merge PR has been reviewed and tested and removed needs review labels Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge PR has been reviewed and tested
Projects
None yet
2 participants