ad5668

Struct AD5668

Source
pub struct AD5668<SPI, CS> { /* private fields */ }
Expand description

AD5668 DAC driver. Wraps an I2C port to send commands to an AD5668

Implementations§

Source§

impl<SPI, CS, E> AD5668<SPI, CS>
where SPI: Write<u8, Error = E>, CS: OutputPin,

Source

pub fn new(spi: SPI, chip_select: CS) -> Self

Construct a new AD5668 driver

Source

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

Write input register for the dac at address with the value, does not update dac register yet

Source

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

Update dac register for the dac at address TODO: Check if the data is written too or if this just updates data written earlier to the dac

Source

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

Write to a single input register, then update all dac channels. This can be used as the last command when updating multiple DACs. First stage values for all DACs then update them simultaniously by performing the last write using this command

Source

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

Write to input register and then update the dac register in one command.

Source

pub fn set_power( &mut self, power_mode: PowerMode, channel_states: u8, ) -> Result<(), E>

Set the power to the dacs. Use power_mode to set the power down mode, channel states can be used to power up the individual dacs by setting the corresponding bits.

Source

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

Enable the internal reference

Source

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

Disable the internal reference

Source

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

Reset the DAC

Source

pub fn destroy(self) -> (SPI, CS)

Destroy the driver and return the wrapped SPI driver to be re-used

Auto Trait Implementations§

§

impl<SPI, CS> Freeze for AD5668<SPI, CS>
where SPI: Freeze, CS: Freeze,

§

impl<SPI, CS> RefUnwindSafe for AD5668<SPI, CS>
where SPI: RefUnwindSafe, CS: RefUnwindSafe,

§

impl<SPI, CS> Send for AD5668<SPI, CS>
where SPI: Send, CS: Send,

§

impl<SPI, CS> Sync for AD5668<SPI, CS>
where SPI: Sync, CS: Sync,

§

impl<SPI, CS> Unpin for AD5668<SPI, CS>
where SPI: Unpin, CS: Unpin,

§

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