3 * Copyright 2004,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 version 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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <usrp_base.h>
26 #include <usrp/usrp_basic.h>
28 class truth_table_element_t
31 truth_table_element_t(int side, unsigned int uses, bool swap_iq, unsigned int mux_val);
32 bool operator==(const truth_table_element_t &in);
33 bool operator!=(const truth_table_element_t &in);
35 unsigned int mux_val() { return d_mux_val; }
41 unsigned int d_mux_val;
45 usrp_base::~usrp_base()
50 usrp_base::set_usrp_basic(boost::shared_ptr<usrp_basic> u)
55 std::vector<std::vector<db_base_sptr> >
58 return d_usrp_basic->db();
61 std::vector<db_base_sptr>
62 usrp_base::db(int which_side)
64 return d_usrp_basic->db(which_side);
68 usrp_base::db(int which_side, int which_dev)
70 return d_usrp_basic->selected_subdev(usrp_subdev_spec(which_side, which_dev));
74 usrp_base::selected_subdev(usrp_subdev_spec ss)
76 return d_usrp_basic->selected_subdev(ss);
80 usrp_base::fpga_master_clock_freq() const
82 return d_usrp_basic->fpga_master_clock_freq();
86 usrp_base::set_fpga_master_clock_freq(long master_clock)
88 d_usrp_basic->set_fpga_master_clock_freq(master_clock);
92 usrp_base::set_verbose (bool verbose)
94 d_usrp_basic->set_verbose (verbose);
98 usrp_base::write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf)
100 return d_usrp_basic->write_eeprom (i2c_addr, eeprom_offset, buf);
104 usrp_base::read_eeprom (int i2c_addr, int eeprom_offset, int len)
106 return d_usrp_basic->read_eeprom (i2c_addr, eeprom_offset, len);
110 usrp_base::write_i2c (int i2c_addr, const std::string buf)
112 return d_usrp_basic->write_i2c (i2c_addr, buf);
116 usrp_base::read_i2c (int i2c_addr, int len)
118 return d_usrp_basic->read_i2c (i2c_addr, len);
122 usrp_base::set_adc_offset (int which, int offset)
124 return d_usrp_basic->set_adc_offset (which, offset);
128 usrp_base::set_dac_offset (int which, int offset, int offset_pin)
130 return d_usrp_basic->set_dac_offset (which, offset, offset_pin);
134 usrp_base::set_adc_buffer_bypass (int which, bool bypass)
136 return d_usrp_basic->set_adc_buffer_bypass (which, bypass);
140 usrp_base::set_dc_offset_cl_enable(int bits, int mask)
142 return d_usrp_basic->set_dc_offset_cl_enable(bits, mask);
146 usrp_base::serial_number()
148 return d_usrp_basic->serial_number();
152 usrp_base::daughterboard_id (int which) const
154 return d_usrp_basic->daughterboard_id (which);
158 usrp_base::write_atr_tx_delay(int value)
160 return d_usrp_basic->write_atr_tx_delay(value);
164 usrp_base::write_atr_rx_delay(int value)
166 return d_usrp_basic->write_atr_rx_delay(value);
170 usrp_base::set_pga (int which, double gain)
172 return d_usrp_basic->set_pga (which, gain);
176 usrp_base::pga (int which) const
178 return d_usrp_basic->pga (which);
182 usrp_base::pga_min () const
184 return d_usrp_basic->pga_min ();
188 usrp_base::pga_max () const
190 return d_usrp_basic->pga_max ();
194 usrp_base::pga_db_per_step () const
196 return d_usrp_basic->pga_db_per_step ();
200 usrp_base::_write_oe (int which_dboard, int value, int mask)
202 return d_usrp_basic->_write_oe (which_dboard, value, mask);
206 usrp_base::write_io (int which_dboard, int value, int mask)
208 return d_usrp_basic->write_io (which_dboard, value, mask);
212 usrp_base::read_io (int which_dboard)
214 return d_usrp_basic->read_io (which_dboard);
218 usrp_base::write_atr_mask(int which_side, int value)
220 return d_usrp_basic->write_atr_mask(which_side, value);
224 usrp_base::write_atr_txval(int which_side, int value)
226 return d_usrp_basic->write_atr_txval(which_side, value);
230 usrp_base::write_atr_rxval(int which_side, int value)
232 return d_usrp_basic->write_atr_rxval(which_side, value);
236 usrp_base::write_aux_dac (int which_dboard, int which_dac, int value)
238 return d_usrp_basic->write_aux_dac (which_dboard, which_dac, value);
242 usrp_base::read_aux_adc (int which_dboard, int which_adc)
244 return d_usrp_basic->read_aux_adc (which_dboard, which_adc);
248 usrp_base::converter_rate() const
250 return d_usrp_basic->converter_rate();
254 usrp_base::_set_led(int which_led, bool on)
256 return d_usrp_basic->_set_led(which_led, on);
260 usrp_base::_write_fpga_reg (int regno, int value)
262 return d_usrp_basic->_write_fpga_reg (regno, value);
266 usrp_base::_write_fpga_reg_masked (int regno, int value, int mask)
268 return d_usrp_basic->_write_fpga_reg_masked (regno, value, mask);
272 usrp_base::_read_fpga_reg (int regno)
274 return d_usrp_basic->_read_fpga_reg (regno);
278 usrp_base::_write_9862 (int which_codec, int regno, unsigned char value)
280 return d_usrp_basic->_write_9862 (which_codec, regno, value);
284 usrp_base::_read_9862 (int which_codec, int regno) const
286 return d_usrp_basic->_read_9862 (which_codec, regno);
290 usrp_base::_write_spi (int optional_header, int enables,
291 int format, std::string buf)
293 return d_usrp_basic->_write_spi (optional_header, enables, format, buf);
297 usrp_base::_read_spi (int optional_header, int enables, int format, int len)
299 return d_usrp_basic->_read_spi (optional_header, enables, format, len);
303 usrp_base::pick_subdev(std::vector<int> candidates)
305 int dbid0 = db(0, 0)->dbid();
306 int dbid1 = db(1, 0)->dbid();
308 for (int i = 0; i < candidates.size(); i++) {
309 int dbid = candidates[i];
311 return usrp_subdev_spec(0, 0);
313 return usrp_subdev_spec(1, 0);
317 return usrp_subdev_spec(0, 0);
319 return usrp_subdev_spec(1, 0);
321 throw std::runtime_error("No suitable daughterboard found!");