[][src]Struct axp173::Axp173

pub struct Axp173<I> { /* fields omitted */ }

AXP173 PMIC instance.

Implementations

impl<I, E> Axp173<I> where
    I: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn set_irq(&mut self, irq: Irq, enabled: bool) -> Result<(), Error<E>>[src]

Enables or disables (masks) selected IRQ.

pub fn clear_irq(&mut self, irq: Irq) -> Result<(), Error<E>>[src]

Clears previously fired selected IRQ.

pub fn clear_all_irq(&mut self) -> Result<(), Error<E>>[src]

Clears ALL pending IRQs.

pub fn check_irq(&mut self, irq: Irq) -> Result<bool, Error<E>>[src]

Checks whether selected IRQ has fired or not. Note: one should clear the IRQ after checking or it will fire indefinitely

impl<I, E> Axp173<I> where
    I: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn new(i2c: I) -> Self[src]

Side-effect-free constructor. Nothing will be read or written before init() call.

pub fn free(self) -> I[src]

Consumes the driver and gives I2C bus back.

pub fn init(&mut self) -> Result<(), Error<E>>[src]

Checks the I2C connection to the AXP173 chip. AXP173 doesn't have a dedicated chip ID register and connection is checked by reading on-chip buffer for a presence of default values.

pub fn check(i2c: &mut I) -> bool[src]

Checks the I2C connection to the AXP173 chip but doesn't consume I2C bus.

pub fn read_onchip_buffer(&mut self) -> Result<[u8; 6], Error<E>>[src]

Reads 6-byte user data buffer from the chip.

pub fn write_onchip_buffer(&mut self, bytes: &[u8; 6]) -> Result<(), Error<E>>[src]

Writes 6-byte user data buffer into the chip.

pub fn vbus_present(&mut self) -> Result<bool, Error<E>>[src]

Returns true if device is connected to the USB power source.

pub fn battery_present(&mut self) -> Result<bool, Error<E>>[src]

Returns true if lithium battery is connected.

pub fn battery_charging(&mut self) -> Result<bool, Error<E>>[src]

Returns true if lithium battery is connected and currently charging.

pub fn enable_ldo(&mut self, ldo: &Ldo) -> Result<(), Error<E>>[src]

Enables selected LDO with selected output voltage.

pub fn disable_ldo(&mut self, ldo: &LdoKind) -> Result<(), Error<E>>[src]

Disables selected LDO.

pub fn read_ldo(&mut self, kind: LdoKind) -> Result<Ldo, Error<E>>[src]

Reads currently active settings of specific LDO from the chip.

pub fn set_charging_current(
    &mut self,
    current: ChargingCurrent
) -> Result<(), Error<E>>
[src]

Sets charging current of the battery. Adjust this for an efficient and safe charging of your lithium battery's capacity.

pub fn set_charging_voltage(
    &mut self,
    voltage: ChargingVoltage
) -> Result<(), Error<E>>
[src]

Sets battery charging regulation voltage. This value varies depending on battery's chemistry and should be as close to the value from battery's datasheet as possible to ensure efficient charging and long battery life.

pub fn set_charging(&mut self, enabled: bool) -> Result<(), Error<E>>[src]

Enables or disables battery charging.

pub fn set_adc_settings(
    &mut self,
    adc_settings: &AdcSettings
) -> Result<(), Error<E>>
[src]

Enables or disables certain ADC functions of AXP173.

pub fn vbus_voltage(&mut self) -> Result<Voltage, Error<E>>[src]

Returns VBUS voltage.

pub fn vbus_current(&mut self) -> Result<Current, Error<E>>[src]

Returns battery charging current.

pub fn batt_voltage(&mut self) -> Result<Voltage, Error<E>>[src]

Returns battery voltage.

pub fn batt_charge_current(&mut self) -> Result<Current, Error<E>>[src]

Returns battery charging current.

pub fn batt_discharge_current(&mut self) -> Result<Current, Error<E>>[src]

Returns battery discharging current.

pub fn set_coulomb_counter(&mut self, enabled: bool) -> Result<(), Error<E>>[src]

Enables or disables battery coulomb counter (e.g. fuel gauge).

NOTE:

  1. false will disable coulomb counter and reset its values to 0. If you want to pause the counter, use pause_coulomb_counter instead.

  2. If coulomb counter was paused before, use resume_coulomb_counter.

pub fn reset_coulomb_counter(&mut self) -> Result<(), Error<E>>[src]

Resets current coulomb counter value.

pub fn pause_coulomb_counter(&mut self) -> Result<(), Error<E>>[src]

Pauses coulomb counter without resetting.

pub fn resume_coulomb_counter(&mut self) -> Result<(), Error<E>>[src]

Resumes coulomb counter without resetting its values.

pub fn read_charge_coulomb_counter(&mut self) -> Result<u32, Error<E>>[src]

Returns current charging coulomb counter value (amount of current to battery).

pub fn read_discharge_coulomb_counter(&mut self) -> Result<u32, Error<E>>[src]

Returns current discharging coulomb counter value (amount of current from battery).

pub fn estimate_charge_level(
    &mut self,
    charge: Option<u32>
) -> Result<Option<f32>, Error<E>>
[src]

Estimates the current battery's State-of-Charge (remaining capacity) from calculated coulomb counter values in mAhs. Returns None if state-of-charge can't be calculated.

Optionally user can provide an initial charge coulombs value to be used instead of the value on-chip. This is useful for the very first usage when there are no charge current flown yet and the full battery is assumed.

Note: due to the separate charge and discharge coulomb counters, in order to correctly calibrate the estimation, the battery must have at least one discharge-charge cycle to have coulomb counters set to their initial values.

pub fn set_boot_time(&mut self, time: BootTime) -> Result<(), Error<E>>[src]

Sets delay before power-on.

pub fn set_long_press_time(
    &mut self,
    time: LongPressTime
) -> Result<(), Error<E>>
[src]

Sets time that's considered a "long button press".

pub fn set_shutdown_long_press_time(
    &mut self,
    time: ShutdownLongPressTime
) -> Result<(), Error<E>>
[src]

Sets button press time to initiate shutdown or power-on.

pub fn set_shutdown_long_press(&mut self, enabled: bool) -> Result<(), Error<E>>[src]

Enables or disables long-press shutdown.

pub fn shutdown(&mut self)[src]

Shuts AXP173 down.

Auto Trait Implementations

impl<I> Send for Axp173<I> where
    I: Send
[src]

impl<I> Sync for Axp173<I> where
    I: Sync
[src]

impl<I> Unpin for Axp173<I> where
    I: Unpin
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.