no-OS
Classes | Functions
adf4368.c File Reference

Implementation of ADF4368 Driver. More...

#include "adf4368.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_print_log.h"
Include dependency graph for adf4368.c:

Classes

struct  adf4368_reg_sequence
 ADF4368 register format structure for default values.
 

Functions

int adf4368_spi_write (struct adf4368_dev *dev, uint16_t reg_addr, uint8_t data)
 Writes data to ADF4368 over SPI. More...
 
int adf4368_spi_read (struct adf4368_dev *dev, uint16_t reg_addr, uint8_t *data)
 Reads data from ADF4368 over SPI. More...
 
int adf4368_spi_update_bits (struct adf4368_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
 Updates the values of the ADF4368 register. More...
 
int adf4368_reg_dump (struct adf4368_dev *dev)
 Will output on the terminal the values of all the ADF4368 registers. More...
 
int adf4368_set_out_power (struct adf4368_dev *dev, uint8_t ch, int32_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. More...
 
int adf4368_get_out_power (struct adf4368_dev *dev, uint8_t ch, int32_t *pwr)
 Gets the output power register value. More...
 
int adf4368_set_en_chan (struct adf4368_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. More...
 
int adf4368_get_en_chan (struct adf4368_dev *dev, uint8_t ch, bool *en)
 Gets the value the output channel if it is enabled or disable. More...
 
int adf4368_set_ref_clk (struct adf4368_dev *dev, uint64_t val)
 Set the desired reference frequency and reset everything over to maximum supported value of 4GHz to the max. value and everything under the minimum supported value of 10MHz to the min. value. More...
 
int adf4368_get_ref_clk (struct adf4368_dev *dev, uint64_t *val)
 Gets the user proposed reference frequency. More...
 
int adf4368_set_en_ref_doubler (struct adf4368_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. More...
 
int adf4368_get_en_ref_doubler (struct adf4368_dev *dev, bool *en)
 Gets the value the doubler if it is enabled or disable and stores it it the dev structure. More...
 
int adf4368_set_ref_div (struct adf4368_dev *dev, int32_t div)
 Set the reference divider value and reset everything over to maximum supported value of 63 to the max. value. More...
 
int adf4368_get_ref_div (struct adf4368_dev *dev, int32_t *div)
 Gets the value the reference divider. More...
 
int adf4368_set_cp_i (struct adf4368_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. More...
 
int adf4368_get_cp_i (struct adf4368_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. More...
 
int adf4368_set_bleed_word (struct adf4368_dev *dev, int32_t word)
 Set the bleed word, which represents the value of the bleed current written to the register space. More...
 
int adf4368_get_bleed_word (struct adf4368_dev *dev, int32_t *word)
 Gets the value of the bleed word. More...
 
int adf4368_set_rfout (struct adf4368_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. More...
 
int adf4368_get_rfout (struct adf4368_dev *dev, uint64_t *val)
 Gets the user proposed output frequency. More...
 
int adf4368_set_sync_setup (struct adf4368_dev *dev, bool en)
 Set EZSYNC and Timed SYNC features' initial state. Waits for SW_SYNC toggle or SYNC pin. More...
 
int adf4368_get_sync_setup (struct adf4368_dev *dev, bool *en)
 Gets the value of the SYNC features' powerdown bit. More...
 
int adf4368_set_sw_sync (struct adf4368_dev *dev, uint8_t sw_sync)
 Set Software SYNC Request. Setting SW_SYNC resets the RF block. Clearing SW_SYNC makes ready for a new reference clock. More...
 
int adf4368_get_sw_sync (struct adf4368_dev *dev, uint8_t *sw_sync)
 Gets the value of the SW_SYNC bit. More...
 
int adf4368_set_temperature (struct adf4368_dev *dev, bool en)
 Set Temperature Readback feature's initial state. This feature should be disabled after reading temperature. More...
 
int adf4368_get_temperature (struct adf4368_dev *dev, int32_t *temp)
 Gets the value of the approximate die temperature. More...
 
int adf4368_set_phase_sdm (struct adf4368_dev *dev, uint32_t phase_fs)
 Set the phase adjustment in femto-seconds with Sigma Delta Modulation. This approach only support MAX %22 in degree phase. Recommend to use in fractional mode. More...
 
int adf4368_get_phase_sdm (struct adf4368_dev *dev, uint32_t *phase_fs)
 Get the phase adjustment in femto-seconds with Sigma Delta Modulation. More...
 
int adf4368_set_phase_bleedi (struct adf4368_dev *dev, uint32_t phase_fs, bool phase_pol)
 Set the phase adjustment in femto-seconds. The phase adjust will enable the Bleed current. Recommend to use in integer mode. More...
 
int adf4368_set_phase (struct adf4368_dev *dev, uint32_t phase_fs, bool phase_pol)
 Set the phase adjustment in femto-seconds. Function choose the phase adjustment method according to Integer mode. More...
 
int adf4368_get_phase (struct adf4368_dev *dev, uint32_t *phase_fs, bool *phase_pol)
 Get the phase adjustment in femto-seconds. Function choose the phase adjustment method according to Integer mode. More...
 
int adf4368_set_default_regs (struct adf4368_dev *dev, bool spi_4wire)
 Applys a softreset, sets the SPI 4 wire mode and writes the default registers. More...
 
int adf4368_get_default_regs (struct adf4368_dev *dev, bool *check)
 Reads and Checks the registers values equal to default values. More...
 
int adf4368_set_freq (struct adf4368_dev *dev)
 Set the output frequency. More...
 
int adf4368_init (struct adf4368_dev **dev, struct adf4368_init_param *init_param)
 Initializes the adf4368. More...
 
int adf4368_remove (struct adf4368_dev *dev)
 Free resources allocated for ADF4368. More...
 

Detailed Description

Implementation of ADF4368 Driver.

Author
Sirac Kucukarabacioglu (sirac.nosp@m..kuc.nosp@m.ukara.nosp@m.baci.nosp@m.oglu@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2024(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

◆ adf4368_get_bleed_word()

int adf4368_get_bleed_word ( struct adf4368_dev dev,
int32_t *  word 
)

Gets the value of the bleed word.

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

◆ adf4368_get_cp_i()

int adf4368_get_cp_i ( struct adf4368_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.

◆ adf4368_get_default_regs()

int adf4368_get_default_regs ( struct adf4368_dev dev,
bool check 
)

Reads and Checks the registers values equal to default values.

Parameters
dev- The device structure
check- default state value
Returns
- 0 in case of success, negative error code otherwise.

◆ adf4368_get_en_chan()

int adf4368_get_en_chan ( struct adf4368_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.

◆ adf4368_get_en_ref_doubler()

int adf4368_get_en_ref_doubler ( struct adf4368_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.

◆ adf4368_get_out_power()

int adf4368_get_out_power ( struct adf4368_dev dev,
uint8_t  ch,
int32_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
- Result of the reading procedure, error code otherwise.

◆ adf4368_get_phase()

int adf4368_get_phase ( struct adf4368_dev dev,
uint32_t *  phase_fs,
bool phase_pol 
)

Get the phase adjustment in femto-seconds. Function choose the phase adjustment method according to Integer mode.

Parameters
dev- The device structure.
phase_fs- The phase adjustment in femto-seconds.
phase_pol- The phase adjustment value's sign.
Returns
- 0 in case of success, negative error code otherwise.

◆ adf4368_get_phase_sdm()

int adf4368_get_phase_sdm ( struct adf4368_dev dev,
uint32_t *  phase_fs 
)

Get the phase adjustment in femto-seconds with Sigma Delta Modulation.

Parameters
dev- The device structure.
phase_fs- The Read value of the phase adjustment in femto-seconds.
Returns
- 0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adf4368_get_ref_clk()

int adf4368_get_ref_clk ( struct adf4368_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
- Reference frequency in KHz.

◆ adf4368_get_ref_div()

int adf4368_get_ref_div ( struct adf4368_dev dev,
int32_t *  div 
)

Gets the value the reference divider.

Parameters
dev- The device structure.
div- The read reference divider value.
Returns
- Result of the reading procedure, error code otherwise.

◆ adf4368_get_rfout()

int adf4368_get_rfout ( struct adf4368_dev dev,
uint64_t *  val 
)

Gets the user proposed output frequency.

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

◆ adf4368_get_sw_sync()

int adf4368_get_sw_sync ( struct adf4368_dev dev,
uint8_t *  sw_sync 
)

Gets the value of the SW_SYNC bit.

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

◆ adf4368_get_sync_setup()

int adf4368_get_sync_setup ( struct adf4368_dev dev,
bool en 
)

Gets the value of the SYNC features' powerdown bit.

Parameters
dev- The device structure.
en- The read value of the SYNC features' powerdown.
Returns
- 0 in case of success or negative error code.

◆ adf4368_get_temperature()

int adf4368_get_temperature ( struct adf4368_dev dev,
int32_t *  temp 
)

Gets the value of the approximate die temperature.

Parameters
dev- The device structure.
temp- The read value of the Temperature Readback.
Returns
- 0 in case of success or negative error code.

◆ adf4368_init()

int adf4368_init ( struct adf4368_dev **  dev,
struct adf4368_init_param init_param 
)

Initializes the adf4368.

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

◆ adf4368_reg_dump()

int adf4368_reg_dump ( struct adf4368_dev dev)

Will output on the terminal the values of all the ADF4368 registers.

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

◆ adf4368_remove()

int adf4368_remove ( struct adf4368_dev dev)

Free resources allocated for ADF4368.

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

◆ adf4368_set_bleed_word()

int adf4368_set_bleed_word ( struct adf4368_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
- 0 in case of success or negative error code.

◆ adf4368_set_cp_i()

int adf4368_set_cp_i ( struct adf4368_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
- 0 in case of success or negative error code.

◆ adf4368_set_default_regs()

int adf4368_set_default_regs ( struct adf4368_dev dev,
bool  spi_4wire 
)

Applys a softreset, sets the SPI 4 wire mode and writes the default registers.

Parameters
dev- The device structure
spi_4wire- SPI 4 wire feature enable input
Returns
- 0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adf4368_set_en_chan()

int adf4368_set_en_chan ( struct adf4368_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.

◆ adf4368_set_en_ref_doubler()

int adf4368_set_en_ref_doubler ( struct adf4368_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.

◆ adf4368_set_freq()

int adf4368_set_freq ( struct adf4368_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:

◆ adf4368_set_out_power()

int adf4368_set_out_power ( struct adf4368_dev dev,
uint8_t  ch,
int32_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.

◆ adf4368_set_phase()

int adf4368_set_phase ( struct adf4368_dev dev,
uint32_t  phase_fs,
bool  phase_pol 
)

Set the phase adjustment in femto-seconds. Function choose the phase adjustment method according to Integer mode.

Parameters
dev- The device structure.
phase_fs- The phase adjustment in femto-seconds.
phase_pol- The phase adjustment value's sign.
Returns
- 0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adf4368_set_phase_bleedi()

int adf4368_set_phase_bleedi ( struct adf4368_dev dev,
uint32_t  phase_fs,
bool  phase_pol 
)

Set the phase adjustment in femto-seconds. The phase adjust will enable the Bleed current. Recommend to use in integer mode.

Parameters
dev- The device structure.
phase_fs- The phase adjustment in femto-seconds.
phase_pol- The phase adjustment value's sign.
Returns
- 0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adf4368_set_phase_sdm()

int adf4368_set_phase_sdm ( struct adf4368_dev dev,
uint32_t  phase_fs 
)

Set the phase adjustment in femto-seconds with Sigma Delta Modulation. This approach only support MAX %22 in degree phase. Recommend to use in fractional mode.

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

◆ adf4368_set_ref_clk()

int adf4368_set_ref_clk ( struct adf4368_dev dev,
uint64_t  val 
)

Set the desired reference frequency and reset everything over to maximum supported value of 4GHz 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.

◆ adf4368_set_ref_div()

int adf4368_set_ref_div ( struct adf4368_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.

◆ adf4368_set_rfout()

int adf4368_set_rfout ( struct adf4368_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:

◆ adf4368_set_sw_sync()

int adf4368_set_sw_sync ( struct adf4368_dev dev,
uint8_t  sw_sync 
)

Set Software SYNC Request. Setting SW_SYNC resets the RF block. Clearing SW_SYNC makes ready for a new reference clock.

Parameters
dev- The device structure.
sw_sync- Set send SW_SYNC request
Returns
- 0 in case of success or negative error code.

◆ adf4368_set_sync_setup()

int adf4368_set_sync_setup ( struct adf4368_dev dev,
bool  en 
)

Set EZSYNC and Timed SYNC features' initial state. Waits for SW_SYNC toggle or SYNC pin.

Parameters
dev- The device structure.
en- The enable or disable SYNC feature.
Returns
- 0 in case of success or negative error code.

◆ adf4368_set_temperature()

int adf4368_set_temperature ( struct adf4368_dev dev,
bool  en 
)

Set Temperature Readback feature's initial state. This feature should be disabled after reading temperature.

Parameters
dev- The device structure.
en- The enable or disable Temperature readback feature.
Returns
- 0 in case of success or negative error code.

◆ adf4368_spi_read()

int adf4368_spi_read ( struct adf4368_dev dev,
uint16_t  reg_addr,
uint8_t *  data 
)

Reads data from ADF4368 over SPI.

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

◆ adf4368_spi_update_bits()

int adf4368_spi_update_bits ( struct adf4368_dev dev,
uint16_t  reg_addr,
uint8_t  mask,
uint8_t  data 
)

Updates the values of the ADF4368 register.

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

◆ adf4368_spi_write()

int adf4368_spi_write ( struct adf4368_dev dev,
uint16_t  reg_addr,
uint8_t  data 
)

Writes data to ADF4368 over SPI.

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