Skip to content

Commit

Permalink
Rename SY/BQ PMU to PPM
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Jun 25, 2024
1 parent 24e8ede commit d0751fb
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 89 deletions.
74 changes: 37 additions & 37 deletions examples/BQ25896_Example/BQ25896_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
#include <XPowersLib.h>

PowersSY6970 PMU;
XPowersPPM PPM;


#ifndef CONFIG_PMU_SDA
Expand All @@ -35,59 +35,59 @@ void setup()
while (!Serial);


bool result = PMU.init(Wire, i2c_sda, i2c_scl, BQ25896_SLAVE_ADDRESS);
bool result = PPM.init(Wire, i2c_sda, i2c_scl, BQ25896_SLAVE_ADDRESS);

if (result == false) {
while (1) {
Serial.println("PMU is not online...");
Serial.println("PPM is not online...");
delay(50);
}
}

// Set the minimum operating voltage. Below this voltage, the PMU will protect
PMU.setSysPowerDownVoltage(3300);
// Set the minimum operating voltage. Below this voltage, the PPM will protect
PPM.setSysPowerDownVoltage(3300);

// Set input current limit, default is 500mA
PMU.setInputCurrentLimit(3250);
PPM.setInputCurrentLimit(3250);

Serial.printf("getInputCurrentLimit: %d mA\n", PMU.getInputCurrentLimit());
Serial.printf("getInputCurrentLimit: %d mA\n", PPM.getInputCurrentLimit());

// Disable current limit pin
PMU.disableCurrentLimitPin();
PPM.disableCurrentLimitPin();

// Set the charging target voltage, Range:3840 ~ 4608mV ,step:16 mV
PMU.setChargeTargetVoltage(4208);
PPM.setChargeTargetVoltage(4208);

// Set the precharge current , Range: 64mA ~ 1024mA ,step:64mA
PMU.setPrechargeCurr(64);
PPM.setPrechargeCurr(64);

// The premise is that Limit Pin is disabled, or it will only follow the maximum charging current set by Limi tPin.
// Set the charging current , Range:0~5056mA ,step:64mA
PMU.setChargerConstantCurr(1024);
PPM.setChargerConstantCurr(1024);

// Get the set charging current
PMU.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n", PMU.getChargerConstantCurr());
PPM.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n", PPM.getChargerConstantCurr());


// To obtain voltage data, the ADC must be enabled first
PMU.enableADCMeasure();
PPM.enableADCMeasure();

// Turn on charging function
// If there is no battery connected, do not turn on the charging function
PMU.enableCharge();
PPM.enableCharge();

// Turn off charging function
// If USB is used as the only power input, it is best to turn off the charging function,
// otherwise the VSYS power supply will have a sawtooth wave, affecting the discharge output capability.
// PMU.disableCharge();
// PPM.disableCharge();


// The OTG function needs to enable OTG, and set the OTG control pin to HIGH
// After OTG is enabled, if an external power supply is plugged in, OTG will be turned off

// PMU.enableOTG();
// PMU.disableOTG();
// PPM.enableOTG();
// PPM.disableOTG();
// pinMode(OTG_ENABLE_PIN, OUTPUT);
// digitalWrite(OTG_ENABLE_PIN, HIGH);

Expand All @@ -104,47 +104,47 @@ void loop()
if (pmu_irq) {
pmu_irq = false;

// Get PMU interrupt status
PMU.getIrqStatus();
// Get PPM interrupt status
PPM.getIrqStatus();

Serial.print("-> [");
Serial.print(millis() / 1000);
Serial.print("] ");

if (PMU.isWatchdogFault()) {
if (PPM.isWatchdogFault()) {

Serial.println("Watchdog Fault");

} else if (PMU.isBoostFault()) {
} else if (PPM.isBoostFault()) {

Serial.println("Boost Fault");

} else if (PMU.isChargeFault()) {
} else if (PPM.isChargeFault()) {

Serial.println("Charge Fault");

} else if (PMU.isBatteryFault()) {
} else if (PPM.isBatteryFault()) {

Serial.println("Batter Fault");

} else if (PMU.isNTCFault()) {
} else if (PPM.isNTCFault()) {

Serial.print("NTC Fault:");
Serial.print(PMU.getNTCStatusString());
Serial.print(PPM.getNTCStatusString());
Serial.print(" Percentage:");
Serial.print(PMU.getNTCPercentage()); Serial.println("%");
Serial.print(PPM.getNTCPercentage()); Serial.println("%");
}
// The battery may be disconnected or damaged.
else if (PMU.isVsysLowVoltageWarning()) {
else if (PPM.isVsysLowVoltageWarning()) {

Serial.println("In VSYSMIN regulation (BAT<VSYSMIN)");

} else {
/*
* When the battery is removed, INT will send an interrupt every 100ms. If the battery is not connected,
* you can use PMU.disableCharge() to turn off the charging function.
* you can use PPM.disableCharge() to turn off the charging function.
* */
// PMU.disableCharge();
// PPM.disableCharge();

Serial.println("Battery remove");
}
Expand All @@ -159,13 +159,13 @@ void loop()
* * */
if (millis() > cycleInterval) {
Serial.printf("CHG TARGET VOLTAGE :%04dmV CURRENT:%04dmA PER_CHARGE_CUR %04dmA\n",
PMU.getChargeTargetVoltage(), PMU.getChargerConstantCurr(), PMU.getPrechargeCurr());
Serial.printf("VBUS:%s %04dmV VBAT:%04dmV VSYS:%04dmV\n", PMU.isVbusIn() ? "Connected" : "Disconnect",
PMU.getVbusVoltage(),
PMU.getBattVoltage(),
PMU.getSystemVoltage());
Serial.printf("BUS STATE:%d STR:%s\n", PMU.getBusStatus(), PMU.getBusStatusString());
Serial.printf("CHG STATE:%d STR:%s CURRENT:%04dmA\n", PMU.chargeStatus(), PMU.getChargeStatusString(), PMU.getChargeCurrent());
PPM.getChargeTargetVoltage(), PPM.getChargerConstantCurr(), PPM.getPrechargeCurr());
Serial.printf("VBUS:%s %04dmV VBAT:%04dmV VSYS:%04dmV\n", PPM.isVbusIn() ? "Connected" : "Disconnect",
PPM.getVbusVoltage(),
PPM.getBattVoltage(),
PPM.getSystemVoltage());
Serial.printf("BUS STATE:%d STR:%s\n", PPM.getBusStatus(), PPM.getBusStatusString());
Serial.printf("CHG STATE:%d STR:%s CURRENT:%04dmA\n", PPM.chargeStatus(), PPM.getChargeStatusString(), PPM.getChargeCurrent());
Serial.printf("[%lu]", millis() / 1000);
Serial.println("----------------------------------------------------------------------------------");
cycleInterval = millis() + 1000;
Expand Down
74 changes: 37 additions & 37 deletions examples/SY6970_Example/SY6970_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#include <XPowersLib.h>

PowersSY6970 PMU;
XPowersPPM PPM;


#ifndef CONFIG_PMU_SDA
Expand All @@ -37,59 +37,59 @@ void setup()
while (!Serial);


bool result = PMU.init(Wire, i2c_sda, i2c_scl, SY6970_SLAVE_ADDRESS);
bool result = PPM.init(Wire, i2c_sda, i2c_scl, SY6970_SLAVE_ADDRESS);

if (result == false) {
while (1) {
Serial.println("PMU is not online...");
Serial.println("PPM is not online...");
delay(50);
}
}

// Set the minimum operating voltage. Below this voltage, the PMU will protect
PMU.setSysPowerDownVoltage(3300);
// Set the minimum operating voltage. Below this voltage, the PPM will protect
PPM.setSysPowerDownVoltage(3300);

// Set input current limit, default is 500mA
PMU.setInputCurrentLimit(3250);
PPM.setInputCurrentLimit(3250);

Serial.printf("getInputCurrentLimit: %d mA\n", PMU.getInputCurrentLimit());
Serial.printf("getInputCurrentLimit: %d mA\n", PPM.getInputCurrentLimit());

// Disable current limit pin
PMU.disableCurrentLimitPin();
PPM.disableCurrentLimitPin();

// Set the charging target voltage, Range:3840 ~ 4608mV ,step:16 mV
PMU.setChargeTargetVoltage(4208);
PPM.setChargeTargetVoltage(4208);

// Set the precharge current , Range: 64mA ~ 1024mA ,step:64mA
PMU.setPrechargeCurr(64);
PPM.setPrechargeCurr(64);

// The premise is that Limit Pin is disabled, or it will only follow the maximum charging current set by Limi tPin.
// Set the charging current , Range:0~5056mA ,step:64mA
PMU.setChargerConstantCurr(1024);
PPM.setChargerConstantCurr(1024);

// Get the set charging current
PMU.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n", PMU.getChargerConstantCurr());
PPM.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n", PPM.getChargerConstantCurr());


// To obtain voltage data, the ADC must be enabled first
PMU.enableADCMeasure();
PPM.enableADCMeasure();

// Turn on charging function
// If there is no battery connected, do not turn on the charging function
PMU.enableCharge();
PPM.enableCharge();

// Turn off charging function
// If USB is used as the only power input, it is best to turn off the charging function,
// otherwise the VSYS power supply will have a sawtooth wave, affecting the discharge output capability.
// PMU.disableCharge();
// PPM.disableCharge();


// The OTG function needs to enable OTG, and set the OTG control pin to HIGH
// After OTG is enabled, if an external power supply is plugged in, OTG will be turned off

// PMU.enableOTG();
// PMU.disableOTG();
// PPM.enableOTG();
// PPM.disableOTG();
// pinMode(OTG_ENABLE_PIN, OUTPUT);
// digitalWrite(OTG_ENABLE_PIN, HIGH);

Expand All @@ -105,47 +105,47 @@ void loop()
{
if (pmu_irq) {
pmu_irq = false;
// Get PMU interrupt status
PMU.getIrqStatus();
// Get PPM interrupt status
PPM.getIrqStatus();

Serial.print("-> [");
Serial.print(millis() / 1000);
Serial.print("] ");

if (PMU.isWatchdogFault()) {
if (PPM.isWatchdogFault()) {

Serial.println("Watchdog Fault");

} else if (PMU.isBoostFault()) {
} else if (PPM.isBoostFault()) {

Serial.println("Boost Fault");

} else if (PMU.isChargeFault()) {
} else if (PPM.isChargeFault()) {

Serial.println("Charge Fault");

} else if (PMU.isBatteryFault()) {
} else if (PPM.isBatteryFault()) {

Serial.println("Batter Fault");

} else if (PMU.isNTCFault()) {
} else if (PPM.isNTCFault()) {

Serial.print("NTC Fault:");
Serial.print(PMU.getNTCStatusString());
Serial.print(PPM.getNTCStatusString());
Serial.print(" Percentage:");
Serial.print(PMU.getNTCPercentage()); Serial.println("%");
Serial.print(PPM.getNTCPercentage()); Serial.println("%");
}
// The battery may be disconnected or damaged.
else if (PMU.isVsysLowVoltageWarning()) {
else if (PPM.isVsysLowVoltageWarning()) {

Serial.println("In VSYSMIN regulation (BAT<VSYSMIN)");

} else {
/*
* When the battery is removed, INT will send an interrupt every 100ms. If the battery is not connected,
* you can use PMU.disableCharge() to turn off the charging function.
* you can use PPM.disableCharge() to turn off the charging function.
* */
// PMU.disableCharge();
// PPM.disableCharge();

Serial.println("Battery remove");
}
Expand All @@ -160,13 +160,13 @@ void loop()
* * */
if (millis() > cycleInterval) {
Serial.printf("CHG TARGET VOLTAGE :%04dmV CURRENT:%04dmA PER_CHARGE_CUR %04dmA\n",
PMU.getChargeTargetVoltage(), PMU.getChargerConstantCurr(), PMU.getPrechargeCurr());
Serial.printf("VBUS:%s %04dmV VBAT:%04dmV VSYS:%04dmV\n", PMU.isVbusIn() ? "Connected" : "Disconnect",
PMU.getVbusVoltage(),
PMU.getBattVoltage(),
PMU.getSystemVoltage());
Serial.printf("BUS STATE:%d STR:%s\n", PMU.getBusStatus(), PMU.getBusStatusString());
Serial.printf("CHG STATE:%d STR:%s CURRENT:%04dmA\n", PMU.chargeStatus(), PMU.getChargeStatusString(), PMU.getChargeCurrent());
PPM.getChargeTargetVoltage(), PPM.getChargerConstantCurr(), PPM.getPrechargeCurr());
Serial.printf("VBUS:%s %04dmV VBAT:%04dmV VSYS:%04dmV\n", PPM.isVbusIn() ? "Connected" : "Disconnect",
PPM.getVbusVoltage(),
PPM.getBattVoltage(),
PPM.getSystemVoltage());
Serial.printf("BUS STATE:%d STR:%s\n", PPM.getBusStatus(), PPM.getBusStatusString());
Serial.printf("CHG STATE:%d STR:%s CURRENT:%04dmA\n", PPM.chargeStatus(), PPM.getChargeStatusString(), PPM.getChargeCurrent());
Serial.printf("[%lu]", millis() / 1000);
Serial.println("----------------------------------------------------------------------------------");
cycleInterval = millis() + 1000;
Expand Down
10 changes: 5 additions & 5 deletions examples/SY6970_Shutdown_Example/SY6970_Shutdown_Example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
#include <XPowersLib.h>

PowersSY6970 PMU;
XPowersPPM PPM;


#ifndef CONFIG_PMU_SDA
Expand All @@ -34,10 +34,10 @@ void setup()
Serial.begin(115200);
while (!Serial);

bool result = PMU.init(Wire, i2c_sda, i2c_scl, SY6970_SLAVE_ADDRESS);
bool result = PPM.init(Wire, i2c_sda, i2c_scl, SY6970_SLAVE_ADDRESS);
if (result == false) {
while (1) {
Serial.println("PMU is not online...");
Serial.println("PPM is not online...");
delay(50);
}
}
Expand All @@ -54,9 +54,9 @@ void loop()
// The shutdown function can only be used when the battery is connected alone,
// and cannot be shut down when connected to USB.
// It can only be powered on in the following two ways:
// 1. Press the PMU/QON button
// 1. Press the /QON button
// 2. Connect to USB
PMU.shutdown();
PPM.shutdown();
countdown = 10000;
}
cycleInterval = millis() + 1000;
Expand Down
Loading

0 comments on commit d0751fb

Please sign in to comment.