xpowers lib updates
This commit is contained in:
parent
ed92647936
commit
2d05e1696e
@ -82,7 +82,7 @@ lib_deps_basic =
|
|||||||
bblanchon/ArduinoJson @ ^6
|
bblanchon/ArduinoJson @ ^6
|
||||||
makuna/RTC @ ^2.3.5
|
makuna/RTC @ ^2.3.5
|
||||||
spacehuhn/SimpleButton
|
spacehuhn/SimpleButton
|
||||||
https://github.com/lewisxhe/XPowersLib.git
|
lewisxhe/XPowersLib @ ^0.1.4
|
||||||
256dpi/MQTT @ ^2.4.8
|
256dpi/MQTT @ ^2.4.8
|
||||||
lib_deps_all =
|
lib_deps_all =
|
||||||
${common.lib_deps_basic}
|
${common.lib_deps_basic}
|
||||||
|
@ -36,10 +36,10 @@ Reset -> reset device
|
|||||||
#define HAS_PMU 1 // has AXP192 chip
|
#define HAS_PMU 1 // has AXP192 chip
|
||||||
#define XPOWERS_CHIP_AXP192 1
|
#define XPOWERS_CHIP_AXP192 1
|
||||||
#define PMU_INT GPIO_NUM_35 // battery interrupt
|
#define PMU_INT GPIO_NUM_35 // battery interrupt
|
||||||
#define PMU_CHG_CURRENT XPOWERS_CHG_CUR_1000MA // battery charge current
|
#define PMU_CHG_CURRENT XPOWERS_AXP192_CHG_CUR_1000MA // battery charge current
|
||||||
// possible values (mA):
|
// possible values (mA):
|
||||||
// 100/190/280/360/450/550/630/700/780/880/960/1000/1080/1160/1240/1320
|
// 100/190/280/360/450/550/630/700/780/880/960/1000/1080/1160/1240/1320
|
||||||
#define PMU_CHG_CUTOFF XPOWERS_CHG_VOL_4V2 // battery charge cutoff
|
#define PMU_CHG_CUTOFF XPOWERS_AXP192_CHG_VOL_4V2 // battery charge cutoff
|
||||||
// possible values (V):
|
// possible values (V):
|
||||||
// 4V1/4V15/4V2/4V36
|
// 4V1/4V15/4V2/4V36
|
||||||
|
|
||||||
|
@ -67,13 +67,11 @@ void AXP192_powerevent_IRQ(void) {
|
|||||||
void AXP192_power(pmu_power_t powerlevel) {
|
void AXP192_power(pmu_power_t powerlevel) {
|
||||||
switch (powerlevel) {
|
switch (powerlevel) {
|
||||||
case pmu_power_off:
|
case pmu_power_off:
|
||||||
pmu.setChargerLedFunction(XPOWER_AXP192_CHGLED_CTRL_MANUAL);
|
pmu.setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||||
pmu.setChargingLedFreq(XPOWERS_AXP192_CHG_LED_DISABLE);
|
|
||||||
pmu.shutdown();
|
pmu.shutdown();
|
||||||
break;
|
break;
|
||||||
case pmu_power_sleep:
|
case pmu_power_sleep:
|
||||||
pmu.setChargerLedFunction(XPOWER_AXP192_CHGLED_CTRL_MANUAL);
|
pmu.setChargingLedMode(XPOWERS_CHG_LED_CTRL_CHG);
|
||||||
pmu.setChargingLedFreq(XPOWERS_AXP192_CHG_LED_FRE_1HZ);
|
|
||||||
// we don't cut off DCDC1, because OLED display will then block i2c bus
|
// we don't cut off DCDC1, because OLED display will then block i2c bus
|
||||||
// pmu.disableDC1(); // OLED off
|
// pmu.disableDC1(); // OLED off
|
||||||
pmu.disableLDO3(); // gps off
|
pmu.disableLDO3(); // gps off
|
||||||
@ -85,8 +83,7 @@ void AXP192_power(pmu_power_t powerlevel) {
|
|||||||
pmu.enableLDO2(); // Lora on T-Beam V1.0/1.1
|
pmu.enableLDO2(); // Lora on T-Beam V1.0/1.1
|
||||||
pmu.enableLDO3(); // Gps on T-Beam V1.0/1.1
|
pmu.enableLDO3(); // Gps on T-Beam V1.0/1.1
|
||||||
pmu.enableDC1(); // OLED on T-Beam v1.0/1.1
|
pmu.enableDC1(); // OLED on T-Beam v1.0/1.1
|
||||||
pmu.setChargerLedFunction(XPOWER_AXP192_CHGLED_CTRL_MANUAL);
|
pmu.setChargingLedMode(XPOWERS_CHG_LED_ON);
|
||||||
pmu.setChargingLedFreq(XPOWERS_AXP192_CHG_LED_LEVEL_LOW);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,9 +112,9 @@ void AXP192_init(void) {
|
|||||||
ESP_LOGD(TAG, "AXP192 ChipID:0x%x", pmu.getChipID());
|
ESP_LOGD(TAG, "AXP192 ChipID:0x%x", pmu.getChipID());
|
||||||
|
|
||||||
// set pmu operating voltages
|
// set pmu operating voltages
|
||||||
pmu.setMinSystemVoltage(2700);
|
pmu.setSysPowerDownVoltage(2700);
|
||||||
pmu.setVbusVoltageLimit(XPOWERS_VBUS_VOL_LIM_4V5);
|
pmu.setVbusVoltageLimit(XPOWERS_AXP192_VBUS_VOL_LIM_4V5);
|
||||||
pmu.disableVbusCurrLimit();
|
pmu.setVbusCurrentLimit(XPOWERS_AXP192_VBUS_CUR_LIM_OFF);
|
||||||
|
|
||||||
// set device operating voltages
|
// set device operating voltages
|
||||||
pmu.setDC1Voltage(3300); // for external OLED display
|
pmu.setDC1Voltage(3300); // for external OLED display
|
||||||
@ -125,8 +122,8 @@ void AXP192_init(void) {
|
|||||||
pmu.setLDO3Voltage(3300); // GPS VDD 3v3
|
pmu.setLDO3Voltage(3300); // GPS VDD 3v3
|
||||||
|
|
||||||
// configure PEK button settings
|
// configure PEK button settings
|
||||||
pmu.setPowerKeyPressOffTime(XPOWERS_AXP192_POWEROFF_4S);
|
pmu.setPowerKeyPressOffTime(XPOWERS_POWEROFF_4S);
|
||||||
pmu.setPowerKeyPressOnTime(XPOWERS_AXP192_POWERON_128MS);
|
pmu.setPowerKeyPressOnTime(XPOWERS_POWERON_128MS);
|
||||||
|
|
||||||
// set battery temperature sensing pin off to save power
|
// set battery temperature sensing pin off to save power
|
||||||
pmu.disableTSPinMeasure();
|
pmu.disableTSPinMeasure();
|
||||||
@ -141,21 +138,21 @@ void AXP192_init(void) {
|
|||||||
pinMode(PMU_INT, INPUT_PULLUP);
|
pinMode(PMU_INT, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(PMU_INT), PMUIRQ, FALLING);
|
attachInterrupt(digitalPinToInterrupt(PMU_INT), PMUIRQ, FALLING);
|
||||||
// disable all interrupts
|
// disable all interrupts
|
||||||
pmu.disableIRQ(XPOWERS_ALL_IRQ);
|
pmu.disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||||
// clear all interrupt flags
|
// clear all interrupt flags
|
||||||
pmu.clearIrqStatus();
|
pmu.clearIrqStatus();
|
||||||
// enable the required interrupt function
|
// enable the required interrupt function
|
||||||
pmu.enableIRQ(XPOWERS_BAT_INSERT_IRQ | XPOWERS_BAT_REMOVE_IRQ | // BATTERY
|
pmu.enableIRQ(XPOWERS_AXP192_BAT_INSERT_IRQ | XPOWERS_AXP192_BAT_REMOVE_IRQ | // BATTERY
|
||||||
XPOWERS_VBUS_INSERT_IRQ | XPOWERS_VBUS_REMOVE_IRQ | // VBUS
|
XPOWERS_AXP192_VBUS_INSERT_IRQ | XPOWERS_AXP192_VBUS_REMOVE_IRQ | // VBUS
|
||||||
XPOWERS_PKEY_SHORT_IRQ | XPOWERS_PKEY_LONG_IRQ | // POWER KEY
|
XPOWERS_AXP192_PKEY_SHORT_IRQ | XPOWERS_AXP192_PKEY_LONG_IRQ | // POWER KEY
|
||||||
XPOWERS_BAT_CHG_DONE_IRQ | XPOWERS_BAT_CHG_START_IRQ // CHARGE
|
XPOWERS_AXP192_BAT_CHG_DONE_IRQ | XPOWERS_AXP192_BAT_CHG_START_IRQ // CHARGE
|
||||||
);
|
);
|
||||||
#endif // PMU_INT
|
#endif // PMU_INT
|
||||||
|
|
||||||
// set charging parameters according to user settings if we have (see power.h)
|
// set charging parameters according to user settings if we have (see power.h)
|
||||||
#ifdef PMU_CHG_CURRENT
|
#ifdef PMU_CHG_CURRENT
|
||||||
pmu.setChargeCurrent(PMU_CHG_CURRENT);
|
pmu.setChargerConstantCurr(PMU_CHG_CURRENT);
|
||||||
pmu.setChargerVoltageLimit(PMU_CHG_CUTOFF);
|
pmu.setChargeTargetVoltage(PMU_CHG_CUTOFF);
|
||||||
pmu.enableCharge();
|
pmu.enableCharge();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user