GNU Radio 3.3.0 C++ API
usrp_base Class Reference

base class for GNU Radio interface to the USRP More...

#include <usrp_base.h>

Inheritance diagram for usrp_base:

List of all members.

Public Member Functions

virtual ~usrp_base ()
std::vector< std::vector
< db_base_sptr > > 
db ()
std::vector< db_base_sptrdb (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)

Detailed Description

base class for GNU Radio interface to the USRP


Constructor & Destructor Documentation

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]

Member Function Documentation

int usrp_base::_read_9862 ( int  which_codec,
int  regno 
) const

Read AD9862 register.

Parameters:
which_codec0 or 1
regno6-bit register number
Returns:
register value if successful, else READ_FAILED
bool usrp_base::_read_fpga_reg ( int  regno,
int *  value 
)

Read FPGA register.

Parameters:
regno7-bit register number
value32-bit value
Returns:
true iff successful
int usrp_base::_read_fpga_reg ( int  regno)

Read FPGA register.

Parameters:
regno7-bit register number
Returns:
register value if successful, else READ_FAILED
std::string usrp_base::_read_spi ( int  optional_header,
int  enables,
int  format,
int  len 
)
bool usrp_base::_set_led ( int  which_led,
bool  on 
)
bool usrp_base::_write_9862 ( int  which_codec,
int  regno,
unsigned char  value 
)

Write AD9862 register.

Parameters:
which_codec0 or 1
regno6-bit register number
value8-bit value
Returns:
true iff successful
bool usrp_base::_write_fpga_reg ( int  regno,
int  value 
)

Write FPGA register.

Parameters:
regno7-bit register number
value32-bit value
Returns:
true iff successful
bool usrp_base::_write_fpga_reg_masked ( int  regno,
int  value,
int  mask 
)

Write FPGA register with mask.

Parameters:
regno7-bit register number
value16-bit value
mask16-bit value
Returns:
true if successful Only use this for registers who actually implement a mask in the verilog firmware, like FR_RX_MASTER_SLAVE
bool usrp_base::_write_oe ( int  which_side,
int  value,
int  mask 
)

Write direction register (output enables) for pins that go to daughterboard.

Parameters:
which_side[0,1] which size
valuevalue to write into register
maskwhich 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.

Parameters:
optional_header0,1 or 2 bytes to write before buf.
enablesbitmask of peripherals to write. See usrp_spi_defs.h
formattransaction format. See usrp_spi_defs.h SPI_FMT_*
bufthe data to write
Returns:
true iff successful Writes are limited to a maximum of 64 bytes.

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
virtual int usrp_base::daughterboard_id ( int  which_side) const [virtual]

Return daughterboard ID for given side [0,1].

Parameters:
which_side[0,1] which daughterboard
Returns:
daughterboard id >= 0 if successful
-1 if no daugherboard
-2 if invalid EEPROM on 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.

Parameters:
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.

Parameters:
which_ampwhich 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.

Parameters:
candidatesVector 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.

Parameters:
which_side[0,1] which d'board
which_adc[0,1]
Returns:
value in the range [0,4095] if successful, else READ_FAILED.
std::string usrp_base::read_eeprom ( int  i2c_addr,
int  eeprom_offset,
int  len 
)

Read EEPROM on motherboard or any daughterboard.

Parameters:
i2c_addrI2C bus address of EEPROM
eeprom_offsetbyte offset in EEPROM to begin reading
lennumber of bytes to read
Returns:
the data read if successful, else a zero length string.
std::string usrp_base::read_i2c ( int  i2c_addr,
int  len 
)

Read from I2C peripheral.

Parameters:
i2c_addrI2C bus address (7-bits)
lennumber of bytes to read
Returns:
the data read if successful, else a zero length string. Reads are limited to a maximum of 64 bytes.
int usrp_base::read_io ( int  which_side)

Read daughterboard i/o pin value.

Parameters:
which_side[0,1] which d'board
Returns:
register value if successful, else READ_FAILED
db_base_sptr usrp_base::selected_subdev ( usrp_subdev_spec  ss)

given a usrp_subdev_spec, return the corresponding daughterboard object.

Exceptions:
std::invalid_argumentif ss is invalid.
Parameters:
ssspecifies the side and subdevice
std::string usrp_base::serial_number ( )

return the usrp's serial number.

Returns:
non-zero length string iff successful.
bool usrp_base::set_adc_buffer_bypass ( int  which_adc,
bool  bypass 
)

Control ADC input buffer.

Parameters:
which_adcwhich ADC[0,3]
bypassif 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.

Parameters:
which_adcwhich ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
offset16-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.

Parameters:
which_dacwhich DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
offset10-bit offset value (ambiguous format: See AD9862 datasheet).
offset_pin1-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.

Parameters:
bitswhich control loops to enable
maskwhich 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.

Parameters:
master_clockUSRP2 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)

Parameters:
which_ampwhich amp [0,3]
gain_in_dbgain value (linear in dB)

gain is rounded to closest setting supported by hardware.

Returns:
true iff sucessful.
See also:
pga_min(), pga_max(), pga_db_per_step()
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.

See also:
write_atr_mask, write_atr_txval, write_atr_rxval
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.

See also:
write_atr_mask, write_atr_txval, write_atr_rxval
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.

Parameters:
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]
Returns:
true iff successful
bool usrp_base::write_eeprom ( int  i2c_addr,
int  eeprom_offset,
const std::string  buf 
)

Write EEPROM on motherboard or any daughterboard.

Parameters:
i2c_addrI2C bus address of EEPROM
eeprom_offsetbyte offset in EEPROM to begin writing
bufthe data to write
Returns:
true iff sucessful
bool usrp_base::write_i2c ( int  i2c_addr,
const std::string  buf 
)

Write to I2C peripheral.

Parameters:
i2c_addrI2C bus address (7-bits)
bufthe data to write
Returns:
true iff successful Writes are limited to a maximum of of 64 bytes.
bool usrp_base::write_io ( int  which_side,
int  value,
int  mask 
)

Write daughterboard i/o pin value.

Parameters:
which_side[0,1] which d'board
valuevalue to write into register
maskwhich bits of value to write into reg
bool usrp_base::write_refclk ( int  which_side,
int  value 
)

Write daughterboard refclk config register.

Parameters:
which_side[0,1] which d'board
valuevalue 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
 

Member Data Documentation

const int usrp_base::READ_FAILED = -99999 [static]

magic value used on alternate register read interfaces


The documentation for this class was generated from the following file: