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.
26 #include <boost/shared_ptr.hpp>
30 A few comments about the WBX boards:
31 They are half-duplex. I.e., transmit and receive are mutually exclusive.
32 There is a single LO for both the Tx and Rx sides.
33 The the shared control signals are hung off of the Rx side.
34 The shared io controls are duplexed onto the Rx side pins.
35 The wbx_high d'board always needs to be in 'auto_tr_mode'
39 class wbx_base : public db_base
45 * Abstract base class for all wbx boards.
47 * Derive board specific subclasses from db_wbx_base_{tx,rx}
51 wbx_base(usrp_basic_sptr usrp, int which);
54 struct freq_result_t set_freq(double freq);
57 float gain_db_per_step();
58 bool set_gain(float gain);
63 virtual bool _lock_detect();
65 // FIXME: After testing, replace these with usrp_basic::common_write_io/oe
66 bool _tx_write_oe(int value, int mask);
67 bool _rx_write_oe(int value, int mask);
68 bool _tx_write_io(int value, int mask);
69 bool _rx_write_io(int value, int mask);
70 virtual bool _rx_read_io();
72 bool _compute_regs(double freq);
73 virtual double _refclk_freq();
74 int _refclk_divisor();
76 bool _set_pga(float pga_gain);
85 /****************************************************************************/
88 class wbx_base_tx : public wbx_base
91 wbx_base_tx(usrp_basic_sptr usrp, int which);
94 bool set_auto_tr(bool on);
95 bool set_enable(bool on);
99 /****************************************************************************/
102 class wbx_base_rx : public wbx_base
105 wbx_base_rx(usrp_basic_sptr usrp, int which);
108 bool set_auto_tr(bool on);
109 bool select_rx_antenna(int which_antenna);
110 bool select_rx_antenna(const std::string &which_antenna);
111 bool set_gain(float gain);
112 bool i_and_q_swapped();
116 /****************************************************************************/
119 class _ADF410X_common
123 virtual ~_ADF410X_common();
125 bool _compute_regs(double freq, int &retR, int &retcontrol,
126 int &retN, double &retfreq);
127 void _write_all(int R, int N, int control);
128 void _write_R(int R);
129 void _write_N(int N);
130 void _write_func(int func);
131 void _write_init(int init);
133 virtual void _write_it(int v);
134 virtual double _refclk_freq();
135 virtual bool _rx_write_io(int value, int mask);
136 virtual bool _lock_detect();
139 virtual usrp_basic* usrp();
141 int d_R_RSV, d_LDP, d_TEST, d_ABP;
142 int d_N_RSV, d_CP_GAIN;
143 int d_P, d_PD2, d_CP2, d_CP1, d_TC, d_FL;
144 int d_CP3S, d_PDP, d_MUXOUT, d_PD1, d_CR;
145 int d_R_DIV, d_A_DIV, d_B_DIV;
153 /****************************************************************************/
156 class _lo_common : public _ADF410X_common
165 void set_divider(int main_or_aux, int divisor);
166 void set_divider(const std::string &main_or_aux, int divisor);
168 struct freq_result_t set_freq(double freq);
171 int d_R_DIV, d_P, d_CP2, d_CP1;
172 int d_DIVSEL, d_DIV2, d_CPGAIN;
173 int d_div, d_aux_div, d_main_div;
177 /****************************************************************************/
180 class db_wbx_lo_tx : public _lo_common, public wbx_base_tx
183 db_wbx_lo_tx(usrp_basic_sptr usrp, int which);
188 float gain_db_per_step();
189 bool set_gain(float gain);
191 double _refclk_freq();
192 bool _rx_write_io(int value, int mask);
200 /****************************************************************************/
203 class db_wbx_lo_rx : public _lo_common, public wbx_base_rx
206 db_wbx_lo_rx(usrp_basic_sptr usrp, int which);
211 float gain_db_per_step();
213 double _refclk_freq();
214 bool _rx_write_io(int value, int mask);