Struct MCP4725

Source
pub struct MCP4725<I: I2c<SevenBitAddress>> { /* private fields */ }
Expand description

The MCP4725 device

Implementations§

Source§

impl<I: I2c<SevenBitAddress>> MCP4725<I>

Source

pub fn new(i2c: I, address: SevenBitAddress) -> Self

Create a new device from an I2C peripheral and address.

Source

pub fn destroy(self) -> I

Destroy this device and get the I2C instance back.

Source

pub async fn set_voltage( &mut self, dac: u16, write_eeprom: bool, ) -> Result<(), I::Error>

Convenience function to just set the output voltage. Only the lower 12 bits of the DAC value are used. If write_eeprom is true, the DAC value will also be written to the EEPROM and the EEPROM power down mode will be set to Normal.

Source

pub async fn read(&mut self) -> Result<(RegisterStatus, EEPROMStatus), I::Error>

Perform a read command. This will return the value in the DAC register and the EEPROM data.

Source

pub async fn fast_write( &mut self, power_down_mode: PowerDownMode, dac: u16, ) -> Result<(), I::Error>

Perform a fast write. This can set the power down mode and the DAC value. This only changes the DAC register and does not affect the EEPROM. Only the lower 12 bits of the DAC value are used.

Source

pub async fn write( &mut self, power_down_mode: PowerDownMode, dac: u16, write_eeprom: bool, ) -> Result<(), I::Error>

Perform a normal write. This can set the power down mode and the DAC value, and optionally write to the EEPROM. Only the lower 12 bits of the DAC value are used.

Auto Trait Implementations§

§

impl<I> Freeze for MCP4725<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for MCP4725<I>
where I: RefUnwindSafe,

§

impl<I> Send for MCP4725<I>
where I: Send,

§

impl<I> Sync for MCP4725<I>
where I: Sync,

§

impl<I> Unpin for MCP4725<I>
where I: Unpin,

§

impl<I> UnwindSafe for MCP4725<I>
where I: 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.