USRP Hardware Driver and USRP Manual  Version: 3.13.0.HEAD-0-gf114cfa0
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 {
44  class device3;
45 
46  namespace usrp{
47 
94 class UHD_API multi_usrp : boost::noncopyable{
95 public:
96  typedef boost::shared_ptr<multi_usrp> sptr;
97 
98  virtual ~multi_usrp(void) = 0;
99 
101  static const size_t ALL_MBOARDS = size_t(~0);
102 
104  static const size_t ALL_CHANS = size_t(~0);
105 
107  static const std::string ALL_GAINS;
108 
110  static const std::string ALL_LOS;
111 
119  static sptr make(const device_addr_t &dev_addr);
120 
126  virtual device::sptr get_device(void) = 0;
127 
130  virtual bool is_device3(void) = 0;
131 
140  virtual boost::shared_ptr<uhd::device3> get_device3(void) = 0;
141 
143  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
144 
146  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
147 
155  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
156 
164  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
165 
166  /*******************************************************************
167  * Mboard methods
168  ******************************************************************/
169 
192  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
193 
199  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
200 
219  virtual meta_range_t get_master_clock_rate_range(const size_t mboard = 0) = 0;
220 
225  virtual std::string get_pp_string(void) = 0;
226 
232  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
233 
239  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
240 
246  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
247 
259  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
260 
273  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
274 
290  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
291 
298  virtual bool get_time_synchronized(void) = 0;
299 
310  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
311 
317  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
318 
331  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
332 
341  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
342 
351  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
352 
358  virtual std::string get_time_source(const size_t mboard) = 0;
359 
365  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
366 
374  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
375 
381  virtual std::string get_clock_source(const size_t mboard) = 0;
382 
388  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
389 
398  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
399 
408  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
409 
413  virtual size_t get_num_mboards(void) = 0;
414 
421  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
422 
428  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
429 
437  virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
438 
439  /*******************************************************************
440  * RX methods
441  ******************************************************************/
450  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
451 
457  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
458 
464  virtual size_t get_rx_num_channels(void) = 0;
465 
471  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
472 
478  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
479 
485  virtual double get_rx_rate(size_t chan = 0) = 0;
486 
492  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
493 
500  virtual tune_result_t set_rx_freq(
501  const tune_request_t &tune_request, size_t chan = 0
502  ) = 0;
503 
509  virtual double get_rx_freq(size_t chan = 0) = 0;
510 
520  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
521 
527  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
528 
529  /**************************************************************************
530  * LO controls
531  *************************************************************************/
545  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
546 
558  virtual void set_rx_lo_source(
559  const std::string &src,
560  const std::string &name = ALL_LOS,
561  size_t chan = 0
562  ) = 0;
563 
572  virtual const std::string get_rx_lo_source(
573  const std::string &name = ALL_LOS,
574  size_t chan = 0
575  ) = 0;
576 
588  virtual std::vector<std::string> get_rx_lo_sources(
589  const std::string &name = ALL_LOS,
590  size_t chan = 0
591  ) = 0;
592 
603  virtual void set_rx_lo_export_enabled(
604  bool enabled,
605  const std::string &name = ALL_LOS,
606  size_t chan = 0
607  ) = 0;
608 
614  virtual bool get_rx_lo_export_enabled(
615  const std::string &name = ALL_LOS,
616  size_t chan = 0
617  ) = 0;
618 
642  virtual double set_rx_lo_freq(
643  double freq,
644  const std::string &name,
645  size_t chan = 0
646  ) = 0;
647 
658  virtual double get_rx_lo_freq(
659  const std::string &name,
660  size_t chan = 0
661  ) = 0;
662 
672  virtual freq_range_t get_rx_lo_freq_range(
673  const std::string &name,
674  size_t chan = 0
675  ) = 0;
676 
689  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
690 
702  virtual void set_tx_lo_source(
703  const std::string &src,
704  const std::string &name = ALL_LOS,
705  const size_t chan = 0
706  ) = 0;
707 
716  virtual const std::string get_tx_lo_source(
717  const std::string &name = ALL_LOS,
718  const size_t chan = 0
719  ) = 0;
720 
731  virtual std::vector<std::string> get_tx_lo_sources(
732  const std::string &name = ALL_LOS,
733  const size_t chan = 0
734  ) = 0;
735 
746  virtual void set_tx_lo_export_enabled(
747  const bool enabled,
748  const std::string &name = ALL_LOS,
749  const size_t chan = 0
750  ) = 0;
751 
757  virtual bool get_tx_lo_export_enabled(
758  const std::string &name = ALL_LOS,
759  const size_t chan = 0
760  ) = 0;
761 
785  virtual double set_tx_lo_freq(
786  const double freq,
787  const std::string &name,
788  const size_t chan=0
789  ) = 0;
790 
801  virtual double get_tx_lo_freq(
802  const std::string &name,
803  const size_t chan=0
804  ) = 0;
805 
815  virtual freq_range_t get_tx_lo_freq_range(
816  const std::string &name,
817  const size_t chan=0
818  ) = 0;
819 
820  /**************************************************************************
821  * Gain controls
822  *************************************************************************/
830  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
831 
844  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
845 
851  virtual void set_rx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
852 
858  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
859 
861  void set_rx_gain(double gain, size_t chan = 0){
862  return this->set_rx_gain(gain, ALL_GAINS, chan);
863  }
864 
881  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
882 
891  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
892 
900  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
901 
903  double get_rx_gain(size_t chan = 0){
904  return this->get_rx_gain(ALL_GAINS, chan);
905  }
906 
917  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
918 
926  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
927 
929  gain_range_t get_rx_gain_range(size_t chan = 0){
930  return this->get_rx_gain_range(ALL_GAINS, chan);
931  }
932 
939  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
940 
946  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
947 
953  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
954 
960  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
961 
967  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
968 
974  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
975 
981  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
982 
990  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
991 
998  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
999 
1005  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
1006 
1019  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
1020 
1028  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
1029 
1034  virtual meta_range_t get_rx_dc_offset_range(size_t chan = ALL_CHANS) = 0;
1035 
1042  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
1043 
1051  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1052 
1053  /*******************************************************************
1054  * TX methods
1055  ******************************************************************/
1064  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
1065 
1071  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1072 
1078  virtual size_t get_tx_num_channels(void) = 0;
1079 
1085  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1086 
1092  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1093 
1099  virtual double get_tx_rate(size_t chan = 0) = 0;
1100 
1106  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1107 
1114  virtual tune_result_t set_tx_freq(
1115  const tune_request_t &tune_request, size_t chan = 0
1116  ) = 0;
1117 
1123  virtual double get_tx_freq(size_t chan = 0) = 0;
1124 
1134  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1135 
1141  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1142 
1150  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
1151 
1164  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1165 
1171  virtual void set_tx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
1172 
1178  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1179 
1181  void set_tx_gain(double gain, size_t chan = 0){
1182  return this->set_tx_gain(gain, ALL_GAINS, chan);
1183  }
1184 
1195  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1196 
1204  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
1205 
1207  double get_tx_gain(size_t chan = 0){
1208  return this->get_tx_gain(ALL_GAINS, chan);
1209  }
1210 
1221  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1222 
1230  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
1231 
1234  return this->get_tx_gain_range(ALL_GAINS, chan);
1235  }
1236 
1243  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1244 
1250  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
1251 
1257  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1258 
1264  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1265 
1271  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1272 
1278  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1279 
1285  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1286 
1294  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1295 
1302  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
1303 
1309  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1310 
1317  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
1318 
1323  virtual meta_range_t get_tx_dc_offset_range(size_t chan = ALL_CHANS) = 0;
1324 
1332  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1333 
1334  /*******************************************************************
1335  * GPIO methods
1336  ******************************************************************/
1337 
1343  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1344 
1361  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;
1362 
1388  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;
1389 
1406  virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1407 
1433  virtual std::vector<std::string> get_gpio_string_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1434 
1435  /*******************************************************************
1436  * Register IO methods
1437  ******************************************************************/
1439  size_t bitwidth;
1440  bool readable;
1441  bool writable;
1442  };
1443 
1449  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1450 
1457  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1458 
1466  virtual void write_register(const std::string &path, const uint32_t field, const uint64_t value, const size_t mboard = 0) = 0;
1467 
1475  virtual uint64_t read_register(const std::string &path, const uint32_t field, const size_t mboard = 0) = 0;
1476 
1477  /*******************************************************************
1478  * Filter API methods
1479  ******************************************************************/
1480 
1491  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1492 
1498  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1499 
1507  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1508 
1509 };
1510 
1511 }}
1512 
1513 #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:929
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:1207
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:1181
Definition: time_spec.hpp:29
bool readable
Definition: multi_usrp.hpp:1440
boost::shared_ptr< device > sptr
Definition: device.hpp:31
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:96
Definition: multi_usrp.hpp:1438
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:903
Definition: tune_request.hpp:25
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:172
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:107
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:94
Definition: stream.hpp:58
#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:861
static const std::string ALL_LOS
A wildcard LO stage name.
Definition: multi_usrp.hpp:110
Definition: subdev_spec.hpp:62
bool writable
Definition: multi_usrp.hpp:1441
Definition: ranges.hpp:64
size_t bitwidth
Definition: multi_usrp.hpp:1439
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:248
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:1233
Definition: device_addr.hpp:38