pub struct Dac<'d> { /* private fields */ }Expand description
A digital-to-analog converter (DAC) channel.
Dropping the driver disables its analog output. The shared DAC clock is disabled after both channels are powered down.
Implementations§
Source§impl<'d> Dac<'d>
impl<'d> Dac<'d>
Sourcepub fn new<T: Instance + 'd>(dac: T, pin: T::Pin) -> Selfwhere
T::Pin: AnalogPin + 'd,
pub fn new<T: Instance + 'd>(dac: T, pin: T::Pin) -> Selfwhere
T::Pin: AnalogPin + 'd,
Creates a new DAC channel.
Sourcepub const fn resolution(&self) -> u8
Available on crate feature unstable only.
pub const fn resolution(&self) -> u8
unstable only.Returns the DAC resolution in bits.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn write(&mut self, value: u16) -> Result<(), Error>
pub fn write(&mut self, value: u16) -> Result<(), Error>
Writes a raw DAC code.
The valid range is 0..(1 << self.resolution()). The nominal output
voltage is Vref * value / ((1 << self.resolution()) - 1).
The DAC uses Low-speed mode with the output buffer bypassed.
§Errors
Error::ValueOutOfRange if value is outside the valid range.
The output remains unchanged on error.