![]() |
no-OS
|
Implementation of ADF4030 Driver. More...
#include "adf4030.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_print_log.h"
Classes | |
struct | adf4030_reg_sequence |
ADF4030 register format structure for default values. | |
Functions | |
int | adf4030_spi_write (struct adf4030_dev *dev, uint16_t reg_addr, uint8_t data) |
Writes data to ADF4030 over SPI. | |
int | adf4030_spi_read (struct adf4030_dev *dev, uint16_t reg_addr, uint8_t *data) |
Reads data from ADF4030 over SPI. | |
int | adf4030_spi_update_bits (struct adf4030_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data) |
Updates the values of the ADF4030 register. | |
int | adf4030_set_default_regs (struct adf4030_dev *dev, bool spi_4wire) |
Applys a softreset, sets the SPI 4 wire mode and writes the default registers. | |
int | adf4030_set_temperature (struct adf4030_dev *dev, bool en) |
Set Temperature Readback feature's initial state. This function should be called before reading temperature to trigger measurement. | |
int | adf4030_get_temperature (struct adf4030_dev *dev, int16_t *temperature) |
Gets the value of the approximate die temperature. | |
int | adf4030_set_chip_address (struct adf4030_dev *dev, uint8_t addr) |
Set the chip address value. | |
int | adf4030_set_ref_clk (struct adf4030_dev *dev, uint32_t val) |
Set the desired reference frequency and reset everything over to maximum supported value of 250MHz to the max. value and everything under the minimum supported value of 10MHz to the min. | |
int | adf4030_set_vco_freq (struct adf4030_dev *dev, uint32_t vco_freq) |
Set the desired VCO frequency. | |
int | adf4030_get_vco_freq (struct adf4030_dev *dev, uint32_t *vco_freq) |
Get the VCO frequency in Hz. | |
int | adf4030_set_bsync_freq (struct adf4030_dev *dev, uint32_t bsync_freq, bool odivb_sel) |
Set the BSYNC frequency in Hz. Output divider will be choose according to odiv sel argument. | |
int | adf4030_get_bsync_freq (struct adf4030_dev *dev, uint32_t *bsync_freq, bool odivb_sel) |
Get the BSYNC frequency in Hz. | |
int | adf4030_set_tdc_source (struct adf4030_dev *dev, uint8_t tdc_source) |
Set the TDC source. | |
int | adf4030_get_tdc_source (struct adf4030_dev *dev, uint8_t *tdc_source) |
Get the TDC source. | |
int | adf4030_set_tdc_measurement (struct adf4030_dev *dev, uint8_t tdc_target) |
Set the TDC measurement target and start the measurement. Before calling this function, please set tdc_source to the desired bsync channel. | |
int | adf4030_get_tdc_measurement (struct adf4030_dev *dev, int64_t *tdc_result_fs) |
Get the TDC measurement result. Reads bitfileds and calculates the TDC result with period of the BSYNC signal. | |
int | adf4030_set_alignment_iter (struct adf4030_dev *dev, uint8_t iter_number) |
Set the iteration number of alignment. | |
int | adf4030_get_alignment_iter (struct adf4030_dev *dev, uint8_t *iter_number) |
Get the iteration number of alignment. | |
int | adf4030_set_alignment_threshold (struct adf4030_dev *dev, uint32_t threshold_fs) |
Set the alignment threshold in femtoseconds. | |
int | adf4030_get_alignment_threshold (struct adf4030_dev *dev, uint32_t *threshold_fs) |
Get the alignment threshold in femtoseconds. | |
int | adf4030_set_single_ch_alignment (struct adf4030_dev *dev, uint8_t tdc_target_ch) |
Perform single-channel alignment. Before calling this function, please set tdc_source to the desired bsync channel. | |
int | adf4030_set_serial_alignment (struct adf4030_dev *dev, uint16_t channel_flags) |
Set serial alignment for multiple BSYNC channels. | |
int | adf4030_get_serial_alignment (struct adf4030_dev *dev, uint16_t *channel_flags) |
Get the serial alignment channel flags for multiple BSYNC channels. | |
int | adf4030_set_background_serial_alignment (struct adf4030_dev *dev, uint16_t channel_flags) |
Set background serial alignment for multiple BSYNC channels. | |
int | adf4030_get_background_serial_alignment (struct adf4030_dev *dev, uint16_t *channel_flags) |
Get the background serial alignment channel flags for multiple BSYNC channels. | |
int | adf4030_set_channel_delay (struct adf4030_dev *dev, uint8_t channel, int64_t delay_fs) |
Set the delay for a specific BSYNC channel. This Delay will show up between TDC_SOURCE and channel. | |
int | adf4030_get_channel_delay (struct adf4030_dev *dev, uint8_t channel, int64_t *delay_fs) |
Get the delay for a specific channel. | |
int | adf4030_set_channel_direction (struct adf4030_dev *dev, uint8_t channel, bool tx_en) |
Set the TX-RX direction of a specific channel. | |
int | adf4030_get_channel_direction (struct adf4030_dev *dev, uint8_t channel, bool *tx_en) |
Get the TX direction (TX/RX) of a specific channel. | |
int | adf4030_set_channel_termination (struct adf4030_dev *dev, uint8_t channel, enum adf4030_terminations_e termination) |
Set the termination type for a specific channel. | |
int | adf4030_get_channel_termination (struct adf4030_dev *dev, uint8_t channel, enum adf4030_terminations_e *termination) |
Get the termination type for a specific channel. | |
int | adf4030_set_channel_prbs (struct adf4030_dev *dev, uint8_t channel, bool prbs_en) |
Set the PRBS (Pseudo-Random Binary Sequence) state for a specific channel. | |
int | adf4030_get_channel_prbs (struct adf4030_dev *dev, uint8_t channel, bool *prbs_en) |
Get the PRBS (Pseudo-Random Binary Sequence) state for a specific channel. | |
int | adf4030_set_channel_odivb (struct adf4030_dev *dev, uint8_t channel, bool odivb_en) |
Set the output divider selection for a specific channel. If odivb_en is enabled, the output divider b will be used for the channel. Otherwise, the output divider a will be used. | |
int | adf4030_get_channel_odivb (struct adf4030_dev *dev, uint8_t channel, bool *odivb_en) |
Get the output divider selection for a specific channel. If odivb_en is enabled, the output divider b will be used for the channel. Otherwise, the output divider a will be used. | |
int | adf4030_set_channel_invert (struct adf4030_dev *dev, uint8_t channel, bool invert_en) |
Set the inversion state for the BSYNC channel. | |
int | adf4030_get_channel_invert (struct adf4030_dev *dev, uint8_t channel, bool *invert_en) |
Get the inversion state for a specific channel. | |
int | adf4030_set_channel_voltage (struct adf4030_dev *dev, uint8_t channel, uint32_t voltage_mv) |
Set the voltage level for the BSYNC channel. | |
int | adf4030_get_channel_voltage (struct adf4030_dev *dev, uint8_t channel, uint32_t *voltage_mv) |
Get the voltage level for a specific channel. | |
int | adf4030_init (struct adf4030_dev **dev, struct adf4030_init_param *init_param) |
Initializes the adf4030. | |
int | adf4030_remove (struct adf4030_dev *dev) |
Free resources allocated for adf4030. | |
Implementation of ADF4030 Driver.
Copyright 2025(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int adf4030_get_alignment_iter | ( | struct adf4030_dev * | dev, |
uint8_t * | iter_number ) |
Get the iteration number of alignment.
dev | - The device structure. |
iter_number | - Read value of number of iterations in one alignment. |
int adf4030_get_alignment_threshold | ( | struct adf4030_dev * | dev, |
uint32_t * | threshold_fs ) |
Get the alignment threshold in femtoseconds.
dev | - The device structure. |
threshold_fs | - Read value of alignment threshold in femtoseconds. |
int adf4030_get_background_serial_alignment | ( | struct adf4030_dev * | dev, |
uint16_t * | channel_flags ) |
Get the background serial alignment channel flags for multiple BSYNC channels.
dev | - The device structure. |
channel_flags | - Read value of the channel alignment flags. |
int adf4030_get_bsync_freq | ( | struct adf4030_dev * | dev, |
uint32_t * | bsync_freq, | ||
bool | odivb_sel ) |
Get the BSYNC frequency in Hz.
dev | - The device structure. |
bsync_freq | - The read BSYNC frequency in Hz. |
odivb_sel | - Selects the output divider to read. |
int adf4030_get_channel_delay | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
int64_t * | delay_fs ) |
Get the delay for a specific channel.
dev | - The device structure. |
channel | - The channel to get the delay for. |
delay_fs | - Read value of the delay in femtoseconds. |
int adf4030_get_channel_direction | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool * | tx_en ) |
Get the TX direction (TX/RX) of a specific channel.
dev | - The device structure. |
channel | - The channel to get the direction for. |
tx_en | - Read the channel's TX direction status. |
int adf4030_get_channel_invert | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool * | invert_en ) |
Get the inversion state for a specific channel.
dev | - The device structure. |
channel | - The channel to get the inversion state for. |
invert_en | - Pointer to store the inversion state. |
int adf4030_get_channel_odivb | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool * | odivb_en ) |
Get the output divider selection for a specific channel. If odivb_en is enabled, the output divider b will be used for the channel. Otherwise, the output divider a will be used.
dev | - The device structure. |
channel | - The channel to get the output divider for. |
odivb_en | - Pointer to store the output divider state. |
int adf4030_get_channel_prbs | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool * | prbs_en ) |
Get the PRBS (Pseudo-Random Binary Sequence) state for a specific channel.
dev | - The device structure. |
channel | - The channel to get the PRBS state for. |
prbs_en | - Pointer to store the PRBS state. |
int adf4030_get_channel_termination | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
enum adf4030_terminations_e * | termination ) |
Get the termination type for a specific channel.
dev | - The device structure. |
channel | - The channel to get the termination for. |
termination | - Read value of the termination type. |
int adf4030_get_channel_voltage | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
uint32_t * | voltage_mv ) |
Get the voltage level for a specific channel.
dev | - The device structure. |
channel | - The channel to get the voltage level for. |
voltage_mv | - Read value of the voltage level in millivolts. |
int adf4030_get_serial_alignment | ( | struct adf4030_dev * | dev, |
uint16_t * | channel_flags ) |
Get the serial alignment channel flags for multiple BSYNC channels.
dev | - The device structure. |
channel_flags | - Read value of the channel alignment flags. |
int adf4030_get_tdc_measurement | ( | struct adf4030_dev * | dev, |
int64_t * | tdc_result_fs ) |
Get the TDC measurement result. Reads bitfileds and calculates the TDC result with period of the BSYNC signal.
dev | - The device structure. |
tdc_result_fs | - Read TDC measurement result in femtoseconds. |
int adf4030_get_tdc_source | ( | struct adf4030_dev * | dev, |
uint8_t * | tdc_source ) |
Get the TDC source.
dev | - The device structure. |
tdc_source | - Read TDC source value. |
int adf4030_get_temperature | ( | struct adf4030_dev * | dev, |
int16_t * | temperature ) |
Gets the value of the approximate die temperature.
dev | - The device structure. |
temperature | - The read value of the Temperature Readback. |
int adf4030_get_vco_freq | ( | struct adf4030_dev * | dev, |
uint32_t * | vco_freq ) |
Get the VCO frequency in Hz.
dev | - The device structure. |
vco_freq | - The VCO frequency in Hz. |
int adf4030_init | ( | struct adf4030_dev ** | dev, |
struct adf4030_init_param * | init_param ) |
Initializes the adf4030.
dev | - The device structure. |
init_param | - The structure containing the device initial parameters. |
int adf4030_remove | ( | struct adf4030_dev * | dev | ) |
Free resources allocated for adf4030.
dev | - The device structure. |
int adf4030_set_alignment_iter | ( | struct adf4030_dev * | dev, |
uint8_t | iter_number ) |
Set the iteration number of alignment.
dev | - The device structure. |
iter_number | - The number of iterations for the alignment. |
int adf4030_set_alignment_threshold | ( | struct adf4030_dev * | dev, |
uint32_t | threshold_fs ) |
Set the alignment threshold in femtoseconds.
dev | - The device structure. |
threshold_fs | - The alignment threshold in femtoseconds. |
int adf4030_set_background_serial_alignment | ( | struct adf4030_dev * | dev, |
uint16_t | channel_flags ) |
Set background serial alignment for multiple BSYNC channels.
dev | - The device structure. |
channel_flags | - Flags indicating the channels to align. |
int adf4030_set_bsync_freq | ( | struct adf4030_dev * | dev, |
uint32_t | bsync_freq, | ||
bool | odivb_sel ) |
Set the BSYNC frequency in Hz. Output divider will be choose according to odiv sel argument.
dev | - The device structure. |
bsync_freq | - The VCO frequency in Hz. |
odivb_sel | - Selects the output divider which will be set. |
int adf4030_set_channel_delay | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
int64_t | delay_fs ) |
Set the delay for a specific BSYNC channel. This Delay will show up between TDC_SOURCE and channel.
dev | - The device structure. |
channel | - The channel to set the delay for. |
delay_fs | - The delay in femtoseconds. |
int adf4030_set_channel_direction | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool | tx_en ) |
Set the TX-RX direction of a specific channel.
dev | - The device structure. |
channel | - The channel to set the direction for. |
tx_en | - Enable or disable the channel. |
int adf4030_set_channel_invert | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool | invert_en ) |
Set the inversion state for the BSYNC channel.
dev | - The device structure. |
channel | - The channel to set the inversion state for. |
invert_en | - Enable or disable inversion. |
int adf4030_set_channel_odivb | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool | odivb_en ) |
Set the output divider selection for a specific channel. If odivb_en is enabled, the output divider b will be used for the channel. Otherwise, the output divider a will be used.
dev | - The device structure. |
channel | - The channel to set the output divider for. |
odivb_en | - Enable or disable the output divider b for the channel. |
int adf4030_set_channel_prbs | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
bool | prbs_en ) |
Set the PRBS (Pseudo-Random Binary Sequence) state for a specific channel.
dev | - The device structure. |
channel | - The channel to set the PRBS state for. |
prbs_en | - Enable or disable PRBS. |
int adf4030_set_channel_termination | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
enum adf4030_terminations_e | termination ) |
Set the termination type for a specific channel.
dev | - The device structure. |
channel | - The channel to set the termination for. |
termination | - The termination type. |
int adf4030_set_channel_voltage | ( | struct adf4030_dev * | dev, |
uint8_t | channel, | ||
uint32_t | voltage_mv ) |
Set the voltage level for the BSYNC channel.
dev | - The device structure. |
channel | - The channel to set the voltage level for. |
voltage_mv | - The desired voltage level in millivolts. |
int adf4030_set_chip_address | ( | struct adf4030_dev * | dev, |
uint8_t | addr ) |
Set the chip address value.
dev | - The device structure. |
addr | - The desired chip address value. |
int adf4030_set_default_regs | ( | struct adf4030_dev * | dev, |
bool | spi_4wire ) |
Applys a softreset, sets the SPI 4 wire mode and writes the default registers.
dev | - The device structure |
spi_4wire | - SPI 4 wire feature enable input |
int adf4030_set_ref_clk | ( | struct adf4030_dev * | dev, |
uint32_t | val ) |
Set the desired reference frequency and reset everything over to maximum supported value of 250MHz to the max. value and everything under the minimum supported value of 10MHz to the min.
dev | - The device structure. |
val | - The desired reference frequency in Hz. |
int adf4030_set_serial_alignment | ( | struct adf4030_dev * | dev, |
uint16_t | channel_flags ) |
Set serial alignment for multiple BSYNC channels.
dev | - The device structure. |
channel_flags | - Flags indicating the channels to align. |
int adf4030_set_single_ch_alignment | ( | struct adf4030_dev * | dev, |
uint8_t | tdc_target_ch ) |
Perform single-channel alignment. Before calling this function, please set tdc_source to the desired bsync channel.
dev | - The device structure. |
tdc_target_ch | - The TDC Target channel for alignment. |
int adf4030_set_tdc_measurement | ( | struct adf4030_dev * | dev, |
uint8_t | tdc_target ) |
Set the TDC measurement target and start the measurement. Before calling this function, please set tdc_source to the desired bsync channel.
dev | - The device structure. |
tdc_target | - TDC measurement target. |
int adf4030_set_tdc_source | ( | struct adf4030_dev * | dev, |
uint8_t | tdc_source ) |
Set the TDC source.
dev | - The device structure. |
tdc_source | - The desired TDC source value. |
int adf4030_set_temperature | ( | struct adf4030_dev * | dev, |
bool | en ) |
Set Temperature Readback feature's initial state. This function should be called before reading temperature to trigger measurement.
dev | - The device structure. |
en | - The enable or disable Temperature readback feature. |
int adf4030_set_vco_freq | ( | struct adf4030_dev * | dev, |
uint32_t | vco_freq ) |
Set the desired VCO frequency.
dev | - The device structure. |
vco_freq | - The desired reference frequency in Hz. |
int adf4030_spi_read | ( | struct adf4030_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t * | data ) |
Reads data from ADF4030 over SPI.
dev | - The device structure. |
reg_addr | - The register address. |
data | - Data read from the device. |
int adf4030_spi_update_bits | ( | struct adf4030_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t | mask, | ||
uint8_t | data ) |
Updates the values of the ADF4030 register.
dev | - The device structure. |
reg_addr | - The register address. |
mask | - Bits to be updated. |
data | - Update value for the mask. |
int adf4030_spi_write | ( | struct adf4030_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t | data ) |
Writes data to ADF4030 over SPI.
dev | - The device structure. |
reg_addr | - The register address. |
data | - Data value to write. |