USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-ga1b5c4ae
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 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
9 #define INCLUDED_UHD_USRP_MULTI_USRP_HPP
10 
11 //define API capabilities for compile time detection of new features
12 #define UHD_USRP_MULTI_USRP_REF_SOURCES_API
13 #define UHD_USRP_MULTI_USRP_GET_RATES_API
14 #define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
15 #define UHD_USRP_MULTI_USRP_FRONTEND_IQ_AUTO_API
16 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
17 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
18 #define UHD_USRP_MULTI_USRP_USER_REGS_API
19 #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
20 #define UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
21 #define UHD_USRP_MULTI_USRP_GPIO_API
22 #define UHD_USRP_MULTI_USRP_REGISTER_API
23 #define UHD_USRP_MULTI_USRP_FILTER_API
24 #define UHD_USRP_MULTI_USRP_LO_CONFIG_API
25 
26 #include <uhd/config.hpp>
27 #include <uhd/device.hpp>
28 #include <uhd/deprecated.hpp>
29 #include <uhd/types/ranges.hpp>
30 #include <uhd/types/stream_cmd.hpp>
33 #include <uhd/types/sensors.hpp>
34 #include <uhd/types/filters.hpp>
35 #include <uhd/usrp/subdev_spec.hpp>
37 #include <boost/shared_ptr.hpp>
38 #include <boost/utility.hpp>
39 #include <complex>
40 #include <string>
41 #include <vector>
42 
43 namespace uhd{ namespace usrp{
44 
91 class UHD_API multi_usrp : boost::noncopyable{
92 public:
93  typedef boost::shared_ptr<multi_usrp> sptr;
94 
95  virtual ~multi_usrp(void) = 0;
96 
98  static const size_t ALL_MBOARDS = size_t(~0);
99 
101  static const size_t ALL_CHANS = size_t(~0);
102 
104  static const std::string ALL_GAINS;
105 
107  static const std::string ALL_LOS;
108 
116  static sptr make(const device_addr_t &dev_addr);
117 
123  virtual device::sptr get_device(void) = 0;
124 
126  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
127 
129  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
130 
138  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
139 
147  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
148 
149  /*******************************************************************
150  * Mboard methods
151  ******************************************************************/
152 
175  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
176 
182  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
183 
188  virtual std::string get_pp_string(void) = 0;
189 
195  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
196 
202  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
203 
209  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
210 
222  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
223 
236  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
237 
253  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
254 
261  virtual bool get_time_synchronized(void) = 0;
262 
273  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
274 
280  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
281 
294  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
295 
304  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
305 
314  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
315 
321  virtual std::string get_time_source(const size_t mboard) = 0;
322 
328  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
329 
337  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
338 
344  virtual std::string get_clock_source(const size_t mboard) = 0;
345 
351  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
352 
361  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
362 
371  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
372 
376  virtual size_t get_num_mboards(void) = 0;
377 
384  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
385 
391  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
392 
400  virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
401 
402  /*******************************************************************
403  * RX methods
404  ******************************************************************/
413  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
414 
420  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
421 
427  virtual size_t get_rx_num_channels(void) = 0;
428 
434  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
435 
441  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
442 
448  virtual double get_rx_rate(size_t chan = 0) = 0;
449 
455  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
456 
463  virtual tune_result_t set_rx_freq(
464  const tune_request_t &tune_request, size_t chan = 0
465  ) = 0;
466 
472  virtual double get_rx_freq(size_t chan = 0) = 0;
473 
483  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
484 
490  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
491 
492  /**************************************************************************
493  * LO controls
494  *************************************************************************/
508  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
509 
521  virtual void set_rx_lo_source(
522  const std::string &src,
523  const std::string &name = ALL_LOS,
524  size_t chan = 0
525  ) = 0;
526 
535  virtual const std::string get_rx_lo_source(
536  const std::string &name = ALL_LOS,
537  size_t chan = 0
538  ) = 0;
539 
551  virtual std::vector<std::string> get_rx_lo_sources(
552  const std::string &name = ALL_LOS,
553  size_t chan = 0
554  ) = 0;
555 
566  virtual void set_rx_lo_export_enabled(
567  bool enabled,
568  const std::string &name = ALL_LOS,
569  size_t chan = 0
570  ) = 0;
571 
577  virtual bool get_rx_lo_export_enabled(
578  const std::string &name = ALL_LOS,
579  size_t chan = 0
580  ) = 0;
581 
605  virtual double set_rx_lo_freq(
606  double freq,
607  const std::string &name,
608  size_t chan = 0
609  ) = 0;
610 
621  virtual double get_rx_lo_freq(
622  const std::string &name,
623  size_t chan = 0
624  ) = 0;
625 
635  virtual freq_range_t get_rx_lo_freq_range(
636  const std::string &name,
637  size_t chan = 0
638  ) = 0;
639 
652  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
653 
665  virtual void set_tx_lo_source(
666  const std::string &src,
667  const std::string &name = ALL_LOS,
668  const size_t chan = 0
669  ) = 0;
670 
679  virtual const std::string get_tx_lo_source(
680  const std::string &name = ALL_LOS,
681  const size_t chan = 0
682  ) = 0;
683 
694  virtual std::vector<std::string> get_tx_lo_sources(
695  const std::string &name = ALL_LOS,
696  const size_t chan = 0
697  ) = 0;
698 
709  virtual void set_tx_lo_export_enabled(
710  const bool enabled,
711  const std::string &name = ALL_LOS,
712  const size_t chan = 0
713  ) = 0;
714 
720  virtual bool get_tx_lo_export_enabled(
721  const std::string &name = ALL_LOS,
722  const size_t chan = 0
723  ) = 0;
724 
748  virtual double set_tx_lo_freq(
749  const double freq,
750  const std::string &name,
751  const size_t chan=0
752  ) = 0;
753 
764  virtual double get_tx_lo_freq(
765  const std::string &name,
766  const size_t chan=0
767  ) = 0;
768 
778  virtual freq_range_t get_tx_lo_freq_range(
779  const std::string &name,
780  const size_t chan=0
781  ) = 0;
782 
783  /**************************************************************************
784  * Gain controls
785  *************************************************************************/
793  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
794 
807  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
808 
814  virtual void set_rx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
815 
821  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
822 
824  void set_rx_gain(double gain, size_t chan = 0){
825  return this->set_rx_gain(gain, ALL_GAINS, chan);
826  }
827 
844  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
845 
854  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
855 
863  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
864 
866  double get_rx_gain(size_t chan = 0){
867  return this->get_rx_gain(ALL_GAINS, chan);
868  }
869 
880  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
881 
889  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
890 
892  gain_range_t get_rx_gain_range(size_t chan = 0){
893  return this->get_rx_gain_range(ALL_GAINS, chan);
894  }
895 
902  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
903 
909  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
910 
916  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
917 
923  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
924 
930  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
931 
937  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
938 
944  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
945 
953  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
954 
961  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
962 
968  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
969 
982  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
983 
991  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
992 
999  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
1000 
1008  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1009 
1010  /*******************************************************************
1011  * TX methods
1012  ******************************************************************/
1021  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
1022 
1028  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1029 
1035  virtual size_t get_tx_num_channels(void) = 0;
1036 
1042  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1043 
1049  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1050 
1056  virtual double get_tx_rate(size_t chan = 0) = 0;
1057 
1063  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1064 
1071  virtual tune_result_t set_tx_freq(
1072  const tune_request_t &tune_request, size_t chan = 0
1073  ) = 0;
1074 
1080  virtual double get_tx_freq(size_t chan = 0) = 0;
1081 
1091  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1092 
1098  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1099 
1107  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
1108 
1121  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1122 
1128  virtual void set_tx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
1129 
1135  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1136 
1138  void set_tx_gain(double gain, size_t chan = 0){
1139  return this->set_tx_gain(gain, ALL_GAINS, chan);
1140  }
1141 
1152  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1153 
1161  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
1162 
1164  double get_tx_gain(size_t chan = 0){
1165  return this->get_tx_gain(ALL_GAINS, chan);
1166  }
1167 
1178  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1179 
1187  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
1188 
1191  return this->get_tx_gain_range(ALL_GAINS, chan);
1192  }
1193 
1200  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1201 
1207  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
1208 
1214  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1215 
1221  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1222 
1228  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1229 
1235  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1236 
1242  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1243 
1251  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1252 
1259  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
1260 
1266  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1267 
1274  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
1275 
1283  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1284 
1285  /*******************************************************************
1286  * GPIO methods
1287  ******************************************************************/
1288 
1294  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1295 
1312  virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const uint32_t value, const uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
1313 
1339  virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const std::string &value, const uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
1340 
1357  virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1358 
1384  virtual std::vector<std::string> get_gpio_string_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1385 
1386  /*******************************************************************
1387  * Register IO methods
1388  ******************************************************************/
1390  size_t bitwidth;
1391  bool readable;
1392  bool writable;
1393  };
1394 
1400  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1401 
1408  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1409 
1417  virtual void write_register(const std::string &path, const uint32_t field, const uint64_t value, const size_t mboard = 0) = 0;
1418 
1426  virtual uint64_t read_register(const std::string &path, const uint32_t field, const size_t mboard = 0) = 0;
1427 
1428  /*******************************************************************
1429  * Filter API methods
1430  ******************************************************************/
1431 
1442  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1443 
1449  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1450 
1458  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1459 
1460 };
1461 
1462 }}
1463 
1464 #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:892
Definition: stream_cmd.hpp:36
Definition: tune_result.hpp:19
double get_tx_gain(size_t chan=0)
A convenience wrapper for getting overall TX gain.
Definition: multi_usrp.hpp:1164
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:1138
Definition: time_spec.hpp:29
bool readable
Definition: multi_usrp.hpp:1391
boost::shared_ptr< device > sptr
Definition: device.hpp:31
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:93
Definition: multi_usrp.hpp:1389
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:866
Definition: tune_request.hpp:23
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:161
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:104
Definition: build_info.hpp:14
Definition: sensors.hpp:29
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:28
Definition: clock_config.hpp:26
Definition: multi_usrp.hpp:91
Definition: stream.hpp:47
#define UHD_API
Definition: config.h:63
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:87
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:54
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:824
static const std::string ALL_LOS
A wildcard LO stage name.
Definition: multi_usrp.hpp:107
Definition: subdev_spec.hpp:62
bool writable
Definition: multi_usrp.hpp:1392
Definition: ranges.hpp:64
size_t bitwidth
Definition: multi_usrp.hpp:1390
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:237
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:1190
Definition: device_addr.hpp:37