ad9959

Struct Ad9959

Source
pub struct Ad9959<I> { /* private fields */ }
Expand description

A device driver for the AD9959 direct digital synthesis (DDS) chip.

This chip provides four independently controllable digital-to-analog output sinusoids with configurable phase, amplitude, and frequency. All channels are inherently synchronized as they are derived off a common system clock.

The chip contains a configurable PLL and supports system clock frequencies up to 500 MHz.

The chip supports a number of serial interfaces to improve data throughput, including normal, dual, and quad SPI configurations.

Implementations§

Source§

impl<I: Interface> Ad9959<I>

Source

pub fn new( interface: I, reset: &mut impl OutputPin, io_update: &mut impl OutputPin, delay: &mut impl DelayUs<u8>, mode: Mode, reference_clock_frequency: f32, multiplier: u5, ) -> Result<Self, Error>

Construct and initialize the DDS.

Args:

  • interface - An interface to the DDS.
  • reset_pin - A pin connected to the DDS reset input.
  • io_update - A pin connected to the DDS io_update input.
  • delay - A delay implementation for blocking operation for specific amounts of time.
  • desired_mode - The desired communication mode of the interface to the DDS.
  • clock_frequency - The clock frequency of the reference clock input.
  • multiplier - The desired clock multiplier for the system clock. This multiplies clock_frequency to generate the system clock.
Source

pub fn csr(&mut self) -> Result<Csr, Error>

Get the current CSR register.

Source

pub fn fr1(&mut self) -> Result<Fr1, Error>

Get the current FR1 register.

Source

pub fn self_test(&mut self) -> Result<bool, Error>

Perform a self-test of the communication interface.

Note: This modifies the existing channel enables. They are restored upon exit.

Returns: True if the self test succeeded. False otherwise.

Source

pub fn set_phase(&mut self, channel: Channel, phase: f32) -> Result<f32, Error>

Configure the phase of a specified channel.

Arguments:

  • channel - The channel to configure the frequency of.
  • phase_turns - The desired phase offset in turns.

Returns: The actual programmed phase offset of the channel in turns.

Source

pub fn get_phase(&mut self, channel: Channel) -> Result<f32, Error>

Get the current phase of a specified channel.

Args:

  • channel - The channel to get the phase of.

Returns: The phase of the channel in turns.

Source

pub fn set_amplitude( &mut self, channel: Channel, amplitude: f32, ) -> Result<f32, Error>

Configure the amplitude of a specified channel.

Arguments:

  • channel - The channel to configure the frequency of.
  • amplitude - A normalized amplitude setting [0, 1].

Returns: The actual normalized amplitude of the channel relative to full-scale range.

Source

pub fn get_amplitude(&mut self, channel: Channel) -> Result<f32, Error>

Get the configured amplitude of a channel.

Args:

  • channel - The channel to get the amplitude of.

Returns: The normalized amplitude of the channel.

Source

pub fn set_frequency( &mut self, channel: Channel, frequency: f32, ) -> Result<f32, Error>

Configure the frequency of a specified channel.

Arguments:

  • channel - The channel to configure the frequency of.
  • frequency - The desired output frequency in Hz.

Returns: The actual programmed frequency of the channel.

Source

pub fn get_frequency(&mut self, channel: Channel) -> Result<f32, Error>

Get the frequency of a channel.

Arguments:

  • channel - The channel to get the frequency of.

Returns: The frequency of the channel in Hz.

Source

pub fn freeze(self) -> (I, Mode)

Finalize DDS configuration

§Note

This is intended for when the DDS profiles will be written as a stream of data to the DDS.

§Returns

(i, mode) where i is the interface to the DDS and mode is the frozen Mode.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<I> UnwindSafe for Ad9959<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.