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>,
impl<I2C, E> Axp192<I2C>where
I2C: I2c<Error = E>,
sourcepub fn new(i2c: I2C) -> Self
pub fn new(i2c: I2C) -> Self
Construct a new Axp192
i2c
must be an object which implements the I2C trait from embedded-hal
sourcepub fn get_power_status(&mut self) -> Result<u8, E>
pub fn get_power_status(&mut self) -> Result<u8, E>
Get input power status register (00)
sourcepub fn get_charging(&mut self) -> Result<bool, E>
pub fn get_charging(&mut self) -> Result<bool, E>
Indicates the direction of battery current
sourcepub fn get_vbus_usable(&mut self) -> Result<bool, E>
pub fn get_vbus_usable(&mut self) -> Result<bool, E>
Instructions VBUS it’s usable or not
sourcepub fn get_vbus_present(&mut self) -> Result<bool, E>
pub fn get_vbus_present(&mut self) -> Result<bool, E>
VBUS Presence indication
sourcepub fn get_acin_usable(&mut self) -> Result<bool, E>
pub fn get_acin_usable(&mut self) -> Result<bool, E>
Instructions ACIN it’s usable or not
sourcepub fn get_acin_present(&mut self) -> Result<bool, E>
pub fn get_acin_present(&mut self) -> Result<bool, E>
ACIN Presence indication
sourcepub fn get_exten_on(&mut self) -> Result<bool, E>
pub fn get_exten_on(&mut self) -> Result<bool, E>
EXTEN Switch status
sourcepub fn set_exten_on(&mut self, state: bool) -> Result<(), E>
pub fn set_exten_on(&mut self, state: bool) -> Result<(), E>
EXTEN Switch control
sourcepub fn get_dcdc1_on(&mut self) -> Result<bool, E>
pub fn get_dcdc1_on(&mut self) -> Result<bool, E>
DC-DC1 Switch status
sourcepub fn set_dcdc1_on(&mut self, state: bool) -> Result<(), E>
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!
sourcepub fn get_dcdc3_on(&mut self) -> Result<bool, E>
pub fn get_dcdc3_on(&mut self) -> Result<bool, E>
DC-DC3 Switch status
sourcepub fn set_dcdc3_on(&mut self, state: bool) -> Result<(), E>
pub fn set_dcdc3_on(&mut self, state: bool) -> Result<(), E>
DC-DC3 Switch control
sourcepub fn get_ldo2_on(&mut self) -> Result<bool, E>
pub fn get_ldo2_on(&mut self) -> Result<bool, E>
LDO2 Switch status
sourcepub fn set_ldo2_on(&mut self, state: bool) -> Result<(), E>
pub fn set_ldo2_on(&mut self, state: bool) -> Result<(), E>
LDO2 Switch control
sourcepub fn get_ldo3_on(&mut self) -> Result<bool, E>
pub fn get_ldo3_on(&mut self) -> Result<bool, E>
LDO3 Switch status
sourcepub fn set_ldo3_on(&mut self, state: bool) -> Result<(), E>
pub fn set_ldo3_on(&mut self, state: bool) -> Result<(), E>
LDO3 Switch control
sourcepub fn get_dcdc2_on(&mut self) -> Result<bool, E>
pub fn get_dcdc2_on(&mut self) -> Result<bool, E>
DC-DC2 Switch status
sourcepub fn set_dcdc2_on(&mut self, state: bool) -> Result<(), E>
pub fn set_dcdc2_on(&mut self, state: bool) -> Result<(), E>
DC-DC2 Switch control
sourcepub fn set_dcdc1_voltage(&mut self, voltage: u16) -> Result<(), E>
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!
sourcepub fn set_dcdc3_voltage(&mut self, voltage: u16) -> Result<(), E>
pub fn set_dcdc3_voltage(&mut self, voltage: u16) -> Result<(), E>
DC-DC3 output voltage setting
0.7-3.5V , 25mV/step
sourcepub fn set_ldo3_voltage(&mut self, voltage: u16) -> Result<(), E>
pub fn set_ldo3_voltage(&mut self, voltage: u16) -> Result<(), E>
LDO3 Output voltage setting
1.8-3.3V , 100mV/step
sourcepub fn set_ldo2_voltage(&mut self, voltage: u16) -> Result<(), E>
pub fn set_ldo2_voltage(&mut self, voltage: u16) -> Result<(), E>
LDO2 Output voltage setting
1.8-3.3V , 100mV/step
sourcepub fn set_ipsout_always(&mut self, state: bool) -> Result<(), E>
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
sourcepub fn set_key_mode(
&mut self,
shutdown_duration: ShutdownDuration,
powerok_delay: PowerOkDelay,
automatic_shutdown: bool,
longpress_duration: LongPress,
boot_time: BootTime,
) -> Result<(), E>
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
sourcepub fn get_acin_voltage(&mut self) -> Result<f32, E>
pub fn get_acin_voltage(&mut self) -> Result<f32, E>
ACIN Voltage ADC
Return unit: volts
sourcepub fn get_acin_current(&mut self) -> Result<f32, E>
pub fn get_acin_current(&mut self) -> Result<f32, E>
ACIN Current ADC
Return unit: amps
sourcepub fn get_vbus_voltage(&mut self) -> Result<f32, E>
pub fn get_vbus_voltage(&mut self) -> Result<f32, E>
VBUS Voltage ADC
Return unit: volts
sourcepub fn get_vbus_current(&mut self) -> Result<f32, E>
pub fn get_vbus_current(&mut self) -> Result<f32, E>
VBUS Current ADC
Return unit: amps
sourcepub fn get_internal_temperature(&mut self) -> Result<f32, E>
pub fn get_internal_temperature(&mut self) -> Result<f32, E>
AXP192 Internal temperature monitoring
Return unit: °C
sourcepub fn get_battery_voltage(&mut self) -> Result<f32, E>
pub fn get_battery_voltage(&mut self) -> Result<f32, E>
Battery voltage
Return unit: volts
sourcepub fn get_battery_charge_current(&mut self) -> Result<f32, E>
pub fn get_battery_charge_current(&mut self) -> Result<f32, E>
battery charging current
Return unit: amps
sourcepub fn get_battery_discharge_current(&mut self) -> Result<f32, E>
pub fn get_battery_discharge_current(&mut self) -> Result<f32, E>
battery discharge current
Return unit: amps
sourcepub fn set_ts_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_ts_adc_enable(&mut self, state: bool) -> Result<(), E>
TS Pin ADC Function enable
sourcepub fn set_aps_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_aps_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
APS Voltage ADC Enable
sourcepub fn set_vbus_current_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_vbus_current_adc_enable(&mut self, state: bool) -> Result<(), E>
VBUS Current ADC Enable
sourcepub fn set_vbus_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_vbus_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
VBUS Voltage ADC Enable
sourcepub fn set_acin_current_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_acin_current_adc_enable(&mut self, state: bool) -> Result<(), E>
ACIN Current ADC Enable
sourcepub fn set_acin_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_acin_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
ACIN Voltage ADC Enable
sourcepub fn set_battery_current_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_battery_current_adc_enable(&mut self, state: bool) -> Result<(), E>
Battery current ADC Enable
sourcepub fn set_battery_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
pub fn set_battery_voltage_adc_enable(&mut self, state: bool) -> Result<(), E>
battery voltage ADC Enable
sourcepub fn set_gpio0_mode(&mut self, mode: GpioMode0) -> Result<(), E>
pub fn set_gpio0_mode(&mut self, mode: GpioMode0) -> Result<(), E>
GPIO0 Pin function setting
sourcepub fn set_gpio0_ldo_voltage(&mut self, voltage: u16) -> Result<(), E>
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
sourcepub fn set_gpio1_mode(&mut self, mode: GpioMode12) -> Result<(), E>
pub fn set_gpio1_mode(&mut self, mode: GpioMode12) -> Result<(), E>
GPIO1 function setting
sourcepub fn set_gpio2_mode(&mut self, mode: GpioMode12) -> Result<(), E>
pub fn set_gpio2_mode(&mut self, mode: GpioMode12) -> Result<(), E>
GPIO2 function setting
sourcepub fn set_gpio0_output(&mut self, state: bool) -> Result<(), E>
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
sourcepub fn set_gpio1_output(&mut self, state: bool) -> Result<(), E>
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
sourcepub fn set_gpio2_output(&mut self, state: bool) -> Result<(), E>
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
sourcepub fn set_gpio3_mode(&mut self, mode: GpioMode34) -> Result<(), E>
pub fn set_gpio3_mode(&mut self, mode: GpioMode34) -> Result<(), E>
GPIO3 Pin function setting
sourcepub fn set_gpio4_mode(&mut self, mode: GpioMode34) -> Result<(), E>
pub fn set_gpio4_mode(&mut self, mode: GpioMode34) -> Result<(), E>
GPIO4 Pin function setting
sourcepub fn set_gpio3_output(&mut self, state: bool) -> Result<(), E>
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
sourcepub fn set_gpio4_output(&mut self, state: bool) -> Result<(), E>
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