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

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

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

Go to the source code of this file.

Classes

struct  adf4157_platform_data
 
struct  adf4157_state
 
struct  adf4157_dev
 
struct  adf4157_init_param
 

Macros

#define ADF4157_MUXOUT_Z   (0x00 << 27)
 
#define ADF4157_MUXOUT_DVdd   (0x01 << 27)
 
#define ADF4157_MUXOUT_DGND   (0x02 << 27)
 
#define ADF4157_MUXOUT_RDIV   (0x03 << 27)
 
#define ADF4157_MUXOUT_NDIV   (0x04 << 27)
 
#define ADF4157_MUXOUT_ALOCK   (0x05 << 27)
 
#define ADF4157_MUXOUT_DLOCK   (0x06 << 27)
 
#define ADF4157_MUXOUT_SDO   (0x07 << 27)
 
#define ADF4157_MUXOUT_CLKDIV   (0x0A << 27)
 
#define ADF4157_MUXOUT_FLS   (0x0C << 27)
 
#define ADF4157_MUXOUT_RDIV2   (0x0D << 27)
 
#define ADF4157_MUXOUT_NDIV2   (0x0E << 27)
 
#define ADF4157_MUXOUT_RESERVED   (0x0F << 27)
 
#define ADF4157_INT_VAL(x)   ((x & 0xFFF) << 15)
 
#define ADF4157_FRAC_VAL_MSB(x)   ((x & 0x1FFE000) >> 10)
 
#define ADF4157_R0_CTRL   0x00
 
#define ADF4157_FRAC_VAL_LSB(x)   ((x & 0x1FFF) << 15)
 
#define ADF4157_R1_CTRL   0x01
 
#define ADF4157_LOW_NOISE   (0x00 << 29)
 
#define ADF4157_LOW_SPUR   (0x03 << 29)
 
#define ADF4157_CSR_EN(x)   ((x & 0x1) << 28)
 
#define ADF4157_CURR_SET(x)   ((x & 0xF) << 24)
 
#define ADF4157_PRESCALER(x)   ((x & 0x1) << 22)
 
#define ADF4157_RDIV2(x)   ((x & 0x1) << 21)
 
#define ADF4157_REF_DBL(x)   ((x & 0x1) << 20)
 
#define ADF4157_R_CNT(x)   ((x & 0x1F) << 15)
 
#define ADF4157_R2_CTRL   0x02
 
#define ADF4157_SIG_DEL_RST(x)   ((x & 0x1) << 14)
 
#define ADF4157_LDP(x)   ((x & 0x1) << 7)
 
#define ADF4157_PD_POL(x)   ((x & 0x1) << 6)
 
#define ADF4157_PD   ((x & 0x1) << 5)
 
#define ADF4157_CP_Z(x)   ((x & 0x1) << 4)
 
#define ADF4157_CNT_RST(x)   ((x & 0x1) << 3)
 
#define ADF4157_R3_CTRL   0x03
 
#define ADF4157_NEG_BLEED_CUR(x)   ((x && 0x3) << 23)
 
#define ADF4157_CLK_DIV_OFF   (0x00 << 19)
 
#define ADF4157_CLK_FAST_LOCK   (0x01 << 19)
 
#define ADF4157_CLK_RESYNC_EN   (0x02 << 19)
 
#define ADF4157_CLK_DIV_VAL(x)   ((x & 0xFFF) << 7)
 
#define ADF4157_R4_CTRL   0x04
 
#define ADF4157_LE_OUT
 
#define ADF4157_LE_LOW
 
#define ADF4157_LE_HIGH
 
#define ADF4157_MUX_OUT
 
#define ADF4157_MUX_LOW
 
#define ADF4157_MUX_HIGH
 
#define ADF4157_CE_OUT
 
#define ADF4157_CE_LOW
 
#define ADF4157_CE_HIGH
 
#define ADF4157_LE2_OUT
 
#define ADF4157_LE2_LOW
 
#define ADF4157_LE2_HIGH
 
#define ADF4157_CE2_OUT
 
#define ADF4157_CE2_LOW
 
#define ADF4157_CE2_HIGH
 
#define ADF4157_MAX_OUT_FREQ   6000 /* MHz */
 
#define ADF4157_MIN_OUT_FREQ   500 /* MHz */
 
#define ADF4157_MAX_FREQ_45_PRESC   3000 /* MHz */
 
#define ADF4157_MAX_FREQ_PFD   32000000 /* Hz */
 
#define ADF4157_MAX_FREQ_REFIN   300000000 /* Hz */
 
#define ADF4157_MIN_FREQ_REFIN   10000000 /* Hz */
 
#define ADF4157_FIXED_MODULUS   33554432 /* 2^25 */
 
#define ADF4157_MAX_R_CNT   32
 
#define ADF4157_MAX_REG_VAL   0x1FFFFFFF
 
#define ADF4157_REG0   0
 
#define ADF4157_REG1   1
 
#define ADF4157_REG2   2
 
#define ADF4157_REG3   3
 
#define ADF4157_REG4   4
 

Functions

int8_t adf4157_init (struct adf4157_dev **device, struct adf4157_init_param init_param)
 Initialize the SPI communication with the device. More...
 
int32_t adf4157_remove (struct adf4157_dev *dev)
 Free the resources allocated by adf4157_init(). More...
 
int8_t adf4157_set (struct adf4157_dev *dev, uint32_t value)
 Transmits 32 bits on SPI. More...
 
int32_t adf4157_tune_r_cnt (struct adf4157_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 adf4157_set_freq (struct adf4157_dev *dev, double freq)
 Sets the ADF4157 output frequency. More...
 

Detailed Description

Header file of ADF4157 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

◆ ADF4157_CE2_HIGH

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

◆ ADF4157_CE2_LOW

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

◆ ADF4157_CE2_OUT

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

◆ ADF4157_CE_HIGH

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

◆ ADF4157_CE_LOW

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

◆ ADF4157_CE_OUT

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

◆ ADF4157_CLK_DIV_OFF

#define ADF4157_CLK_DIV_OFF   (0x00 << 19)

◆ ADF4157_CLK_DIV_VAL

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

◆ ADF4157_CLK_FAST_LOCK

#define ADF4157_CLK_FAST_LOCK   (0x01 << 19)

◆ ADF4157_CLK_RESYNC_EN

#define ADF4157_CLK_RESYNC_EN   (0x02 << 19)

◆ ADF4157_CNT_RST

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

◆ ADF4157_CP_Z

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

◆ ADF4157_CSR_EN

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

◆ ADF4157_CURR_SET

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

◆ ADF4157_FIXED_MODULUS

#define ADF4157_FIXED_MODULUS   33554432 /* 2^25 */

◆ ADF4157_FRAC_VAL_LSB

#define ADF4157_FRAC_VAL_LSB (   x)    ((x & 0x1FFF) << 15)

◆ ADF4157_FRAC_VAL_MSB

#define ADF4157_FRAC_VAL_MSB (   x)    ((x & 0x1FFE000) >> 10)

◆ ADF4157_INT_VAL

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

◆ ADF4157_LDP

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

◆ ADF4157_LE2_HIGH

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

◆ ADF4157_LE2_LOW

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

◆ ADF4157_LE2_OUT

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

◆ ADF4157_LE_HIGH

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

◆ ADF4157_LE_LOW

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

◆ ADF4157_LE_OUT

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

◆ ADF4157_LOW_NOISE

#define ADF4157_LOW_NOISE   (0x00 << 29)

◆ ADF4157_LOW_SPUR

#define ADF4157_LOW_SPUR   (0x03 << 29)

◆ ADF4157_MAX_FREQ_45_PRESC

#define ADF4157_MAX_FREQ_45_PRESC   3000 /* MHz */

◆ ADF4157_MAX_FREQ_PFD

#define ADF4157_MAX_FREQ_PFD   32000000 /* Hz */

◆ ADF4157_MAX_FREQ_REFIN

#define ADF4157_MAX_FREQ_REFIN   300000000 /* Hz */

◆ ADF4157_MAX_OUT_FREQ

#define ADF4157_MAX_OUT_FREQ   6000 /* MHz */

◆ ADF4157_MAX_R_CNT

#define ADF4157_MAX_R_CNT   32

◆ ADF4157_MAX_REG_VAL

#define ADF4157_MAX_REG_VAL   0x1FFFFFFF

◆ ADF4157_MIN_FREQ_REFIN

#define ADF4157_MIN_FREQ_REFIN   10000000 /* Hz */

◆ ADF4157_MIN_OUT_FREQ

#define ADF4157_MIN_OUT_FREQ   500 /* MHz */

◆ ADF4157_MUX_HIGH

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

◆ ADF4157_MUX_LOW

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

◆ ADF4157_MUX_OUT

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

◆ ADF4157_MUXOUT_ALOCK

#define ADF4157_MUXOUT_ALOCK   (0x05 << 27)

◆ ADF4157_MUXOUT_CLKDIV

#define ADF4157_MUXOUT_CLKDIV   (0x0A << 27)

◆ ADF4157_MUXOUT_DGND

#define ADF4157_MUXOUT_DGND   (0x02 << 27)

◆ ADF4157_MUXOUT_DLOCK

#define ADF4157_MUXOUT_DLOCK   (0x06 << 27)

◆ ADF4157_MUXOUT_DVdd

#define ADF4157_MUXOUT_DVdd   (0x01 << 27)

◆ ADF4157_MUXOUT_FLS

#define ADF4157_MUXOUT_FLS   (0x0C << 27)

◆ ADF4157_MUXOUT_NDIV

#define ADF4157_MUXOUT_NDIV   (0x04 << 27)

◆ ADF4157_MUXOUT_NDIV2

#define ADF4157_MUXOUT_NDIV2   (0x0E << 27)

◆ ADF4157_MUXOUT_RDIV

#define ADF4157_MUXOUT_RDIV   (0x03 << 27)

◆ ADF4157_MUXOUT_RDIV2

#define ADF4157_MUXOUT_RDIV2   (0x0D << 27)

◆ ADF4157_MUXOUT_RESERVED

#define ADF4157_MUXOUT_RESERVED   (0x0F << 27)

◆ ADF4157_MUXOUT_SDO

#define ADF4157_MUXOUT_SDO   (0x07 << 27)

◆ ADF4157_MUXOUT_Z

#define ADF4157_MUXOUT_Z   (0x00 << 27)

◆ ADF4157_NEG_BLEED_CUR

#define ADF4157_NEG_BLEED_CUR (   x)    ((x && 0x3) << 23)

◆ ADF4157_PD

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

◆ ADF4157_PD_POL

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

◆ ADF4157_PRESCALER

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

◆ ADF4157_R0_CTRL

#define ADF4157_R0_CTRL   0x00

◆ ADF4157_R1_CTRL

#define ADF4157_R1_CTRL   0x01

◆ ADF4157_R2_CTRL

#define ADF4157_R2_CTRL   0x02

◆ ADF4157_R3_CTRL

#define ADF4157_R3_CTRL   0x03

◆ ADF4157_R4_CTRL

#define ADF4157_R4_CTRL   0x04

◆ ADF4157_R_CNT

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

◆ ADF4157_RDIV2

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

◆ ADF4157_REF_DBL

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

◆ ADF4157_REG0

#define ADF4157_REG0   0

◆ ADF4157_REG1

#define ADF4157_REG1   1

◆ ADF4157_REG2

#define ADF4157_REG2   2

◆ ADF4157_REG3

#define ADF4157_REG3   3

◆ ADF4157_REG4

#define ADF4157_REG4   4

◆ ADF4157_SIG_DEL_RST

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

Function Documentation

◆ adf4157_init()

int8_t adf4157_init ( struct adf4157_dev **  device,
struct adf4157_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.

◆ adf4157_remove()

int32_t adf4157_remove ( struct adf4157_dev dev)

Free the resources allocated by adf4157_init().

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

◆ adf4157_set()

int8_t adf4157_set ( struct adf4157_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:

◆ adf4157_set_freq()

double adf4157_set_freq ( struct adf4157_dev dev,
double  freq 
)

Sets the ADF4157 output frequency.

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

◆ adf4157_tune_r_cnt()

int32_t adf4157_tune_r_cnt ( struct adf4157_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.
Here is the caller graph for this function:
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