axp173
What is this?
This is a embedded-hal driver for X-Powers' Power Management IC AXP173.
It's device-agnostic and uses embedded-hal's Write/WriteRead for I2C communication.
Usage
-
Add dependency to
Cargo.toml: -
Instantiate and init the device:
// ... declare and configure your I2c peripheral ... // Init AXP173 PMIC let axp173 = new; axp173.init?; Ok -
Configure the PMIC
// Set charging current to 100mA axp173 .set_charging_current?; // Enable internal ADCs // 25Hz sample rate, Disable TS, enable current sensing ADC axp173 .set_adc_settings?; // Enable battery gas gauge axp173.set_coulomb_counter?; axp173.resume_coulomb_counter?; // Power-off the device after 4 seconds of // long press of power button axp173.set_shutdown_long_press_time?; // Clear pending IRQs and enable some interesting IRQs axp173.clear_all_irq?; axp173.set_irq?; axp173.set_irq?; axp173.set_irq?; -
Handle PMIC IRQs:
// Inside an IRQ ISR: if axp173.check_irq? axp173.clear_all_irq?; // Clear everything else
Status
What is done and tested and what is not yet:
- Coulomb counter reading
- Coulomb counter control
- IRQs
- Battery voltage & current readings
- VBUS voltage & current readings
- AXP173 on-chip buffer
- Reading
- Checking default values
- Writing
- AXP173 LDO2, LDO3, LDO4 enable/disable
- LDO voltage setup
- VBUS presence
- Battery presence
- Battery charging status
- Charging current setup
- Charging regulated voltage setup
- Internal ADC settings:
- Sample rate
- Enable/Disable various ADC channels (batt. voltage, current, etc.)
- Button settings
- DC/DC settings
- Temperature sensor readings
- Instantaneous battery power reading