USRP Hardware Driver and USRP Manual  Version: 003.009.007-0-g50839059
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 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
19 #define INCLUDED_UHD_USRP_MULTI_USRP_HPP
20 
21 //define API capabilities for compile time detection of new features
22 #define UHD_USRP_MULTI_USRP_REF_SOURCES_API
23 #define UHD_USRP_MULTI_USRP_GET_RATES_API
24 #define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
25 #define UHD_USRP_MULTI_USRP_FRONTEND_IQ_AUTO_API
26 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
27 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
28 #define UHD_USRP_MULTI_USRP_USER_REGS_API
29 #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
30 #define UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
31 #define UHD_USRP_MULTI_USRP_GPIO_API
32 #define UHD_USRP_MULTI_USRP_REGISTER_API
33 #define UHD_USRP_MULTI_USRP_FILTER_API
34 
35 #include <uhd/config.hpp>
36 #include <uhd/device.hpp>
37 #include <uhd/deprecated.hpp>
38 #include <uhd/types/ranges.hpp>
39 #include <uhd/types/stream_cmd.hpp>
42 #include <uhd/types/sensors.hpp>
43 #include <uhd/types/filters.hpp>
44 #include <uhd/usrp/subdev_spec.hpp>
46 #include <boost/shared_ptr.hpp>
47 #include <boost/utility.hpp>
48 #include <complex>
49 #include <string>
50 #include <vector>
51 
52 namespace uhd{ namespace usrp{
53 
100 class UHD_API multi_usrp : boost::noncopyable{
101 public:
102  typedef boost::shared_ptr<multi_usrp> sptr;
103 
104  virtual ~multi_usrp(void) = 0;
105 
107  static const size_t ALL_MBOARDS = size_t(~0);
108 
110  static const size_t ALL_CHANS = size_t(~0);
111 
113  static const std::string ALL_GAINS;
114 
122  static sptr make(const device_addr_t &dev_addr);
123 
129  virtual device::sptr get_device(void) = 0;
130 
132  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
133 
135  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
136 
144  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
145 
153  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
154 
155  /*******************************************************************
156  * Mboard methods
157  ******************************************************************/
158 
181  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
182 
188  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
189 
194  virtual std::string get_pp_string(void) = 0;
195 
201  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
202 
208  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
209 
215  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
216 
228  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
229 
242  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
243 
259  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
260 
267  virtual bool get_time_synchronized(void) = 0;
268 
279  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
280 
286  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
287 
300  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
301 
310  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
311 
320  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
321 
327  virtual std::string get_time_source(const size_t mboard) = 0;
328 
334  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
335 
343  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
344 
350  virtual std::string get_clock_source(const size_t mboard) = 0;
351 
357  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
358 
367  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
368 
377  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
378 
382  virtual size_t get_num_mboards(void) = 0;
383 
390  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
391 
397  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
398 
406  virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
407 
408  /*******************************************************************
409  * RX methods
410  ******************************************************************/
419  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
420 
426  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
427 
433  virtual size_t get_rx_num_channels(void) = 0;
434 
440  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
441 
447  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
448 
454  virtual double get_rx_rate(size_t chan = 0) = 0;
455 
461  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
462 
469  virtual tune_result_t set_rx_freq(
470  const tune_request_t &tune_request, size_t chan = 0
471  ) = 0;
472 
478  virtual double get_rx_freq(size_t chan = 0) = 0;
479 
489  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
490 
496  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
497 
505  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
506 
508  void set_rx_gain(double gain, size_t chan = 0){
509  return this->set_rx_gain(gain, ALL_GAINS, chan);
510  }
511 
528  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
529 
538  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
539 
547  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
548 
550  double get_rx_gain(size_t chan = 0){
551  return this->get_rx_gain(ALL_GAINS, chan);
552  }
553 
564  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
565 
573  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
574 
576  gain_range_t get_rx_gain_range(size_t chan = 0){
577  return this->get_rx_gain_range(ALL_GAINS, chan);
578  }
579 
586  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
587 
593  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
594 
600  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
601 
607  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
608 
614  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
615 
621  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
622 
628  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
629 
637  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
638 
645  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
646 
652  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
653 
666  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
667 
675  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
676 
683  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
684 
692  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
693 
694  /*******************************************************************
695  * TX methods
696  ******************************************************************/
705  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
706 
712  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
713 
719  virtual size_t get_tx_num_channels(void) = 0;
720 
726  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
727 
733  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
734 
740  virtual double get_tx_rate(size_t chan = 0) = 0;
741 
747  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
748 
755  virtual tune_result_t set_tx_freq(
756  const tune_request_t &tune_request, size_t chan = 0
757  ) = 0;
758 
764  virtual double get_tx_freq(size_t chan = 0) = 0;
765 
775  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
776 
782  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
783 
791  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
792 
794  void set_tx_gain(double gain, size_t chan = 0){
795  return this->set_tx_gain(gain, ALL_GAINS, chan);
796  }
797 
808  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
809 
817  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
818 
820  double get_tx_gain(size_t chan = 0){
821  return this->get_tx_gain(ALL_GAINS, chan);
822  }
823 
834  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
835 
843  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
844 
846  gain_range_t get_tx_gain_range(size_t chan = 0){
847  return this->get_tx_gain_range(ALL_GAINS, chan);
848  }
849 
856  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
857 
863  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
864 
870  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
871 
877  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
878 
884  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
885 
891  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
892 
898  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
899 
907  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
908 
915  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
916 
922  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
923 
930  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
931 
939  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
940 
941  /*******************************************************************
942  * GPIO methods
943  ******************************************************************/
944 
950  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
951 
968  virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const boost::uint32_t value, const boost::uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
969 
986  virtual boost::uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
987 
988  /*******************************************************************
989  * Register IO methods
990  ******************************************************************/
992  size_t bitwidth;
993  bool readable;
994  bool writable;
995  };
996 
1002  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
1003 
1010  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1011 
1019  virtual void write_register(const std::string &path, const boost::uint32_t field, const boost::uint64_t value, const size_t mboard = 0) = 0;
1020 
1028  virtual boost::uint64_t read_register(const std::string &path, const boost::uint32_t field, const size_t mboard = 0) = 0;
1029 
1030  /*******************************************************************
1031  * Filter API methods
1032  ******************************************************************/
1033 
1044  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1045 
1051  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1052 
1060  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1061 
1062 };
1063 
1064 }}
1065 
1066 #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:576
Definition: stream_cmd.hpp:46
Definition: tune_result.hpp:29
double get_tx_gain(size_t chan=0)
A convenience wrapper for getting overall TX gain.
Definition: multi_usrp.hpp:820
size_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:98
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:794
Definition: time_spec.hpp:39
bool readable
Definition: multi_usrp.hpp:993
boost::shared_ptr< device > sptr
Definition: device.hpp:41
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:102
Definition: multi_usrp.hpp:991
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:550
Definition: tune_request.hpp:33
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:184
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:113
Definition: convert.hpp:28
Definition: sensors.hpp:38
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:38
Definition: clock_config.hpp:36
Definition: multi_usrp.hpp:100
Definition: stream.hpp:57
#define UHD_API
Definition: config.h:66
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:61
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:508
Definition: subdev_spec.hpp:66
bool writable
Definition: multi_usrp.hpp:994
Definition: ranges.hpp:68
size_t bitwidth
Definition: multi_usrp.hpp:992
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:260
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:846
Definition: device_addr.hpp:47