diff --git a/examples/BQ25896_Example/BQ25896_Example.ino b/examples/BQ25896_Example/BQ25896_Example.ino index 886293c..864d6b9 100644 --- a/examples/BQ25896_Example/BQ25896_Example.ino +++ b/examples/BQ25896_Example/BQ25896_Example.ino @@ -8,7 +8,7 @@ */ #include -PowersSY6970 PMU; +XPowersPPM PPM; #ifndef CONFIG_PMU_SDA @@ -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); @@ -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 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; diff --git a/examples/SY6970_Example/SY6970_Example.ino b/examples/SY6970_Example/SY6970_Example.ino index c371868..9df4bfd 100644 --- a/examples/SY6970_Example/SY6970_Example.ino +++ b/examples/SY6970_Example/SY6970_Example.ino @@ -10,7 +10,7 @@ */ #include -PowersSY6970 PMU; +XPowersPPM PPM; #ifndef CONFIG_PMU_SDA @@ -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); @@ -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 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; diff --git a/examples/SY6970_Shutdown_Example/SY6970_Shutdown_Example.ino b/examples/SY6970_Shutdown_Example/SY6970_Shutdown_Example.ino index 1b51be5..e060e94 100644 --- a/examples/SY6970_Shutdown_Example/SY6970_Shutdown_Example.ino +++ b/examples/SY6970_Shutdown_Example/SY6970_Shutdown_Example.ino @@ -8,7 +8,7 @@ */ #include -PowersSY6970 PMU; +XPowersPPM PPM; #ifndef CONFIG_PMU_SDA @@ -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); } } @@ -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; diff --git a/examples/SY6970_Watchdog_Example/SY6970_Watchdog_Example.ino b/examples/SY6970_Watchdog_Example/SY6970_Watchdog_Example.ino index 03d87d7..89f709c 100644 --- a/examples/SY6970_Watchdog_Example/SY6970_Watchdog_Example.ino +++ b/examples/SY6970_Watchdog_Example/SY6970_Watchdog_Example.ino @@ -8,7 +8,7 @@ */ #include -PowersSY6970 PMU; +XPowersPPM PPM; #ifndef CONFIG_PMU_SDA @@ -34,29 +34,29 @@ void setup() while (!Serial); - // Begin SY6970 PMU , Default disable watchdog timer - bool result = PMU.init(Wire, i2c_sda, i2c_scl, SY6970_SLAVE_ADDRESS); + // Begin SY6970 PPM , Default disable watchdog timer + 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); } } // Disable battery charge function - PMU.disableCharge(); + PPM.disableCharge(); /* * Example: - * PMU.enableWatchdog( SY6970_WDT_TIMEROUT_40SEC ); + * PPM.enableWatchdog( SY6970_WDT_TIMEROUT_40SEC ); * Optional parameters: * SY6970_WDT_TIMEROUT_40SEC, //40 Second * SY6970_WDT_TIMEROUT_80SEC, //80 Second * SY6970_WDT_TIMEROUT_160SEC, //160 Second * * */ - // Enabale SY6970 PMU watchdog function ,default timer out 40 second - PMU.enableWatchdog(); + // Enable SY6970 PPM watchdog function ,default timer out 40 second + PPM.enableWatchdog(); } @@ -64,9 +64,9 @@ void setup() void loop() { - // Feed watchdog , If the dog is not fed, the PMU will restart after a timeout, and all PMU settings will be restored to their default values + // Feed watchdog , If the dog is not fed, the PPM will restart after a timeout, and all PPM settings will be restored to their default values Serial.print(millis() / 1000); Serial.println(" Second"); - PMU.feedWatchdog(); + PPM.feedWatchdog(); delay(1000); }