no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
adf4153.h
Go to the documentation of this file.
1/**************************************************************************/
34#ifndef __ADF4153_H__
35#define __ADF4153_H__
36
37#include <stdint.h>
38#include "no_os_gpio.h"
39#include "no_os_spi.h"
40
41/* GPIOs */
42#define ADF4153_LE_OUT no_os_gpio_direction_output(dev->gpio_le, \
43 NO_OS_GPIO_HIGH)
44#define ADF4153_LE_LOW no_os_gpio_set_value(dev->gpio_le, \
45 NO_OS_GPIO_LOW)
46#define ADF4153_LE_HIGH no_os_gpio_set_value(dev->gpio_le, \
47 NO_OS_GPIO_HIGH)
48
49#define ADF4153_CE_OUT no_os_gpio_direction_output(dev->gpio_ce, \
50 NO_OS_GPIO_HIGH)
51#define ADF4153_CE_LOW no_os_gpio_set_value(dev->gpio_ce, \
52 NO_OS_GPIO_LOW)
53#define ADF4153_CE_HIGH no_os_gpio_set_value(dev->gpio_ce, \
54 NO_OS_GPIO_HIGH)
55
56#define ADF4153_LE2_OUT no_os_gpio_direction_output(dev->gpio_le2, \
57 NO_OS_GPIO_HIGH)
58#define ADF4153_LE2_LOW no_os_gpio_set_value(dev->gpio_le2, \
59 NO_OS_GPIO_LOW)
60#define ADF4153_LE2_HIGH no_os_gpio_set_value(dev->gpio_le2, \
61 NO_OS_GPIO_HIGH)
62
63#define ADF4153_CE2_OUT no_os_gpio_direction_output(dev->gpio_ce2, \
64 NO_OS_GPIO_HIGH)
65#define ADF4153_CE2_LOW no_os_gpio_set_value(dev->gpio_ce2, \
66 NO_OS_GPIO_LOW)
67#define ADF4153_CE2_HIGH no_os_gpio_set_value(dev->gpio_ce2, \
68 NO_OS_GPIO_HIGH)
69
70/* Control Bits */
71#define ADF4153_CTRL_MASK 0x3
72
73#define ADF4153_CTRL_N_DIVIDER 0 /* N Divider Register */
74#define ADF4153_CTRL_R_DIVIDER 1 /* R Divider Register */
75#define ADF4153_CTRL_CONTROL 2 /* Control Register */
76#define ADF4153_CTRL_NOISE_SPUR 3 /* Noise and Spur Reg*/
77
78/* N Divider Register */
79
80/* 12-bit fractional value */
81#define ADF4153_R0_FRAC_OFFSET 2
82#define ADF4153_R0_FRAC_MASK 0xFFFul
83#define ADF4153_R0_FRAC(x) ((x) & ADF4153_R0_FRAC_MASK) \
84 << ADF4153_R0_FRAC_OFFSET
85/* 9-bit integer value */
86#define ADF4153_R0_INT_OFFSET 14
87#define ADF4153_R0_INT_MASK 0x1FFul
88#define ADF4153_R0_INT(x) ((x) & ADF4153_R0_INT_MASK) \
89 << ADF4153_R0_INT_OFFSET
90
91/* Fast-Lock */
92#define ADF4153_R0_FASTLOCK_OFFSET 23
93#define ADF4153_R0_FASTLOCK_MASK 0x1
94#define ADF4153_R0_FASTLOCK(x) ((x) & ADF4153_R0_FASTLOCK_MASK) \
95 << ADF4153_R0_FASTLOCK_OFFSET
96
97/* R Divider Register */
98
99/* 12-bit interpolator modulus value */
100#define ADF4153_R1_MOD_OFFSET 2
101#define ADF4153_R1_MOD_MASK 0xFFFul
102#define ADF4153_R1_MOD(x) ((x) & ADF4153_R1_MOD_MASK) \
103 << ADF4153_R1_MOD_OFFSET
104/* 4-bit R Counter */
105#define ADF4153_R1_RCOUNTER_OFFSET 14
106#define ADF4153_R1_RCOUNTER_MASK 0xFul
107#define ADF4153_R1_RCOUNTER(x) ((x) & ADF4153_R1_RCOUNTER_MASK) \
108 << ADF4153_R1_RCOUNTER_OFFSET
109/* Prescale */
110#define ADF4153_R1_PRESCALE_OFFSET 18
111#define ADF4153_R1_PRESCALE_MASK 0x1ul
112#define ADF4153_R1_PRESCALE(x) ((x) & ADF4153_R1_PRESCALE_MASK) \
113 << ADF4153_R1_PRESCALE_OFFSET
114/* MUXOUT */
115#define ADF4153_R1_MUXOUT_OFFSET 20
116#define ADF4153_R1_MUXOUT_MASK 0x7
117#define ADF4153_R1_MUXOUT(x) ((x) & ADF4153_R1_MUXOUT_MASK) \
118 << ADF4153_R1_MUXOUT_OFFSET
119/* Load Control */
120#define ADF4153_R1_LOAD_OFFSET 23
121#define ADF4153_R1_LOAD_MASK 0x1
122#define ADF4153_R1_LOAD(x) ((x) & ADF4153_R1_LOAD_MASK) \
123 << ADF4153_R1_LOAD_OFFSET
124
125/* Control Register */
126
127/* Counter Reset */
128#define ADF4153_R2_COUNTER_RST_OFFSET 2
129#define ADF4153_R2_COUNTER_RST_MASK 0x1ul
130#define ADF4153_R2_COUNTER_RST(x) ((x) & ADF4153_R2_COUNTER_RST_MASK)\
131 << ADF4153_R2_COUNTER_RST_OFFSET
132/* CP Three-State */
133#define ADF4153_R2_CP_3STATE_OFFSET 3
134#define ADF4153_R2_CP_3STATE_MASK 0x1
135#define ADF4153_R2_CP_3STATE(x) ((x) & ADF4153_R2_CP_3STATE_MASK) \
136 << ADF4153_R2_CP_3STATE_OFFSET
137/* Power-down */
138#define ADF4153_R2_POWER_DOWN_OFFSET 4
139#define ADF4153_R2_POWER_DOWN_MASK 0x1
140#define ADF4153_R2_POWER_DOWN(x) ((x) & ADF4153_R2_POWER_DOWN_MASK) \
141 << ADF4153_R2_POWER_DOWN_OFFSET
142/* LDP */
143#define ADF4153_R2_LDP_OFFSET 5
144#define ADF4153_R2_LDP_MASK 0x1
145#define ADF4153_R2_LDP(x) ((x) & ADF4153_R2_LDP_MASK) \
146 << ADF4153_R2_LDP_OFFSET
147/* PD Polarity */
148#define ADF4153_R2_PD_POL_OFFSET 6
149#define ADF4153_R2_PD_POL_MASK 0x1
150#define ADF4153_R2_PD_POL(x) ((x) & ADF4153_R2_PD_POL_MASK) \
151 << ADF4153_R2_PD_POL_OFFSET
152/* CP Current Settings and CP/2 */
153#define ADF4153_R2_CP_CURRENT_OFFSET 7
154#define ADF4153_R2_CP_CURRENT_MASK 0xF
155#define ADF4153_R2_CP_CURRENT(x) ((x) & ADF4153_R2_CP_CURRENT_MASK) \
156 << ADF4153_R2_CP_CURRENT_OFFSET
157/* Reference doubler */
158#define ADF4153_R2_REF_DOUBLER_OFFSET 11
159#define ADF4153_R2_REF_DOUBLER_MASK 0x1
160#define ADF4153_R2_REF_DOUBLER(x) ((x) & ADF4153_R2_REF_DOUBLER_MASK)\
161 << ADF4153_R2_REF_DOUBLER_OFFSET
162/* Resync */
163#define ADF4153_R2_RESYNC_OFFSET 12
164#define ADF4153_R2_RESYNC_MASK 0x7
165#define ADF4153_R2_RESYNC(x) ((x) & ADF4153_R2_RESYNC_MASK) \
166 << ADF4153_R2_RESYNC_OFFSET
167
168/* Noise and spur register */
169
170/* Noise and spur mode */
171#define ADF4153_R3_NOISE_SPURG_MASK 0x3C4
172#define ADF4153_R3_NOISE_SPURG(x) ( (((x) << 0x2) & 0x7) | \
173 (((x) >> 0x1) << 0x6) ) &\
174 ADF4153_R3_NOISE_SPURG_MASK
175
176/* Fast-Lock definitions */
177#define ADF4153_FASTLOCK_DISABLED 0
178#define ADF4153_FASTLOCK_ENABLED 1
179/* Prescale definitions */
180#define ADF4153_PRESCALER_4_5 0
181#define ADF4153_PRESCALER_8_9 1
182/* Muxout definitions */
183#define ADF4153_MUXOUT_THREESTATE 0
184#define ADF4153_MUXOUT_DIGITAL_LOCK 1
185#define ADF4153_MUXOUT_NDIV_OUTPUT 2
186#define ADF4153_MUXOUT_LOGICHIGH 3
187#define ADF4153_MUXOUT_RDIV_OUTPUT 4
188#define ADF4153_MUXOUT_ANALOG_LOCK 5
189#define ADF4153_MUXOUT_FASTLOCK 6
190#define ADF4153_MUXOUT_LOGICLOW 7
191/* Load Control definitions */
192#define ADF4153_LOAD_NORMAL 0
193#define ADF4153_LOAD_RESYNC 1
194/* Counter Reset Definitions */
195#define ADF4153_CR_DISABLED 0
196#define ADF4153_CR_ENABLED 1
197/* CP Three-state definitions */
198#define ADF4153_CP_DISABLED 0
199#define ADF4153_CP_THREE_STATE 1
200/* Power-down definitions */
201#define ADF4153_PD_DISABLED 0
202#define ADF4153_PD_ENABLED 1
203/* LDP definitions */
204#define ADF4153_LDP_24 0
205#define ADF4153_LDP_40 1
206/* PD Polarity definitions */
207#define ADF4153_PD_POL_NEGATIV 0
208#define ADF4153_PD_POL_POSITIVE 1
209/* CR Current Settings definitions */
210#define ADF4153_CP_CURRENT_0_63 0
211#define ADF4153_CP_CURRENT_1_25 1
212#define ADF4153_CP_CURRENT_1_88 2
213#define ADF4153_CP_CURRENT_2_50 3
214#define ADF4153_CP_CURRENT_3_13 4
215#define ADF4153_CP_CURRENT_3_75 5
216#define ADF4153_CP_CURRENT_4_38 6
217#define ADF4153_CP_CURRENT_5_00 7
218#define ADF4153_CP2_CURRENT_0_31 8
219#define ADF4153_CP2_CURRENT_0_63 9
220#define ADF4153_CP2_CURRENT_0_94 10
221#define ADF4153_CP2_CURRENT_1_25 11
222#define ADF4153_CP2_CURRENT_1_57 12
223#define ADF4153_CP2_CURRENT_1_88 13
224#define ADF4153_CP2_CURRENT_2_19 14
225#define ADF4153_CP2_CURRENT_2_50 15
226
227/* Reference doubler definition */
228#define ADF4153_REF_DOUBLER_DIS 0
229#define ADF4153_REF_DOUBLER_EN 1
230/* Noise and Spur mode definitions */
231#define ADF4153_LOW_SPUR_MODE 0b00000
232#define ADF4153_LOW_NOISE_SPUR 0b11100
233#define ADF4153_LOWEST_NOISE 0b11111
234
240
242
243 /* Reference Input Frequency*/
244 uint32_t ref_in;
245 /* Channel resolution or Channel spacing */
247
248 /* N Divider */
252 uint16_t frac_value : 12;
256 uint16_t int_value : 9;
258 uint8_t fastlock : 1;
259
260 /* R Divider */
264 uint16_t mod_value : 12;
269 uint8_t r_counter : 4;
274 uint8_t prescaler : 1;
276 uint8_t muxout : 3;
281 uint8_t load_control : 1;
282
283 /* Control Register */
285 uint8_t counter_reset : 1;
289 uint8_t cp_three_state : 1;
291 uint8_t power_down : 1;
293 uint8_t ldp : 1;
295 uint8_t pd_polarity : 1;
299 uint8_t cp_current : 4;
303 uint8_t ref_doubler : 1;
307 uint8_t resync : 4;
308
309 /* Noise and Spur register */
313 uint8_t noise_spur : 5;
314
315};
316
318 /* SPI */
320 /* GPIO */
325 /* Device Settings */
327 /* RF input frequency limits */
330 /* Maximum PFD frequency */
332 /* VCO out frequency limits */
335 /* maximum interpolator modulus value */
337
338 /* Internal buffers for each latch */
339 uint32_t r0; /* the actual value of N Divider Register */
340 uint32_t r1; /* the actual value of R Divider Register */
341 uint32_t r2; /* the actual value of Control Register */
342 uint32_t r3; /* the actual value of Noise and Spur Reg*/
343};
344
356
357/* Initialize the communication with the device */
358int8_t adf4153_init(struct adf4153_dev **device,
360
361/* Free the resources allocated by adf4153_init(). */
362int32_t adf4153_remove(struct adf4153_dev *dev);
363
364/* Update register function */
365void adf4153_update_latch(struct adf4153_dev *dev,
366 uint32_t latch_data);
367
368/* Return the value of a desired latch */
369uint32_t adf4153_read_latch(struct adf4153_dev *dev,
370 uint8_t latch_type);
371
372/* Set the frequency to a desired value */
373uint64_t adf4153_set_frequency(struct adf4153_dev *dev,
374 uint64_t frequency);
375
376/* Return the value of the channel spacing */
377uint32_t adf4153_get_channel_spacing(struct adf4153_dev *dev);
378
379#endif // __ADF4153_H__
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int8_t adf4153_init(struct adf4153_dev **device, struct adf4153_init_param init_param)
Initialize SPI and Initial Values for ADF4106 Board.
Definition adf4153.c:60
uint32_t adf4153_read_latch(struct adf4153_dev *dev, uint8_t latch_type)
Return the value of a desired latch.
Definition adf4153.c:237
uint32_t adf4153_get_channel_spacing(struct adf4153_dev *dev)
Return the value of the channel spacing.
Definition adf4153.c:392
int32_t adf4153_remove(struct adf4153_dev *dev)
Free the resources allocated by adf4153_init().
Definition adf4153.c:168
void adf4153_update_latch(struct adf4153_dev *dev, uint32_t latch_data)
Update one of the latch via the SPI interface.
Definition adf4153.c:190
uint64_t adf4153_set_frequency(struct adf4153_dev *dev, uint64_t frequency)
Sets the output frequency.
Definition adf4153.c:292
Header file of GPIO Interface.
Header file of SPI Interface.
Definition adf4153.h:317
struct no_os_gpio_desc * gpio_le
Definition adf4153.h:321
struct no_os_gpio_desc * gpio_ce
Definition adf4153.h:322
uint32_t adf4153_vco_min_frq
Definition adf4153.h:333
struct no_os_gpio_desc * gpio_le2
Definition adf4153.h:323
struct adf4153_settings_t adf4153_st
Definition adf4153.h:326
uint32_t adf4153_rfin_max_frq
Definition adf4153.h:329
uint32_t r1
Definition adf4153.h:340
uint32_t adf4153_pfd_max_frq
Definition adf4153.h:331
uint32_t adf4153_rfin_min_frq
Definition adf4153.h:328
uint16_t adf4153_mod_max
Definition adf4153.h:336
uint64_t adf4153_vco_max_frq
Definition adf4153.h:334
uint32_t r3
Definition adf4153.h:342
struct no_os_gpio_desc * gpio_ce2
Definition adf4153.h:324
uint32_t r0
Definition adf4153.h:339
uint32_t r2
Definition adf4153.h:341
struct no_os_spi_desc * spi_desc
Definition adf4153.h:319
Definition adf4153.h:345
struct no_os_gpio_init_param gpio_le2
Definition adf4153.h:351
struct no_os_gpio_init_param gpio_ce
Definition adf4153.h:350
struct no_os_gpio_init_param gpio_le
Definition adf4153.h:349
struct no_os_gpio_init_param gpio_ce2
Definition adf4153.h:352
struct adf4153_settings_t adf4153_st
Definition adf4153.h:354
struct no_os_spi_init_param spi_init
Definition adf4153.h:347
Definition adf4153.h:241
uint8_t cp_current
Definition adf4153.h:299
uint8_t counter_reset
Definition adf4153.h:285
uint8_t noise_spur
Definition adf4153.h:313
uint32_t ref_in
Definition adf4153.h:244
uint8_t power_down
Definition adf4153.h:291
uint8_t ref_doubler
Definition adf4153.h:303
uint8_t resync
Definition adf4153.h:307
uint16_t int_value
Definition adf4153.h:256
uint8_t ldp
Definition adf4153.h:293
uint8_t fastlock
Definition adf4153.h:258
uint32_t channel_spacing
Definition adf4153.h:246
uint8_t muxout
Definition adf4153.h:276
uint16_t frac_value
Definition adf4153.h:252
uint16_t mod_value
Definition adf4153.h:264
uint8_t cp_three_state
Definition adf4153.h:289
uint8_t pd_polarity
Definition adf4153.h:295
uint8_t load_control
Definition adf4153.h:281
uint8_t prescaler
Definition adf4153.h:274
uint8_t r_counter
Definition adf4153.h:269
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128