no-OS
Classes | Macros | Functions
adf4156.h File Reference

Header file of ADF4156 Driver for Microblaze processor. More...

#include <stdint.h>
#include "no-os/gpio.h"
#include "no-os/spi.h"
Include dependency graph for adf4156.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  adf4156_platform_data
 
struct  adf4156_state
 
struct  adf4156_dev
 
struct  adf4156_init_param
 

Macros

#define ADF4156_MUXOUT_Z   (0x00 << 27)
 
#define ADF4156_MUXOUT_DVdd   (0x01 << 27)
 
#define ADF4156_MUXOUT_DGND   (0x02 << 27)
 
#define ADF4156_MUXOUT_RDIV   (0x03 << 27)
 
#define ADF4156_MUXOUT_NDIV   (0x04 << 27)
 
#define ADF4156_MUXOUT_ALOCK   (0x05 << 27)
 
#define ADF4156_MUXOUT_DLOCK   (0x06 << 27)
 
#define ADF4156_MUXOUT_SDO   (0x07 << 27)
 
#define ADF4156_MUXOUT_CLKDIV   (0x0A << 27)
 
#define ADF4156_MUXOUT_FLS   (0x0C << 27)
 
#define ADF4156_MUXOUT_RDIV2   (0x0D << 27)
 
#define ADF4156_MUXOUT_NDIV2   (0x0E << 27)
 
#define ADF4156_MUXOUT_RESERVED   (0x0F << 27)
 
#define ADF4156_INT_VAL(x)   ((x & 0xFFF) << 15)
 
#define ADF4156_FRAC_VAL(x)   ((x & 0xFFF) << 3)
 
#define ADF4156_R0_CTRL   0x00
 
#define ADF4156_PHASE_VAL(x)   ((x & 0xFFF) << 3)
 
#define ADF4156_R1_CTRL   0x01
 
#define ADF4156_LOW_NOISE   (0x00 << 29)
 
#define ADF4156_LOW_SPUR   (0x03 << 29)
 
#define ADF4156_CSR_EN(x)   ((x & 0x1) << 28)
 
#define ADF4156_CURR_SET(x)   ((x & 0xF) << 24)
 
#define ADF4156_PRESCALER(x)   ((x & 0x1) << 22)
 
#define ADF4156_RDIV2(x)   ((x & 0x1) << 21)
 
#define ADF4156_REF_DBL(x)   ((x & 0x1) << 20)
 
#define ADF4156_R_CNT(x)   ((x & 0x1F) << 15)
 
#define ADF4156_MOD_WORD(x)   ((x & 0xFFF) << 3)
 
#define ADF4156_R2_CTRL   0x02
 
#define ADF4156_SIG_DEL_RST(x)   ((x & 0x1) << 14)
 
#define ADF4156_LDP(x)   ((x & 0x1) << 7)
 
#define ADF4156_PD_POL(x)   ((x & 0x1) << 6)
 
#define ADF4156_PD   ((x & 0x1) << 5)
 
#define ADF4156_CP_Z(x)   ((x & 0x1) << 4)
 
#define ADF4156_CNT_RST(x)   ((x & 0x1) << 3)
 
#define ADF4156_R3_CTRL   0x03
 
#define ADF4156_CLK_DIV_OFF   (0x00 << 19)
 
#define ADF4156_CLK_FAST_LOCK   (0x01 << 19)
 
#define ADF4156_CLK_RESYNC_EN   (0x02 << 19)
 
#define ADF4156_CLK_DIV_VAL(x)   ((x & 0xFFF) << 7)
 
#define ADF4156_R4_CTRL   0x04
 
#define ADF4156_LE_OUT
 
#define ADF4156_LE_LOW
 
#define ADF4156_LE_HIGH
 
#define ADF4156_MUX_OUT
 
#define ADF4156_MUX_LOW
 
#define ADF4156_MUX_HIGH
 
#define ADF4156_CE_OUT
 
#define ADF4156_CE_LOW
 
#define ADF4156_CE_HIGH
 
#define ADF4156_LE2_OUT
 
#define ADF4156_LE2_LOW
 
#define ADF4156_LE2_HIGH
 
#define ADF4156_CE2_OUT
 
#define ADF4156_CE2_LOW
 
#define ADF4156_CE2_HIGH
 
#define ADF4156_MAX_OUT_FREQ   6200 /* MHz */
 
#define ADF4156_MIN_OUT_FREQ   500 /* MHz */
 
#define ADF4156_MAX_FREQ_45_PRESC   3000 /* MHz */
 
#define ADF4156_MAX_FREQ_PFD   32000000 /* Hz */
 
#define ADF4156_MAX_FREQ_REFIN   250000000 /* Hz */
 
#define ADF4156_MIN_FREQ_REFIN   10000000 /* Hz */
 
#define ADF4156_MAX_MODULUS   4095 /* (2^12)-1 */
 
#define ADF4156_MAX_R_CNT   32
 
#define ADF4156_MAX_REG_VAL   0x1FFFFFFF
 
#define ADF4156_REG0   0
 
#define ADF4156_REG1   1
 
#define ADF4156_REG2   2
 
#define ADF4156_REG3   3
 
#define ADF4156_REG4   4
 

Functions

int8_t adf4156_init (struct adf4156_dev **device, struct adf4156_init_param init_param)
 Initialize the SPI communication with the device. More...
 
int32_t adf4156_remove (struct adf4156_dev *dev)
 Free the resources allocated by adf4156_init(). More...
 
int8_t adf4156_set (struct adf4156_dev *dev, uint32_t value)
 Transmits 32 bits on SPI. More...
 
int32_t adf4156_tune_r_cnt (struct adf4156_dev *dev, int32_t r_cnt)
 Increases the R counter value until the PFD frequency is smaller than ADF4351_MAX_FREQ_PFD. More...
 
uint32_t gcd (uint32_t x, uint32_t y)
 Computes the greatest common divider of two numbers. More...
 
double adf4156_set_freq (struct adf4156_dev *dev, double freq)
 Sets the ADF4156 output frequency. More...
 

Detailed Description

Header file of ADF4156 Driver for Microblaze processor.

Author
Lucian Sin (Lucia.nosp@m.n.Si.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Copyright 2013(c) Analog Devices, Inc.

All rights reserved.

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 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.

Macro Definition Documentation

◆ ADF4156_CE2_HIGH

#define ADF4156_CE2_HIGH
Value:
gpio_set_value(dev->gpio_ce2, \

◆ ADF4156_CE2_LOW

#define ADF4156_CE2_LOW
Value:
gpio_set_value(dev->gpio_ce2, \

◆ ADF4156_CE2_OUT

#define ADF4156_CE2_OUT
Value:
gpio_direction_output(dev->gpio_ce2, \

◆ ADF4156_CE_HIGH

#define ADF4156_CE_HIGH
Value:
gpio_set_value(dev->gpio_ce, \

◆ ADF4156_CE_LOW

#define ADF4156_CE_LOW
Value:
gpio_set_value(dev->gpio_ce, \

◆ ADF4156_CE_OUT

#define ADF4156_CE_OUT
Value:
gpio_direction_output(dev->gpio_ce, \

◆ ADF4156_CLK_DIV_OFF

#define ADF4156_CLK_DIV_OFF   (0x00 << 19)

◆ ADF4156_CLK_DIV_VAL

#define ADF4156_CLK_DIV_VAL (   x)    ((x & 0xFFF) << 7)

◆ ADF4156_CLK_FAST_LOCK

#define ADF4156_CLK_FAST_LOCK   (0x01 << 19)

◆ ADF4156_CLK_RESYNC_EN

#define ADF4156_CLK_RESYNC_EN   (0x02 << 19)

◆ ADF4156_CNT_RST

#define ADF4156_CNT_RST (   x)    ((x & 0x1) << 3)

◆ ADF4156_CP_Z

#define ADF4156_CP_Z (   x)    ((x & 0x1) << 4)

◆ ADF4156_CSR_EN

#define ADF4156_CSR_EN (   x)    ((x & 0x1) << 28)

◆ ADF4156_CURR_SET

#define ADF4156_CURR_SET (   x)    ((x & 0xF) << 24)

◆ ADF4156_FRAC_VAL

#define ADF4156_FRAC_VAL (   x)    ((x & 0xFFF) << 3)

◆ ADF4156_INT_VAL

#define ADF4156_INT_VAL (   x)    ((x & 0xFFF) << 15)

◆ ADF4156_LDP

#define ADF4156_LDP (   x)    ((x & 0x1) << 7)

◆ ADF4156_LE2_HIGH

#define ADF4156_LE2_HIGH
Value:
gpio_set_value(dev->gpio_le2, \

◆ ADF4156_LE2_LOW

#define ADF4156_LE2_LOW
Value:
gpio_set_value(dev->gpio_le2, \

◆ ADF4156_LE2_OUT

#define ADF4156_LE2_OUT
Value:
gpio_direction_output(dev->gpio_le2, \

◆ ADF4156_LE_HIGH

#define ADF4156_LE_HIGH
Value:
gpio_set_value(dev->gpio_le, \

◆ ADF4156_LE_LOW

#define ADF4156_LE_LOW
Value:
gpio_set_value(dev->gpio_le, \

◆ ADF4156_LE_OUT

#define ADF4156_LE_OUT
Value:
gpio_direction_output(dev->gpio_le, \

◆ ADF4156_LOW_NOISE

#define ADF4156_LOW_NOISE   (0x00 << 29)

◆ ADF4156_LOW_SPUR

#define ADF4156_LOW_SPUR   (0x03 << 29)

◆ ADF4156_MAX_FREQ_45_PRESC

#define ADF4156_MAX_FREQ_45_PRESC   3000 /* MHz */

◆ ADF4156_MAX_FREQ_PFD

#define ADF4156_MAX_FREQ_PFD   32000000 /* Hz */

◆ ADF4156_MAX_FREQ_REFIN

#define ADF4156_MAX_FREQ_REFIN   250000000 /* Hz */

◆ ADF4156_MAX_MODULUS

#define ADF4156_MAX_MODULUS   4095 /* (2^12)-1 */

◆ ADF4156_MAX_OUT_FREQ

#define ADF4156_MAX_OUT_FREQ   6200 /* MHz */

◆ ADF4156_MAX_R_CNT

#define ADF4156_MAX_R_CNT   32

◆ ADF4156_MAX_REG_VAL

#define ADF4156_MAX_REG_VAL   0x1FFFFFFF

◆ ADF4156_MIN_FREQ_REFIN

#define ADF4156_MIN_FREQ_REFIN   10000000 /* Hz */

◆ ADF4156_MIN_OUT_FREQ

#define ADF4156_MIN_OUT_FREQ   500 /* MHz */

◆ ADF4156_MOD_WORD

#define ADF4156_MOD_WORD (   x)    ((x & 0xFFF) << 3)

◆ ADF4156_MUX_HIGH

#define ADF4156_MUX_HIGH
Value:
gpio_set_value(dev->gpio_mux, \

◆ ADF4156_MUX_LOW

#define ADF4156_MUX_LOW
Value:
gpio_set_value(dev->gpio_mux, \

◆ ADF4156_MUX_OUT

#define ADF4156_MUX_OUT
Value:
gpio_direction_output(dev->gpio_mux, \

◆ ADF4156_MUXOUT_ALOCK

#define ADF4156_MUXOUT_ALOCK   (0x05 << 27)

◆ ADF4156_MUXOUT_CLKDIV

#define ADF4156_MUXOUT_CLKDIV   (0x0A << 27)

◆ ADF4156_MUXOUT_DGND

#define ADF4156_MUXOUT_DGND   (0x02 << 27)

◆ ADF4156_MUXOUT_DLOCK

#define ADF4156_MUXOUT_DLOCK   (0x06 << 27)

◆ ADF4156_MUXOUT_DVdd

#define ADF4156_MUXOUT_DVdd   (0x01 << 27)

◆ ADF4156_MUXOUT_FLS

#define ADF4156_MUXOUT_FLS   (0x0C << 27)

◆ ADF4156_MUXOUT_NDIV

#define ADF4156_MUXOUT_NDIV   (0x04 << 27)

◆ ADF4156_MUXOUT_NDIV2

#define ADF4156_MUXOUT_NDIV2   (0x0E << 27)

◆ ADF4156_MUXOUT_RDIV

#define ADF4156_MUXOUT_RDIV   (0x03 << 27)

◆ ADF4156_MUXOUT_RDIV2

#define ADF4156_MUXOUT_RDIV2   (0x0D << 27)

◆ ADF4156_MUXOUT_RESERVED

#define ADF4156_MUXOUT_RESERVED   (0x0F << 27)

◆ ADF4156_MUXOUT_SDO

#define ADF4156_MUXOUT_SDO   (0x07 << 27)

◆ ADF4156_MUXOUT_Z

#define ADF4156_MUXOUT_Z   (0x00 << 27)

◆ ADF4156_PD

#define ADF4156_PD   ((x & 0x1) << 5)

◆ ADF4156_PD_POL

#define ADF4156_PD_POL (   x)    ((x & 0x1) << 6)

◆ ADF4156_PHASE_VAL

#define ADF4156_PHASE_VAL (   x)    ((x & 0xFFF) << 3)

◆ ADF4156_PRESCALER

#define ADF4156_PRESCALER (   x)    ((x & 0x1) << 22)

◆ ADF4156_R0_CTRL

#define ADF4156_R0_CTRL   0x00

◆ ADF4156_R1_CTRL

#define ADF4156_R1_CTRL   0x01

◆ ADF4156_R2_CTRL

#define ADF4156_R2_CTRL   0x02

◆ ADF4156_R3_CTRL

#define ADF4156_R3_CTRL   0x03

◆ ADF4156_R4_CTRL

#define ADF4156_R4_CTRL   0x04

◆ ADF4156_R_CNT

#define ADF4156_R_CNT (   x)    ((x & 0x1F) << 15)

◆ ADF4156_RDIV2

#define ADF4156_RDIV2 (   x)    ((x & 0x1) << 21)

◆ ADF4156_REF_DBL

#define ADF4156_REF_DBL (   x)    ((x & 0x1) << 20)

◆ ADF4156_REG0

#define ADF4156_REG0   0

◆ ADF4156_REG1

#define ADF4156_REG1   1

◆ ADF4156_REG2

#define ADF4156_REG2   2

◆ ADF4156_REG3

#define ADF4156_REG3   3

◆ ADF4156_REG4

#define ADF4156_REG4   4

◆ ADF4156_SIG_DEL_RST

#define ADF4156_SIG_DEL_RST (   x)    ((x & 0x1) << 14)

Function Documentation

◆ adf4156_init()

int8_t adf4156_init ( struct adf4156_dev **  device,
struct adf4156_init_param  init_param 
)

Initialize the SPI communication with the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
status - Result of the initialization procedure. Example: 0 - if initialization was successful; -1 - if initialization was unsuccessful.

◆ adf4156_remove()

int32_t adf4156_remove ( struct adf4156_dev dev)

Free the resources allocated by adf4156_init().

Parameters
dev- The device structure.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ adf4156_set()

int8_t adf4156_set ( struct adf4156_dev dev,
uint32_t  value 
)

Transmits 32 bits on SPI.

Parameters
dev- The device structure.
value- Data which will be transmitted.
Returns
none.
Here is the caller graph for this function:

◆ adf4156_set_freq()

double adf4156_set_freq ( struct adf4156_dev dev,
double  freq 
)

Sets the ADF4156 output frequency.

Parameters
dev- The device structure.
freq- The desired frequency value.
Returns
calculatedFrequency - The actual frequency value that was set.

◆ adf4156_tune_r_cnt()

int32_t adf4156_tune_r_cnt ( struct adf4156_dev dev,
int32_t  r_cnt 
)

Increases the R counter value until the PFD frequency is smaller than ADF4351_MAX_FREQ_PFD.

Parameters
dev- The device structure.
r_cnt- Initial r_cnt value.
Returns
Final r_cnt value.
Here is the caller graph for this function:

◆ gcd()

uint32_t gcd ( uint32_t  x,
uint32_t  y 
)

Computes the greatest common divider of two numbers.

Returns
Returns the gcd.
gpio_direction_output
int32_t gpio_direction_output(struct gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: gpio.c:124
GPIO_LOW
@ GPIO_LOW
Definition: gpio.h:99
gpio_set_value
int32_t gpio_set_value(struct gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: gpio.c:160
GPIO_HIGH
@ GPIO_HIGH
Definition: gpio.h:101