no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
adf4377.c File Reference

Implementation of adf4377 Driver. More...

#include <malloc.h>
#include "adf4377.h"
#include "no_os_error.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
#include "no_os_print_log.h"
#include "no_os_util.h"
Include dependency graph for adf4377.c:

Classes

struct  adf4377_reg_sequence
 ADF4377 register format structure for default values. More...
 

Functions

int adf4377_spi_write (struct adf4377_dev *dev, uint8_t reg_addr, uint8_t data)
 Writes data to ADF4377 over SPI.
 
int adf4377_spi_read (struct adf4377_dev *dev, uint8_t reg_addr, uint8_t *data)
 Reads data from ADF4377 over SPI.
 
int adf4377_spi_update_bit (struct adf4377_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
 Update ADF4377 register.
 
int adf4377_check_scratchpad (struct adf4377_dev *dev)
 ADF4377 SPI Scratchpad check.
 
int adf4377_set_ref_clk (struct adf4377_dev *dev, uint64_t val)
 Set the desired reference frequency and reset everything over to maximum supported value of 5GHz to the max. value and everything under the minimum supported value of 10MHz to the min. value.
 
int adf4377_get_ref_clk (struct adf4377_dev *dev, uint64_t *val)
 Gets the user proposed reference frequency.
 
int adf4377_set_cp_i (struct adf4377_dev *dev, int32_t reg_val)
 Set the charge pump value which will be written to the register. The value will be between 0 and 15 on 8 bits. For more information please consult the Datasheet.
 
int adf4377_get_cp_i (struct adf4377_dev *dev, int32_t *reg_val)
 Gets the charge pump value from the register. The value will be between 0 and 15 on 8 bits. For more information please consult the Datasheet.
 
int adf4377_set_ref_div (struct adf4377_dev *dev, int32_t div)
 Set the reference divider value and reset everything over to maximum supported value of 63 to the max. value.
 
int adf4377_get_ref_div (struct adf4377_dev *dev, int32_t *div)
 Gets the value the reference divider.
 
int adf4377_set_en_ref_doubler (struct adf4377_dev *dev, bool en)
 Set the reference doubler to enable or disable based on the passed parameter. If the parameter is different then 0 it will set the doubler to enable.
 
int adf4377_get_en_ref_doubler (struct adf4377_dev *dev, bool *en)
 Gets the value the doubler if it is enabled or disable and stores it it the dev structure.
 
int adf4377_set_bleed_word (struct adf4377_dev *dev, int32_t word)
 Set the bleed word, which represents the value of the bleed current written to the register space.
 
int adf4377_get_bleed_word (struct adf4377_dev *dev, int32_t *bleed_word)
 Gets the value of the set bleed word.
 
int adf4377_set_en_chan (struct adf4377_dev *dev, uint8_t ch, bool en)
 Set the output channel to enable or disable based on the passed parameter. If the parameter is different then 0 it will set the doubler to enable.
 
int adf4377_get_en_chan (struct adf4377_dev *dev, uint8_t ch, bool *en)
 Gets the value the output channel if it is enabled or disable.
 
int adf4377_set_out_power (struct adf4377_dev *dev, uint8_t ch, int8_t pwr)
 Set the output power register value of a channel and reset everything over to maximum supported value of 15 to the max. value.
 
int adf4377_get_out_power (struct adf4377_dev *dev, uint8_t ch, int8_t *pwr)
 Gets the output power register value.
 
int adf4377_set_rfout_divider (struct adf4377_dev *dev, uint8_t div)
 Set the rfout frequency divider register value and reset everything over to maximum supported value of /128 to the max. value.
 
int adf4377_get_rfout_divider (struct adf4377_dev *dev, int8_t *div)
 Gets the rfout divider register value.
 
int adf4377_set_rfout (struct adf4377_dev *dev, uint64_t val)
 Set the desired output frequency and reset everything over to maximum supported value of 12.8GHz to the max. value and everything under the minimum supported value of 800MHz to the min. value.
 
int adf4377_set_freq (struct adf4377_dev *dev)
 
int adf4377_get_rfout (struct adf4377_dev *dev, uint64_t *val)
 Gets the user proposed output frequency.
 
int adf4377_set_sr_del_adj (struct adf4377_dev *dev, int32_t val)
 Set the value of SR_DEL Adjustment Feature Translated to Pico Seconds on the output. Reset to Max value of 127.
 
int adf4377_get_sr_del_adj (struct adf4377_dev *dev, int32_t *val)
 Gets the value of the set SR_DEL Adjustment Feature Translated to Pico Seconds on the output.
 
int adf4377_set_en_sr_inv_adj (struct adf4377_dev *dev, bool en)
 Set the value of SR_INV_ADJ Adjustment to enable or disable which adds a constant value to the skew adjustment output.
 
int adf4377_get_en_sr_inv_adj (struct adf4377_dev *dev, bool *en)
 Gets the value of the set SR_INV_ADJ Adjustment to enable or disable which adds a constant value to the skew adjustment output.
 
int adf4377_set_en_sysref_monitor (struct adf4377_dev *dev, bool en)
 Set enable/disable sysref monitoring.
 
int adf4377_get_en_sysref_monitor (struct adf4377_dev *dev, bool *en)
 Gets the value of the set sysref monitoring.
 
int32_t adf4377_init (struct adf4377_dev **device, struct adf4377_init_param *init_param)
 Initializes the ADF4377.
 
int32_t adf4377_remove (struct adf4377_dev *dev)
 Free resoulces allocated for ADF4377.
 

Detailed Description

Implementation of adf4377 Driver.

Author
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)
Jude Osemene (jude..nosp@m.osem.nosp@m.ene@a.nosp@m.nalo.nosp@m.g.com)

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Function Documentation

◆ adf4377_check_scratchpad()

int adf4377_check_scratchpad ( struct adf4377_dev * dev)

ADF4377 SPI Scratchpad check.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code.
Here is the caller graph for this function:

◆ adf4377_get_bleed_word()

int adf4377_get_bleed_word ( struct adf4377_dev * dev,
int32_t * bleed_word )

Gets the value of the set bleed word.

Parameters
dev- The device structure.
bleed_word- The read bleed current register value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_cp_i()

int adf4377_get_cp_i ( struct adf4377_dev * dev,
int32_t * reg_val )

Gets the charge pump value from the register. The value will be between 0 and 15 on 8 bits. For more information please consult the Datasheet.

Parameters
dev- The device structure.
reg_val- The read charge pump register value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_en_chan()

int adf4377_get_en_chan ( struct adf4377_dev * dev,
uint8_t ch,
bool * en )

Gets the value the output channel if it is enabled or disable.

Parameters
dev- The device structure.
ch- The channel to get state.
en- The status of the output channel.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_en_ref_doubler()

int adf4377_get_en_ref_doubler ( struct adf4377_dev * dev,
bool * en )

Gets the value the doubler if it is enabled or disable and stores it it the dev structure.

Parameters
dev- The device structure.
en- The read value of the reference doubler.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_en_sr_inv_adj()

int adf4377_get_en_sr_inv_adj ( struct adf4377_dev * dev,
bool * en )

Gets the value of the set SR_INV_ADJ Adjustment to enable or disable which adds a constant value to the skew adjustment output.

Parameters
dev- The device structure.
en- The read value of SR_INV.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_en_sysref_monitor()

int adf4377_get_en_sysref_monitor ( struct adf4377_dev * dev,
bool * en )

Gets the value of the set sysref monitoring.

Parameters
dev- The device structure.
en- The read value of the sysref monitor.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_out_power()

int adf4377_get_out_power ( struct adf4377_dev * dev,
uint8_t ch,
int8_t * pwr )

Gets the output power register value.

Parameters
dev- The device structure.
ch- The channel to get the power off.
pwr- The output power register value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_ref_clk()

int adf4377_get_ref_clk ( struct adf4377_dev * dev,
uint64_t * val )

Gets the user proposed reference frequency.

Parameters
dev- The device structure.
val- The set value of the reference frequency in Hz.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_ref_div()

int adf4377_get_ref_div ( struct adf4377_dev * dev,
int32_t * div )

Gets the value the reference divider.

Parameters
dev- The device structure.
div- The read reference divider value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_rfout()

int adf4377_get_rfout ( struct adf4377_dev * dev,
uint64_t * val )

Gets the user proposed output frequency.

Parameters
dev- The device structure.
val- The set value of the output frequency in Hz.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_rfout_divider()

int adf4377_get_rfout_divider ( struct adf4377_dev * dev,
int8_t * div )

Gets the rfout divider register value.

Parameters
dev- The device structure.
div- The rfoutdiv divider register value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_get_sr_del_adj()

int adf4377_get_sr_del_adj ( struct adf4377_dev * dev,
int32_t * val )

Gets the value of the set SR_DEL Adjustment Feature Translated to Pico Seconds on the output.

Parameters
dev- The device structure.
val- The read SR_DEL register value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_init()

int32_t adf4377_init ( struct adf4377_dev ** device,
struct adf4377_init_param * init_param )

Initializes the ADF4377.

Parameters
device- The device structure.
init_param- The structure containing the device initial parameters.
Returns
- Returns 0 in case of success or negative error code.
Here is the caller graph for this function:

◆ adf4377_remove()

int32_t adf4377_remove ( struct adf4377_dev * dev)

Free resoulces allocated for ADF4377.

Parameters
dev- The device structure.
Returns
- Returns 0 in case of success or negative error code.
Here is the caller graph for this function:

◆ adf4377_set_bleed_word()

int adf4377_set_bleed_word ( struct adf4377_dev * dev,
int32_t word )

Set the bleed word, which represents the value of the bleed current written to the register space.

Parameters
dev- The device structure.
word- The bleed current register value.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_set_cp_i()

int adf4377_set_cp_i ( struct adf4377_dev * dev,
int32_t reg_val )

Set the charge pump value which will be written to the register. The value will be between 0 and 15 on 8 bits. For more information please consult the Datasheet.

Parameters
dev- The device structure.
reg_val- The desired charge pump register value.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_set_en_chan()

int adf4377_set_en_chan ( struct adf4377_dev * dev,
uint8_t ch,
bool en )

Set the output channel to enable or disable based on the passed parameter. If the parameter is different then 0 it will set the doubler to enable.

Parameters
dev- The device structure.
ch- The channel to set state.
en- The enable or disable value of the output channel.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_set_en_ref_doubler()

int adf4377_set_en_ref_doubler ( struct adf4377_dev * dev,
bool en )

Set the reference doubler to enable or disable based on the passed parameter. If the parameter is different then 0 it will set the doubler to enable.

Parameters
dev- The device structure.
en- The enable or disable value of the reference doubler.
Returns
- 0 in case of success or negative error code.

◆ adf4377_set_en_sr_inv_adj()

int adf4377_set_en_sr_inv_adj ( struct adf4377_dev * dev,
bool en )

Set the value of SR_INV_ADJ Adjustment to enable or disable which adds a constant value to the skew adjustment output.

Parameters
dev- The device structure.
en- The enable or disable value of SR_INV.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_set_en_sysref_monitor()

int adf4377_set_en_sysref_monitor ( struct adf4377_dev * dev,
bool en )

Set enable/disable sysref monitoring.

Parameters
dev- The device structure.
en- The enable or disable value of the sysref monitor.
Returns
- 0 in case of success or negative error code.

◆ adf4377_set_freq()

int adf4377_set_freq ( struct adf4377_dev * dev)

Set the output frequency.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adf4377_set_out_power()

int adf4377_set_out_power ( struct adf4377_dev * dev,
uint8_t ch,
int8_t pwr )

Set the output power register value of a channel and reset everything over to maximum supported value of 15 to the max. value.

Parameters
dev- The device structure.
ch- The channel to set the power off.
pwr- The output power register value.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_set_ref_clk()

int adf4377_set_ref_clk ( struct adf4377_dev * dev,
uint64_t val )

Set the desired reference frequency and reset everything over to maximum supported value of 5GHz to the max. value and everything under the minimum supported value of 10MHz to the min. value.

Parameters
dev- The device structure.
val- The desired reference frequency in Hz.
Returns
- 0 in case of success or negative error code.

◆ adf4377_set_ref_div()

int adf4377_set_ref_div ( struct adf4377_dev * dev,
int32_t div )

Set the reference divider value and reset everything over to maximum supported value of 63 to the max. value.

Parameters
dev- The device structure.
div- The reference divider value.
Returns
- 0 in case of success or negative error code.

◆ adf4377_set_rfout()

int adf4377_set_rfout ( struct adf4377_dev * dev,
uint64_t val )

Set the desired output frequency and reset everything over to maximum supported value of 12.8GHz to the max. value and everything under the minimum supported value of 800MHz to the min. value.

Parameters
dev- The device structure.
val- The desired output frequency in Hz.
Returns
- 0 in case of success or negative error code.
Here is the caller graph for this function:

◆ adf4377_set_rfout_divider()

int adf4377_set_rfout_divider ( struct adf4377_dev * dev,
uint8_t div )

Set the rfout frequency divider register value and reset everything over to maximum supported value of /128 to the max. value.

Parameters
dev- The device structure.
div- The rfoutdiv divider register value.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_set_sr_del_adj()

int adf4377_set_sr_del_adj ( struct adf4377_dev * dev,
int32_t val )

Set the value of SR_DEL Adjustment Feature Translated to Pico Seconds on the output. Reset to Max value of 127.

Parameters
dev- The device structure.
val- The desired SR_DEL register value.
Returns
- Result of the writing procedure, error code otherwise.

◆ adf4377_spi_read()

int adf4377_spi_read ( struct adf4377_dev * dev,
uint8_t reg_addr,
uint8_t * data )

Reads data from ADF4377 over SPI.

Parameters
dev- The device structure.
reg_addr- The register address.
data- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adf4377_spi_update_bit()

int adf4377_spi_update_bit ( struct adf4377_dev * dev,
uint16_t reg_addr,
uint8_t mask,
uint8_t data )

Update ADF4377 register.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Mask for specific register bits to be updated.
data- Data written to the device (requires prior bit shifting).
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adf4377_spi_write()

int adf4377_spi_write ( struct adf4377_dev * dev,
uint8_t reg_addr,
uint8_t data )

Writes data to ADF4377 over SPI.

Parameters
dev- The device structure.
reg_addr- The register address.
data- Data value to write.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function: