USRP Hardware Driver and USRP Manual  Version: 4.7.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 
299  virtual void set_time_next_pps(
300  const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
301 
322  virtual void set_time_unknown_pps(const time_spec_t& time_spec) = 0;
323 
330  virtual bool get_time_synchronized(void) = 0;
331 
342  virtual void set_command_time(
343  const uhd::time_spec_t& time_spec, size_t mboard = ALL_MBOARDS) = 0;
344 
350  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
351 
364  virtual void issue_stream_cmd(
365  const stream_cmd_t& stream_cmd, size_t chan = ALL_CHANS) = 0;
366 
409  virtual void set_time_source(
410  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
411 
417  virtual std::string get_time_source(const size_t mboard) = 0;
418 
424  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
425 
476  virtual void set_clock_source(
477  const std::string& source, const size_t mboard = ALL_MBOARDS) = 0;
478 
484  virtual std::string get_clock_source(const size_t mboard) = 0;
485 
491  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
492 
503  virtual void set_sync_source(const std::string& clock_source,
504  const std::string& time_source,
505  const size_t mboard = ALL_MBOARDS) = 0;
506 
537  virtual void set_sync_source(
538  const device_addr_t& sync_source, const size_t mboard = ALL_MBOARDS) = 0;
539 
545  virtual device_addr_t get_sync_source(const size_t mboard) = 0;
546 
552  virtual std::vector<device_addr_t> get_sync_sources(const size_t mboard) = 0;
553 
568  virtual void set_clock_source_out(
569  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
570 
585  virtual void set_time_source_out(
586  const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
587 
591  virtual size_t get_num_mboards(void) = 0;
592 
599  virtual sensor_value_t get_mboard_sensor(
600  const std::string& name, size_t mboard = 0) = 0;
601 
607  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
608 
618  virtual void set_user_register(
619  const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
620 
645  virtual uhd::wb_iface::sptr get_user_settings_iface(const size_t chan = 0) = 0;
646 
664  virtual uhd::rfnoc::radio_control& get_radio_control(const size_t chan = 0) = 0;
665 
673  virtual uhd::extension::extension::sptr get_extension(
674  const direction_t trx, const size_t chan) = 0;
675 
685  template <typename T>
686  typename T::sptr get_extension(const direction_t trx, const size_t chan)
687  {
688  return std::dynamic_pointer_cast<T>(get_extension(trx, chan));
689  }
690 
691  /*******************************************************************
692  * RX methods
693  ******************************************************************/
704  virtual void set_rx_subdev_spec(
705  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
706 
712  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
713 
719  virtual size_t get_rx_num_channels(void) = 0;
720 
726  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
727 
737  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
738 
748  virtual void set_rx_spp(const size_t spp, const size_t chan = ALL_CHANS) = 0;
749 
755  virtual double get_rx_rate(size_t chan = 0) = 0;
756 
762  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
763 
774  virtual tune_result_t set_rx_freq(
775  const tune_request_t& tune_request, size_t chan = 0) = 0;
776 
782  virtual double get_rx_freq(size_t chan = 0) = 0;
783 
793  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
794 
800  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
801 
802  /**************************************************************************
803  * LO controls
804  *************************************************************************/
818  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
819 
838  virtual void set_rx_lo_source(
839  const std::string& src, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
840 
849  virtual const std::string get_rx_lo_source(
850  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
851 
864  virtual std::vector<std::string> get_rx_lo_sources(
865  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
866 
877  virtual void set_rx_lo_export_enabled(
878  bool enabled, const std::string& name = ALL_LOS, size_t chan = 0) = 0;
879 
885  virtual bool get_rx_lo_export_enabled(
886  const std::string& name = ALL_LOS, size_t chan = 0) = 0;
887 
912  virtual double set_rx_lo_freq(
913  double freq, const std::string& name, size_t chan = 0) = 0;
914 
925  virtual double get_rx_lo_freq(const std::string& name, size_t chan = 0) = 0;
926 
936  virtual freq_range_t get_rx_lo_freq_range(
937  const std::string& name, size_t chan = 0) = 0;
938 
951  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
952 
968  virtual void set_tx_lo_source(const std::string& src,
969  const std::string& name = ALL_LOS,
970  const size_t chan = 0) = 0;
971 
980  virtual const std::string get_tx_lo_source(
981  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
982 
993  virtual std::vector<std::string> get_tx_lo_sources(
994  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
995 
1006  virtual void set_tx_lo_export_enabled(
1007  const bool enabled, const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
1008 
1014  virtual bool get_tx_lo_export_enabled(
1015  const std::string& name = ALL_LOS, const size_t chan = 0) = 0;
1016 
1041  virtual double set_tx_lo_freq(
1042  const double freq, const std::string& name, const size_t chan = 0) = 0;
1043 
1054  virtual double get_tx_lo_freq(const std::string& name, const size_t chan = 0) = 0;
1055 
1065  virtual freq_range_t get_tx_lo_freq_range(
1066  const std::string& name, const size_t chan = 0) = 0;
1067 
1068  /**************************************************************************
1069  * Gain controls
1070  *************************************************************************/
1084  virtual void set_rx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
1085 
1098  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
1099 
1108  virtual void set_rx_gain_profile(
1109  const std::string& profile, const size_t chan = 0) = 0;
1110 
1116  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
1117 
1119  void set_rx_gain(double gain, size_t chan = 0)
1120  {
1121  return this->set_rx_gain(gain, ALL_GAINS, chan);
1122  }
1123 
1141  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
1142 
1160  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
1161 
1169  virtual double get_rx_gain(const std::string& name, size_t chan = 0) = 0;
1170 
1172  double get_rx_gain(size_t chan = 0)
1173  {
1174  return this->get_rx_gain(ALL_GAINS, chan);
1175  }
1176 
1187  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
1188 
1196  virtual gain_range_t get_rx_gain_range(const std::string& name, size_t chan = 0) = 0;
1197 
1200  {
1201  return this->get_rx_gain_range(ALL_GAINS, chan);
1202  }
1203 
1210  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
1211 
1220  virtual void set_rx_antenna(const std::string& ant, size_t chan = 0) = 0;
1221 
1227  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
1228 
1234  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
1235 
1245  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1246 
1252  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
1253 
1259  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
1260 
1268  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
1269 
1276  virtual sensor_value_t get_rx_sensor(const std::string& name, size_t chan = 0) = 0;
1277 
1283  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
1284 
1297  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
1298 
1306  virtual void set_rx_dc_offset(
1307  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1308 
1313  virtual meta_range_t get_rx_dc_offset_range(size_t chan = 0) = 0;
1314 
1321  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
1322 
1330  virtual void set_rx_iq_balance(
1331  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1332 
1333 
1334  /**************************************************************************
1335  * Power level controls
1336  *************************************************************************/
1353  virtual bool has_rx_power_reference(const size_t chan = 0) = 0;
1354 
1369  virtual void set_rx_power_reference(
1370  const double power_dbm, const size_t chan = 0) = 0;
1371 
1384  virtual double get_rx_power_reference(const size_t chan = 0) = 0;
1385 
1395  virtual meta_range_t get_rx_power_range(const size_t chan) = 0;
1396 
1397  /*******************************************************************
1398  * TX methods
1399  ******************************************************************/
1409  virtual void set_tx_subdev_spec(
1410  const uhd::usrp::subdev_spec_t& spec, size_t mboard = ALL_MBOARDS) = 0;
1411 
1417  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1418 
1424  virtual size_t get_tx_num_channels(void) = 0;
1425 
1431  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1432 
1442  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1443 
1449  virtual double get_tx_rate(size_t chan = 0) = 0;
1450 
1456  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1457 
1468  virtual tune_result_t set_tx_freq(
1469  const tune_request_t& tune_request, size_t chan = 0) = 0;
1470 
1476  virtual double get_tx_freq(size_t chan = 0) = 0;
1477 
1487  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1488 
1494  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1495 
1509  virtual void set_tx_gain(double gain, const std::string& name, size_t chan = 0) = 0;
1510 
1523  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1524 
1533  virtual void set_tx_gain_profile(
1534  const std::string& profile, const size_t chan = 0) = 0;
1535 
1541  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1542 
1544  void set_tx_gain(double gain, size_t chan = 0)
1545  {
1546  return this->set_tx_gain(gain, ALL_GAINS, chan);
1547  }
1548 
1561  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1562 
1570  virtual double get_tx_gain(const std::string& name, size_t chan = 0) = 0;
1571 
1573  double get_tx_gain(size_t chan = 0)
1574  {
1575  return this->get_tx_gain(ALL_GAINS, chan);
1576  }
1577 
1588  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1589 
1597  virtual gain_range_t get_tx_gain_range(const std::string& name, size_t chan = 0) = 0;
1598 
1601  {
1602  return this->get_tx_gain_range(ALL_GAINS, chan);
1603  }
1604 
1611  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1612 
1613  /**************************************************************************
1614  * Power level controls
1615  *************************************************************************/
1632  virtual bool has_tx_power_reference(const size_t chan = 0) = 0;
1633 
1648  virtual void set_tx_power_reference(
1649  const double power_dbm, const size_t chan = 0) = 0;
1650 
1663  virtual double get_tx_power_reference(const size_t chan = 0) = 0;
1664 
1674  virtual meta_range_t get_tx_power_range(const size_t chan) = 0;
1675 
1684  virtual void set_tx_antenna(const std::string& ant, size_t chan = 0) = 0;
1685 
1691  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1692 
1698  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1699 
1709  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1710 
1716  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1717 
1723  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1724 
1732  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1733 
1740  virtual sensor_value_t get_tx_sensor(const std::string& name, size_t chan = 0) = 0;
1741 
1747  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1748 
1755  virtual void set_tx_dc_offset(
1756  const std::complex<double>& offset, size_t chan = ALL_CHANS) = 0;
1757 
1762  virtual meta_range_t get_tx_dc_offset_range(size_t chan = 0) = 0;
1763 
1771  virtual void set_tx_iq_balance(
1772  const std::complex<double>& correction, size_t chan = ALL_CHANS) = 0;
1773 
1774  /*******************************************************************
1775  * GPIO methods
1776  ******************************************************************/
1777 
1783  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1784 
1837  virtual void set_gpio_attr(const std::string& bank,
1838  const std::string& attr,
1839  const uint32_t value,
1840  const uint32_t mask = 0xffffffff,
1841  const size_t mboard = 0) = 0;
1842 
1862  virtual uint32_t get_gpio_attr(
1863  const std::string& bank, const std::string& attr, const size_t mboard = 0) = 0;
1864 
1881  virtual std::vector<std::string> get_gpio_src_banks(const size_t mboard = 0) = 0;
1882 
1893  virtual std::vector<std::string> get_gpio_srcs(
1894  const std::string& bank, const size_t mboard = 0) = 0;
1895 
1905  virtual std::vector<std::string> get_gpio_src(
1906  const std::string& bank, const size_t mboard = 0) = 0;
1907 
1922  virtual void set_gpio_src(const std::string& bank,
1923  const std::vector<std::string>& src,
1924  const size_t mboard = 0) = 0;
1925 
1926  /*******************************************************************
1927  * Filter API methods
1928  ******************************************************************/
1929  // TODO: This should be a const function, but I don't want to wrestle with the
1930  // compiler right now
1938  virtual std::vector<std::string> get_rx_filter_names(const size_t chan) = 0;
1939 
1946  virtual uhd::filter_info_base::sptr get_rx_filter(
1947  const std::string& name, const size_t chan) = 0;
1948 
1956  virtual void set_rx_filter(const std::string& name,
1958  const size_t chan) = 0;
1959 
1960  // TODO: This should be a const function, but I don't want to wrestle with the
1961  // compiler right now
1969  virtual std::vector<std::string> get_tx_filter_names(const size_t chan) = 0;
1970 
1977  virtual uhd::filter_info_base::sptr get_tx_filter(
1978  const std::string& name, const size_t chan) = 0;
1979 
1987  virtual void set_tx_filter(const std::string& name,
1989  const size_t chan) = 0;
1990 
2008  virtual uhd::rfnoc::mb_controller& get_mb_controller(const size_t mboard = 0) = 0;
2009 };
2010 
2011 }} // 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:1199
T::sptr get_extension(const direction_t trx, const size_t chan)
Definition: multi_usrp.hpp:686
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:1573
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:1544
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:1172
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:56
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:1119
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:1600
std::shared_ptr< extension > sptr
Definition: extension.hpp:38
Definition: device_addr.hpp:37