USRP Hardware Driver and USRP Manual  Version: 3.15.0.HEAD-0-gaea0e2de
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 #define UHD_USRP_MULTI_USRP_TX_LO_CONFIG_API
26 
27 #include <uhd/config.hpp>
28 #include <uhd/deprecated.hpp>
29 #include <uhd/device.hpp>
30 #include <uhd/types/filters.hpp>
31 #include <uhd/types/ranges.hpp>
32 #include <uhd/types/sensors.hpp>
33 #include <uhd/types/stream_cmd.hpp>
36 #include <uhd/types/wb_iface.hpp>
38 #include <uhd/usrp/subdev_spec.hpp>
39 #include <boost/shared_ptr.hpp>
41 #include <complex>
42 #include <string>
43 #include <vector>
44 
45 namespace uhd {
46 class device3;
47 
48 namespace usrp {
49 
97 {
98 public:
99  typedef boost::shared_ptr<multi_usrp> sptr;
100 
101  virtual ~multi_usrp(void) = 0;
102 
104  static const size_t ALL_MBOARDS;
105 
107  static const size_t ALL_CHANS;
108 
110  static const std::string ALL_GAINS;
111 
113  static const std::string ALL_LOS;
114 
122  static sptr make(const device_addr_t& dev_addr);
123 
129  virtual device::sptr get_device(void) = 0;
130 
133  virtual bool is_device3(void) = 0;
134 
143  virtual boost::shared_ptr<uhd::device3> get_device3(void) = 0;
144 
146  virtual rx_streamer::sptr get_rx_stream(const stream_args_t& args) = 0;
147 
149  virtual tx_streamer::sptr get_tx_stream(const stream_args_t& args) = 0;
150 
158  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
159 
167  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
168 
169  /*******************************************************************
170  * Mboard methods
171  ******************************************************************/
172 
195  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
196 
202  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
203 
222  virtual meta_range_t get_master_clock_rate_range(const size_t mboard = 0) = 0;
223 
228  virtual std::string get_pp_string(void) = 0;
229 
235  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
236 
242  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
243 
249  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
250 
262  virtual void set_time_now(
263  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
264 
277  virtual void set_time_next_pps(
278  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
279 
295  virtual void set_time_unknown_pps(const time_spec_t& time_spec) = 0;
296 
303  virtual bool get_time_synchronized(void) = 0;
304 
315  virtual void set_command_time(
316  const uhd::time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
317 
323  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
324 
337  virtual void issue_stream_cmd(
338  const stream_cmd_t& stream_cmd, size_t chan = ALL_CHANS) = 0;
339 
348  virtual void set_clock_config(
349  const clock_config_t& clock_config, size_t mboard = ALL_MBOARDS) = 0;
350 
393  virtual void set_time_source(
394  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
395 
401  virtual std::string get_time_source(const size_t mboard) = 0;
402 
408  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
409 
452  virtual void set_clock_source(
453  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
454 
460  virtual std::string get_clock_source(const size_t mboard) = 0;
461 
467  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
468 
479  virtual void set_sync_source(const std::string& clock_source,
480  const std::string& time_source,
481  const size_t mboard = ALL_MBOARDS) = 0;
482 
505  virtual void set_sync_source(
506  const device_addr_t& sync_source, const size_t mboard = ALL_MBOARDS) = 0;
507 
513  virtual device_addr_t get_sync_source(const size_t mboard) = 0;
514 
520  virtual std::vector<device_addr_t> get_sync_sources(const size_t mboard) = 0;
521 
530  virtual void set_clock_source_out(
531  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
532 
541  virtual void set_time_source_out(
542  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
543 
547  virtual size_t get_num_mboards(void) = 0;
548 
555  virtual sensor_value_t get_mboard_sensor(
556  const std::string& name, size_t mboard = 0) = 0;
557 
563  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
564 
572  virtual void set_user_register(
573  const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
574 
599  virtual uhd::wb_iface::sptr get_user_settings_iface(const size_t chan = 0) = 0;
600 
601  /*******************************************************************
602  * RX methods
603  ******************************************************************/
612  virtual void set_rx_subdev_spec(
613  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
614 
620  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
621 
627  virtual size_t get_rx_num_channels(void) = 0;
628 
634  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
635 
641  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
642 
648  virtual double get_rx_rate(size_t chan = 0) = 0;
649 
655  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
656 
663  virtual tune_result_t set_rx_freq(
664  const tune_request_t& tune_request, size_t chan = 0) = 0;
665 
671  virtual double get_rx_freq(size_t chan = 0) = 0;
672 
682  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
683 
689  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
690 
691  /**************************************************************************
692  * LO controls
693  *************************************************************************/
707  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
708 
720  virtual void set_rx_lo_source(
721  const std::string& src, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
722 
731  virtual const std::string get_rx_lo_source(
732  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
733 
745  virtual std::vector<std::string> get_rx_lo_sources(
746  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
747 
758  virtual void set_rx_lo_export_enabled(
759  bool enabled, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
760 
766  virtual bool get_rx_lo_export_enabled(
767  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
768 
792  virtual double set_rx_lo_freq(
793  double freq, const std::string& name, size_t chan = 0) = 0;
794 
805  virtual double get_rx_lo_freq(const std::string& name, size_t chan = 0) = 0;
806 
816  virtual freq_range_t get_rx_lo_freq_range(
817  const std::string& name, size_t chan = 0) = 0;
818 
831  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
832 
844  virtual void set_tx_lo_source(const std::string& src,
845  const std::string& name = ALL_LOS,
846  const size_t chan = 0) = 0;
847 
856  virtual const std::string get_tx_lo_source(
857  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
858 
869  virtual std::vector<std::string> get_tx_lo_sources(
870  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
871 
882  virtual void set_tx_lo_export_enabled(
883  const bool enabled, const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
884 
890  virtual bool get_tx_lo_export_enabled(
891  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
892 
916  virtual double set_tx_lo_freq(
917  const double freq, const std::string& name, const size_t chan = 0) = 0;
918 
929  virtual double get_tx_lo_freq(const std::string& name, const size_t chan = 0) = 0;
930 
940  virtual freq_range_t get_tx_lo_freq_range(
941  const std::string& name, const size_t chan = 0) = 0;
942 
943  /**************************************************************************
944  * Gain controls
945  *************************************************************************/
953  virtual void set_rx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
954 
967  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
968 
974  virtual void set_rx_gain_profile(
975  const std::string& profile, const size_t chan = 0) = 0;
976 
982  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
983 
985  void set_rx_gain(double gain, size_t chan = 0)
986  {
987  return this->set_rx_gain(gain, ALL_GAINS, chan);
988  }
989 
1006  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
1007 
1016  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
1017 
1025  virtual double get_rx_gain(const std::string& name, size_t chan = 0) = 0;
1026 
1028  double get_rx_gain(size_t chan = 0)
1029  {
1030  return this->get_rx_gain(ALL_GAINS, chan);
1031  }
1032 
1043  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
1044 
1052  virtual gain_range_t get_rx_gain_range(const std::string& name, size_t chan = 0) = 0;
1053 
1056  {
1057  return this->get_rx_gain_range(ALL_GAINS, chan);
1058  }
1059 
1066  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
1067 
1073  virtual void set_rx_antenna(const std::string& ant, size_t chan = 0) = 0;
1074 
1080  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
1081 
1087  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
1088 
1094  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1095 
1101  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
1102 
1108  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
1109 
1117  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
1118 
1125  virtual sensor_value_t get_rx_sensor(const std::string& name, size_t chan = 0) = 0;
1126 
1132  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
1133 
1146  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
1147 
1155  virtual void set_rx_dc_offset(
1156  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1157 
1162  virtual meta_range_t get_rx_dc_offset_range(size_t chan = 0) = 0;
1163 
1170  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
1171 
1179  virtual void set_rx_iq_balance(
1180  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1181 
1182  /*******************************************************************
1183  * TX methods
1184  ******************************************************************/
1193  virtual void set_tx_subdev_spec(
1194  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
1195 
1201  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1202 
1208  virtual size_t get_tx_num_channels(void) = 0;
1209 
1215  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1216 
1222  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1223 
1229  virtual double get_tx_rate(size_t chan = 0) = 0;
1230 
1236  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1237 
1244  virtual tune_result_t set_tx_freq(
1245  const tune_request_t& tune_request, size_t chan = 0) = 0;
1246 
1252  virtual double get_tx_freq(size_t chan = 0) = 0;
1253 
1263  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1264 
1270  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1271 
1279  virtual void set_tx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
1280 
1293  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1294 
1300  virtual void set_tx_gain_profile(
1301  const std::string& profile, const size_t chan = 0) = 0;
1302 
1308  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1309 
1311  void set_tx_gain(double gain, size_t chan = 0)
1312  {
1313  return this->set_tx_gain(gain, ALL_GAINS, chan);
1314  }
1315 
1326  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1327 
1335  virtual double get_tx_gain(const std::string& name, size_t chan = 0) = 0;
1336 
1338  double get_tx_gain(size_t chan = 0)
1339  {
1340  return this->get_tx_gain(ALL_GAINS, chan);
1341  }
1342 
1353  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1354 
1362  virtual gain_range_t get_tx_gain_range(const std::string& name, size_t chan = 0) = 0;
1363 
1366  {
1367  return this->get_tx_gain_range(ALL_GAINS, chan);
1368  }
1369 
1376  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1377 
1383  virtual void set_tx_antenna(const std::string& ant, size_t chan = 0) = 0;
1384 
1390  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1391 
1397  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1398 
1404  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1405 
1411  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1412 
1418  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1419 
1427  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1428 
1435  virtual sensor_value_t get_tx_sensor(const std::string& name, size_t chan = 0) = 0;
1436 
1442  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1443 
1450  virtual void set_tx_dc_offset(
1451  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1452 
1457  virtual meta_range_t get_tx_dc_offset_range(size_t chan = 0) = 0;
1458 
1466  virtual void set_tx_iq_balance(
1467  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1468 
1469  /*******************************************************************
1470  * GPIO methods
1471  ******************************************************************/
1472 
1478  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1479 
1496  virtual void set_gpio_attr(const std::string& bank,
1497  const std::string& attr,
1498  const uint32_t value,
1499  const uint32_t mask = 0xffffffff,
1500  const size_t mboard = 0) = 0;
1501 
1532  virtual void set_gpio_attr(const std::string& bank,
1533  const std::string& attr,
1534  const std::string& value,
1535  const uint32_t mask = 0xffffffff,
1536  const size_t mboard = 0) = 0;
1537 
1554  virtual uint32_t get_gpio_attr(
1555  const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
1556 
1590  virtual std::vector<std::string> get_gpio_string_attr(
1591  const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
1592 
1593  /*******************************************************************
1594  * Register IO methods
1595  ******************************************************************/
1597  {
1598  size_t bitwidth;
1599  bool readable;
1600  bool writable;
1601  };
1602 
1608  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1609 
1617  virtual register_info_t get_register_info(
1618  const std::string& path, const size_t mboard = 0) = 0;
1619 
1627  virtual void write_register(const std::string& path,
1628  const uint32_t field,
1629  const uint64_t value,
1630  const size_t mboard = 0) = 0;
1631 
1639  virtual uint64_t read_register(
1640  const std::string& path, const uint32_t field, const size_t mboard = 0) = 0;
1641 
1642  /*******************************************************************
1643  * Filter API methods
1644  ******************************************************************/
1645 
1656  virtual std::vector<std::string> get_filter_names(
1657  const std::string& search_mask = "") = 0;
1658 
1664  virtual filter_info_base::sptr get_filter(const std::string& path) = 0;
1665 
1673  virtual void set_filter(const std::string& path, filter_info_base::sptr filter) = 0;
1674 };
1675 
1676 } // namespace usrp
1677 } // namespace uhd
1678 
1679 #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:1055
boost::shared_ptr< wb_iface > sptr
Definition: wb_iface.hpp:21
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:1338
boost::noncopyable noncopyable
Definition: noncopyable.hpp:46
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:1311
Definition: time_spec.hpp:29
static const size_t ALL_MBOARDS
A wildcard motherboard index.
Definition: multi_usrp.hpp:104
bool readable
Definition: multi_usrp.hpp:1599
boost::shared_ptr< device > sptr
Definition: device.hpp:31
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:99
Definition: multi_usrp.hpp:1596
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:1028
Definition: tune_request.hpp:25
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:173
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:110
Definition: build_info.hpp:13
Definition: sensors.hpp:29
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:27
Definition: clock_config.hpp:26
Definition: multi_usrp.hpp:96
Definition: stream.hpp:59
#define UHD_API
Definition: config.h:68
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:88
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:56
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:985
static const std::string ALL_LOS
A wildcard LO stage name.
Definition: multi_usrp.hpp:113
Definition: subdev_spec.hpp:60
bool writable
Definition: multi_usrp.hpp:1600
Definition: ranges.hpp:65
size_t bitwidth
Definition: multi_usrp.hpp:1598
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:251
static const size_t ALL_CHANS
A wildcard channel index.
Definition: multi_usrp.hpp:107
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:1365
Definition: device_addr.hpp:38