Ad983x

Struct Ad983x 

Source
pub struct Ad983x<DEV, IC> { /* private fields */ }
Expand description

AD983x direct digital synthesizer

Implementations§

Source§

impl<DEV, E> Ad983x<DEV, Ad9833Ad9837>
where DEV: SpiDevice<Error = E>,

Source

pub fn new_ad9833(spi: DEV) -> Self

Create a new instance of an AD9833 device.

Remember to call reset() before using the device after power up.

Source

pub fn new_ad9837(spi: DEV) -> Self

Create a new instance of an AD9837 device.

Remember to call reset() before using the device after power up.

Source

pub fn set_output_waveform( &mut self, waveform: OutputWaveform, ) -> Result<(), Error<E>>

Set the output waveform

Source§

impl<DEV, E> Ad983x<DEV, Ad9834Ad9838>
where DEV: SpiDevice<Error = E>,

Source

pub fn new_ad9834(spi: DEV) -> Self

Create a new instance of an AD9834 device. Remember to call reset() before using the device after power up.

Source

pub fn new_ad9838(spi: DEV) -> Self

Create a new instance of an AD9838 device. Remember to call reset() before using the device after power up.

Source

pub fn set_output_waveform( &mut self, waveform: OutputWaveform, ) -> Result<(), Error<E>>

Set the output waveform

Will return Error::InvalidArgument for SquareMsbOfDac and SquareMsbOfDacDiv2 as this is not available on AD9834/AD9838 devices. To set the digital output, please use

Source

pub fn set_sign_bit_output( &mut self, configuration: SignBitOutput, ) -> Result<(), Error<E>>

Set the digital output

Source

pub fn set_control_source( &mut self, source: ControlSource, ) -> Result<(), Error<E>>

Set the control source used for the functions: frequency register selection, phase register selection, reset of internal registers, and DAC power-down.

Source§

impl<DEV, IC> Ad983x<DEV, IC>

Source

pub fn destroy(self) -> DEV

Destroy driver instance, return SPI bus instance and CS output pin.

Source§

impl<DEV, IC, E> Ad983x<DEV, IC>
where DEV: SpiDevice<Error = E>,

Source

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

Resets the internal registers and leaves the device disabled.

Note that this is ignored in AD9834/AD9838 devices if hardware pin control source is selected.

Source

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

Disable the device (enable reset)

This resets the internal registers. Note that this is ignored in AD9834/AD9838 devices if hardware pin control source is selected.

Source

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

Enable the device (disable reset)

Note that this is ignored in AD9834/AD9838 devices if hardware pin control source is selected.

Source

pub fn set_frequency( &mut self, register: FrequencyRegister, value: u32, ) -> Result<(), Error<E>>

Set the frequency as a 28-bit word

This will change the mode to 28-bit if it is not used. Returns Error::InvalidArgument if providing a value that does not fit in 28 bits.

Source

pub fn set_frequency_msb( &mut self, register: FrequencyRegister, value: u16, ) -> Result<(), Error<E>>

Set the frequency 14-bit MSBs

This will deactivate the 28-bit mode if it is not already the case. Returns Error::InvalidArgument if providing a value that does not fit in 14 bits.

Source

pub fn set_frequency_lsb( &mut self, register: FrequencyRegister, value: u16, ) -> Result<(), Error<E>>

Set the frequency 14-bit LSBs

This will deactivate the 28-bit mode if it is not already the case. Returns Error::InvalidArgument if providing a value that does not fit in 14 bits.

Source

pub fn select_frequency( &mut self, register: FrequencyRegister, ) -> Result<(), Error<E>>

Select the frequency register that is used

Note: this can be overriden through the FSELECT pin in AD9834/AD9838 devices if hardware pin control source is selected.

Source

pub fn set_phase( &mut self, register: PhaseRegister, value: u16, ) -> Result<(), Error<E>>

Set a phase register (12-bit value)

Returns Error::InvalidArgument if providing a value that does not fit in 12 bits.

Source

pub fn select_phase(&mut self, register: PhaseRegister) -> Result<(), Error<E>>

Select the phase register that is used.

Note: this can be overriden through the PSELECT pin in AD9834/AD9838 devices if hardware pin control source is selected.

Source

pub fn set_powered_down(&mut self, config: PoweredDown) -> Result<(), Error<E>>

Set device parts powered-down state.

Note: This can be overriden through the SLEEP pin in AD9834/AD9838 devices if hardware pin control source is selected.

Trait Implementations§

Source§

impl<DEV: Debug, IC: Debug> Debug for Ad983x<DEV, IC>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<DEV, IC> Freeze for Ad983x<DEV, IC>
where DEV: Freeze,

§

impl<DEV, IC> RefUnwindSafe for Ad983x<DEV, IC>
where DEV: RefUnwindSafe, IC: RefUnwindSafe,

§

impl<DEV, IC> Send for Ad983x<DEV, IC>
where DEV: Send, IC: Send,

§

impl<DEV, IC> Sync for Ad983x<DEV, IC>
where DEV: Sync, IC: Sync,

§

impl<DEV, IC> Unpin for Ad983x<DEV, IC>
where DEV: Unpin, IC: Unpin,

§

impl<DEV, IC> UnwindSafe for Ad983x<DEV, IC>
where DEV: UnwindSafe, IC: 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.