USRP Hardware Driver and USRP Manual  Version: 4.6.0.0
UHD and USRP Manual
radio_control.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2019 Ettus Research, a National Instruments Brand
3 //
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 //
6 
7 #pragma once
8 
9 #include <uhd/config.hpp>
15 #include <uhd/types/direction.hpp>
16 #include <uhd/types/eeprom.hpp>
17 #include <uhd/types/ranges.hpp>
18 #include <uhd/types/sensors.hpp>
19 #include <uhd/types/stream_cmd.hpp>
20 
21 namespace uhd { namespace rfnoc {
22 
102  public rf_control::core_iface,
105 {
106 public:
107  static const std::string ALL_LOS;
108  static const std::string ALL_GAINS;
109  static constexpr size_t ALL_CHANS = size_t(~0);
110 
112 
113  /**************************************************************************
114  * Rate-Related API Calls
115  *************************************************************************/
117  //
118  // This function will coerce the rate and return the actual, current value.
119  virtual double set_rate(const double rate) = 0;
120 
122  virtual double get_rate() const = 0;
123 
125  virtual uhd::meta_range_t get_rate_range() const = 0;
126 
128  //
129  // Some radios may operate on multiple samples per clock cycle, usually in
130  // order to handle large bandwidths without requiring very fast FPGA clock
131  // rates.
132  //
133  // When the SPC value is greater than one, certain API calls may behave
134  // slightly differently. This is most relevant for issue_stream_cmd(). Other
135  // commands may round their execution time to the next integer multiple of
136  // SPC as well.
137  //
138  // Ultimately, the exact impact of SPC is device-dependent.
139  virtual size_t get_spc() const = 0;
140 
141  /**************************************************************************
142  * Time-Related API Calls
143  *************************************************************************/
148  virtual uint64_t get_ticks_now() = 0;
153  virtual uhd::time_spec_t get_time_now() = 0;
154 
155  /**************************************************************************
156  * RF-Related API Calls
157  *************************************************************************/
160  virtual std::vector<std::string> get_tx_gain_profile_names(
161  const size_t chan) const = 0;
162 
165  virtual std::vector<std::string> get_rx_gain_profile_names(
166  const size_t chan) const = 0;
167 
170  virtual void set_tx_gain_profile(const std::string& profile, const size_t chan) = 0;
171 
174  virtual void set_rx_gain_profile(const std::string& profile, const size_t chan) = 0;
175 
178  virtual std::string get_tx_gain_profile(const size_t chan) const = 0;
179 
182  virtual std::string get_rx_gain_profile(const size_t chan) const = 0;
183 
184  /**************************************************************************
185  * Calibration-Related API Calls
186  *************************************************************************/
194  virtual void set_tx_dc_offset(const std::complex<double>& offset, size_t chan) = 0;
195 
200  virtual meta_range_t get_tx_dc_offset_range(size_t chan) const = 0;
201 
209  virtual void set_tx_iq_balance(
210  const std::complex<double>& correction, size_t chan) = 0;
211 
223  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
224 
232  virtual void set_rx_dc_offset(const std::complex<double>& offset, size_t chan) = 0;
233 
238  virtual meta_range_t get_rx_dc_offset_range(size_t chan) const = 0;
239 
245  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
246 
252  virtual void set_rx_iq_balance(
253  const std::complex<double>& correction, size_t chan) = 0;
254 
255  /**************************************************************************
256  * GPIO Controls
257  *************************************************************************/
262  virtual std::vector<std::string> get_gpio_banks() const = 0;
263 
278  virtual void set_gpio_attr(
279  const std::string& bank, const std::string& attr, const uint32_t value) = 0;
280 
296  virtual uint32_t get_gpio_attr(const std::string& bank, const std::string& attr) = 0;
297 
298  /**************************************************************************
299  * Sensor API
300  *************************************************************************/
305  virtual std::vector<std::string> get_rx_sensor_names(size_t chan) const = 0;
306 
313  virtual uhd::sensor_value_t get_rx_sensor(const std::string& name, size_t chan) = 0;
314 
319  virtual std::vector<std::string> get_tx_sensor_names(size_t chan) const = 0;
320 
327  virtual uhd::sensor_value_t get_tx_sensor(const std::string& name, size_t chan) = 0;
328 
329  /**************************************************************************
330  * Streaming-Related API Calls
331  *************************************************************************/
346  virtual void issue_stream_cmd(
347  const uhd::stream_cmd_t& stream_cmd, const size_t port) = 0;
348 
351  virtual void enable_rx_timestamps(const bool enable, const size_t chan) = 0;
352 
353  /**************************************************************************
354  * Radio Identification API Calls
355  *************************************************************************/
357  virtual std::string get_slot_name() const = 0;
358 
360  //
361  // Example: "0" -> 0 (for UBX), or "A" -> 0 (for E310)
362  virtual size_t get_chan_from_dboard_fe(
363  const std::string& fe, const uhd::direction_t direction) const = 0;
364 
366  //
367  // Example: 0 -> "0" (for UBX), or 0 -> "A" (for E310)
368  virtual std::string get_dboard_fe_from_chan(
369  const size_t chan, const uhd::direction_t direction) const = 0;
370 
372  virtual std::string get_fe_name(
373  const size_t chan, const uhd::direction_t direction) const = 0;
374 
375  /**************************************************************************
376  * EEPROM API Calls
377  *************************************************************************/
379  //
380  // Note: EEPROMs have finite numbers of write cycles, so don't overuse this
381  // method!
382  virtual void set_db_eeprom(const uhd::eeprom_map_t& db_eeprom) = 0;
383 
385  virtual uhd::eeprom_map_t get_db_eeprom() = 0;
386 };
387 
388 }} // namespace uhd::rfnoc
virtual std::vector< std::string > get_rx_gain_profile_names(const size_t chan) const =0
static const std::string ALL_LOS
Definition: radio_control.hpp:107
Definition: stream_cmd.hpp:39
virtual uhd::time_spec_t get_time_now()=0
virtual uint64_t get_ticks_now()=0
Definition: time_spec.hpp:28
virtual void set_db_eeprom(const uhd::eeprom_map_t &db_eeprom)=0
Update the daughterboard EEPROM.
virtual double set_rate(const double rate)=0
Set the sample rate.
virtual void set_rx_dc_offset(const bool enb, size_t chan=ALL_CHANS)=0
virtual double get_rate() const =0
Get the sample rate.
std::map< std::string, std::vector< uint8_t > > eeprom_map_t
Definition: eeprom.hpp:16
#define RFNOC_DECLARE_BLOCK(CLASS_NAME)
Definition: noc_block_base.hpp:22
virtual void enable_rx_timestamps(const bool enable, const size_t chan)=0
Definition: build_info.hpp:12
virtual std::string get_fe_name(const size_t chan, const uhd::direction_t direction) const =0
Return the name of the frontend, as given by the dboard driver.
Definition: noc_block_base.hpp:42
Definition: sensors.hpp:28
static const std::string ALL_GAINS
Definition: radio_control.hpp:108
Definition: core_iface.hpp:25
virtual uint32_t get_gpio_attr(const std::string &bank, const std::string &attr)=0
Definition: power_reference_iface.hpp:22
virtual void set_tx_gain_profile(const std::string &profile, const size_t chan)=0
virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const uint32_t value)=0
virtual void set_tx_dc_offset(const std::complex< double > &offset, size_t chan)=0
Definition: discoverable_feature_getter_iface.hpp:17
virtual void set_rx_iq_balance(const bool enb, size_t chan)=0
virtual void issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd, const size_t port)=0
virtual meta_range_t get_tx_dc_offset_range(size_t chan) const =0
virtual std::vector< std::string > get_rx_sensor_names(size_t chan) const =0
virtual std::string get_tx_gain_profile(const size_t chan) const =0
direction_t
Definition: direction.hpp:12
virtual uhd::eeprom_map_t get_db_eeprom()=0
Return the content of the daughterboard EEPROM.
virtual std::string get_rx_gain_profile(const size_t chan) const =0
virtual size_t get_chan_from_dboard_fe(const std::string &fe, const uhd::direction_t direction) const =0
Return the channel that corresponds to a frontend&#39;s name.
static constexpr size_t ALL_CHANS
Definition: radio_control.hpp:109
Definition: radio_control.hpp:101
virtual void set_tx_iq_balance(const std::complex< double > &correction, size_t chan)=0
virtual size_t get_spc() const =0
Return the samples per clock (SPC) value of this radio.
virtual std::string get_slot_name() const =0
Returns this radio&#39;s slot name (typically "A" or "B")
Definition: ranges.hpp:65
virtual std::vector< std::string > get_tx_gain_profile_names(const size_t chan) const =0
virtual std::vector< std::string > get_tx_sensor_names(size_t chan) const =0
virtual void set_rx_gain_profile(const std::string &profile, const size_t chan)=0
virtual std::vector< std::string > get_gpio_banks() const =0
virtual uhd::sensor_value_t get_tx_sensor(const std::string &name, size_t chan)=0
virtual uhd::meta_range_t get_rate_range() const =0
Return a list of valid rates.
virtual std::string get_dboard_fe_from_chan(const size_t chan, const uhd::direction_t direction) const =0
Return the frontend name for a channel index.
virtual meta_range_t get_rx_dc_offset_range(size_t chan) const =0
virtual uhd::sensor_value_t get_rx_sensor(const std::string &name, size_t chan)=0