3 // Copyright 2008,2009 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.
25 #include <usrp/db_base.h>
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();
58 bool _set_pga(float pga_gain);
60 int power_on() { return d_power_on; }
61 int power_off() { return 0; }
69 _AD4360_common *d_common;
72 // ----------------------------------------------------------------
74 class flexrf_base_tx : public flexrf_base
80 flexrf_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0);
83 // All RFX tx d'boards have fixed gain
86 float gain_db_per_step();
88 bool set_auto_tr(bool on);
89 bool set_enable(bool on);
90 bool set_gain(float gain);
93 class flexrf_base_rx : public flexrf_base
99 flexrf_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0);
102 bool set_auto_tr(bool on);
103 bool select_rx_antenna(int which_antenna);
104 bool select_rx_antenna(const std::string &which_antenna);
105 bool set_gain(float gain);
109 // ----------------------------------------------------------------
116 virtual ~_AD4360_common();
118 virtual double freq_min() = 0;
119 virtual double freq_max() = 0;
121 bool _compute_regs(double refclk_freq, double freq, int &retR,
122 int &retcontrol, int &retN, double &retfreq);
123 int _compute_control_reg();
124 virtual int _refclk_divisor();
127 void R_DIV(int div) { d_R_DIV = div; }
130 int d_R_RSV, d_BSC, d_TEST, d_LDP, d_ABP, d_N_RSV, d_PL, d_MTLD;
131 int d_CPG, d_CP3S, d_PDP, d_MUXOUT, d_CR, d_PC;
133 // FIXME: d_PD might cause conflict from flexrf_base
134 int d_A_DIV, d_B_DIV, d_R_DIV, d_P, d_PD, d_CP2, d_CP1, d_DIVSEL;
135 int d_DIV2, d_CPGAIN, d_freq_mult;
139 //----------------------------------------------------------------------
141 class _2200_common : public _AD4360_common
151 //----------------------------------------------------------------------
153 class _2400_common : public _AD4360_common
163 //----------------------------------------------------------------------
165 class _1200_common : public _AD4360_common
175 //-------------------------------------------------------------------------
177 class _1800_common : public _AD4360_common
187 //-------------------------------------------------------------------------
189 class _900_common : public _AD4360_common
199 //-------------------------------------------------------------------------
201 class _400_common : public _AD4360_common
211 class _400_tx : public _400_common
218 class _400_rx : public _400_common
225 //------------------------------------------------------------
227 class db_flexrf_2200_tx : public flexrf_base_tx
230 db_flexrf_2200_tx(usrp_basic_sptr usrp, int which);
231 ~db_flexrf_2200_tx();
233 // Wrapper calls to d_common functions
234 bool _compute_regs(double freq, int &retR, int &retcontrol,
235 int &retN, double &retfreq);
238 class db_flexrf_2200_rx : public flexrf_base_rx
241 db_flexrf_2200_rx(usrp_basic_sptr usrp, int which);
242 ~db_flexrf_2200_rx();
246 float gain_db_per_step();
247 bool i_and_q_swapped();
249 bool _compute_regs(double freq, int &retR, int &retcontrol,
250 int &retN, double &retfreq);
253 //------------------------------------------------------------
255 class db_flexrf_2400_tx : public flexrf_base_tx
258 db_flexrf_2400_tx(usrp_basic_sptr usrp, int which);
259 ~db_flexrf_2400_tx();
261 // Wrapper calls to d_common functions
262 bool _compute_regs(double freq, int &retR, int &retcontrol,
263 int &retN, double &retfreq);
266 class db_flexrf_2400_rx : public flexrf_base_rx
269 db_flexrf_2400_rx(usrp_basic_sptr usrp, int which);
270 ~db_flexrf_2400_rx();
274 float gain_db_per_step();
275 bool i_and_q_swapped();
277 bool _compute_regs(double freq, int &retR, int &retcontrol,
278 int &retN, double &retfreq);
281 //------------------------------------------------------------
283 class db_flexrf_1200_tx : public flexrf_base_tx
286 db_flexrf_1200_tx(usrp_basic_sptr usrp, int which);
287 ~db_flexrf_1200_tx();
289 // Wrapper calls to d_common functions
290 bool _compute_regs(double freq, int &retR, int &retcontrol,
291 int &retN, double &retfreq);
294 class db_flexrf_1200_rx : public flexrf_base_rx
297 db_flexrf_1200_rx(usrp_basic_sptr usrp, int which);
298 ~db_flexrf_1200_rx();
302 float gain_db_per_step();
303 bool i_and_q_swapped();
305 bool _compute_regs(double freq, int &retR, int &retcontrol,
306 int &retN, double &retfreq);
309 //------------------------------------------------------------
311 class db_flexrf_1800_tx : public flexrf_base_tx
314 db_flexrf_1800_tx(usrp_basic_sptr usrp, int which);
315 ~db_flexrf_1800_tx();
317 // Wrapper calls to d_common functions
318 bool _compute_regs(double freq, int &retR, int &retcontrol,
319 int &retN, double &retfreq);
322 class db_flexrf_1800_rx : public flexrf_base_rx
325 db_flexrf_1800_rx(usrp_basic_sptr usrp, int which);
326 ~db_flexrf_1800_rx();
330 float gain_db_per_step();
331 bool i_and_q_swapped();
333 bool _compute_regs(double freq, int &retR, int &retcontrol,
334 int &retN, double &retfreq);
337 //------------------------------------------------------------
339 class db_flexrf_900_tx : public flexrf_base_tx
342 db_flexrf_900_tx(usrp_basic_sptr usrp, int which);
345 // Wrapper calls to d_common functions
346 bool _compute_regs(double freq, int &retR, int &retcontrol,
347 int &retN, double &retfreq);
350 class db_flexrf_900_rx : public flexrf_base_rx
353 db_flexrf_900_rx(usrp_basic_sptr usrp, int which);
358 float gain_db_per_step();
359 bool i_and_q_swapped();
361 bool _compute_regs(double freq, int &retR, int &retcontrol,
362 int &retN, double &retfreq);
366 //------------------------------------------------------------
368 class db_flexrf_400_tx : public flexrf_base_tx
371 db_flexrf_400_tx(usrp_basic_sptr usrp, int which);
374 // Wrapper calls to d_common functions
375 bool _compute_regs(double freq, int &retR, int &retcontrol,
376 int &retN, double &retfreq);
379 class db_flexrf_400_rx : public flexrf_base_rx
382 db_flexrf_400_rx(usrp_basic_sptr usrp, int which);
387 float gain_db_per_step();
388 bool i_and_q_swapped();
390 bool _compute_regs(double freq, int &retR, int &retcontrol,
391 int &retN, double &retfreq);