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.
21 #include <usrp/db_basic.h>
22 #include <db_base_impl.h>
24 db_basic_tx::db_basic_tx(boost::shared_ptr<usrp_basic> usrp, int which)
25 : db_base(usrp, which)
27 // Handler for Basic Tx daughterboards.
29 // @param usrp: instance of usrp.source_c
30 // @param which: which side: 0 or 1 corresponding to TX_A or TX_B respectively
32 set_gain((gain_min() + gain_max()) / 2); // initialize gain
35 db_basic_tx::~db_basic_tx()
40 db_basic_tx::freq_min()
46 db_basic_tx::freq_max()
52 db_basic_tx::set_freq(double target_freq)
56 // @param freq: target RF frequency in Hz
59 // @returns (ok, actual_baseband_freq) where:
60 // ok is True or False and indicates success or failure,
61 // actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
63 struct freq_result_t args = {false, 0};
65 args.baseband_freq = 0.0;
70 db_basic_tx::gain_min()
72 return usrp()->pga_min();
76 db_basic_tx::gain_max()
78 return usrp()->pga_max();
82 db_basic_tx::gain_db_per_step()
84 return usrp()->pga_db_per_step();
88 db_basic_tx::set_gain(float gain)
92 // @param gain: gain in decibels
93 // @returns True/False
95 bool ok = usrp()->set_pga(d_which * 2 + 0, gain);
96 ok = ok && usrp()->set_pga(d_which * 2 + 1, gain);
101 db_basic_tx::is_quadrature()
103 // Return True if this board requires both I & Q analog channels.
109 /******************************************************************************/
112 db_basic_rx::db_basic_rx(usrp_basic_sptr usrp, int which, int subdev)
113 : db_base(usrp, which)
115 // Handler for Basic Rx daughterboards.
117 // @param usrp: instance of usrp.source_c
118 // @param which: which side: 0 or 1 corresponding to TX_A or TX_B respectively
119 // @param subdev: which analog i/o channel: 0 or 1
124 bypass_adc_buffers(true);
126 if(0) { // Doing this would give us a different default than the historical values...
127 set_gain(float(gain_min() + gain_max()) / 2.0); // initialize gain
131 db_basic_rx::~db_basic_rx()
136 db_basic_rx::freq_min()
142 db_basic_rx::freq_max()
148 db_basic_rx::set_freq(double target_freq)
150 // Set the frequency.
152 // @param freq: target RF frequency in Hz
153 // @type freq: double
155 // @returns (ok, actual_baseband_freq) where:
156 // ok is True or False and indicates success or failure,
157 // actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
159 struct freq_result_t args = {true, 0.0};
164 db_basic_rx::gain_min()
166 return usrp()->pga_min();
170 db_basic_rx::gain_max()
172 return usrp()->pga_max();
176 db_basic_rx::gain_db_per_step()
178 return usrp()->pga_db_per_step();
182 db_basic_rx::set_gain(float gain)
186 // @param gain: gain in decibels
187 // @returns True/False
189 return usrp()->set_pga(d_which * 2 + d_subdev, gain);
193 db_basic_rx::is_quadrature()
195 // Return True if this board requires both I & Q analog channels.
197 // This bit of info is useful when setting up the USRP Rx mux register.
199 return (d_subdev == 2);
204 /******************************************************************************/
207 db_lf_tx::db_lf_tx(usrp_basic_sptr usrp, int which)
208 : db_basic_tx(usrp, which)
210 // Handler for Low Freq Tx daughterboards.
212 // @param usrp: instance of usrp.source_c
213 // @param which: which side: 0 or 1 corresponding to RX_A or RX_B respectively
216 db_lf_tx::~db_lf_tx()
232 /******************************************************************************/
235 db_lf_rx::db_lf_rx(usrp_basic_sptr usrp, int which, int subdev)
236 : db_basic_rx(usrp, which, subdev)
238 // Handler for Low Freq Rx daughterboards.
240 // @param usrp: instance of usrp.source_c
241 // @param which: which side: 0 or 1 corresponding to RX_A or RX_B respectively
242 // @param subdev: which analog i/o channel: 0 or 1
246 db_lf_rx::~db_lf_rx()