no-OS
adf4371.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef ADF4371_H_
34 #define ADF4371_H_
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include "no_os_spi.h"
41 
42 /******************************************************************************/
43 /********************** Macros and Types Declarations *************************/
44 /******************************************************************************/
46  bool enable;
47  uint64_t freq;
48 };
49 
51  uint32_t icp;
52  uint32_t regval;
53 };
54 
56  uint32_t num;
58 };
59 
60 struct adf4371_dev {
63  uint32_t num_channels;
67  uint32_t pd_pol;
70  bool muxout_en;
72  uint32_t ref_div_factor;
73  uint32_t clkin_freq;
74  uint32_t fpfd;
75  uint32_t integer;
76  uint32_t fract1;
77  uint32_t fract2;
78  uint32_t mod2;
79  uint32_t rf_div_sel;
80  uint8_t buf[10];
81 };
82 
86  uint32_t clkin_frequency;
91  uint32_t muxout_select;
93  uint32_t num_channels;
95 };
96 
97 /******************************************************************************/
98 /************************ Functions Declarations ******************************/
99 /******************************************************************************/
100 /* Initialize the device. */
101 int32_t adf4371_init(struct adf4371_dev **device,
102  const struct adf4371_init_param *init_param);
103 
104 /* Remove the device. */
105 int32_t adf4371_remove(struct adf4371_dev *device);
106 
107 /* Recalculate rate corresponding to a channel. */
108 int32_t adf4371_clk_recalc_rate(struct adf4371_dev *dev, uint32_t chan,
109  uint64_t *rate);
110 
111 /* Calculate closest possible rate */
112 int32_t adf4371_clk_round_rate(struct adf4371_dev *dev, uint64_t rate,
113  uint64_t *rounded_rate);
114 
115 /* Set channel rate. */
116 int32_t adf4371_clk_set_rate(struct adf4371_dev *dev, uint32_t chan,
117  uint64_t rate);
118 
119 #endif
adf4371_clk_recalc_rate
int32_t adf4371_clk_recalc_rate(struct adf4371_dev *dev, uint32_t chan, uint64_t *rate)
Definition: adf4371.c:692
timeout
uint32_t timeout
Definition: ad413x.c:49
no_os_alloc.h
ADF4371_RDIV2
@ ADF4371_RDIV2
Definition: adf4371.c:160
adf4371_clk_round_rate
int32_t adf4371_clk_round_rate(struct adf4371_dev *dev, uint64_t rate, uint64_t *rounded_rate)
Definition: adf4371.c:710
adf4371_dev::clkin_freq
uint32_t clkin_freq
Definition: adf4371.h:73
adf4371_channel_config
Definition: adf4371.h:45
adf4371_variant
adf4371_variant
Definition: adf4371.c:150
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
ADF4371_ADDR_ASC_R
#define ADF4371_ADDR_ASC_R(x)
Definition: adf4371.c:60
ADF4371_TRISTATE
@ ADF4371_TRISTATE
Definition: adf4371.c:156
adf4371_dev::fract1
uint32_t fract1
Definition: adf4371.h:76
no_os_spi.h
Header file of SPI Interface.
reg_sequence
ADF4382 register format structure for default values.
Definition: adf4371.c:185
adf4371_muxout
adf4371_muxout
Definition: adf4371.c:155
ADF4371_MIN_VCO_FREQ
#define ADF4371_MIN_VCO_FREQ
Definition: adf4371.c:116
ADF4371_ADDR
#define ADF4371_ADDR(x)
Definition: adf4371.c:51
ADF4371_MUXOUT_ENABLE
@ ADF4371_MUXOUT_ENABLE
Definition: adf4371.c:140
ADF4371_CHANNEL_NAME
@ ADF4371_CHANNEL_NAME
Definition: adf4371.c:139
adf4371_dev::fract2
uint32_t fract2
Definition: adf4371.h:77
adf4371_init_param::mute_till_lock_enable
bool mute_till_lock_enable
Definition: adf4371.h:90
adf4371_dev::muxout_1v8_en
bool muxout_1v8_en
Definition: adf4371.h:71
adf4371_dev::differential_ref_clk
bool differential_ref_clk
Definition: adf4371.h:66
ADF4371_CP_CURRENT
#define ADF4371_CP_CURRENT(x)
Definition: adf4371.c:83
ADF4371_REFIN_MODE_MASK
#define ADF4371_REFIN_MODE_MASK
Definition: adf4371.c:96
ADF4371_MUXOUT_LVL
#define ADF4371_MUXOUT_LVL(x)
Definition: adf4371.c:91
adf4371_init_param::loop_filter_inverting
bool loop_filter_inverting
Definition: adf4371.h:88
ADF4372
@ ADF4372
Definition: adf4371.c:152
adf4371_clk_set_rate
int32_t adf4371_clk_set_rate(struct adf4371_dev *dev, uint32_t chan, uint64_t rate)
Definition: adf4371.c:725
device
Definition: ad9361_util.h:69
ADF4371_MODULUS1
#define ADF4371_MODULUS1
Definition: adf4371.c:129
adf4371_remove
int32_t adf4371_remove(struct adf4371_dev *device)
Definition: adf4371.c:819
ADF4371_MUXOUT
#define ADF4371_MUXOUT(x)
Definition: adf4371.c:89
adf4371_dev::pd_pol
uint32_t pd_pol
Definition: adf4371.h:67
no_os_find_closest
uint32_t no_os_find_closest(int32_t val, const int32_t *array, uint32_t size)
adf4371.h
Header file of ADF4371 Driver.
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
adf4371_channel_config::freq
uint64_t freq
Definition: adf4371.h:47
adf4371_dev::cp_settings
struct adf4371_cp_settings cp_settings
Definition: adf4371.h:65
ADF4371_ADDR_ASC
#define ADF4371_ADDR_ASC(x)
Definition: adf4371.c:58
ADF4371_MOD2WORD
#define ADF4371_MOD2WORD(x)
Definition: adf4371.c:79
ADF4371_REG
#define ADF4371_REG(x)
Definition: adf4371.c:54
adf4371_dev::muxout_default_mode
uint32_t muxout_default_mode
Definition: adf4371.h:69
no_os_do_div
uint64_t no_os_do_div(uint64_t *n, uint64_t base)
adf4371_dev::rf_div_sel
uint32_t rf_div_sel
Definition: adf4371.h:79
adf4371_cp_settings
Definition: adf4371.h:50
no_os_error.h
Error codes definition.
adf4371_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: adf4371.h:84
NO_OS_DIV_ROUND_UP
#define NO_OS_DIV_ROUND_UP(x, y)
Definition: no_os_util.h:52
ADF4371_CH_RF32
@ ADF4371_CH_RF32
Definition: adf4371.c:147
adf4371_pwrdown::reg
uint32_t reg
Definition: adf4371.c:169
adf4371_dev::fpfd
uint32_t fpfd
Definition: adf4371.h:74
adf4371_pwrdown::bit
uint32_t bit
Definition: adf4371.c:170
ADF4371_PD_POL_MSK
#define ADF4371_PD_POL_MSK
Definition: adf4371.c:84
adf4371_dev
Definition: adf4371.h:60
adf4371_cp_settings::regval
uint32_t regval
Definition: adf4371.h:52
reg_sequence::val
uint8_t val
Definition: adf4371.c:187
ADF4371_READ
#define ADF4371_READ
Definition: adf4371.c:50
ADF4371_PD_POL
#define ADF4371_PD_POL(x)
Definition: adf4371.c:85
ADF4371_HIGH
@ ADF4371_HIGH
Definition: adf4371.c:163
adf4371_dev::mute_till_lock_en
bool mute_till_lock_en
Definition: adf4371.h:68
adf4371_init_param::clkin_frequency
uint32_t clkin_frequency
Definition: adf4371.h:86
ADF4371
@ ADF4371
Definition: adf4371.c:151
ADF4371_MUTE_LD_MSK
#define ADF4371_MUTE_LD_MSK
Definition: adf4371.c:104
ADF4371_VCO_TEST
@ ADF4371_VCO_TEST
Definition: adf4371.c:162
adf4371_dev::mod2
uint32_t mod2
Definition: adf4371.h:78
ADF4371_VCO_ALC_TOUT
#define ADF4371_VCO_ALC_TOUT(x)
Definition: adf4371.c:113
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
adf4371_chan_spec::power_up_frequency
uint64_t power_up_frequency
Definition: adf4371.h:57
no_os_clamp
#define no_os_clamp(val, min_val, max_val)
Definition: no_os_util.h:69
ADF4371_REFIN_MODE
#define ADF4371_REFIN_MODE(x)
Definition: adf4371.c:97
adf4371_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adf4371.h:61
ADF4371_N_DIV_OUT
@ ADF4371_N_DIV_OUT
Definition: adf4371.c:161
no_os_greatest_common_divisor
uint32_t no_os_greatest_common_divisor(uint32_t a, uint32_t b)
adf4371_init_param::muxout_level_1v8_enable
bool muxout_level_1v8_enable
Definition: adf4371.h:92
ADF4371_ADDR_ASC_MSK
#define ADF4371_ADDR_ASC_MSK
Definition: adf4371.c:57
adf4371_clk_recalc_rate
int32_t adf4371_clk_recalc_rate(struct adf4371_dev *dev, uint32_t chan, uint64_t *rate)
Definition: adf4371.c:692
ADF4371_SDO_ACT_R
#define ADF4371_SDO_ACT_R(x)
Definition: adf4371.c:64
ADF4371_POWER_DOWN
@ ADF4371_POWER_DOWN
Definition: adf4371.c:138
adf4371_init_param
Definition: adf4371.h:83
adf4371_init_param::num_channels
uint32_t num_channels
Definition: adf4371.h:93
adf4371_dev::num_channels
uint32_t num_channels
Definition: adf4371.h:63
ADF4371_CH_RF8
@ ADF4371_CH_RF8
Definition: adf4371.c:144
adf4371_init
int32_t adf4371_init(struct adf4371_dev **device, const struct adf4371_init_param *init_param)
Definition: adf4371.c:741
adf4371_pwrdown
Definition: adf4371.c:168
ADF4371_SDO_ACT_MSK
#define ADF4371_SDO_ACT_MSK
Definition: adf4371.c:61
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
adf4371_channel_config::enable
bool enable
Definition: adf4371.h:46
ADF4371_FRAC2WORD_H
#define ADF4371_FRAC2WORD_H(x)
Definition: adf4371.c:75
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
ADF4371_MAX_MODULUS2
#define ADF4371_MAX_MODULUS2
Definition: adf4371.c:131
adf4371_chan_spec::num
uint32_t num
Definition: adf4371.h:56
ADF4371_SDO_ACT_R_MSK
#define ADF4371_SDO_ACT_R_MSK
Definition: adf4371.c:63
ADF4371_CH_PUMP_DOWN
@ ADF4371_CH_PUMP_DOWN
Definition: adf4371.c:159
ADF4371_WRITE
#define ADF4371_WRITE
Definition: adf4371.c:49
adf4371_init_param::channels
struct adf4371_chan_spec * channels
Definition: adf4371.h:94
adf4371_init_param::charge_pump_microamp
uint32_t charge_pump_microamp
Definition: adf4371.h:89
adf4371_init_param::spi_3wire_enable
bool spi_3wire_enable
Definition: adf4371.h:85
adf4371_clk_set_rate
int32_t adf4371_clk_set_rate(struct adf4371_dev *dev, uint32_t chan, uint64_t rate)
Definition: adf4371.c:725
adf4371_dev::channel_cfg
struct adf4371_channel_config channel_cfg[4]
Definition: adf4371.h:64
ADF4371_CHECK_RANGE
#define ADF4371_CHECK_RANGE(freq, range)
Definition: adf4371.c:133
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
adf4371_dev::buf
uint8_t buf[10]
Definition: adf4371.h:80
adf4371_dev::ref_div_factor
uint32_t ref_div_factor
Definition: adf4371.h:72
ADF4371_ADDR_ASC_R_MSK
#define ADF4371_ADDR_ASC_R_MSK
Definition: adf4371.c:59
ADF4371_RESET_CMD
#define ADF4371_RESET_CMD
Definition: adf4371.c:65
ADF4371_FRAC2WORD_L
#define ADF4371_FRAC2WORD_L(x)
Definition: adf4371.c:69
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
ADF4371_CH_PUMP_UP
@ ADF4371_CH_PUMP_UP
Definition: adf4371.c:158
adf4371_dev::muxout_en
bool muxout_en
Definition: adf4371.h:70
ADF4371_FRAC1WORD
#define ADF4371_FRAC1WORD(x)
Definition: adf4371.c:71
ADF4371_CP_CURRENT_MSK
#define ADF4371_CP_CURRENT_MSK
Definition: adf4371.c:82
adf4371_init
int32_t adf4371_init(struct adf4371_dev **device, const struct adf4371_init_param *init_param)
Definition: adf4371.c:741
ADF4371_MUXOUT_MSK
#define ADF4371_MUXOUT_MSK
Definition: adf4371.c:88
ADF4371_RF_DIV_SEL_MSK
#define ADF4371_RF_DIV_SEL_MSK
Definition: adf4371.c:100
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
adf4371_cp_settings::icp
uint32_t icp
Definition: adf4371.h:51
no_os_util.h
Header file of utility functions.
ADF4371_VCO_CALIB_R_BAND
@ ADF4371_VCO_CALIB_R_BAND
Definition: adf4371.c:164
adf4371_dev::integer
uint32_t integer
Definition: adf4371.h:75
ADF4371_MUTE_LD
#define ADF4371_MUTE_LD(x)
Definition: adf4371.c:105
adf4371_chan_spec
Definition: adf4371.h:55
ADF4371_CH_RFAUX8
@ ADF4371_CH_RFAUX8
Definition: adf4371.c:145
ADF4371_VCO_CALIB_N_BAND
@ ADF4371_VCO_CALIB_N_BAND
Definition: adf4371.c:165
ADF4371_MUXOUT_LVL_MSK
#define ADF4371_MUXOUT_LVL_MSK
Definition: adf4371.c:90
ADF4371_CH_RF16
@ ADF4371_CH_RF16
Definition: adf4371.c:146
ADF4371_FREQ
@ ADF4371_FREQ
Definition: adf4371.c:137
ADF4371_DIG_LOCK
@ ADF4371_DIG_LOCK
Definition: adf4371.c:157
ADF4371_MUXOUT_EN
#define ADF4371_MUXOUT_EN(x)
Definition: adf4371.c:93
ADF4371_RF_DIV_SEL
#define ADF4371_RF_DIV_SEL(x)
Definition: adf4371.c:101
adf4371_dev::spi_3wire_en
bool spi_3wire_en
Definition: adf4371.h:62
reg_sequence::reg
uint16_t reg
Definition: adf4371.c:186
ADF4371_SDO_ACT
#define ADF4371_SDO_ACT(x)
Definition: adf4371.c:62
adf4371_init_param::muxout_select
uint32_t muxout_select
Definition: adf4371.h:91
adf4371_init_param::differential_ref_clock
bool differential_ref_clock
Definition: adf4371.h:87
ADF4371_MUXOUT_EN_MSK
#define ADF4371_MUXOUT_EN_MSK
Definition: adf4371.c:92
NO_OS_DIV_ROUND_CLOSEST
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54
adf4371_remove
int32_t adf4371_remove(struct adf4371_dev *device)
Definition: adf4371.c:819
ADF4371_TIMEOUT
#define ADF4371_TIMEOUT(x)
Definition: adf4371.c:109
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
adf4371_clk_round_rate
int32_t adf4371_clk_round_rate(struct adf4371_dev *dev, uint64_t rate, uint64_t *rounded_rate)
Definition: adf4371.c:710
ADF4371_MAX_FREQ_PFD
#define ADF4371_MAX_FREQ_PFD
Definition: adf4371.c:125