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>
impl<I: Interface> Ad9959<I>
Sourcepub 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>
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 multipliesclock_frequency
to generate the system clock.
Sourcepub fn self_test(&mut self) -> Result<bool, Error>
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.
Sourcepub fn set_phase(&mut self, channel: Channel, phase: f32) -> Result<f32, Error>
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.
Sourcepub fn get_phase(&mut self, channel: Channel) -> Result<f32, Error>
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.
Sourcepub fn set_amplitude(
&mut self,
channel: Channel,
amplitude: f32,
) -> Result<f32, Error>
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.
Sourcepub fn get_amplitude(&mut self, channel: Channel) -> Result<f32, Error>
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.
Sourcepub fn set_frequency(
&mut self,
channel: Channel,
frequency: f32,
) -> Result<f32, Error>
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.