Skip to main content

Axp2101Driver

Struct Axp2101Driver 

Source
pub struct Axp2101Driver { /* private fields */ }

Implementations§

Source§

impl Axp2101Driver

Source

pub fn new(i2c: &'static SharedI2cBus, address: u8) -> Self

Source

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.

Source

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.

Source

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.

Source

pub async fn battery_voltage_mv(&mut self) -> Result<u16, Axp2101Error>

Read battery voltage in mV (14-bit ADC, 1 mV/LSB).

Source

pub async fn vbus_present(&mut self) -> Result<bool, Axp2101Error>

Returns true if VBUS (USB power) is present.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Axp2101Driver

§

impl !Send for Axp2101Driver

§

impl !Sync for Axp2101Driver

§

impl !UnwindSafe for Axp2101Driver

§

impl Freeze for Axp2101Driver

§

impl PsramSafe for Axp2101Driver

§

impl Unpin for Axp2101Driver

§

impl UnsafeUnpin for Axp2101Driver

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.