2 // Copyright 2008,2009 Free Software Foundation, Inc.
4 // This file is part of GNU Radio
6 // GNU Radio is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either asversion 3, or (at your option)
11 // GNU Radio is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with GNU Radio; see the file COPYING. If not, write to
18 // the Free Software Foundation, Inc., 51 Franklin Street,
19 // Boston, MA 02110-1301, USA.
25 #include <usrp/db_basic.h>
26 #include <db_base_impl.h>
28 db_basic_tx::db_basic_tx(boost::shared_ptr<usrp_basic> usrp, int which)
29 : db_base(usrp, which)
31 // Handler for Basic Tx daughterboards.
33 // @param usrp: instance of usrp.source_c
34 // @param which: which side: 0 or 1 corresponding to TX_A or TX_B respectively
36 set_gain((gain_min() + gain_max()) / 2); // initialize gain
39 db_basic_tx::~db_basic_tx()
44 db_basic_tx::freq_min()
50 db_basic_tx::freq_max()
56 db_basic_tx::set_freq(double target_freq)
60 // @param freq: target RF frequency in Hz
63 // @returns (ok, actual_baseband_freq) where:
64 // ok is True or False and indicates success or failure,
65 // actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
67 struct freq_result_t args = {false, 0};
69 args.baseband_freq = 0.0;
74 db_basic_tx::gain_min()
76 return usrp()->pga_min();
80 db_basic_tx::gain_max()
82 return usrp()->pga_max();
86 db_basic_tx::gain_db_per_step()
88 return usrp()->pga_db_per_step();
92 db_basic_tx::set_gain(float gain)
96 // @param gain: gain in decibels
97 // @returns True/False
99 bool ok = usrp()->set_pga(d_which * 2 + 0, gain);
100 ok = ok && usrp()->set_pga(d_which * 2 + 1, gain);
105 db_basic_tx::is_quadrature()
107 // Return True if this board requires both I & Q analog channels.
113 /******************************************************************************/
116 db_basic_rx::db_basic_rx(usrp_basic_sptr usrp, int which, int subdev)
117 : db_base(usrp, which)
119 // Handler for Basic Rx daughterboards.
121 // @param usrp: instance of usrp.source_c
122 // @param which: which side: 0 or 1 corresponding to TX_A or TX_B respectively
123 // @param subdev: which analog i/o channel: 0 or 1
128 bypass_adc_buffers(true);
130 if(0) { // Doing this would give us a different default than the historical values...
131 set_gain(float(gain_min() + gain_max()) / 2.0); // initialize gain
135 db_basic_rx::~db_basic_rx()
140 db_basic_rx::freq_min()
146 db_basic_rx::freq_max()
152 db_basic_rx::set_freq(double target_freq)
154 // Set the frequency.
156 // @param freq: target RF frequency in Hz
157 // @type freq: double
159 // @returns (ok, actual_baseband_freq) where:
160 // ok is True or False and indicates success or failure,
161 // actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
163 struct freq_result_t args = {true, 0.0};
168 db_basic_rx::gain_min()
170 return usrp()->pga_min();
174 db_basic_rx::gain_max()
176 return usrp()->pga_max();
180 db_basic_rx::gain_db_per_step()
182 return usrp()->pga_db_per_step();
186 db_basic_rx::set_gain(float gain)
190 // @param gain: gain in decibels
191 // @returns True/False
193 return usrp()->set_pga(d_which * 2 + d_subdev, gain);
197 db_basic_rx::is_quadrature()
199 // Return True if this board requires both I & Q analog channels.
201 // This bit of info is useful when setting up the USRP Rx mux register.
203 return (d_subdev == 2);
208 /******************************************************************************/
211 db_lf_tx::db_lf_tx(usrp_basic_sptr usrp, int which)
212 : db_basic_tx(usrp, which)
214 // Handler for Low Freq Tx daughterboards.
216 // @param usrp: instance of usrp.source_c
217 // @param which: which side: 0 or 1 corresponding to RX_A or RX_B respectively
220 db_lf_tx::~db_lf_tx()
236 /******************************************************************************/
239 db_lf_rx::db_lf_rx(usrp_basic_sptr usrp, int which, int subdev)
240 : db_basic_rx(usrp, which, subdev)
242 // Handler for Low Freq Rx daughterboards.
244 // @param usrp: instance of usrp.source_c
245 // @param which: which side: 0 or 1 corresponding to RX_A or RX_B respectively
246 // @param subdev: which analog i/o channel: 0 or 1
250 db_lf_rx::~db_lf_rx()