GNU Radio 3.3.0 C++ API
|
base class for GNU Radio interface to the USRP More...
#include <usrp_base.h>
Public Member Functions | |
virtual | ~usrp_base () |
std::vector< std::vector < db_base_sptr > > | db () |
std::vector< db_base_sptr > | db (int which_side) |
db_base_sptr | db (int which_side, int which_dev) |
db_base_sptr | selected_subdev (usrp_subdev_spec ss) |
given a usrp_subdev_spec, return the corresponding daughterboard object. | |
long | fpga_master_clock_freq () const |
return frequency of master oscillator on USRP | |
void | set_fpga_master_clock_freq (long master_clock) |
void | set_verbose (bool on) |
bool | write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf) |
Write EEPROM on motherboard or any daughterboard. | |
std::string | read_eeprom (int i2c_addr, int eeprom_offset, int len) |
Read EEPROM on motherboard or any daughterboard. | |
bool | write_i2c (int i2c_addr, const std::string buf) |
Write to I2C peripheral. | |
std::string | read_i2c (int i2c_addr, int len) |
Read from I2C peripheral. | |
bool | set_adc_offset (int which_adc, int offset) |
Set ADC offset correction. | |
bool | set_dac_offset (int which_dac, int offset, int offset_pin) |
Set DAC offset correction. | |
bool | set_adc_buffer_bypass (int which_adc, bool bypass) |
Control ADC input buffer. | |
bool | set_dc_offset_cl_enable (int bits, int mask) |
Enable/disable automatic DC offset removal control loop in FPGA. | |
std::string | serial_number () |
return the usrp's serial number. | |
virtual int | daughterboard_id (int which_side) const |
Return daughterboard ID for given side [0,1]. | |
bool | write_atr_tx_delay (int value) |
Clock ticks to delay rising of T/R signal. | |
bool | write_atr_rx_delay (int value) |
Clock ticks to delay falling edge of T/R signal. | |
bool | set_pga (int which_amp, double gain_in_db) |
Set Programmable Gain Amplifier (PGA) | |
double | pga (int which_amp) const |
Return programmable gain amplifier gain setting in dB. | |
double | pga_min () const |
Return minimum legal PGA gain in dB. | |
double | pga_max () const |
Return maximum legal PGA gain in dB. | |
double | pga_db_per_step () const |
Return hardware step size of PGA (linear in dB). | |
bool | _write_oe (int which_side, int value, int mask) |
Write direction register (output enables) for pins that go to daughterboard. | |
bool | write_io (int which_side, int value, int mask) |
Write daughterboard i/o pin value. | |
int | read_io (int which_side) |
Read daughterboard i/o pin value. | |
bool | write_refclk (int which_side, int value) |
Write daughterboard refclk config register. | |
bool | write_atr_mask (int which_side, int value) |
bool | write_atr_txval (int which_side, int value) |
bool | write_atr_rxval (int which_side, int value) |
bool | write_aux_dac (int which_side, int which_dac, int value) |
Write auxiliary digital to analog converter. | |
int | read_aux_adc (int which_side, int which_adc) |
Read auxiliary analog to digital converter. | |
long | converter_rate () const |
returns A/D or D/A converter rate in Hz | |
bool | _set_led (int which_led, bool on) |
bool | _write_fpga_reg (int regno, int value) |
Write FPGA register. | |
bool | _read_fpga_reg (int regno, int *value) |
Read FPGA register. | |
int | _read_fpga_reg (int regno) |
Read FPGA register. | |
bool | _write_fpga_reg_masked (int regno, int value, int mask) |
Write FPGA register with mask. | |
bool | _write_9862 (int which_codec, int regno, unsigned char value) |
Write AD9862 register. | |
int | _read_9862 (int which_codec, int regno) const |
Read AD9862 register. | |
bool | _write_spi (int optional_header, int enables, int format, std::string buf) |
Write data to SPI bus peripheral. | |
std::string | _read_spi (int optional_header, int enables, int format, int len) |
usrp_subdev_spec | pick_subdev (std::vector< int > candidates=std::vector< int >(0)) |
Static Public Attributes | |
static const int | READ_FAILED = -99999 |
magic value used on alternate register read interfaces | |
Protected Member Functions | |
usrp_base (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature) | |
void | set_usrp_basic (boost::shared_ptr< usrp_basic > u) |
base class for GNU Radio interface to the USRP
usrp_base::usrp_base | ( | const std::string & | name, |
gr_io_signature_sptr | input_signature, | ||
gr_io_signature_sptr | output_signature | ||
) | [inline, protected] |
virtual usrp_base::~usrp_base | ( | ) | [virtual] |
int usrp_base::_read_9862 | ( | int | which_codec, |
int | regno | ||
) | const |
Read AD9862 register.
which_codec | 0 or 1 |
regno | 6-bit register number |
bool usrp_base::_read_fpga_reg | ( | int | regno, |
int * | value | ||
) |
Read FPGA register.
regno | 7-bit register number |
value | 32-bit value |
int usrp_base::_read_fpga_reg | ( | int | regno | ) |
Read FPGA register.
regno | 7-bit register number |
std::string usrp_base::_read_spi | ( | int | optional_header, |
int | enables, | ||
int | format, | ||
int | len | ||
) |
bool usrp_base::_write_9862 | ( | int | which_codec, |
int | regno, | ||
unsigned char | value | ||
) |
Write AD9862 register.
which_codec | 0 or 1 |
regno | 6-bit register number |
value | 8-bit value |
bool usrp_base::_write_fpga_reg | ( | int | regno, |
int | value | ||
) |
Write FPGA register.
regno | 7-bit register number |
value | 32-bit value |
bool usrp_base::_write_fpga_reg_masked | ( | int | regno, |
int | value, | ||
int | mask | ||
) |
Write FPGA register with mask.
regno | 7-bit register number |
value | 16-bit value |
mask | 16-bit value |
bool usrp_base::_write_oe | ( | int | which_side, |
int | value, | ||
int | mask | ||
) |
Write direction register (output enables) for pins that go to daughterboard.
which_side | [0,1] which size |
value | value to write into register |
mask | which bits of value to write into reg |
Each d'board has 16-bits of general purpose i/o. Setting the bit makes it an output from the FPGA to the d'board.
This register is initialized based on a value stored in the d'board EEPROM. In general, you shouldn't be using this routine without a very good reason. Using this method incorrectly will kill your USRP motherboard and/or daughterboard.
bool usrp_base::_write_spi | ( | int | optional_header, |
int | enables, | ||
int | format, | ||
std::string | buf | ||
) |
Write data to SPI bus peripheral.
optional_header | 0,1 or 2 bytes to write before buf. |
enables | bitmask of peripherals to write. See usrp_spi_defs.h |
format | transaction format. See usrp_spi_defs.h SPI_FMT_* |
buf | the data to write |
If format
specifies that optional_header bytes are present, they are written to the peripheral immediately prior to writing buf
.
long usrp_base::converter_rate | ( | ) | const |
returns A/D or D/A converter rate in Hz
Referenced by usrp_source_base::adc_freq(), usrp_source_base::adc_rate(), usrp_sink_base::dac_freq(), and usrp_sink_base::dac_rate().
virtual int usrp_base::daughterboard_id | ( | int | which_side | ) | const [virtual] |
Return daughterboard ID for given side [0,1].
which_side | [0,1] which daughterboard |
db_base_sptr usrp_base::db | ( | int | which_side, |
int | which_dev | ||
) |
Return the daughterboard instance corresponding to the selected side of the USRP and selected daughterboard subdevice. N.B. To ensure proper lifetime management, the caller should continue to hold these as weak pointers, not shared pointers. As long as the caller does not attempt to directly use the weak pointers after this usrp object has been destroyed, everything will work out fine.
std::vector<std::vector<db_base_sptr> > usrp_base::db | ( | ) |
std::vector<db_base_sptr> usrp_base::db | ( | int | which_side | ) |
Return a vector of size 1 or 2 that contains shared pointers to the daughterboard instance(s) associated with the specified side.
which_side | [0,1] which daughterboard |
N.B. To ensure proper lifetime management, the caller should continue to hold these as weak pointers, not shared pointers. As long as the caller does not attempt to directly use the weak pointers after this usrp object has been destroyed, everything will work out fine.
long usrp_base::fpga_master_clock_freq | ( | ) | const |
return frequency of master oscillator on USRP
double usrp_base::pga | ( | int | which_amp | ) | const |
Return programmable gain amplifier gain setting in dB.
which_amp | which amp [0,3] |
double usrp_base::pga_db_per_step | ( | ) | const |
Return hardware step size of PGA (linear in dB).
double usrp_base::pga_max | ( | ) | const |
Return maximum legal PGA gain in dB.
double usrp_base::pga_min | ( | ) | const |
Return minimum legal PGA gain in dB.
usrp_subdev_spec usrp_base::pick_subdev | ( | std::vector< int > | candidates = std::vector< int >(0) | ) |
Return an existing daughterboard from list of candidate dbids, or the first found on side A or side B.
candidates | Vector of candidate dbids |
Throws std::runtime_error if not found
int usrp_base::read_aux_adc | ( | int | which_side, |
int | which_adc | ||
) |
Read auxiliary analog to digital converter.
which_side | [0,1] which d'board |
which_adc | [0,1] |
std::string usrp_base::read_eeprom | ( | int | i2c_addr, |
int | eeprom_offset, | ||
int | len | ||
) |
Read EEPROM on motherboard or any daughterboard.
i2c_addr | I2C bus address of EEPROM |
eeprom_offset | byte offset in EEPROM to begin reading |
len | number of bytes to read |
std::string usrp_base::read_i2c | ( | int | i2c_addr, |
int | len | ||
) |
Read from I2C peripheral.
i2c_addr | I2C bus address (7-bits) |
len | number of bytes to read |
int usrp_base::read_io | ( | int | which_side | ) |
Read daughterboard i/o pin value.
which_side | [0,1] which d'board |
db_base_sptr usrp_base::selected_subdev | ( | usrp_subdev_spec | ss | ) |
given a usrp_subdev_spec, return the corresponding daughterboard object.
std::invalid_argument | if ss is invalid. |
ss | specifies the side and subdevice |
std::string usrp_base::serial_number | ( | ) |
return the usrp's serial number.
Control ADC input buffer.
which_adc | which ADC[0,3] |
bypass | if non-zero, bypass input buffer and connect input directly to switched cap SHA input of RxPGA. |
bool usrp_base::set_adc_offset | ( | int | which_adc, |
int | offset | ||
) |
Set ADC offset correction.
which_adc | which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q... |
offset | 16-bit value to subtract from raw ADC input. |
bool usrp_base::set_dac_offset | ( | int | which_dac, |
int | offset, | ||
int | offset_pin | ||
) |
Set DAC offset correction.
which_dac | which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q... |
offset | 10-bit offset value (ambiguous format: See AD9862 datasheet). |
offset_pin | 1-bit value. If 0 offset applied to -ve differential pin; If 1 offset applied to +ve differential pin. |
bool usrp_base::set_dc_offset_cl_enable | ( | int | bits, |
int | mask | ||
) |
Enable/disable automatic DC offset removal control loop in FPGA.
bits | which control loops to enable |
mask | which bits to pay attention to |
If the corresponding bit is set, enable the automatic DC offset correction control loop.
The 4 low bits are significant:
ADC0 = (1 << 0) ADC1 = (1 << 1) ADC2 = (1 << 2) ADC3 = (1 << 3)
By default the control loop is enabled on all ADC's.
void usrp_base::set_fpga_master_clock_freq | ( | long | master_clock | ) |
Tell API that the master oscillator on the USRP is operating at a non-standard fixed frequency. This is only needed for custom USRP hardware modified to operate at a different frequency from the default factory configuration. This function must be called prior to any other API function.
master_clock | USRP2 FPGA master clock frequency in Hz (10..64 MHz) |
bool usrp_base::set_pga | ( | int | which_amp, |
double | gain_in_db | ||
) |
Set Programmable Gain Amplifier (PGA)
which_amp | which amp [0,3] |
gain_in_db | gain value (linear in dB) |
gain is rounded to closest setting supported by hardware.
void usrp_base::set_usrp_basic | ( | boost::shared_ptr< usrp_basic > | u | ) | [protected] |
void usrp_base::set_verbose | ( | bool | on | ) |
bool usrp_base::write_atr_mask | ( | int | which_side, |
int | value | ||
) |
bool usrp_base::write_atr_rx_delay | ( | int | value | ) |
Clock ticks to delay falling edge of T/R signal.
bool usrp_base::write_atr_rxval | ( | int | which_side, |
int | value | ||
) |
bool usrp_base::write_atr_tx_delay | ( | int | value | ) |
Clock ticks to delay rising of T/R signal.
bool usrp_base::write_atr_txval | ( | int | which_side, |
int | value | ||
) |
bool usrp_base::write_aux_dac | ( | int | which_side, |
int | which_dac, | ||
int | value | ||
) |
Write auxiliary digital to analog converter.
which_side | [0,1] which d'board N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's. SLOT_TX_B and SLOT_RX_B share the same AUX DAC's. |
which_dac | [2,3] TX slots must use only 2 and 3. |
value | [0,4095] |
bool usrp_base::write_eeprom | ( | int | i2c_addr, |
int | eeprom_offset, | ||
const std::string | buf | ||
) |
Write EEPROM on motherboard or any daughterboard.
i2c_addr | I2C bus address of EEPROM |
eeprom_offset | byte offset in EEPROM to begin writing |
buf | the data to write |
bool usrp_base::write_i2c | ( | int | i2c_addr, |
const std::string | buf | ||
) |
Write to I2C peripheral.
i2c_addr | I2C bus address (7-bits) |
buf | the data to write |
bool usrp_base::write_io | ( | int | which_side, |
int | value, | ||
int | mask | ||
) |
Write daughterboard i/o pin value.
which_side | [0,1] which d'board |
value | value to write into register |
mask | which bits of value to write into reg |
bool usrp_base::write_refclk | ( | int | which_side, |
int | value | ||
) |
Write daughterboard refclk config register.
which_side | [0,1] which d'board |
value | value to write into register, see below |
Control whether a reference clock is sent to the daughterboards, and what frequency. The refclk is sent on d'board i/o pin 0.
3 2 1 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +-----------------------------------------------+-+------------+ | Reserved (Must be zero) |E| DIVISOR | +-----------------------------------------------+-+------------+
Bit 7 -- 1 turns on refclk, 0 allows IO use Bits 6:0 Divider value
const int usrp_base::READ_FAILED = -99999 [static] |
magic value used on alternate register read interfaces