INA229

Struct INA229 

Source
pub struct INA229<SPI, NCS> { /* private fields */ }
Expand description

INA229 voltage/current/power monitor

Implementations§

Source§

impl<SPI, NCS, SPIError, CSError> INA229<SPI, NCS>
where SPI: Transfer<u8, Error = SPIError> + Write<u8, Error = SPIError>, NCS: OutputPin<Error = CSError>,

Source

pub fn new(spi: SPI, ncs: NCS) -> Self

Create a new instance of an INA229 device.

Source

pub fn release(self) -> (SPI, NCS)

Destroy the INA229 instance and return the SPI.

Source

pub fn set_configuration( &mut self, configuration: Configuration, ) -> Result<(), Error<SPIError, CSError>>

Sets the CONFIG register with the value provided.

Source

pub fn configuration( &mut self, ) -> Result<Configuration, Error<SPIError, CSError>>

Get the configuration.

Source

pub fn shunt_calibration(&mut self) -> Result<u16, Error<SPIError, CSError>>

Gets the value from the shunt calibration register.

Source

pub fn set_shunt_calibration( &mut self, value: u16, ) -> Result<(), Error<SPIError, CSError>>

Sets the shunt calibration register to the value provided.

Source

pub fn calibrate( &mut self, shunt_resistance: f64, current_expected_max: f64, ) -> Result<(), Error<SPIError, CSError>>

Calculate the shunt calibration value and write to the shunt calibration register.

Source

pub fn configure_and_calibrate( &mut self, configuration: Configuration, shunt_resistance: f64, current_expected_max: f64, ) -> Result<(), Error<SPIError, CSError>>

Calculate the shunt calibration value and write to the shunt calibration register.

Source

pub fn bus_voltage_raw(&mut self) -> Result<i32, Error<SPIError, CSError>>

Get the raw bus voltage reading.

Source

pub fn bus_voltage_microvolts( &mut self, ) -> Result<f64, Error<SPIError, CSError>>

Get the bus voltage reading in microvolts.

Source

pub fn shunt_voltage_raw(&mut self) -> Result<i32, Error<SPIError, CSError>>

Get the raw shunt voltage reading.

Source

pub fn shunt_voltage_nanovolts( &mut self, ) -> Result<f64, Error<SPIError, CSError>>

Get the shunt voltage reading in nanovolts.

Source

pub fn temperature_raw(&mut self) -> Result<i16, Error<SPIError, CSError>>

Get the raw die temperature value.

Source

pub fn temperature_millidegrees_celsius( &mut self, ) -> Result<f64, Error<SPIError, CSError>>

Get the die temperature in millidegrees Celsius.

Source

pub fn current_raw(&mut self) -> Result<i32, Error<SPIError, CSError>>

Get the raw value from the current register.

Source

pub fn current_amps(&mut self) -> Result<f64, Error<SPIError, CSError>>

Get the current reading in Amps.

Source

pub fn power_raw(&mut self) -> Result<u32, Error<SPIError, CSError>>

Get the raw value from the power register

Source

pub fn power_watts(&mut self) -> Result<f64, Error<SPIError, CSError>>

Get the power reading in Watts.

Source

pub fn manufacturer_id(&mut self) -> Result<u16, Error<SPIError, CSError>>

Get the unique manufacturer identification number.

Source

pub fn device_id(&mut self) -> Result<u16, Error<SPIError, CSError>>

Get the unique die identification number.

Auto Trait Implementations§

§

impl<SPI, NCS> Freeze for INA229<SPI, NCS>
where SPI: Freeze, NCS: Freeze,

§

impl<SPI, NCS> RefUnwindSafe for INA229<SPI, NCS>
where SPI: RefUnwindSafe, NCS: RefUnwindSafe,

§

impl<SPI, NCS> Send for INA229<SPI, NCS>
where SPI: Send, NCS: Send,

§

impl<SPI, NCS> Sync for INA229<SPI, NCS>
where SPI: Sync, NCS: Sync,

§

impl<SPI, NCS> Unpin for INA229<SPI, NCS>
where SPI: Unpin, NCS: Unpin,

§

impl<SPI, NCS> UnwindSafe for INA229<SPI, NCS>
where SPI: UnwindSafe, NCS: 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.