pub struct Axp2101Driver { /* private fields */ }Implementations§
Source§impl Axp2101Driver
impl Axp2101Driver
pub fn new(i2c: &'static SharedI2cBus, address: u8) -> Self
Sourcepub async fn set_dldo1(
&mut self,
enabled: bool,
mv: u16,
) -> Result<(), Axp2101Error>
pub async fn set_dldo1( &mut self, enabled: bool, mv: u16, ) -> Result<(), Axp2101Error>
Enable or disable DLDO1 and set output voltage (mV). Range: 500–3400 mV, 100 mV steps.
Sourcepub async fn power_off(&mut self) -> Result<(), Axp2101Error>
pub async fn power_off(&mut self) -> Result<(), Axp2101Error>
Soft power-off: drop every rail and stay down until the power key is pressed.
The deepest off state CoreS3 has: every rail down, against the ~10-30 mA an ESP deep sleep still leaves on VDD_3V3 (AW9523B, FT6336U, LCD logic, this chip). The power key reaches PWRON and nothing else, which is exactly what brings the rails back.
The alternative is an ESP deep sleep woken by touch: TOUCH_INT ->
AW9523B P1_2 -> AW9523B INTN -> GPIO21, an RTC IO (M5Unified uses it as
its CoreS3 _wakeupPin). That trades the residual draw for a nicer wake
gesture; this trades the gesture for the draw.
Read-modify-write — REG 0x10 also holds the PWRON-shutdown, PWROK-pin and internal-discharge configuration.
Returns only if the write failed; on success the caller is gone with the rails. Note the PMIC powers back up on its own while VBUS is present.
Sourcepub async fn enable_battery_adc(&mut self) -> Result<(), Axp2101Error>
pub async fn enable_battery_adc(&mut self) -> Result<(), Axp2101Error>
Enable the battery-voltage ADC channel (REG 0x30 bit 0). Must be called
once before battery_voltage_mv returns a
live reading — the ADC is off at reset, so the VBAT registers read 0.
Sourcepub async fn battery_voltage_mv(&mut self) -> Result<u16, Axp2101Error>
pub async fn battery_voltage_mv(&mut self) -> Result<u16, Axp2101Error>
Read battery voltage in mV (14-bit ADC, 1 mV/LSB).
Sourcepub async fn vbus_present(&mut self) -> Result<bool, Axp2101Error>
pub async fn vbus_present(&mut self) -> Result<bool, Axp2101Error>
Returns true if VBUS (USB power) is present.