3 // Copyright 2008 Free Software Foundation, Inc.
5 // This file is part of GNU Radio
7 // GNU Radio is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either asversion 3, or (at your option)
12 // GNU Radio is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with GNU Radio; see the file COPYING. If not, write to
19 // the Free Software Foundation, Inc., 51 Franklin Street,
20 // Boston, MA 02110-1301, USA.
28 //debug_using_gui = true // Must be set to True or False
29 #define debug_using_gui false // Must be set to True or False
33 class flexrf_base : public db_base
36 flexrf_base(usrp_basic_sptr usrp, int which, int _power_on=0);
39 struct freq_result_t set_freq(double freq);
46 void _write_all(int R, int control, int N);
47 void _write_control(int control);
50 void _write_it(int v);
53 virtual bool _compute_regs(double freq, int &retR, int &retcontrol,
54 int &retN, double &retfreq);
55 int _compute_control_reg();
56 int _refclk_divisor();
57 double _refclk_freq();
59 bool _set_pga(float pga_gain);
61 int power_on() { return d_power_on; }
62 int power_off() { return 0; }
70 _AD4360_common *d_common;
73 // ----------------------------------------------------------------
75 class flexrf_base_tx : public flexrf_base
81 flexrf_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
84 // All RFX tx d'boards have fixed gain
87 float gain_db_per_step();
89 bool set_auto_tr(bool on);
90 bool set_enable(bool on);
91 bool set_gain(float gain);
94 class flexrf_base_rx : public flexrf_base
100 flexrf_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
103 bool set_auto_tr(bool on);
104 bool select_rx_antenna(int which_antenna);
105 bool select_rx_antenna(const std::string &which_antenna);
106 bool set_gain(float gain);
110 // ----------------------------------------------------------------
117 virtual ~_AD4360_common();
119 virtual double freq_min() = 0;
120 virtual double freq_max() = 0;
122 bool _compute_regs(double refclk_freq, double freq, int &retR,
123 int &retcontrol, int &retN, double &retfreq);
124 int _compute_control_reg();
125 virtual int _refclk_divisor();
128 void R_DIV(int div) { d_R_DIV = div; }
131 int d_R_RSV, d_BSC, d_TEST, d_LDP, d_ABP, d_N_RSV, d_PL, d_MTLD;
132 int d_CPG, d_CP3S, d_PDP, d_MUXOUT, d_CR, d_PC;
134 // FIXME: d_PD might cause conflict from flexrf_base
135 int d_A_DIV, d_B_DIV, d_R_DIV, d_P, d_PD, d_CP2, d_CP1, d_DIVSEL;
136 int d_DIV2, d_CPGAIN, d_freq_mult;
140 //----------------------------------------------------------------------
142 class _2400_common : public _AD4360_common
152 //----------------------------------------------------------------------
154 class _1200_common : public _AD4360_common
164 //-------------------------------------------------------------------------
166 class _1800_common : public _AD4360_common
176 //-------------------------------------------------------------------------
178 class _900_common : public _AD4360_common
188 //-------------------------------------------------------------------------
190 class _400_common : public _AD4360_common
200 class _400_tx : public _400_common
207 class _400_rx : public _400_common
214 //------------------------------------------------------------
216 class db_flexrf_2400_tx : public flexrf_base_tx
219 db_flexrf_2400_tx(usrp_basic_sptr usrp, int which);
220 ~db_flexrf_2400_tx();
222 // Wrapper calls to d_common functions
223 bool _compute_regs(double freq, int &retR, int &retcontrol,
224 int &retN, double &retfreq);
227 class db_flexrf_2400_rx : public flexrf_base_rx
230 db_flexrf_2400_rx(usrp_basic_sptr usrp, int which);
231 ~db_flexrf_2400_rx();
235 float gain_db_per_step();
236 bool i_and_q_swapped();
238 bool _compute_regs(double freq, int &retR, int &retcontrol,
239 int &retN, double &retfreq);
242 //------------------------------------------------------------
244 class db_flexrf_1200_tx : public flexrf_base_tx
247 db_flexrf_1200_tx(usrp_basic_sptr usrp, int which);
248 ~db_flexrf_1200_tx();
250 // Wrapper calls to d_common functions
251 bool _compute_regs(double freq, int &retR, int &retcontrol,
252 int &retN, double &retfreq);
255 class db_flexrf_1200_rx : public flexrf_base_rx
258 db_flexrf_1200_rx(usrp_basic_sptr usrp, int which);
259 ~db_flexrf_1200_rx();
263 float gain_db_per_step();
264 bool i_and_q_swapped();
266 bool _compute_regs(double freq, int &retR, int &retcontrol,
267 int &retN, double &retfreq);
270 //------------------------------------------------------------
272 class db_flexrf_1800_tx : public flexrf_base_tx
275 db_flexrf_1800_tx(usrp_basic_sptr usrp, int which);
276 ~db_flexrf_1800_tx();
278 // Wrapper calls to d_common functions
279 bool _compute_regs(double freq, int &retR, int &retcontrol,
280 int &retN, double &retfreq);
283 class db_flexrf_1800_rx : public flexrf_base_rx
286 db_flexrf_1800_rx(usrp_basic_sptr usrp, int which);
287 ~db_flexrf_1800_rx();
291 float gain_db_per_step();
292 bool i_and_q_swapped();
294 bool _compute_regs(double freq, int &retR, int &retcontrol,
295 int &retN, double &retfreq);
298 //------------------------------------------------------------
300 class db_flexrf_900_tx : public flexrf_base_tx
303 db_flexrf_900_tx(usrp_basic_sptr usrp, int which);
306 // Wrapper calls to d_common functions
307 bool _compute_regs(double freq, int &retR, int &retcontrol,
308 int &retN, double &retfreq);
311 class db_flexrf_900_rx : public flexrf_base_rx
314 db_flexrf_900_rx(usrp_basic_sptr usrp, int which);
319 float gain_db_per_step();
320 bool i_and_q_swapped();
322 bool _compute_regs(double freq, int &retR, int &retcontrol,
323 int &retN, double &retfreq);
327 //------------------------------------------------------------
329 class db_flexrf_400_tx : public flexrf_base_tx
332 db_flexrf_400_tx(usrp_basic_sptr usrp, int which);
335 // Wrapper calls to d_common functions
336 bool _compute_regs(double freq, int &retR, int &retcontrol,
337 int &retN, double &retfreq);
340 class db_flexrf_400_rx : public flexrf_base_rx
343 db_flexrf_400_rx(usrp_basic_sptr usrp, int which);
348 float gain_db_per_step();
349 bool i_and_q_swapped();
351 bool _compute_regs(double freq, int &retR, int &retcontrol,
352 int &retN, double &retfreq);