INA226

Struct INA226 

Source
pub struct INA226<I2C> { /* private fields */ }
Expand description

INA226 voltage/current/power monitor

Implementations§

Source§

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

Source

pub fn new(i2c: I2C, address: u8) -> INA226<I2C>

Create a new instance of an INA226 device.

Source

pub fn configuration_raw(&mut self) -> Result<u16, E>

Gets the raw configuration value.

Source

pub fn configuration(&mut self) -> Result<Option<Config>, E>

Gets the configuration.

Source

pub fn set_configuration(&mut self, config: &Config) -> Result<(), E>

Set the configuration of the device.

Source

pub fn shunt_voltage_raw(&mut self) -> Result<i16, E>

Gets the raw shunt voltage measurement.

Source

pub fn shunt_voltage_microvolts(&mut self) -> Result<f64, E>

Gets the shunt voltage in microvolts.

Source

pub fn bus_voltage_raw(&mut self) -> Result<u16, E>

Gets the raw bus voltage measurement.

Source

pub fn bus_voltage_millivolts(&mut self) -> Result<f64, E>

Gets the bus voltage in millivolts.

Source

pub fn power_raw(&mut self) -> Result<u16, E>

Gets the raw calculated power being delivered to the load. Returns zero if callibration has not been performed.

Source

pub fn power_watts(&mut self) -> Result<Option<f64>, E>

Gets the calculated power (in Watts) being delivered to the load. Requires callibration.

Source

pub fn current_raw(&mut self) -> Result<i16, E>

Gets the calculated current flowing through the shunt resistor. Returns zero if callibration has not been performed.

Source

pub fn current_amps(&mut self) -> Result<Option<f64>, E>

Gets the calculated current (in Amps) flowing through the shunt resistor. Requires callibration.

Source

pub fn callibration(&mut self) -> Result<u16, E>

Gets the callibration register, which controls full-scale range of current and power measurements.

Source

pub fn set_callibration_raw(&mut self, value: u16) -> Result<(), E>

Set the callibration register directly. NB: after calling this, only _raw methods can be used.

Source

pub fn callibrate( &mut self, shunt_resistance: f64, current_expected_max: f64, ) -> Result<(), E>

Calibrate the sensitvity of the current and power values.

Source

pub fn mask_enable(&mut self) -> Result<MaskEnableFlags, E>

Get the Alert configuration and Conversion Ready flag.

Source

pub fn set_mask_enable(&mut self, flags: MaskEnableFlags) -> Result<(), E>

Set the Alert configuration and Conversion Ready flags.

Source

pub fn alert_limit(&mut self) -> Result<u16, E>

Get the limit value to compare to the selected Alert function.

Source

pub fn set_alert_limit(&mut self, value: u16) -> Result<(), E>

Set the Alert Limit register.

Source

pub fn manufacturer_id(&mut self) -> Result<u16, E>

Get the unique manufacturer identification number

Source

pub fn die_id(&mut self) -> Result<u16, E>

Get the unique die identification number.

Source

pub fn destroy(self) -> I2C

Destroy the INA226 instance and return the I2C.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<I2C> UnwindSafe for INA226<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>,

Source§

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>,

Source§

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.