no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad6676.h
Go to the documentation of this file.
1/***************************************************************************/
34#ifndef AD6676_H_
35#define AD6676_H_
36
37#include <stdint.h>
38#include "no_os_util.h"
39#include "no_os_delay.h"
40#include "no_os_spi.h"
41
42#define AD6676_SPI_CONFIG 0x000
43#define AD6676_DEVICE_CONFIG 0x002
44#define AD6676_CHIP_TYPE 0x003
45#define AD6676_CHIP_ID0 0x004
46#define AD6676_CHIP_ID1 0x005
47#define AD6676_GRADE_REVISION 0x006
48#define AD6676_VENDOR_ID0 0x00C
49#define AD6676_VENDOR_ID1 0x00D
50#define AD6676_PCBL_DONE 0x0FE
51
52/* CONFIGURATION SETTINGS */
53#define AD6676_FADC_0 0x100
54#define AD6676_FADC_1 0x101
55#define AD6676_FIF_0 0x102
56#define AD6676_FIF_1 0x103
57#define AD6676_BW_0 0x104
58#define AD6676_BW_1 0x105
59#define AD6676_LEXT 0x106
60#define AD6676_MRGN_L 0x107
61#define AD6676_MRGN_U 0x108
62#define AD6676_MRGN_IF 0x109
63#define AD6676_XSCALE_1 0x10A
64
65/* BP SD ADC CALIBRATION/PROFILE */
66#define AD6676_CAL_CTRL 0x115
67#define AD6676_CAL_CMD 0x116
68#define AD6676_CAL_DONE 0x117
69#define AD6676_ADC_CONFIG 0x118
70#define AD6676_FORCE_END_CAL 0x11A
71
72/* DIGITAL SIGNAL PATH */
73#define AD6676_DEC_MODE 0x140
74#define AD6676_MIX1_TUNING 0x141
75#define AD6676_MIX2_TUNING 0x142
76#define AD6676_MIX1_INIT 0x143
77#define AD6676_MIX2_INIT_LSB 0x144
78#define AD6676_MIX2_INIT_MSB 0x145
79#define AD6676_DP_CTRL 0x146
80
81/* POWER CONTROL */
82#define AD6676_STANDBY 0x150
83#define AD6676_PD_DIG 0x151
84#define AD6676_PD_PIN_CTRL 0x152
85#define AD6676_STBY_DAC 0x250
86
87/* ATTENUATOR */
88#define AD6676_ATTEN_MODE 0x180
89#define AD6676_ATTEN_VALUE_PIN0 0x181
90#define AD6676_ATTEN_VALUE_PIN1 0x182
91#define AD6676_ATTEN_INIT 0x183
92#define AD6676_ATTEN_CTL 0x184
93
94/* ADC RESET CONTROL */
95#define AD6676_ADCRE_THRH 0x188
96#define AD6676_ADCRE_PULSE_LEN 0x189
97#define AD6676_ATTEN_STEP_RE 0x18A
98#define AD6676_TIME_PER_STEP 0x18B
99
100/* PEAK DETECTOR AND AGC FLAG CONTROL */
101#define AD6676_ADC_UNSTABLE 0x18F
102#define AD6676_PKTHRH0_LSB 0x193
103#define AD6676_PKTHRH0_MSB 0x194
104#define AD6676_PKTHRH1_LSB 0x195
105#define AD6676_PKTHRH1_MSB 0x196
106#define AD6676_LOWTHRH_LSB 0x197
107#define AD6676_LOWTHRH_MSB 0x198
108#define AD6676_DWELL_TIME_MANTISSA 0x199
109#define AD6676_DWELL_TIME_EXP 0x19A
110#define AD6676_FLAG0_SEL 0x19B
111#define AD6676_FLAG1_SEL 0x19C
112#define AD6676_EN_FLAG 0x19E
113
114/* GPIO CONFIGURATION */
115#define AD6676_FORCE_GPIO 0x1B0
116#define AD6676_FORCE_GPIO_OUT 0x1B1
117#define AD6676_FORCE_GPIO_VAL 0x1B2
118#define AD6676_READ_GPO 0x1B3
119#define AD6676_READ_GPI 0x1B4
120
121/* AD6676 JESD204B INTERFACE */
122#define AD6676_DID 0x1C0
123#define AD6676_BID 0x1C1
124#define AD6676_L 0x1C3
125#define AD6676_F 0x1C4
126#define AD6676_K 0x1C5
127#define AD6676_M 0x1C6
128#define AD6676_S 0x1C9
129#define AD6676_HD 0x1CA
130#define AD6676_RES1 0x1CB
131#define AD6676_RES2 0x1CC
132#define AD6676_LID0 0x1D0
133#define AD6676_LID1 0x1D1
134#define AD6676_FCHK0 0x1D8
135#define AD6676_FCHK1 0x1D9
136#define AD6676_EN_LFIFO 0x1E0
137#define AD6676_SWAP 0x1E1
138#define AD6676_LANE_PD 0x1E2
139#define AD6676_MIS1 0x1E3
140#define AD6676_SYNC_PIN 0x1E4
141#define AD6676_TEST_GEN 0x1E5
142#define AD6676_KF_ILAS 0x1E6
143#define AD6676_SYNCB_CTRL 0x1E7
144#define AD6676_MIX_CTRL 0x1E8
145#define AD6676_K_OFFSET 0x1E9
146#define AD6676_SYSREF 0x1EA
147#define AD6676_SER1 0x1EB
148#define AD6676_SER2 0x1EC
149
150#define AD6676_CLKSYN_ENABLE 0x2A0
151#define AD6676_CLKSYN_INT_N_LSB 0x2A1
152#define AD6676_CLKSYN_INT_N_MSB 0x2A2
153#define AD6676_CLKSYN_LOGEN 0x2A5
154#define AD6676_CLKSYN_KVCO_VCO 0x2A9
155#define AD6676_CLKSYN_VCO_BIAS 0x2AA
156#define AD6676_CLKSYN_VCO_CAL 0x2AB
157#define AD6676_CLKSYN_I_CP 0x2AC
158#define AD6676_CLKSYN_CP_CAL 0x2AD
159#define AD6676_CLKSYN_VCO_VAR 0x2B7
160#define AD6676_CLKSYN_R_DIV 0x2BB
161#define AD6676_CLKSYN_STATUS 0x2BC
162#define AD6676_JESDSYN_STATUS 0x2DC
163
164#define AD6676_SHUFFLE_THREG0 0x342
165#define AD6676_SHUFFLE_THREG1 0x343
166
167/*
168 * AD6676_SPI_CONFIG
169 */
170
171#define SPI_CONF_SW_RESET (0x81)
172#define SPI_CONF_SDIO_DIR (0x18)
173
174
175/*
176 * AD6676_CLKSYN_STATUS, AD6676_JESDSYN_STATUS
177 */
178#define SYN_STAT_PLL_LCK (1 << 3)
179#define SYN_STAT_VCO_CAL_BUSY (1 << 1)
180#define SYN_STAT_CP_CAL_DONE (1 << 0)
181
182/*
183 * AD6676_DP_CTRL
184 */
185#define DP_CTRL_OFFSET_BINARY (1 << 0)
186#define DP_CTRL_TWOS_COMPLEMENT (0 << 0)
187
188/*
189 * AD6676_TEST_GEN
190 */
191#define TESTGENMODE_OFF 0x0
192#define TESTGENMODE_ALT_CHECKERBOARD 0x1
193#define TESTGENMODE_ONE_ZERO_TOGGLE 0x2
194#define TESTGENMODE_PN23_SEQ 0x3
195#define TESTGENMODE_PN9_SEQ 0x4
196#define TESTGENMODE_REP_USER_PAT 0x5
197#define TESTGENMODE_SING_USER_PAT 0x6
198#define TESTGENMODE_RAMP 0x7
199#define TESTGENMODE_MOD_RPAT 0x8
200#define TESTGENMODE_JSPAT 0x10
201#define TESTGENMODE_JTSPAT 0x11
202
203/*
204 * AD6676_CLKSYN_R_DIV
205 */
206
207#define R_DIV(x) ((x) << 6)
208#define CLKSYN_R_DIV_SYSREF_CTRL (1 << 3)
209#define CLKSYN_R_DIV_CLKIN_IMPED (1 << 2)
210#define CLKSYN_R_DIV_RESERVED 0x31
211
212/*
213 * AD6676_CLKSYN_ENABLE
214 */
215#define EN_EXT_CK (1 << 7)
216#define EN_ADC_CK (1 << 6)
217#define EN_SYNTH (1 << 5)
218#define EN_VCO_PTAT (1 << 4)
219#define EN_VCO_ALC (1 << 3)
220#define EN_VCO (1 << 2)
221#define EN_OVER_IDE_CAL (1 << 1)
222#define EN_OVER_IDE (1 << 0)
223
224/*
225 * AD6676_CLKSYN_LOGEN
226 */
227
228#define RESET_CAL (1 << 3)
229
230/*
231 * AD6676_CLKSYN_VCO_CAL
232 */
233
234#define INIT_ALC_VALUE(x) ((x) << 4)
235#define ALC_DIS (1 << 3)
236
237/*
238 * AD6676_CLKSYN_CP_CAL
239 */
240#define CP_CAL_EN (1 << 7)
241
242/*
243 * AD6676_DEC_MODE
244 */
245
246#define DEC_32 1
247#define DEC_24 2
248#define DEC_16 3
249#define DEC_12 4
250
251/*
252 * AD6676_CAL_CMD
253 */
254
255#define XCMD3 (1 << 7)
256#define XCMD2 (1 << 6)
257#define XCMD1 (1 << 5)
258#define XCMD0 (1 << 4)
259#define RESON1_CAL (1 << 3)
260#define FLASH_CAL (1 << 2)
261#define INIT_ADC (1 << 1)
262#define TUNE_ADC (1 << 0)
263
264/*
265 * AD6676_SYNCB_CTRL
266 */
267#define PD_SYSREF_RX (1 << 3)
268#define LVDS_SYNCB (1 << 2)
269
270/* AD6676_L */
271#define SCR (1 << 7)
272
273/* AD6676_FORCE_END_CAL */
274#define FORCE_END_CAL (1 << 0)
275
276/* AD6676_CAL_DONE */
277#define CAL_DONE (1 << 0)
278
279#define MHz 1000000UL
280#define MIN_FADC 2000000000ULL /* SPS */
281#define MIN_FADC_INT_SYNTH 2925000000ULL /* SPS REVISIT */
282#define MAX_FADC 3200000000ULL /* SPS */
283
284#define MIN_FIF 70000000ULL /* Hz */
285#define MAX_FIF 450000000ULL /* Hz */
286
287#define MIN_BW 20000000ULL /* Hz */
288#define MAX_BW 160000000ULL /* Hz */
289
290#define CHIP_ID1_AD6676 0x03
291#define CHIP_ID0_AD6676 0xBB
292
294 uint32_t ref_clk; // reference_clk rate Hz
295 uint32_t f_adc_hz; // adc frequency Hz
296 uint32_t f_if_hz; // intermediate frequency hz
297 uint32_t bw_hz; // bandwidth Hz;
301 uint8_t decimation; // decimation
302 uint8_t ext_l; // external inductance l_nh
303 uint8_t attenuation; //
304 uint8_t scale; // fullscale adjust
305 uint8_t use_extclk; // use external clk enable
306 uint8_t spi3wire; // set device spi intereface 3/4 wires
307 // shuffle
308 uint8_t shuffle_ctrl; // shuffler control
309 uint8_t shuffle_thresh; // shuffler threshold
310 // jesd
311 uint8_t scrambling_en; // jesd_scrambling_enable
312 uint8_t lvds_syncb; // jesd_use_lvds_syncb_enable
313 uint8_t sysref_pd; // jesd_powerdown_sysref_enable
314 uint8_t n_lanes; // lanes
316 uint64_t m;
317 /* SPI */
319};
320
322 /* SPI */
324};
325
326/* SPI read from device. */
327int32_t ad6676_spi_read(struct ad6676_dev *dev,
328 uint16_t reg_addr,
329 uint8_t *reg_data);
330
331/* SPI write to device. */
332int32_t ad6676_spi_write(struct ad6676_dev *dev,
333 uint16_t reg_addr,
334 uint8_t reg_data);
335
336/* Initialize the device. */
337int32_t ad6676_setup(struct ad6676_dev **device,
339
340/* Reconfigure device for other target frequency and bandwidth and
341 * recalibrate. */
342int32_t ad6676_update(struct ad6676_dev *dev,
344
345/* Set attenuation in decibels or disable attenuator. */
346int32_t ad6676_set_attenuation(struct ad6676_dev *dev,
348
349/* Set the target IF frequency. */
350int32_t ad6676_set_fif(struct ad6676_dev *dev,
352
353/* Get the target IF frequency. */
354uint64_t ad6676_get_fif(struct ad6676_dev *dev,
356
357/* Perform an interface test. */
358int32_t ad6676_test(struct ad6676_dev *dev,
359 uint32_t test_mode);
360#endif
int32_t ad6676_set_attenuation(struct ad6676_dev *dev, struct ad6676_init_param *init_param)
Set attenuation in decibels or disable attenuator.
Definition ad6676.c:608
int32_t ad6676_spi_write(struct ad6676_dev *dev, uint16_t reg_addr, uint8_t reg_data)
SPI write to device.
Definition ad6676.c:75
uint64_t ad6676_get_fif(struct ad6676_dev *dev, struct ad6676_init_param *init_param)
Get the target IF frequency.
Definition ad6676.c:201
int32_t ad6676_spi_read(struct ad6676_dev *dev, uint16_t reg_addr, uint8_t *reg_data)
SPI read from device.
Definition ad6676.c:49
int32_t ad6676_test(struct ad6676_dev *dev, uint32_t test_mode)
Perform an interface test.
Definition ad6676.c:779
int32_t ad6676_update(struct ad6676_dev *dev, struct ad6676_init_param *init_param)
Reconfigure device for other target frequency and bandwidth and recalibrate.
Definition ad6676.c:731
int32_t ad6676_set_fif(struct ad6676_dev *dev, struct ad6676_init_param *init_param)
Set the target IF frequency.
Definition ad6676.c:185
int32_t ad6676_setup(struct ad6676_dev **device, struct ad6676_init_param init_param)
Initialize the device.
Definition ad6676.c:629
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of Delay functions.
Header file of SPI Interface.
Header file of utility functions.
Definition ad6676.h:321
struct no_os_spi_desc * spi_desc
Definition ad6676.h:323
Definition ad6676.h:293
uint8_t bw_margin_low_mhz
Definition ad6676.h:298
uint8_t scrambling_en
Definition ad6676.h:311
uint8_t n_lanes
Definition ad6676.h:314
uint64_t m
Definition ad6676.h:316
uint32_t ref_clk
Definition ad6676.h:294
struct no_os_spi_init_param spi_init
Definition ad6676.h:318
uint8_t scale
Definition ad6676.h:304
uint8_t shuffle_ctrl
Definition ad6676.h:308
int8_t bw_margin_if_mhz
Definition ad6676.h:300
uint8_t sysref_pd
Definition ad6676.h:313
uint32_t f_if_hz
Definition ad6676.h:296
uint8_t ext_l
Definition ad6676.h:302
uint8_t frames_per_multiframe
Definition ad6676.h:315
uint8_t attenuation
Definition ad6676.h:303
uint8_t use_extclk
Definition ad6676.h:305
uint8_t spi3wire
Definition ad6676.h:306
uint8_t shuffle_thresh
Definition ad6676.h:309
uint8_t bw_margin_high_mhz
Definition ad6676.h:299
uint8_t lvds_syncb
Definition ad6676.h:312
uint8_t decimation
Definition ad6676.h:301
uint32_t bw_hz
Definition ad6676.h:297
uint32_t f_adc_hz
Definition ad6676.h:295
Definition ad9361_util.h:63
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128