USRP Hardware Driver and USRP Manual  Version: 003.010.000.HEAD-0-g6e1ac3fc
UHD and USRP Manual
multi_usrp.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012,2014-2015 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
19 #define INCLUDED_UHD_USRP_MULTI_USRP_HPP
20 
21 //define API capabilities for compile time detection of new features
22 #define UHD_USRP_MULTI_USRP_REF_SOURCES_API
23 #define UHD_USRP_MULTI_USRP_GET_RATES_API
24 #define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
25 #define UHD_USRP_MULTI_USRP_FRONTEND_IQ_AUTO_API
26 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
27 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
28 #define UHD_USRP_MULTI_USRP_USER_REGS_API
29 #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
30 #define UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
31 #define UHD_USRP_MULTI_USRP_GPIO_API
32 #define UHD_USRP_MULTI_USRP_REGISTER_API
33 #define UHD_USRP_MULTI_USRP_FILTER_API
34 #define UHD_USRP_MULTI_USRP_LO_CONFIG_API
35 
36 #include <uhd/config.hpp>
37 #include <uhd/device.hpp>
38 #include <uhd/deprecated.hpp>
39 #include <uhd/types/ranges.hpp>
40 #include <uhd/types/stream_cmd.hpp>
43 #include <uhd/types/sensors.hpp>
44 #include <uhd/types/filters.hpp>
45 #include <uhd/usrp/subdev_spec.hpp>
47 #include <boost/shared_ptr.hpp>
48 #include <boost/utility.hpp>
49 #include <complex>
50 #include <string>
51 #include <vector>
52 
53 namespace uhd{ namespace usrp{
54 
101 class UHD_API multi_usrp : boost::noncopyable{
102 public:
103  typedef boost::shared_ptr<multi_usrp> sptr;
104 
105  virtual ~multi_usrp(void) = 0;
106 
108  static const size_t ALL_MBOARDS = size_t(~0);
109 
111  static const size_t ALL_CHANS = size_t(~0);
112 
114  static const std::string ALL_GAINS;
115 
117  static const std::string ALL_LOS;
118 
124  static sptr make(const device_addr_t &dev_addr);
125 
131  virtual device::sptr get_device(void) = 0;
132 
134  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
135 
137  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
138 
146  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
147 
155  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
156 
157  /*******************************************************************
158  * Mboard methods
159  ******************************************************************/
160 
176  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
177 
183  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
184 
189  virtual std::string get_pp_string(void) = 0;
190 
196  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
197 
203  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
204 
210  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
211 
223  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
224 
237  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
238 
254  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
255 
262  virtual bool get_time_synchronized(void) = 0;
263 
274  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
275 
281  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
282 
295  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
296 
305  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
306 
315  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
316 
322  virtual std::string get_time_source(const size_t mboard) = 0;
323 
329  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
330 
338  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
339 
345  virtual std::string get_clock_source(const size_t mboard) = 0;
346 
352  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
353 
362  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
363 
372  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
373 
377  virtual size_t get_num_mboards(void) = 0;
378 
385  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
386 
392  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
393 
401  virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
402 
403  /*******************************************************************
404  * RX methods
405  ******************************************************************/
414  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
415 
421  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
422 
428  virtual size_t get_rx_num_channels(void) = 0;
429 
435  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
436 
442  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
443 
449  virtual double get_rx_rate(size_t chan = 0) = 0;
450 
456  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
457 
464  virtual tune_result_t set_rx_freq(
465  const tune_request_t &tune_request, size_t chan = 0
466  ) = 0;
467 
473  virtual double get_rx_freq(size_t chan = 0) = 0;
474 
484  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
485 
491  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
492 
498  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
499 
509  virtual void set_rx_lo_source(const std::string &src, const std::string &name = ALL_LOS, size_t chan = 0) = 0;
510 
519  virtual const std::string get_rx_lo_source(const std::string &name = ALL_LOS, size_t chan = 0) = 0;
520 
529  virtual std::vector<std::string> get_rx_lo_sources(const std::string &name = ALL_LOS, size_t chan = 0) = 0;
530 
539  virtual void set_rx_lo_export_enabled(bool enabled, const std::string &name = ALL_LOS, size_t chan = 0) = 0;
540 
546  virtual bool get_rx_lo_export_enabled(const std::string &name = ALL_LOS, size_t chan = 0) = 0;
547 
555  virtual double set_rx_lo_freq(double freq, const std::string &name, size_t chan = 0) = 0;
556 
565  virtual double get_rx_lo_freq(const std::string &name, size_t chan = 0) = 0;
566 
575  virtual freq_range_t get_rx_lo_freq_range(const std::string &name, size_t chan = 0) = 0;
576 
584  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
585 
587  void set_rx_gain(double gain, size_t chan = 0){
588  return this->set_rx_gain(gain, ALL_GAINS, chan);
589  }
590 
607  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
608 
617  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
618 
626  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
627 
629  double get_rx_gain(size_t chan = 0){
630  return this->get_rx_gain(ALL_GAINS, chan);
631  }
632 
643  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
644 
652  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
653 
655  gain_range_t get_rx_gain_range(size_t chan = 0){
656  return this->get_rx_gain_range(ALL_GAINS, chan);
657  }
658 
665  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
666 
672  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
673 
679  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
680 
686  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
687 
693  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
694 
700  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
701 
707  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
708 
716  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
717 
724  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
725 
731  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
732 
745  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
746 
754  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
755 
762  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
763 
771  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
772 
773  /*******************************************************************
774  * TX methods
775  ******************************************************************/
784  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
785 
791  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
792 
798  virtual size_t get_tx_num_channels(void) = 0;
799 
805  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
806 
812  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
813 
819  virtual double get_tx_rate(size_t chan = 0) = 0;
820 
826  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
827 
834  virtual tune_result_t set_tx_freq(
835  const tune_request_t &tune_request, size_t chan = 0
836  ) = 0;
837 
843  virtual double get_tx_freq(size_t chan = 0) = 0;
844 
854  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
855 
861  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
862 
870  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
871 
873  void set_tx_gain(double gain, size_t chan = 0){
874  return this->set_tx_gain(gain, ALL_GAINS, chan);
875  }
876 
887  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
888 
896  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
897 
899  double get_tx_gain(size_t chan = 0){
900  return this->get_tx_gain(ALL_GAINS, chan);
901  }
902 
913  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
914 
922  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
923 
925  gain_range_t get_tx_gain_range(size_t chan = 0){
926  return this->get_tx_gain_range(ALL_GAINS, chan);
927  }
928 
935  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
936 
942  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
943 
949  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
950 
956  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
957 
963  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
964 
970  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
971 
977  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
978 
986  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
987 
994  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
995 
1001  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1002 
1009  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
1010 
1018  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1019 
1020  /*******************************************************************
1021  * GPIO methods
1022  ******************************************************************/
1023 
1029  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1030 
1047  virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const boost::uint32_t value, const boost::uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
1048 
1065  virtual boost::uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1066 
1067  /*******************************************************************
1068  * Register IO methods
1069  ******************************************************************/
1071  size_t bitwidth;
1072  bool readable;
1073  bool writable;
1074  };
1075 
1081  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1082 
1089  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1090 
1098  virtual void write_register(const std::string &path, const boost::uint32_t field, const boost::uint64_t value, const size_t mboard = 0) = 0;
1099 
1107  virtual boost::uint64_t read_register(const std::string &path, const boost::uint32_t field, const size_t mboard = 0) = 0;
1108 
1109  /*******************************************************************
1110  * Filter API methods
1111  ******************************************************************/
1112 
1123  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1124 
1130  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1131 
1139  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1140 
1141 };
1142 
1143 }}
1144 
1145 #endif /* INCLUDED_UHD_USRP_MULTI_USRP_HPP */
gain_range_t get_rx_gain_range(size_t chan=0)
A convenience wrapper for getting overall RX gain range.
Definition: multi_usrp.hpp:655
Definition: stream_cmd.hpp:46
Definition: tune_result.hpp:29
double get_tx_gain(size_t chan=0)
A convenience wrapper for getting overall TX gain.
Definition: multi_usrp.hpp:899
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:873
Definition: time_spec.hpp:39
bool readable
Definition: multi_usrp.hpp:1072
boost::shared_ptr< device > sptr
Definition: device.hpp:41
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:103
Definition: multi_usrp.hpp:1070
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:629
Definition: tune_request.hpp:33
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:184
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:114
Definition: build_info.hpp:25
Definition: sensors.hpp:38
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:38
Definition: clock_config.hpp:36
Definition: multi_usrp.hpp:101
Definition: stream.hpp:57
#define UHD_API
Definition: config.h:73
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:64
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:587
static const std::string ALL_LOS
A wildcard gain element name.
Definition: multi_usrp.hpp:117
Definition: subdev_spec.hpp:66
bool writable
Definition: multi_usrp.hpp:1073
Definition: ranges.hpp:68
size_t bitwidth
Definition: multi_usrp.hpp:1071
UHD_INLINE size_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:98
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:256
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:925
Definition: device_addr.hpp:47