USRP Hardware Driver and USRP Manual  Version: 4.0.0.0-506-g6c213ecd0
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 #pragma once
9 
10 // define API capabilities for compile time detection of new features
11 #define UHD_USRP_MULTI_USRP_REF_SOURCES_API
12 #define UHD_USRP_MULTI_USRP_GET_RATES_API
13 #define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
14 #define UHD_USRP_MULTI_USRP_FRONTEND_IQ_AUTO_API
15 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
16 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
17 #define UHD_USRP_MULTI_USRP_USER_REGS_API
18 #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
19 #define UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
20 #define UHD_USRP_MULTI_USRP_GPIO_API
21 #define UHD_USRP_MULTI_USRP_REGISTER_API
22 #define UHD_USRP_MULTI_USRP_FILTER_API
23 #define UHD_USRP_MULTI_USRP_LO_CONFIG_API
24 #define UHD_USRP_MULTI_USRP_TX_LO_CONFIG_API
25 #define UHD_USRP_MULTI_USRP_POWER_LEVEL
26 
27 #include <uhd/config.hpp>
28 #include <uhd/device.hpp>
29 #include <uhd/types/filters.hpp>
30 #include <uhd/types/ranges.hpp>
31 #include <uhd/types/sensors.hpp>
32 #include <uhd/types/stream_cmd.hpp>
35 #include <uhd/types/wb_iface.hpp>
37 #include <uhd/usrp/subdev_spec.hpp>
40 #include <complex>
41 #include <memory>
42 #include <string>
43 #include <vector>
44 
45 namespace uhd {
46 class device3;
47 
48 namespace usrp {
49 
97 {
98 public:
99  typedef std::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 
138  virtual device::sptr get_device(void) = 0;
139 
142  virtual uhd::property_tree::sptr get_tree(void) const = 0;
143 
145  virtual rx_streamer::sptr get_rx_stream(const stream_args_t& args) = 0;
146 
148  virtual tx_streamer::sptr get_tx_stream(const stream_args_t& args) = 0;
149 
157  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
158 
166  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
167 
168  /*******************************************************************
169  * Mboard methods
170  ******************************************************************/
171 
194  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
195 
201  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
202 
221  virtual meta_range_t get_master_clock_rate_range(const size_t mboard = 0) = 0;
222 
227  virtual std::string get_pp_string(void) = 0;
228 
234  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
235 
241  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
242 
248  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
249 
261  virtual void set_time_now(
262  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
263 
276  virtual void set_time_next_pps(
277  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
278 
294  virtual void set_time_unknown_pps(const time_spec_t& time_spec) = 0;
295 
302  virtual bool get_time_synchronized(void) = 0;
303 
314  virtual void set_command_time(
315  const uhd::time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
316 
322  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
323 
336  virtual void issue_stream_cmd(
337  const stream_cmd_t& stream_cmd, size_t chan = ALL_CHANS) = 0;
338 
381  virtual void set_time_source(
382  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
383 
389  virtual std::string get_time_source(const size_t mboard) = 0;
390 
396  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
397 
440  virtual void set_clock_source(
441  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
442 
448  virtual std::string get_clock_source(const size_t mboard) = 0;
449 
455  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
456 
467  virtual void set_sync_source(const std::string& clock_source,
468  const std::string& time_source,
469  const size_t mboard = ALL_MBOARDS) = 0;
470 
493  virtual void set_sync_source(
494  const device_addr_t& sync_source, const size_t mboard = ALL_MBOARDS) = 0;
495 
501  virtual device_addr_t get_sync_source(const size_t mboard) = 0;
502 
508  virtual std::vector<device_addr_t> get_sync_sources(const size_t mboard) = 0;
509 
518  virtual void set_clock_source_out(
519  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
520 
529  virtual void set_time_source_out(
530  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
531 
535  virtual size_t get_num_mboards(void) = 0;
536 
543  virtual sensor_value_t get_mboard_sensor(
544  const std::string& name, size_t mboard = 0) = 0;
545 
551  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
552 
562  virtual void set_user_register(
563  const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
564 
589  virtual uhd::wb_iface::sptr get_user_settings_iface(const size_t chan = 0) = 0;
590 
608  virtual uhd::rfnoc::radio_control& get_radio_control(const size_t chan = 0) = 0;
609 
610  /*******************************************************************
611  * RX methods
612  ******************************************************************/
621  virtual void set_rx_subdev_spec(
622  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
623 
629  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
630 
636  virtual size_t get_rx_num_channels(void) = 0;
637 
643  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
644 
650  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
651 
661  virtual void set_rx_spp(const size_t spp, const size_t chan = ALL_CHANS) = 0;
662 
668  virtual double get_rx_rate(size_t chan = 0) = 0;
669 
675  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
676 
683  virtual tune_result_t set_rx_freq(
684  const tune_request_t& tune_request, size_t chan = 0) = 0;
685 
691  virtual double get_rx_freq(size_t chan = 0) = 0;
692 
702  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
703 
709  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
710 
711  /**************************************************************************
712  * LO controls
713  *************************************************************************/
727  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
728 
740  virtual void set_rx_lo_source(
741  const std::string& src, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
742 
751  virtual const std::string get_rx_lo_source(
752  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
753 
765  virtual std::vector<std::string> get_rx_lo_sources(
766  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
767 
778  virtual void set_rx_lo_export_enabled(
779  bool enabled, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
780 
786  virtual bool get_rx_lo_export_enabled(
787  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
788 
812  virtual double set_rx_lo_freq(
813  double freq, const std::string& name, size_t chan = 0) = 0;
814 
825  virtual double get_rx_lo_freq(const std::string& name, size_t chan = 0) = 0;
826 
836  virtual freq_range_t get_rx_lo_freq_range(
837  const std::string& name, size_t chan = 0) = 0;
838 
851  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
852 
864  virtual void set_tx_lo_source(const std::string& src,
865  const std::string& name = ALL_LOS,
866  const size_t chan = 0) = 0;
867 
876  virtual const std::string get_tx_lo_source(
877  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
878 
889  virtual std::vector<std::string> get_tx_lo_sources(
890  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
891 
902  virtual void set_tx_lo_export_enabled(
903  const bool enabled, const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
904 
910  virtual bool get_tx_lo_export_enabled(
911  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
912 
936  virtual double set_tx_lo_freq(
937  const double freq, const std::string& name, const size_t chan = 0) = 0;
938 
949  virtual double get_tx_lo_freq(const std::string& name, const size_t chan = 0) = 0;
950 
960  virtual freq_range_t get_tx_lo_freq_range(
961  const std::string& name, const size_t chan = 0) = 0;
962 
963  /**************************************************************************
964  * Gain controls
965  *************************************************************************/
973  virtual void set_rx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
974 
987  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
988 
994  virtual void set_rx_gain_profile(
995  const std::string& profile, const size_t chan = 0) = 0;
996 
1002  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
1003 
1005  void set_rx_gain(double gain, size_t chan = 0)
1006  {
1007  return this->set_rx_gain(gain, ALL_GAINS, chan);
1008  }
1009 
1026  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
1027 
1036  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
1037 
1045  virtual double get_rx_gain(const std::string& name, size_t chan = 0) = 0;
1046 
1048  double get_rx_gain(size_t chan = 0)
1049  {
1050  return this->get_rx_gain(ALL_GAINS, chan);
1051  }
1052 
1063  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
1064 
1072  virtual gain_range_t get_rx_gain_range(const std::string& name, size_t chan = 0) = 0;
1073 
1076  {
1077  return this->get_rx_gain_range(ALL_GAINS, chan);
1078  }
1079 
1086  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
1087 
1093  virtual void set_rx_antenna(const std::string& ant, size_t chan = 0) = 0;
1094 
1100  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
1101 
1107  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
1108 
1114  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1115 
1121  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
1122 
1128  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
1129 
1137  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
1138 
1145  virtual sensor_value_t get_rx_sensor(const std::string& name, size_t chan = 0) = 0;
1146 
1152  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
1153 
1166  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
1167 
1175  virtual void set_rx_dc_offset(
1176  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1177 
1182  virtual meta_range_t get_rx_dc_offset_range(size_t chan = 0) = 0;
1183 
1190  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
1191 
1199  virtual void set_rx_iq_balance(
1200  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1201 
1202 
1203  /**************************************************************************
1204  * Power level controls
1205  *************************************************************************/
1222  virtual bool has_rx_power_reference(const size_t chan = 0) = 0;
1223 
1238  virtual void set_rx_power_reference(
1239  const double power_dbm, const size_t chan = 0) = 0;
1240 
1253  virtual double get_rx_power_reference(const size_t chan = 0) = 0;
1254 
1255  /*******************************************************************
1256  * TX methods
1257  ******************************************************************/
1266  virtual void set_tx_subdev_spec(
1267  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
1268 
1274  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1275 
1281  virtual size_t get_tx_num_channels(void) = 0;
1282 
1288  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1289 
1295  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1296 
1302  virtual double get_tx_rate(size_t chan = 0) = 0;
1303 
1309  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1310 
1317  virtual tune_result_t set_tx_freq(
1318  const tune_request_t& tune_request, size_t chan = 0) = 0;
1319 
1325  virtual double get_tx_freq(size_t chan = 0) = 0;
1326 
1336  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1337 
1343  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1344 
1352  virtual void set_tx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
1353 
1366  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1367 
1373  virtual void set_tx_gain_profile(
1374  const std::string& profile, const size_t chan = 0) = 0;
1375 
1381  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1382 
1384  void set_tx_gain(double gain, size_t chan = 0)
1385  {
1386  return this->set_tx_gain(gain, ALL_GAINS, chan);
1387  }
1388 
1399  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1400 
1408  virtual double get_tx_gain(const std::string& name, size_t chan = 0) = 0;
1409 
1411  double get_tx_gain(size_t chan = 0)
1412  {
1413  return this->get_tx_gain(ALL_GAINS, chan);
1414  }
1415 
1426  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1427 
1435  virtual gain_range_t get_tx_gain_range(const std::string& name, size_t chan = 0) = 0;
1436 
1439  {
1440  return this->get_tx_gain_range(ALL_GAINS, chan);
1441  }
1442 
1449  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1450 
1451  /**************************************************************************
1452  * Power level controls
1453  *************************************************************************/
1470  virtual bool has_tx_power_reference(const size_t chan = 0) = 0;
1471 
1486  virtual void set_tx_power_reference(
1487  const double power_dbm, const size_t chan = 0) = 0;
1488 
1501  virtual double get_tx_power_reference(const size_t chan = 0) = 0;
1502 
1508  virtual void set_tx_antenna(const std::string& ant, size_t chan = 0) = 0;
1509 
1515  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1516 
1522  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1523 
1529  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1530 
1536  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1537 
1543  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1544 
1552  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1553 
1560  virtual sensor_value_t get_tx_sensor(const std::string& name, size_t chan = 0) = 0;
1561 
1567  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1568 
1575  virtual void set_tx_dc_offset(
1576  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1577 
1582  virtual meta_range_t get_tx_dc_offset_range(size_t chan = 0) = 0;
1583 
1591  virtual void set_tx_iq_balance(
1592  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1593 
1594  /*******************************************************************
1595  * GPIO methods
1596  ******************************************************************/
1597 
1603  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1604 
1621  virtual void set_gpio_attr(const std::string& bank,
1622  const std::string& attr,
1623  const uint32_t value,
1624  const uint32_t mask = 0xffffffff,
1625  const size_t mboard = 0) = 0;
1626 
1643  virtual uint32_t get_gpio_attr(
1644  const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
1645 
1659  virtual std::vector<std::string> get_gpio_src_banks(const size_t mboard = 0) = 0;
1660 
1671  virtual std::vector<std::string> get_gpio_srcs(
1672  const std::string& bank, const size_t mboard = 0) = 0;
1673 
1683  virtual std::vector<std::string> get_gpio_src(
1684  const std::string& bank, const size_t mboard = 0) = 0;
1685 
1696  virtual void set_gpio_src(const std::string& bank,
1697  const std::vector<std::string>& src,
1698  const size_t mboard = 0) = 0;
1699 
1700  /*******************************************************************
1701  * Filter API methods
1702  ******************************************************************/
1703  // TODO: This should be a const function, but I don't want to wrestle with the
1704  // compiler right now
1712  virtual std::vector<std::string> get_rx_filter_names(const size_t chan) = 0;
1713 
1720  virtual uhd::filter_info_base::sptr get_rx_filter(
1721  const std::string& name, const size_t chan) = 0;
1722 
1730  virtual void set_rx_filter(const std::string& name,
1732  const size_t chan) = 0;
1733 
1734  // TODO: This should be a const function, but I don't want to wrestle with the
1735  // compiler right now
1743  virtual std::vector<std::string> get_tx_filter_names(const size_t chan) = 0;
1744 
1751  virtual uhd::filter_info_base::sptr get_tx_filter(
1752  const std::string& name, const size_t chan) = 0;
1753 
1761  virtual void set_tx_filter(const std::string& name,
1763  const size_t chan) = 0;
1764 };
1765 
1766 } // namespace usrp
1767 } // namespace uhd
std::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:172
gain_range_t get_rx_gain_range(size_t chan=0)
A convenience wrapper for getting overall RX gain range.
Definition: multi_usrp.hpp:1075
Definition: stream_cmd.hpp:35
Definition: tune_result.hpp:18
double get_tx_gain(size_t chan=0)
A convenience wrapper for getting overall TX gain.
Definition: multi_usrp.hpp:1411
boost::noncopyable noncopyable
Definition: noncopyable.hpp:45
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:1384
Definition: time_spec.hpp:28
static const size_t ALL_MBOARDS
A wildcard motherboard index.
Definition: multi_usrp.hpp:104
std::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:99
std::shared_ptr< device > sptr
Definition: device.hpp:29
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:1048
Definition: tune_request.hpp:24
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:110
Definition: build_info.hpp:12
Definition: sensors.hpp:28
Definition: multi_usrp.hpp:96
source
Identify the source of calibration data, i.e., where was it stored.
Definition: database.hpp:22
std::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:55
Definition: stream.hpp:58
std::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:26
#define UHD_API
Definition: config.h:67
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:87
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:1005
static const std::string ALL_LOS
A wildcard LO stage name.
Definition: multi_usrp.hpp:113
Definition: radio_control.hpp:23
Definition: subdev_spec.hpp:59
std::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:250
Definition: ranges.hpp:64
std::shared_ptr< wb_iface > sptr
Definition: wb_iface.hpp:20
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:217
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:1438
Definition: device_addr.hpp:37