USRP Hardware Driver and USRP Manual  Version: 004.000.000.HEAD-0-g8773fb2c
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/device3.hpp>
39 #include <uhd/deprecated.hpp>
40 #include <uhd/types/ranges.hpp>
41 #include <uhd/types/stream_cmd.hpp>
44 #include <uhd/types/sensors.hpp>
45 #include <uhd/types/filters.hpp>
46 #include <uhd/usrp/subdev_spec.hpp>
48 #include <boost/shared_ptr.hpp>
49 #include <boost/utility.hpp>
50 #include <complex>
51 #include <string>
52 #include <vector>
53 
54 namespace uhd{ namespace usrp{
55 
102 class UHD_API multi_usrp : boost::noncopyable{
103 public:
104  typedef boost::shared_ptr<multi_usrp> sptr;
105 
106  virtual ~multi_usrp(void) = 0;
107 
109  static const size_t ALL_MBOARDS = size_t(~0);
110 
112  static const size_t ALL_CHANS = size_t(~0);
113 
115  static const std::string ALL_GAINS;
116 
118  static const std::string ALL_LOS;
119 
125  static sptr make(const device_addr_t &dev_addr);
126 
132  virtual device::sptr get_device(void) = 0;
133 
136  virtual bool is_device3(void) = 0;
137 
146  virtual device3::sptr get_device3(void) = 0;
147 
149  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
150 
152  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
153 
161  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
162 
170  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
171 
172  /*******************************************************************
173  * Mboard methods
174  ******************************************************************/
175 
191  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
192 
198  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
199 
204  virtual std::string get_pp_string(void) = 0;
205 
211  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
212 
218  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
219 
225  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
226 
238  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
239 
252  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
253 
269  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
270 
277  virtual bool get_time_synchronized(void) = 0;
278 
289  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
290 
296  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
297 
310  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
311 
320  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
321 
330  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
331 
337  virtual std::string get_time_source(const size_t mboard) = 0;
338 
344  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
345 
353  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
354 
360  virtual std::string get_clock_source(const size_t mboard) = 0;
361 
367  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
368 
377  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
378 
387  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
388 
392  virtual size_t get_num_mboards(void) = 0;
393 
400  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
401 
407  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
408 
416  virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
417 
418  /*******************************************************************
419  * RX methods
420  ******************************************************************/
429  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
430 
436  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
437 
443  virtual size_t get_rx_num_channels(void) = 0;
444 
450  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
451 
457  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
458 
464  virtual double get_rx_rate(size_t chan = 0) = 0;
465 
471  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
472 
479  virtual tune_result_t set_rx_freq(
480  const tune_request_t &tune_request, size_t chan = 0
481  ) = 0;
482 
488  virtual double get_rx_freq(size_t chan = 0) = 0;
489 
499  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
500 
506  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
507 
513  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
514 
524  virtual void set_rx_lo_source(const std::string &src, const std::string &name = ALL_LOS, size_t chan = 0) = 0;
525 
534  virtual const std::string get_rx_lo_source(const std::string &name = ALL_LOS, size_t chan = 0) = 0;
535 
544  virtual std::vector<std::string> get_rx_lo_sources(const std::string &name = ALL_LOS, size_t chan = 0) = 0;
545 
554  virtual void set_rx_lo_export_enabled(bool enabled, const std::string &name = ALL_LOS, size_t chan = 0) = 0;
555 
561  virtual bool get_rx_lo_export_enabled(const std::string &name = ALL_LOS, size_t chan = 0) = 0;
562 
570  virtual double set_rx_lo_freq(double freq, const std::string &name, size_t chan = 0) = 0;
571 
580  virtual double get_rx_lo_freq(const std::string &name, size_t chan = 0) = 0;
581 
590  virtual freq_range_t get_rx_lo_freq_range(const std::string &name, size_t chan = 0) = 0;
591 
599  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
600 
602  void set_rx_gain(double gain, size_t chan = 0){
603  return this->set_rx_gain(gain, ALL_GAINS, chan);
604  }
605 
622  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
623 
632  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
633 
641  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
642 
644  double get_rx_gain(size_t chan = 0){
645  return this->get_rx_gain(ALL_GAINS, chan);
646  }
647 
658  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
659 
667  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
668 
670  gain_range_t get_rx_gain_range(size_t chan = 0){
671  return this->get_rx_gain_range(ALL_GAINS, chan);
672  }
673 
680  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
681 
687  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
688 
694  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
695 
701  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
702 
708  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
709 
715  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
716 
722  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
723 
731  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
732 
739  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
740 
746  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
747 
760  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
761 
769  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
770 
777  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
778 
786  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
787 
788  /*******************************************************************
789  * TX methods
790  ******************************************************************/
799  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
800 
806  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
807 
813  virtual size_t get_tx_num_channels(void) = 0;
814 
820  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
821 
827  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
828 
834  virtual double get_tx_rate(size_t chan = 0) = 0;
835 
841  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
842 
849  virtual tune_result_t set_tx_freq(
850  const tune_request_t &tune_request, size_t chan = 0
851  ) = 0;
852 
858  virtual double get_tx_freq(size_t chan = 0) = 0;
859 
869  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
870 
876  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
877 
885  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
886 
888  void set_tx_gain(double gain, size_t chan = 0){
889  return this->set_tx_gain(gain, ALL_GAINS, chan);
890  }
891 
902  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
903 
911  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
912 
914  double get_tx_gain(size_t chan = 0){
915  return this->get_tx_gain(ALL_GAINS, chan);
916  }
917 
928  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
929 
937  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
938 
940  gain_range_t get_tx_gain_range(size_t chan = 0){
941  return this->get_tx_gain_range(ALL_GAINS, chan);
942  }
943 
950  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
951 
957  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
958 
964  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
965 
971  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
972 
978  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
979 
985  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
986 
992  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
993 
1001  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1002 
1009  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
1010 
1016  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1017 
1024  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
1025 
1033  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1034 
1035  /*******************************************************************
1036  * GPIO methods
1037  ******************************************************************/
1038 
1044  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1045 
1062  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;
1063 
1080  virtual boost::uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1081 
1082  /*******************************************************************
1083  * Register IO methods
1084  ******************************************************************/
1086  size_t bitwidth;
1087  bool readable;
1088  bool writable;
1089  };
1090 
1096  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1097 
1104  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1105 
1113  virtual void write_register(const std::string &path, const boost::uint32_t field, const boost::uint64_t value, const size_t mboard = 0) = 0;
1114 
1122  virtual boost::uint64_t read_register(const std::string &path, const boost::uint32_t field, const size_t mboard = 0) = 0;
1123 
1124  /*******************************************************************
1125  * Filter API methods
1126  ******************************************************************/
1127 
1138  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1139 
1145  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1146 
1154  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1155 
1156 };
1157 
1158 }}
1159 
1160 #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:670
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:914
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:888
Definition: time_spec.hpp:39
bool readable
Definition: multi_usrp.hpp:1087
boost::shared_ptr< device > sptr
Definition: device.hpp:41
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:104
Definition: multi_usrp.hpp:1085
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:644
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:115
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:102
Definition: stream.hpp:57
#define UHD_API
Definition: config.h:73
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:98
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:602
static const std::string ALL_LOS
A wildcard gain element name.
Definition: multi_usrp.hpp:118
Definition: subdev_spec.hpp:66
bool writable
Definition: multi_usrp.hpp:1088
Definition: ranges.hpp:68
size_t bitwidth
Definition: multi_usrp.hpp:1086
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:256
boost::shared_ptr< device3 > sptr
Definition: device3.hpp:39
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:940
Definition: device_addr.hpp:47