Struct axp192::Axp192

source ·
pub struct Axp192<I2C> { /* private fields */ }
Expand description

The Axp192 struct is the main interface for this crate

Implementations§

source§

impl<I2C, E> Axp192<I2C>
where I2C: I2c<Error = E>,

source

pub fn new(i2c: I2C) -> Self

Construct a new Axp192

i2c must be an object which implements the I2C trait from embedded-hal

source

pub fn get_power_status(&mut self) -> Result<u8, E>

Get input power status register (00)

source

pub fn get_charging(&mut self) -> Result<bool, E>

Indicates the direction of battery current

source

pub fn get_vbus_usable(&mut self) -> Result<bool, E>

Instructions VBUS it’s usable or not

source

pub fn get_vbus_present(&mut self) -> Result<bool, E>

VBUS Presence indication

source

pub fn get_acin_usable(&mut self) -> Result<bool, E>

Instructions ACIN it’s usable or not

source

pub fn get_acin_present(&mut self) -> Result<bool, E>

ACIN Presence indication

source

pub fn get_exten_on(&mut self) -> Result<bool, E>

EXTEN Switch status

source

pub fn set_exten_on(&mut self, state: bool) -> Result<(), E>

EXTEN Switch control

source

pub fn get_dcdc1_on(&mut self) -> Result<bool, E>

DC-DC1 Switch status

source

pub fn set_dcdc1_on(&mut self, state: bool) -> Result<(), E>

DC-DC1 Switch control

Warning! This output is often connected to the microcontroller that you are controlling the AXP192 from!

source

pub fn get_dcdc3_on(&mut self) -> Result<bool, E>

DC-DC3 Switch status

source

pub fn set_dcdc3_on(&mut self, state: bool) -> Result<(), E>

DC-DC3 Switch control

source

pub fn get_ldo2_on(&mut self) -> Result<bool, E>

LDO2 Switch status

source

pub fn set_ldo2_on(&mut self, state: bool) -> Result<(), E>

LDO2 Switch control

source

pub fn get_ldo3_on(&mut self) -> Result<bool, E>

LDO3 Switch status

source

pub fn set_ldo3_on(&mut self, state: bool) -> Result<(), E>

LDO3 Switch control

source

pub fn get_dcdc2_on(&mut self) -> Result<bool, E>

DC-DC2 Switch status

source

pub fn set_dcdc2_on(&mut self, state: bool) -> Result<(), E>

DC-DC2 Switch control

source

pub fn set_dcdc1_voltage(&mut self, voltage: u16) -> Result<(), E>

DC-DC1 output voltage setting

0.7-3.5V , 25mV/step

Warning! This output is often connected to the microcontroller that you are controlling the AXP192 from!

source

pub fn set_dcdc3_voltage(&mut self, voltage: u16) -> Result<(), E>

DC-DC3 output voltage setting

0.7-3.5V , 25mV/step

source

pub fn set_ldo3_voltage(&mut self, voltage: u16) -> Result<(), E>

LDO3 Output voltage setting

1.8-3.3V , 100mV/step

source

pub fn set_ldo2_voltage(&mut self, voltage: u16) -> Result<(), E>

LDO2 Output voltage setting

1.8-3.3V , 100mV/step

source

pub fn set_ipsout_always(&mut self, state: bool) -> Result<(), E>

VBUS-IPSOUT channel management VBUS When available VBUS-IPSOUT Path selection control signal false: by N_VBUSEN pin Decide whether to open this channel true: :VBUS-IPSOUT Access can be selected to open, regardless of N_VBUSEN status

source

pub fn set_key_mode( &mut self, shutdown_duration: ShutdownDuration, powerok_delay: PowerOkDelay, automatic_shutdown: bool, longpress_duration: LongPress, boot_time: BootTime, ) -> Result<(), E>

PEK key parameter setting

source

pub fn get_acin_voltage(&mut self) -> Result<f32, E>

ACIN Voltage ADC

Return unit: volts

source

pub fn get_acin_current(&mut self) -> Result<f32, E>

ACIN Current ADC

Return unit: amps

source

pub fn get_vbus_voltage(&mut self) -> Result<f32, E>

VBUS Voltage ADC

Return unit: volts

source

pub fn get_vbus_current(&mut self) -> Result<f32, E>

VBUS Current ADC

Return unit: amps

source

pub fn get_internal_temperature(&mut self) -> Result<f32, E>

AXP192 Internal temperature monitoring

Return unit: °C

source

pub fn get_battery_voltage(&mut self) -> Result<f32, E>

Battery voltage

Return unit: volts

source

pub fn get_battery_charge_current(&mut self) -> Result<f32, E>

battery charging current

Return unit: amps

source

pub fn get_battery_discharge_current(&mut self) -> Result<f32, E>

battery discharge current

Return unit: amps

source

pub fn set_ts_adc_enable(&mut self, state: bool) -> Result<(), E>

TS Pin ADC Function enable

source

pub fn set_aps_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>

APS Voltage ADC Enable

source

pub fn set_vbus_current_adc_enable(&mut self, state: bool) -> Result<(), E>

VBUS Current ADC Enable

source

pub fn set_vbus_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>

VBUS Voltage ADC Enable

source

pub fn set_acin_current_adc_enable(&mut self, state: bool) -> Result<(), E>

ACIN Current ADC Enable

source

pub fn set_acin_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>

ACIN Voltage ADC Enable

source

pub fn set_battery_current_adc_enable(&mut self, state: bool) -> Result<(), E>

Battery current ADC Enable

source

pub fn set_battery_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>

battery voltage ADC Enable

source

pub fn set_gpio0_mode(&mut self, mode: GpioMode0) -> Result<(), E>

GPIO0 Pin function setting

source

pub fn set_gpio0_ldo_voltage(&mut self, voltage: u16) -> Result<(), E>

Output voltage setting when GPIO0 is in LDO mode

The input is clamped to between 1800mV and 3300mV, in steps of 100mV

source

pub fn set_gpio1_mode(&mut self, mode: GpioMode12) -> Result<(), E>

GPIO1 function setting

source

pub fn set_gpio2_mode(&mut self, mode: GpioMode12) -> Result<(), E>

GPIO2 function setting

source

pub fn set_gpio0_output(&mut self, state: bool) -> Result<(), E>

GPIO0 Output settings

  • false: Output low level, ground NMOS turn on
  • true: Output floating, grounded NMOS shut down
source

pub fn set_gpio1_output(&mut self, state: bool) -> Result<(), E>

GPIO1 Output settings

  • false: Output low level, ground NMOS turn on
  • true: Output floating, grounded NMOS shut down
source

pub fn set_gpio2_output(&mut self, state: bool) -> Result<(), E>

GPIO2 Output settings

  • false: Output low level, ground NMOS turn on
  • true: Output floating, grounded NMOS shut down
source

pub fn set_gpio3_mode(&mut self, mode: GpioMode34) -> Result<(), E>

GPIO3 Pin function setting

source

pub fn set_gpio4_mode(&mut self, mode: GpioMode34) -> Result<(), E>

GPIO4 Pin function setting

source

pub fn set_gpio3_output(&mut self, state: bool) -> Result<(), E>

GPIO3 Output settings

  • false: Output low level, NMOS turn on
  • true: Floating, NMOS shut down
source

pub fn set_gpio4_output(&mut self, state: bool) -> Result<(), E>

GPIO4 Output settings

  • false: Output low level, NMOS turn on
  • true: Floating, NMOS shut down

Auto Trait Implementations§

§

impl<I2C> Freeze for Axp192<I2C>
where I2C: Freeze,

§

impl<I2C> RefUnwindSafe for Axp192<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for Axp192<I2C>
where I2C: Send,

§

impl<I2C> Sync for Axp192<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for Axp192<I2C>
where I2C: Unpin,

§

impl<I2C> UnwindSafe for Axp192<I2C>
where I2C: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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.
source§

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

Performs the conversion.