USRP Hardware Driver and USRP Manual  Version: 4.6.0.0
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>
32 #include <uhd/types/filters.hpp>
33 #include <uhd/types/ranges.hpp>
34 #include <uhd/types/sensors.hpp>
35 #include <uhd/types/stream_cmd.hpp>
38 #include <uhd/types/wb_iface.hpp>
40 #include <uhd/usrp/subdev_spec.hpp>
42 #include <complex>
43 #include <memory>
44 #include <string>
45 #include <vector>
46 
47 namespace uhd { namespace usrp {
48 
96 {
97 public:
98  typedef std::shared_ptr<multi_usrp> sptr;
99 
100  virtual ~multi_usrp(void) = 0;
101 
103  static const size_t ALL_MBOARDS;
104 
106  static const size_t ALL_CHANS;
107 
109  static const std::string ALL_GAINS;
110 
112  static const std::string ALL_LOS;
113 
121  static sptr make(const device_addr_t& dev_addr);
122 
137  virtual device::sptr get_device(void) = 0;
138 
141  virtual uhd::property_tree::sptr get_tree(void) const = 0;
142 
144  virtual rx_streamer::sptr get_rx_stream(const stream_args_t& args) = 0;
145 
147  virtual tx_streamer::sptr get_tx_stream(const stream_args_t& args) = 0;
148 
156  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
157 
165  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
166 
167  /*******************************************************************
168  * Mboard methods
169  ******************************************************************/
170 
193  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
194 
200  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
201 
220  virtual meta_range_t get_master_clock_rate_range(const size_t mboard = 0) = 0;
221 
226  virtual std::string get_pp_string(void) = 0;
227 
233  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
234 
245  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
246 
257  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
258 
268  virtual void set_time_now(
269  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
270 
294  virtual void set_time_next_pps(
295  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
296 
312  virtual void set_time_unknown_pps(const time_spec_t& time_spec) = 0;
313 
320  virtual bool get_time_synchronized(void) = 0;
321 
332  virtual void set_command_time(
333  const uhd::time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
334 
340  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
341 
354  virtual void issue_stream_cmd(
355  const stream_cmd_t& stream_cmd, size_t chan = ALL_CHANS) = 0;
356 
399  virtual void set_time_source(
400  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
401 
407  virtual std::string get_time_source(const size_t mboard) = 0;
408 
414  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
415 
458  virtual void set_clock_source(
459  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
460 
466  virtual std::string get_clock_source(const size_t mboard) = 0;
467 
473  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
474 
485  virtual void set_sync_source(const std::string& clock_source,
486  const std::string& time_source,
487  const size_t mboard = ALL_MBOARDS) = 0;
488 
511  virtual void set_sync_source(
512  const device_addr_t& sync_source, const size_t mboard = ALL_MBOARDS) = 0;
513 
519  virtual device_addr_t get_sync_source(const size_t mboard) = 0;
520 
526  virtual std::vector<device_addr_t> get_sync_sources(const size_t mboard) = 0;
527 
542  virtual void set_clock_source_out(
543  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
544 
559  virtual void set_time_source_out(
560  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
561 
565  virtual size_t get_num_mboards(void) = 0;
566 
573  virtual sensor_value_t get_mboard_sensor(
574  const std::string& name, size_t mboard = 0) = 0;
575 
581  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
582 
592  virtual void set_user_register(
593  const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
594 
619  virtual uhd::wb_iface::sptr get_user_settings_iface(const size_t chan = 0) = 0;
620 
638  virtual uhd::rfnoc::radio_control& get_radio_control(const size_t chan = 0) = 0;
639 
647  virtual uhd::extension::extension::sptr get_extension(
648  const direction_t trx, const size_t chan) = 0;
649 
659  template <typename T>
660  typename T::sptr get_extension(const direction_t trx, const size_t chan)
661  {
662  return std::dynamic_pointer_cast<T>(get_extension(trx, chan));
663  }
664 
665  /*******************************************************************
666  * RX methods
667  ******************************************************************/
678  virtual void set_rx_subdev_spec(
679  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
680 
686  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
687 
693  virtual size_t get_rx_num_channels(void) = 0;
694 
700  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
701 
711  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
712 
722  virtual void set_rx_spp(const size_t spp, const size_t chan = ALL_CHANS) = 0;
723 
729  virtual double get_rx_rate(size_t chan = 0) = 0;
730 
736  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
737 
748  virtual tune_result_t set_rx_freq(
749  const tune_request_t& tune_request, size_t chan = 0) = 0;
750 
756  virtual double get_rx_freq(size_t chan = 0) = 0;
757 
767  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
768 
774  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
775 
776  /**************************************************************************
777  * LO controls
778  *************************************************************************/
792  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
793 
812  virtual void set_rx_lo_source(
813  const std::string& src, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
814 
823  virtual const std::string get_rx_lo_source(
824  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
825 
838  virtual std::vector<std::string> get_rx_lo_sources(
839  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
840 
851  virtual void set_rx_lo_export_enabled(
852  bool enabled, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
853 
859  virtual bool get_rx_lo_export_enabled(
860  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
861 
886  virtual double set_rx_lo_freq(
887  double freq, const std::string& name, size_t chan = 0) = 0;
888 
899  virtual double get_rx_lo_freq(const std::string& name, size_t chan = 0) = 0;
900 
910  virtual freq_range_t get_rx_lo_freq_range(
911  const std::string& name, size_t chan = 0) = 0;
912 
925  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
926 
942  virtual void set_tx_lo_source(const std::string& src,
943  const std::string& name = ALL_LOS,
944  const size_t chan = 0) = 0;
945 
954  virtual const std::string get_tx_lo_source(
955  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
956 
967  virtual std::vector<std::string> get_tx_lo_sources(
968  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
969 
980  virtual void set_tx_lo_export_enabled(
981  const bool enabled, const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
982 
988  virtual bool get_tx_lo_export_enabled(
989  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
990 
1015  virtual double set_tx_lo_freq(
1016  const double freq, const std::string& name, const size_t chan = 0) = 0;
1017 
1028  virtual double get_tx_lo_freq(const std::string& name, const size_t chan = 0) = 0;
1029 
1039  virtual freq_range_t get_tx_lo_freq_range(
1040  const std::string& name, const size_t chan = 0) = 0;
1041 
1042  /**************************************************************************
1043  * Gain controls
1044  *************************************************************************/
1058  virtual void set_rx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
1059 
1072  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
1073 
1082  virtual void set_rx_gain_profile(
1083  const std::string& profile, const size_t chan = 0) = 0;
1084 
1090  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
1091 
1093  void set_rx_gain(double gain, size_t chan = 0)
1094  {
1095  return this->set_rx_gain(gain, ALL_GAINS, chan);
1096  }
1097 
1115  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
1116 
1134  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
1135 
1143  virtual double get_rx_gain(const std::string& name, size_t chan = 0) = 0;
1144 
1146  double get_rx_gain(size_t chan = 0)
1147  {
1148  return this->get_rx_gain(ALL_GAINS, chan);
1149  }
1150 
1161  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
1162 
1170  virtual gain_range_t get_rx_gain_range(const std::string& name, size_t chan = 0) = 0;
1171 
1174  {
1175  return this->get_rx_gain_range(ALL_GAINS, chan);
1176  }
1177 
1184  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
1185 
1194  virtual void set_rx_antenna(const std::string& ant, size_t chan = 0) = 0;
1195 
1201  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
1202 
1208  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
1209 
1219  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1220 
1226  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
1227 
1233  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
1234 
1242  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
1243 
1250  virtual sensor_value_t get_rx_sensor(const std::string& name, size_t chan = 0) = 0;
1251 
1257  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
1258 
1271  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
1272 
1280  virtual void set_rx_dc_offset(
1281  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1282 
1287  virtual meta_range_t get_rx_dc_offset_range(size_t chan = 0) = 0;
1288 
1295  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
1296 
1304  virtual void set_rx_iq_balance(
1305  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1306 
1307 
1308  /**************************************************************************
1309  * Power level controls
1310  *************************************************************************/
1327  virtual bool has_rx_power_reference(const size_t chan = 0) = 0;
1328 
1343  virtual void set_rx_power_reference(
1344  const double power_dbm, const size_t chan = 0) = 0;
1345 
1358  virtual double get_rx_power_reference(const size_t chan = 0) = 0;
1359 
1369  virtual meta_range_t get_rx_power_range(const size_t chan) = 0;
1370 
1371  /*******************************************************************
1372  * TX methods
1373  ******************************************************************/
1383  virtual void set_tx_subdev_spec(
1384  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
1385 
1391  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1392 
1398  virtual size_t get_tx_num_channels(void) = 0;
1399 
1405  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1406 
1416  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1417 
1423  virtual double get_tx_rate(size_t chan = 0) = 0;
1424 
1430  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1431 
1442  virtual tune_result_t set_tx_freq(
1443  const tune_request_t& tune_request, size_t chan = 0) = 0;
1444 
1450  virtual double get_tx_freq(size_t chan = 0) = 0;
1451 
1461  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1462 
1468  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1469 
1483  virtual void set_tx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
1484 
1497  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1498 
1507  virtual void set_tx_gain_profile(
1508  const std::string& profile, const size_t chan = 0) = 0;
1509 
1515  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1516 
1518  void set_tx_gain(double gain, size_t chan = 0)
1519  {
1520  return this->set_tx_gain(gain, ALL_GAINS, chan);
1521  }
1522 
1535  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1536 
1544  virtual double get_tx_gain(const std::string& name, size_t chan = 0) = 0;
1545 
1547  double get_tx_gain(size_t chan = 0)
1548  {
1549  return this->get_tx_gain(ALL_GAINS, chan);
1550  }
1551 
1562  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1563 
1571  virtual gain_range_t get_tx_gain_range(const std::string& name, size_t chan = 0) = 0;
1572 
1575  {
1576  return this->get_tx_gain_range(ALL_GAINS, chan);
1577  }
1578 
1585  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1586 
1587  /**************************************************************************
1588  * Power level controls
1589  *************************************************************************/
1606  virtual bool has_tx_power_reference(const size_t chan = 0) = 0;
1607 
1622  virtual void set_tx_power_reference(
1623  const double power_dbm, const size_t chan = 0) = 0;
1624 
1637  virtual double get_tx_power_reference(const size_t chan = 0) = 0;
1638 
1648  virtual meta_range_t get_tx_power_range(const size_t chan) = 0;
1649 
1658  virtual void set_tx_antenna(const std::string& ant, size_t chan = 0) = 0;
1659 
1665  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1666 
1672  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1673 
1683  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1684 
1690  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1691 
1697  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1698 
1706  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1707 
1714  virtual sensor_value_t get_tx_sensor(const std::string& name, size_t chan = 0) = 0;
1715 
1721  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1722 
1729  virtual void set_tx_dc_offset(
1730  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1731 
1736  virtual meta_range_t get_tx_dc_offset_range(size_t chan = 0) = 0;
1737 
1745  virtual void set_tx_iq_balance(
1746  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1747 
1748  /*******************************************************************
1749  * GPIO methods
1750  ******************************************************************/
1751 
1757  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1758 
1811  virtual void set_gpio_attr(const std::string& bank,
1812  const std::string& attr,
1813  const uint32_t value,
1814  const uint32_t mask = 0xffffffff,
1815  const size_t mboard = 0) = 0;
1816 
1836  virtual uint32_t get_gpio_attr(
1837  const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
1838 
1855  virtual std::vector<std::string> get_gpio_src_banks(const size_t mboard = 0) = 0;
1856 
1867  virtual std::vector<std::string> get_gpio_srcs(
1868  const std::string& bank, const size_t mboard = 0) = 0;
1869 
1879  virtual std::vector<std::string> get_gpio_src(
1880  const std::string& bank, const size_t mboard = 0) = 0;
1881 
1896  virtual void set_gpio_src(const std::string& bank,
1897  const std::vector<std::string>& src,
1898  const size_t mboard = 0) = 0;
1899 
1900  /*******************************************************************
1901  * Filter API methods
1902  ******************************************************************/
1903  // TODO: This should be a const function, but I don't want to wrestle with the
1904  // compiler right now
1912  virtual std::vector<std::string> get_rx_filter_names(const size_t chan) = 0;
1913 
1920  virtual uhd::filter_info_base::sptr get_rx_filter(
1921  const std::string& name, const size_t chan) = 0;
1922 
1930  virtual void set_rx_filter(const std::string& name,
1932  const size_t chan) = 0;
1933 
1934  // TODO: This should be a const function, but I don't want to wrestle with the
1935  // compiler right now
1943  virtual std::vector<std::string> get_tx_filter_names(const size_t chan) = 0;
1944 
1951  virtual uhd::filter_info_base::sptr get_tx_filter(
1952  const std::string& name, const size_t chan) = 0;
1953 
1961  virtual void set_tx_filter(const std::string& name,
1963  const size_t chan) = 0;
1964 
1982  virtual uhd::rfnoc::mb_controller& get_mb_controller(const size_t mboard = 0) = 0;
1983 };
1984 
1985 }} // namespace uhd::usrp
std::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:169
gain_range_t get_rx_gain_range(size_t chan=0)
A convenience wrapper for getting overall RX gain range.
Definition: multi_usrp.hpp:1173
T::sptr get_extension(const direction_t trx, const size_t chan)
Definition: multi_usrp.hpp:660
Definition: stream_cmd.hpp:39
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:1547
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:1518
Definition: mb_controller.hpp:25
Definition: time_spec.hpp:28
static const size_t ALL_MBOARDS
A wildcard motherboard index.
Definition: multi_usrp.hpp:103
std::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:98
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:1146
Definition: tune_request.hpp:24
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:109
Definition: build_info.hpp:12
Definition: sensors.hpp:28
Definition: multi_usrp.hpp:95
source
Identify the source of calibration data, i.e., where was it stored.
Definition: database.hpp:23
std::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:55
direction_t
Definition: direction.hpp:12
Definition: stream.hpp:47
std::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:26
#define UHD_API
Definition: config.h:87
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:86
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:1093
static const std::string ALL_LOS
A wildcard LO stage name.
Definition: multi_usrp.hpp:112
Definition: radio_control.hpp:101
Definition: subdev_spec.hpp:59
std::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:267
Definition: ranges.hpp:65
std::shared_ptr< wb_iface > sptr
Definition: wb_iface.hpp:20
std::shared_ptr< property_tree > sptr
Definition: property_tree.hpp:223
static const size_t ALL_CHANS
A wildcard channel index.
Definition: multi_usrp.hpp:106
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:1574
std::shared_ptr< extension > sptr
Definition: extension.hpp:38
Definition: device_addr.hpp:37