pub struct Dac80501<Spi> { /* private fields */ }
Expand description
A 16 bit DAC
Implementations
sourceimpl<Spi> Dac80501<Spi> where
Spi: SpiDevice,
Spi::Bus: SpiBusWrite,
DacError: From<<Spi as ErrorType>::Error>,
impl<Spi> Dac80501<Spi> where
Spi: SpiDevice,
Spi::Bus: SpiBusWrite,
DacError: From<<Spi as ErrorType>::Error>,
sourceimpl<Spi> Dac80501<Spi> where
Spi: SpiDevice,
Spi::Bus: SpiBusWrite,
DacError: From<<Spi as ErrorType>::Error>,
impl<Spi> Dac80501<Spi> where
Spi: SpiDevice,
Spi::Bus: SpiBusWrite,
DacError: From<<Spi as ErrorType>::Error>,
sourcepub fn new(spi: Spi) -> Self
pub fn new(spi: Spi) -> Self
Creates a new instance of the specified dac with the internal state set to match the device defaults
sourcepub fn set_internal_reference(
&mut self,
intern_ref: InternRefState
) -> Result<(), DacError>
pub fn set_internal_reference(
&mut self,
intern_ref: InternRefState
) -> Result<(), DacError>
Enables and disables the device internal reference. The internal reference is on by default
sourcepub fn set_power_state(&mut self, state: PowerState) -> Result<(), DacError>
pub fn set_power_state(&mut self, state: PowerState) -> Result<(), DacError>
In power-off state the device output is connected to GND through a 1-kΩ internal
resistor. The device is in power On
state by default. This reduces current
consumption to typically 15 µA at 5 V.
sourcepub fn set_reference_divider(
&mut self,
ref_div: RefDivState
) -> Result<(), DacError>
pub fn set_reference_divider(
&mut self,
ref_div: RefDivState
) -> Result<(), DacError>
The reference voltage to the device (either from the internal or external reference) can be
divided by a factor of two by setting the reference divider to Half
. Make sure to configure
the reference divider so that there is sufficient headroom from VDD to the DAC operating
reference voltage. Improper configuration of the reference divider triggers a reference
alarm condition. In the case of an alarm condition, the reference buffer is shut down, and
all the DAC outputs go to 0 V. The DAC data registers are unaffected by the alarm
condition, and thus enable the DAC output to return to normal operation after the reference
divider is configured correctly. When the reference divider is set to Half
, the reference
voltage is internally divided by a factor of 2. The reference divider is set to OneX
by
default
sourcepub fn set_output_gain(&mut self, gain: GainState) -> Result<(), DacError>
pub fn set_output_gain(&mut self, gain: GainState) -> Result<(), DacError>
When set to TwoX
, the buffer amplifier for the DAC has a gain of 2x doubling the
voltage output. When set to OneX
it has a gain of 1x. Using this gain can be
especially useful when using the internal reference divider set to Half
. The
output gain is set to TwoX
by default
sourceimpl<Spi> Dac80501<Spi> where
Spi: SpiDevice,
Spi::Bus: SpiBusRead,
DacError: From<<Spi as ErrorType>::Error>,
impl<Spi> Dac80501<Spi> where
Spi: SpiDevice,
Spi::Bus: SpiBusRead,
DacError: From<<Spi as ErrorType>::Error>,
sourcepub fn ref_alarm_status(&mut self) -> Result<AlarmStatus, DacError>
pub fn ref_alarm_status(&mut self) -> Result<AlarmStatus, DacError>
AlarmStatus
is High
when the difference between the reference and supply pins is below a minimum
analog threshold. The status is Low
otherwise. When High
, the reference buffer is shut down, and the DAC
outputs are all zero volts. The DAC codes are unaffected, and the DAC output returns to
normal when the difference is above the analog threshold.
Auto Trait Implementations
impl<Spi> RefUnwindSafe for Dac80501<Spi> where
Spi: RefUnwindSafe,
impl<Spi> Send for Dac80501<Spi> where
Spi: Send,
impl<Spi> Sync for Dac80501<Spi> where
Spi: Sync,
impl<Spi> Unpin for Dac80501<Spi> where
Spi: Unpin,
impl<Spi> UnwindSafe for Dac80501<Spi> where
Spi: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more