Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/device_drivers/ADF4153/adf4153.h

raw symbols SCIP
1 /**************************************************************************//**
2 * @file adf4153.h
3 * @brief Header file of adf4153 driver.
4 *
5 * @author Istvan Csomortani ([email protected])
6 *
7 *******************************************************************************
8 * Copyright 2013(c) Analog Devices, Inc.
9 *
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without modification,
13 * are permitted provided that the following conditions are met:
14 * - Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 * - Neither the name of Analog Devices, Inc. nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 * - The use of this software may or may not infringe the patent rights
24 * of one or more patent holders. This license does not release you
25 * from the requirement that you obtain separate licenses from these
26 * patent holders to use this software.
27 * - Use of the software either in source or binary form, must be run
28 * on or directly connected to an Analog Devices Inc. component.
29 *
30 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
32 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
33 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 ******************************************************************************/
42 #ifndef __ADF4153_H__
43 #define __ADF4153_H__
44
45 #include "Communication.h"
46
47 /*****************************************************************************/
48 /* Device specific MACROs */
49 /*****************************************************************************/
50 /* GPIOs */
51 #define ADF4153_LE_OUT GPIO0_PIN_OUT
52 #define ADF4153_LE_LOW GPIO0_LOW
53 #define ADF4153_LE_HIGH GPIO0_HIGH
54
55 #define ADF4153_CE_OUT GPIO2_PIN_OUT
56 #define ADF4153_CE_LOW GPIO2_LOW
57 #define ADF4153_CE_HIGH GPIO2_HIGH
58
59 #define ADF4153_LE2_OUT GPIO6_PIN_OUT
60 #define ADF4153_LE2_LOW GPIO6_LOW
61 #define ADF4153_LE2_HIGH GPIO6_HIGH
62
63 #define ADF4153_CE2_OUT GPIO7_PIN_OUT
64 #define ADF4153_CE2_LOW GPIO7_LOW
65 #define ADF4153_CE2_HIGH GPIO7_HIGH
66
67 /* Control Bits */
68 #define ADF4153_CTRL_MASK 0x3
69
70 #define ADF4153_CTRL_N_DIVIDER 0 /* N Divider Register */
71 #define ADF4153_CTRL_R_DIVIDER 1 /* R Divider Register */
72 #define ADF4153_CTRL_CONTROL 2 /* Control Register */
73 #define ADF4153_CTRL_NOISE_SPUR 3 /* Noise and Spur Reg*/
74
75 /* N Divider Register */
76
77 /* 12-bit fractional value */
78 #define ADF4153_R0_FRAC_OFFSET 2
79 #define ADF4153_R0_FRAC_MASK 0xFFF
80 #define ADF4153_R0_FRAC(x) ((x) & ADF4153_R0_FRAC_MASK) \
81 << ADF4153_R0_FRAC_OFFSET
82 /* 9-bit integer value */
83 #define ADF4153_R0_INT_OFFSET 14
84 #define ADF4153_R0_INT_MASK 0x1FF
85 #define ADF4153_R0_INT(x) ((x) & ADF4153_R0_INT_MASK) \
86 << ADF4153_R0_INT_OFFSET
87
88 /* Fast-Lock */
89 #define ADF4153_R0_FASTLOCK_OFFSET 23
90 #define ADF4153_R0_FASTLOCK_MASK 0x1
91 #define ADF4153_R0_FASTLOCK(x) ((x) & ADF4153_R0_FASTLOCK_MASK) \
92 << ADF4153_R0_FASTLOCK_OFFSET
93
94 /* R Divider Register */
95
96 /* 12-bit interpolator modulus value */
97 #define ADF4153_R1_MOD_OFFSET 2
98 #define ADF4153_R1_MOD_MASK 0xFFF
99 #define ADF4153_R1_MOD(x) ((x) & ADF4153_R1_MOD_MASK) \
100 << ADF4153_R1_MOD_OFFSET
101 /* 4-bit R Counter */
102 #define ADF4153_R1_RCOUNTER_OFFSET 14
103 #define ADF4153_R1_RCOUNTER_MASK 0xF
104 #define ADF4153_R1_RCOUNTER(x) ((x) & ADF4153_R1_RCOUNTER_MASK) \
105 << ADF4153_R1_RCOUNTER_OFFSET
106 /* Prescale */
107 #define ADF4153_R1_PRESCALE_OFFSET 18
108 #define ADF4153_R1_PRESCALE_MASK 0x1
109 #define ADF4153_R1_PRESCALE(x) ((x) & ADF4153_R1_PRESCALE_MASK) \
110 << ADF4153_R1_PRESCALE_OFFSET
111 /* MUXOUT */
112 #define ADF4153_R1_MUXOUT_OFFSET 20
113 #define ADF4153_R1_MUXOUT_MASK 0x7
114 #define ADF4153_R1_MUXOUT(x) ((x) & ADF4153_R1_MUXOUT_MASK) \
115 << ADF4153_R1_MUXOUT_OFFSET
116 /* Load Control */
117 #define ADF4153_R1_LOAD_OFFSET 23
118 #define ADF4153_R1_LOAD_MASK 0x1
119 #define ADF4153_R1_LOAD(x) ((x) & ADF4153_R1_LOAD_MASK) \
120 << ADF4153_R1_LOAD_OFFSET
121
122 /* Control Register */
123
124 /* Counter Reset */
125 #define ADF4153_R2_COUNTER_RST_OFFSET 2
126 #define ADF4153_R2_COUNTER_RST_MASK 0x1
127 #define ADF4153_R2_COUNTER_RST(x) ((x) & ADF4153_R2_COUNTER_RST_MASK)\
128 << ADF4153_R2_COUNTER_RST_OFFSET
129 /* CP Three-State */
130 #define ADF4153_R2_CP_3STATE_OFFSET 3
131 #define ADF4153_R2_CP_3STATE_MASK 0x1
132 #define ADF4153_R2_CP_3STATE(x) ((x) & ADF4153_R2_CP_3STATE_MASK) \
133 << ADF4153_R2_CP_3STATE_OFFSET
134 /* Power-down */
135 #define ADF4153_R2_POWER_DOWN_OFFSET 4
136 #define ADF4153_R2_POWER_DOWN_MASK 0x1
137 #define ADF4153_R2_POWER_DOWN(x) ((x) & ADF4153_R2_POWER_DOWN_MASK) \
138 << ADF4153_R2_POWER_DOWN_OFFSET
139 /* LDP */
140 #define ADF4153_R2_LDP_OFFSET 5
141 #define ADF4153_R2_LDP_MASK 0x1
142 #define ADF4153_R2_LDP(x) ((x) & ADF4153_R2_LDP_MASK) \
143 << ADF4153_R2_LDP_OFFSET
144 /* PD Polarity */
145 #define ADF4153_R2_PD_POL_OFFSET 6
146 #define ADF4153_R2_PD_POL_MASK 0x1
147 #define ADF4153_R2_PD_POL(x) ((x) & ADF4153_R2_PD_POL_MASK) \
148 << ADF4153_R2_PD_POL_OFFSET
149 /* CP Current Settings and CP/2 */
150 #define ADF4153_R2_CP_CURRENT_OFFSET 7
151 #define ADF4153_R2_CP_CURRENT_MASK 0xF
152 #define ADF4153_R2_CP_CURRENT(x) ((x) & ADF4153_R2_CP_CURRENT_MASK) \
153 << ADF4153_R2_CP_CURRENT_OFFSET
154 /* Reference doubler */
155 #define ADF4153_R2_REF_DOUBLER_OFFSET 11
156 #define ADF4153_R2_REF_DOUBLER_MASK 0x1
157 #define ADF4153_R2_REF_DOUBLER(x) ((x) & ADF4153_R2_REF_DOUBLER_MASK)\
158 << ADF4153_R2_REF_DOUBLER_OFFSET
159 /* Resync */
160 #define ADF4153_R2_RESYNC_OFFSET 12
161 #define ADF4153_R2_RESYNC_MASK 0x7
162 #define ADF4153_R2_RESYNC(x) ((x) & ADF4153_R2_RESYNC_MASK) \
163 << ADF4153_R2_RESYNC_OFFSET
164
165 /* Noise and spur register */
166
167 /* Noise and spur mode */
168 #define ADF4153_R3_NOISE_SPURG_MASK 0x3C4
169 #define ADF4153_R3_NOISE_SPURG(x) ( (((x) << 0x2) & 0x7) | \
170 (((x) >> 0x1) << 0x6) ) &\
171 ADF4153_R3_NOISE_SPURG_MASK
172
173 /* Fast-Lock definitions */
174 #define ADF4153_FASTLOCK_DISABLED 0
175 #define ADF4153_FASTLOCK_ENABLED 1
176 /* Prescale definitions */
177 #define ADF4153_PRESCALER_4_5 0
178 #define ADF4153_PRESCALER_8_9 1
179 /* Muxout definitions */
180 #define ADF4153_MUXOUT_THREESTATE 0
181 #define ADF4153_MUXOUT_DIGITAL_LOCK 1
182 #define ADF4153_MUXOUT_NDIV_OUTPUT 2
183 #define ADF4153_MUXOUT_LOGICHIGH 3
184 #define ADF4153_MUXOUT_RDIV_OUTPUT 4
185 #define ADF4153_MUXOUT_ANALOG_LOCK 5
186 #define ADF4153_MUXOUT_FASTLOCK 6
187 #define ADF4153_MUXOUT_LOGICLOW 7
188 /* Load Control definitions */
189 #define ADF4153_LOAD_NORMAL 0
190 #define ADF4153_LOAD_RESYNC 1
191 /* Counter Reset Definitions */
192 #define ADF4153_CR_DISABLED 0
193 #define ADF4153_CR_ENABLED 1
194 /* CP Three-state definitions */
195 #define ADF4153_CP_DISABLED 0
196 #define ADF4153_CP_THREE_STATE 1
197 /* Power-down definitions */
198 #define ADF4153_PD_DISABLED 0
199 #define ADF4153_PD_ENABLED 1
200 /* LDP definitions */
201 #define ADF4153_LDP_24 0
202 #define ADF4153_LDP_40 1
203 /* PD Polarity definitions */
204 #define ADF4153_PD_POL_NEGATIV 0
205 #define ADF4153_PD_POL_POSITIVE 1
206 /* CR Current Settings definitions */
207 #define ADF4153_CP_CURRENT_0_63 0
208 #define ADF4153_CP_CURRENT_1_25 1
209 #define ADF4153_CP_CURRENT_1_88 2
210 #define ADF4153_CP_CURRENT_2_50 3
211 #define ADF4153_CP_CURRENT_3_13 4
212 #define ADF4153_CP_CURRENT_3_75 5
213 #define ADF4153_CP_CURRENT_4_38 6
214 #define ADF4153_CP_CURRENT_5_00 7
215 #define ADF4153_CP2_CURRENT_0_31 8
216 #define ADF4153_CP2_CURRENT_0_63 9
217 #define ADF4153_CP2_CURRENT_0_94 10
218 #define ADF4153_CP2_CURRENT_1_25 11
219 #define ADF4153_CP2_CURRENT_1_57 12
220 #define ADF4153_CP2_CURRENT_1_88 13
221 #define ADF4153_CP2_CURRENT_2_19 14
222 #define ADF4153_CP2_CURRENT_2_50 15
223
224 /* Reference doubler definition */
225 #define ADF4153_REF_DOUBLER_DIS 0
226 #define ADF4153_REF_DOUBLER_EN 1
227 /* Noise and Spur mode definitions */
228 #define ADF4153_LOW_SPUR_MODE 0b00000
229 #define ADF4153_LOW_NOISE_SPUR 0b11100
230 #define ADF4153_LOWEST_NOISE 0b11111
231
232 /* The default slave ID for SPI interface */
233 #define ADF4153_SLAVE_ID 1
234
235 /*****************************************************************************/
236 /************************** Types Declarations *******************************/
237 /*****************************************************************************/
238
239 /**
240 * struct ADF4106_settings_t - store the value of all the latch and the input
241 * reference frequency
242 *
243 * N Divider Register
244 * @fracValue - these 12 bits control what is loaded as the FRAC value into
245 * the fractional interpolator.
246 * @intValue - these nine bits control what is loaded as the INT value, this
247 * is used to determine the overall division factor
248 * @fastlock - when set to logic high fast-lock is enabled
249 *
250 * R Divider Register
251 * @modValue - set the fractional modulus, this is the ratio of the PFD
252 * frequency to the channel step resolution on the RF output
253 * @rCounter - the r counter allows the input reference frequency to
254 * be divided down to produce the reference clock to phase
255 * frequency detector
256 * @prescaler - the dual-modulus prescaler, along with the INT, FRAC and MOD
257 * counters, determines the overall division ratio from the RFin
258 * to PFD input
259 * @muxout - the on chip multiplexer selection bits
260 * @loadControl - when set to logic high the value being programmed in the
261 * modulus is not loaded into the modulus. Instead, it sets the
262 * resync delay of the Sigma-Delta.
263 *
264 * Control Register
265 * @counterReset - resets the R and N counters
266 * @cpThreeState - puts the charge pump into three-state mode when programmed
267 * to 1
268 * @powerDown - activate power down mode
269 * @ldp - lock detect precision
270 * @pdPolarity - phase detector polarity
271 * @cpCurrent - Charge Pump Current settings, this should be set to the charge
272 * pump current that the loop filter is designed with
273 * @refDoubler - REFin Doubler, when the doubler is enabled, both the rising
274 * and falling edges of REFin become active edges at the PFD input
275 * @resync - define the time between two resync, if it is zero, than
276 * the phase resync feature is disabled
277 *
278 * Noise and Spur register
279 * @noiseSpur - allows the user to optimize a design either for improved
280 * spurious performance or for improved phase noise performance
281 */
282
283 typedef struct _ADF4153_settings_t {
284
285 /* Reference Input Frequency*/
286 unsigned long refIn;
287 /* Channel resolution or Channel spacing */
288 unsigned long channelSpacing;
289
290 /* N Divider */
291 unsigned short fracValue : 12;
292 unsigned short intValue : 9;
293 unsigned char fastlock : 1;
294
295 /* R Divider */
296 unsigned short modValue : 12;
297 unsigned char rCounter : 4;
298 unsigned char prescaler : 1;
299 unsigned char muxout : 3;
300 unsigned char loadControl : 1;
301
302 /* Control Register */
303 unsigned char counterReset : 1;
304 unsigned char cpThreeState : 1;
305 unsigned char powerDown : 1;
306 unsigned char ldp : 1;
307 unsigned char pdPolarity : 1;
308 unsigned char cpCurrent : 4;
309 unsigned char refDoubler : 1;
310 unsigned char resync : 4;
311
312 /* Noise and Spur register */
313 unsigned char noiseSpur : 5;
314
315 } ADF4153_settings_t;
316
317 /*****************************************************************************/
318 /* Functions Prototypes */
319 /*****************************************************************************/
320 /* Initialize the communication with the device */
321 char ADF4153_Init(ADF4153_settings_t ADF4153_st);
322
323 /* Update register function */
324 void ADF4153_UpdateLatch(unsigned long latchData);
325
326 /* Return the value of a desired latch */
327 unsigned long ADF4153_ReadLatch(unsigned char latchType);
328
329 /* Set the frequency to a desired value */
330 unsigned long long ADF4153_SetFrequency(unsigned long long frequency);
331
332 /* Return the value of the channel spacing */
333 unsigned long ADF4153_GetChannelSpacing( void );
334
335 #endif // __ADF4153_H__