USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
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 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
8 #define INCLUDED_UHD_USRP_MULTI_USRP_HPP
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 
25 #include <uhd/config.hpp>
26 #include <uhd/device.hpp>
27 #include <uhd/deprecated.hpp>
28 #include <uhd/types/ranges.hpp>
29 #include <uhd/types/stream_cmd.hpp>
32 #include <uhd/types/sensors.hpp>
33 #include <uhd/types/filters.hpp>
34 #include <uhd/usrp/subdev_spec.hpp>
36 #include <boost/shared_ptr.hpp>
37 #include <boost/utility.hpp>
38 #include <complex>
39 #include <string>
40 #include <vector>
41 
42 namespace uhd{ namespace usrp{
43 
90 class UHD_API multi_usrp : boost::noncopyable{
91 public:
92  typedef boost::shared_ptr<multi_usrp> sptr;
93 
94  virtual ~multi_usrp(void) = 0;
95 
97  static const size_t ALL_MBOARDS = size_t(~0);
98 
100  static const size_t ALL_CHANS = size_t(~0);
101 
103  static const std::string ALL_GAINS;
104 
106  static const std::string ALL_LOS;
107 
115  static sptr make(const device_addr_t &dev_addr);
116 
122  virtual device::sptr get_device(void) = 0;
123 
125  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
126 
128  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
129 
137  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
138 
146  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
147 
148  /*******************************************************************
149  * Mboard methods
150  ******************************************************************/
151 
174  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
175 
181  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
182 
187  virtual std::string get_pp_string(void) = 0;
188 
194  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
195 
201  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
202 
208  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
209 
221  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
222 
235  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
236 
252  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
253 
260  virtual bool get_time_synchronized(void) = 0;
261 
272  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
273 
279  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
280 
293  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
294 
303  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
304 
313  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
314 
320  virtual std::string get_time_source(const size_t mboard) = 0;
321 
327  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
328 
336  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
337 
343  virtual std::string get_clock_source(const size_t mboard) = 0;
344 
350  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
351 
360  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
361 
370  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
371 
375  virtual size_t get_num_mboards(void) = 0;
376 
383  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
384 
390  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
391 
399  virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
400 
401  /*******************************************************************
402  * RX methods
403  ******************************************************************/
412  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
413 
419  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
420 
426  virtual size_t get_rx_num_channels(void) = 0;
427 
433  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
434 
440  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
441 
447  virtual double get_rx_rate(size_t chan = 0) = 0;
448 
454  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
455 
462  virtual tune_result_t set_rx_freq(
463  const tune_request_t &tune_request, size_t chan = 0
464  ) = 0;
465 
471  virtual double get_rx_freq(size_t chan = 0) = 0;
472 
482  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
483 
489  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
490 
491  /**************************************************************************
492  * LO controls
493  *************************************************************************/
507  virtual std::vector<std::string> get_rx_lo_names(size_t chan = 0) = 0;
508 
520  virtual void set_rx_lo_source(
521  const std::string &src,
522  const std::string &name = ALL_LOS,
523  size_t chan = 0
524  ) = 0;
525 
534  virtual const std::string get_rx_lo_source(
535  const std::string &name = ALL_LOS,
536  size_t chan = 0
537  ) = 0;
538 
550  virtual std::vector<std::string> get_rx_lo_sources(
551  const std::string &name = ALL_LOS,
552  size_t chan = 0
553  ) = 0;
554 
565  virtual void set_rx_lo_export_enabled(
566  bool enabled,
567  const std::string &name = ALL_LOS,
568  size_t chan = 0
569  ) = 0;
570 
576  virtual bool get_rx_lo_export_enabled(
577  const std::string &name = ALL_LOS,
578  size_t chan = 0
579  ) = 0;
580 
604  virtual double set_rx_lo_freq(
605  double freq,
606  const std::string &name,
607  size_t chan = 0
608  ) = 0;
609 
620  virtual double get_rx_lo_freq(
621  const std::string &name,
622  size_t chan = 0
623  ) = 0;
624 
634  virtual freq_range_t get_rx_lo_freq_range(
635  const std::string &name,
636  size_t chan = 0
637  ) = 0;
638 
651  virtual std::vector<std::string> get_tx_lo_names(size_t chan = 0) = 0;
652 
664  virtual void set_tx_lo_source(
665  const std::string &src,
666  const std::string &name = ALL_LOS,
667  const size_t chan = 0
668  ) = 0;
669 
678  virtual const std::string get_tx_lo_source(
679  const std::string &name = ALL_LOS,
680  const size_t chan = 0
681  ) = 0;
682 
693  virtual std::vector<std::string> get_tx_lo_sources(
694  const std::string &name = ALL_LOS,
695  const size_t chan = 0
696  ) = 0;
697 
708  virtual void set_tx_lo_export_enabled(
709  const bool enabled,
710  const std::string &name = ALL_LOS,
711  const size_t chan = 0
712  ) = 0;
713 
719  virtual bool get_tx_lo_export_enabled(
720  const std::string &name = ALL_LOS,
721  const size_t chan = 0
722  ) = 0;
723 
747  virtual double set_tx_lo_freq(
748  const double freq,
749  const std::string &name,
750  const size_t chan=0
751  ) = 0;
752 
763  virtual double get_tx_lo_freq(
764  const std::string &name,
765  const size_t chan=0
766  ) = 0;
767 
777  virtual freq_range_t get_tx_lo_freq_range(
778  const std::string &name,
779  const size_t chan=0
780  ) = 0;
781 
782  /**************************************************************************
783  * Gain controls
784  *************************************************************************/
792  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
793 
806  virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0;
807 
813  virtual void set_rx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
814 
820  virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0;
821 
823  void set_rx_gain(double gain, size_t chan = 0){
824  return this->set_rx_gain(gain, ALL_GAINS, chan);
825  }
826 
843  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
844 
853  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
854 
862  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
863 
865  double get_rx_gain(size_t chan = 0){
866  return this->get_rx_gain(ALL_GAINS, chan);
867  }
868 
879  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
880 
888  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
889 
891  gain_range_t get_rx_gain_range(size_t chan = 0){
892  return this->get_rx_gain_range(ALL_GAINS, chan);
893  }
894 
901  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
902 
908  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
909 
915  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
916 
922  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
923 
929  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
930 
936  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
937 
943  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
944 
952  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
953 
960  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
961 
967  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
968 
981  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
982 
990  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
991 
998  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
999 
1007  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1008 
1009  /*******************************************************************
1010  * TX methods
1011  ******************************************************************/
1020  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
1021 
1027  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
1028 
1034  virtual size_t get_tx_num_channels(void) = 0;
1035 
1041  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
1042 
1048  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
1049 
1055  virtual double get_tx_rate(size_t chan = 0) = 0;
1056 
1062  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
1063 
1070  virtual tune_result_t set_tx_freq(
1071  const tune_request_t &tune_request, size_t chan = 0
1072  ) = 0;
1073 
1079  virtual double get_tx_freq(size_t chan = 0) = 0;
1080 
1090  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
1091 
1097  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
1098 
1106  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
1107 
1120  virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0;
1121 
1127  virtual void set_tx_gain_profile(const std::string& profile, const size_t chan = 0) = 0;
1128 
1134  virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0;
1135 
1137  void set_tx_gain(double gain, size_t chan = 0){
1138  return this->set_tx_gain(gain, ALL_GAINS, chan);
1139  }
1140 
1151  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
1152 
1160  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
1161 
1163  double get_tx_gain(size_t chan = 0){
1164  return this->get_tx_gain(ALL_GAINS, chan);
1165  }
1166 
1177  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
1178 
1186  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
1187 
1190  return this->get_tx_gain_range(ALL_GAINS, chan);
1191  }
1192 
1199  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
1200 
1206  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
1207 
1213  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
1214 
1220  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
1221 
1227  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
1228 
1234  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
1235 
1241  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
1242 
1250  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
1251 
1258  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
1259 
1265  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
1266 
1273  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
1274 
1282  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
1283 
1284  /*******************************************************************
1285  * GPIO methods
1286  ******************************************************************/
1287 
1293  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
1294 
1311  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;
1312 
1329  virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
1330 
1331  /*******************************************************************
1332  * Register IO methods
1333  ******************************************************************/
1335  size_t bitwidth;
1336  bool readable;
1337  bool writable;
1338  };
1339 
1345  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1346 
1353  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1354 
1362  virtual void write_register(const std::string &path, const uint32_t field, const uint64_t value, const size_t mboard = 0) = 0;
1363 
1371  virtual uint64_t read_register(const std::string &path, const uint32_t field, const size_t mboard = 0) = 0;
1372 
1373  /*******************************************************************
1374  * Filter API methods
1375  ******************************************************************/
1376 
1387  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1388 
1394  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1395 
1403  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1404 
1405 };
1406 
1407 }}
1408 
1409 #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:891
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:1163
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:1137
Definition: time_spec.hpp:28
bool readable
Definition: multi_usrp.hpp:1336
boost::shared_ptr< device > sptr
Definition: device.hpp:30
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:92
Definition: multi_usrp.hpp:1334
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:865
Definition: tune_request.hpp:22
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:160
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:103
Definition: build_info.hpp:14
Definition: sensors.hpp:28
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:27
Definition: clock_config.hpp:25
Definition: multi_usrp.hpp:90
Definition: stream.hpp:46
#define UHD_API
Definition: config.h:62
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:86
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:53
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:823
static const std::string ALL_LOS
A wildcard LO stage name.
Definition: multi_usrp.hpp:106
Definition: subdev_spec.hpp:61
bool writable
Definition: multi_usrp.hpp:1337
Definition: ranges.hpp:63
size_t bitwidth
Definition: multi_usrp.hpp:1335
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:236
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:1189
Definition: device_addr.hpp:36