Expand description
§AXP192 Power Management Chip Interface
This crate provides a bisync-based driver for the AXP192 power management IC,
built upon the device-driver
crate for robust, declarative register
definitions via a YAML manifest. It supports both asynchronous (async
)
and blocking operation through a unified API, using the bisync
crate
for seamless compatibility with both embedded-hal
and embedded-hal-async
traits.
§Features
- Declarative Register Map: Full device configuration defined in
device.yaml
. - Unified Async/Blocking Support: Write your code once and use it in both async and blocking contexts via bisync.
- Type-Safe API: High-level functions for common operations (e.g., setting voltages)
and a generated low-level API (
ll
) for direct register access. - Comprehensive Register Coverage: Aims to support the full feature set of the AXP192.
defmt
andlog
Integration: Optional support for logging and debugging.
§Getting Started
To use the driver, instantiate Axp192
(blocking) or Axp192Async
(async) with your I2C bus implementation:
let i2c_bus = todo!();
let mut axp = Axp192::new(i2c_bus);
axp.set_dcdc_voltage(DcId::Dcdc1, 3300)?;
For async environments, use Axp192Async
(re-exported from the asynchronous
module):
let i2c_bus = todo!();
let mut axp = Axp192Async::new(i2c_bus);
axp.set_dcdc_voltage(DcId::Dcdc1, 3300).await?;
For a detailed register map, please refer to the device.yaml
file in the
repository.
§Supported Devices
The AXP192 is found in various embedded devices, including but not limited to:
- M5Stack Core 2 (including the Core 2 for AWS variant)
- M5Stack Tough
- M5StickC
- M5StickC PLUS
§Warning!
Caution! This chip controls power to the microcontroller and other critical components. Incorrect configuration can potentially damage or brick your device. Proceed with care and always consult the AXP192 datasheet.
§Datasheet
Modules§
- field_
sets - Module containing the generated fieldsets of the registers and commands
Structs§
- Axp192
- Axp192
Async - AxpInterface
- AxpLow
Level - Root block of the AxpLowLevel driver
Enums§
- AdcSample
Rate Value - AxpError
- AxpStartup
Mode - Backup
Charge Current Value - Backup
Target Voltage Value - Battery
Flow Direction - Charge
Current Value - Charge
EndCurrent Threshold Value - Charge
Target Voltage Value - ChgLed
Control Source Select - ChgLed
Function Setting - Constant
Current Timeout Value - DcDc
Mode Selection - DcId
- External
Path Charge Current Value - Gpio0
Function Select - Gpio1
Function Select - Gpio2
Function Select - Gpio3
Function Setting - Gpio4
Function Setting - Gpio5
Direction - Gpio
AdcRange - LdoId
- NoeShutdown
Delay Value - Nrsto
PinFunction - PekLong
Press Time - PekPower
OnTime - PekShutdown
Time - Precharge
Timeout Value - Pwrok
Signal Delay - TsPin
Current Value - TsPin
Output Mode - Vbus
Current Limit Value - Vbus
Path Selection Control - Vbus
Valid Threshold Value - Vhold
Voltage Value - Voff
Voltage Value - VrcRise
Slope