usrp_basic Class Reference

base class for usrp operations More...

#include <usrp_basic.h>

Inheritance diagram for usrp_basic:

Inheritance graph
[legend]
Collaboration diagram for usrp_basic:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~usrp_basic ()
long fpga_master_clock_freq () const
 return frequency of master oscillator on USRP
int usb_data_rate () const
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, int offset)
 Set ADC offset correction.
bool set_dac_offset (int which, int offset, int offset_pin)
 Set DAC offset correction.
bool set_adc_buffer_bypass (int which, bool bypass)
 Control ADC input buffer.
std::string serial_number ()
 return the usrp's serial number.
bool _set_led (int which, 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.
bool _read_9862 (int which_codec, int regno, unsigned char *value) const
 Read 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)
bool start ()
 Start data transfers. Called in base class to derived class order.
bool stop ()
 Stop data transfers. Called in base class to derived class order.

Static Public Attributes

static const int READ_FAILED = -99999
 magic value used on alternate register read interfaces

Protected Member Functions

 usrp_basic (int which_board, struct usb_dev_handle *open_interface(struct usb_device *dev), const std::string fpga_filename="", const std::string firmware_filename="")
void set_usb_data_rate (int usb_data_rate)
 advise usrp_basic of usb data rate (bytes/sec)
bool write_aux_dac (int slot, int which_dac, int value)
 Write auxiliary digital to analog converter.
bool read_aux_adc (int slot, int which_adc, int *value)
 Read auxiliary analog to digital converter.
int read_aux_adc (int slot, int which_adc)
 Read auxiliary analog to digital converter.

Protected Attributes

struct usb_dev_handled_udh
int d_usb_data_rate
int d_bytes_per_poll
bool d_verbose
unsigned int d_fpga_shadows [MAX_REGS]

Static Protected Attributes

static const int MAX_REGS = 128


Detailed Description

base class for usrp operations

Constructor & Destructor Documentation

usrp_basic::usrp_basic ( int  which_board,
struct usb_dev_handle open_interfacestruct usb_device *dev,
const std::string  fpga_filename = "",
const std::string  firmware_filename = "" 
) [protected]

usrp_basic::~usrp_basic (  )  [virtual]

References d_udh.


Member Function Documentation

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

Read AD9862 register.

Parameters:
which_codec 0 or 1
regno 6-bit register number
Returns:
register value if successful, else READ_FAILED

References _read_9862(), and READ_FAILED.

bool usrp_basic::_read_9862 ( int  which_codec,
int  regno,
unsigned char *  value 
) const

Read AD9862 register.

Parameters:
which_codec 0 or 1
regno 6-bit register number
value 8-bit value
Returns:
true iff successful

References d_udh, and usrp_9862_read().

Referenced by _read_9862(), usrp_basic_tx::pga(), usrp_basic_rx::pga(), set_adc_buffer_bypass(), and usrp_basic_rx::set_pga().

int usrp_basic::_read_fpga_reg ( int  regno  ) 

Read FPGA register.

Parameters:
regno 7-bit register number
Returns:
register value if successful, else READ_FAILED

References _read_fpga_reg(), and READ_FAILED.

bool usrp_basic::_read_fpga_reg ( int  regno,
int *  value 
)

Read FPGA register.

Parameters:
regno 7-bit register number
value 32-bit value
Returns:
true iff successful

References d_udh, and usrp_read_fpga_reg().

Referenced by _read_fpga_reg(), usrp_basic_tx::read_io(), usrp_basic_rx::read_io(), and usrp_standard_common::usrp_standard_common().

std::string usrp_basic::_read_spi ( int  optional_header,
int  enables,
int  format,
int  len 
)

References d_udh, and usrp_spi_read().

bool usrp_basic::_set_led ( int  which,
bool  on 
)

References d_udh, and usrp_set_led().

bool usrp_basic::_write_9862 ( int  which_codec,
int  regno,
unsigned char  value 
)

Write AD9862 register.

Parameters:
which_codec 0 or 1
regno 6-bit register number
value 8-bit value
Returns:
true iff successful

References d_udh, d_verbose, and usrp_9862_write().

Referenced by set_adc_buffer_bypass(), set_dac_offset(), usrp_basic_tx::set_pga(), usrp_basic_rx::set_pga(), and usrp_standard_tx::set_tx_freq().

bool usrp_basic::_write_fpga_reg ( int  regno,
int  value 
)

bool usrp_basic::_write_fpga_reg_masked ( int  regno,
int  value,
int  mask 
)

Write FPGA register with mask.

Parameters:
regno 7-bit register number
value 16-bit value
mask 16-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

References d_fpga_shadows, d_udh, d_verbose, MAX_REGS, and usrp_write_fpga_reg().

bool usrp_basic::_write_spi ( int  optional_header,
int  enables,
int  format,
std::string  buf 
)

Write data to SPI bus peripheral.

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

References d_udh, and usrp_spi_write().

long usrp_basic::fpga_master_clock_freq (  )  const [inline]

return frequency of master oscillator on USRP

Referenced by usrp_basic_tx::converter_rate(), and usrp_basic_rx::converter_rate().

int usrp_basic::read_aux_adc ( int  slot,
int  which_adc 
) [protected]

Read auxiliary analog to digital converter.

Parameters:
slot 2-bit slot number. E.g., SLOT_TX_A
which_adc [0,1]
Returns:
value in the range [0,4095] if successful, else READ_FAILED.

Reimplemented in usrp_basic_rx, and usrp_basic_tx.

References read_aux_adc(), and READ_FAILED.

bool usrp_basic::read_aux_adc ( int  slot,
int  which_adc,
int *  value 
) [protected]

Read auxiliary analog to digital converter.

Parameters:
slot 2-bit slot number. E.g., SLOT_TX_A
which_adc [0,1]
value return 12-bit value [0,4095]
Returns:
true iff successful

Reimplemented in usrp_basic_rx, and usrp_basic_tx.

References d_udh, and usrp_read_aux_adc().

Referenced by read_aux_adc().

std::string usrp_basic::read_eeprom ( int  i2c_addr,
int  eeprom_offset,
int  len 
)

Read EEPROM on motherboard or any daughterboard.

Parameters:
i2c_addr I2C bus address of EEPROM
eeprom_offset byte offset in EEPROM to begin reading
len number of bytes to read
Returns:
the data read if successful, else a zero length string.

References d_udh, and usrp_eeprom_read().

std::string usrp_basic::read_i2c ( int  i2c_addr,
int  len 
)

Read from I2C peripheral.

Parameters:
i2c_addr I2C bus address (7-bits)
len number of bytes to read
Returns:
the data read if successful, else a zero length string. Reads are limited to a maximum of 64 bytes.

References d_udh, and usrp_i2c_read().

std::string usrp_basic::serial_number (  ) 

return the usrp's serial number.

Returns:
non-zero length string iff successful.

References d_udh, and usrp_serial_number().

bool usrp_basic::set_adc_buffer_bypass ( int  which,
bool  bypass 
)

Control ADC input buffer.

Parameters:
which which ADC[0,3]
bypass if non-zero, bypass input buffer and connect input directly to switched cap SHA input of RxPGA.

References _read_9862(), _write_9862(), REG_RX_A, REG_RX_B, REG_RX_PWR_DN, RX_PWR_DN_BUF_A, RX_PWR_DN_BUF_B, and RX_X_BYPASS_INPUT_BUFFER.

bool usrp_basic::set_adc_offset ( int  which,
int  offset 
)

Set ADC offset correction.

Parameters:
which which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
offset 16-bit value to subtract from raw ADC input.

References _write_fpga_reg().

Referenced by usrp_basic_rx::probe_rx_slots().

bool usrp_basic::set_dac_offset ( int  which,
int  offset,
int  offset_pin 
)

Set DAC offset correction.

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

References _write_9862(), REG_TX_A_OFFSET_HI, REG_TX_A_OFFSET_LO, REG_TX_B_OFFSET_HI, and REG_TX_B_OFFSET_LO.

void usrp_basic::set_usb_data_rate ( int  usb_data_rate  )  [protected]

advise usrp_basic of usb data rate (bytes/sec)

N.B., this doesn't tweak any hardware. Derived classes should call this to inform us of the data rate whenever it's first set or if it changes.

Parameters:
usb_data_rate bytes/sec

References d_bytes_per_poll, and d_usb_data_rate.

Referenced by usrp_standard_rx::set_decim_rate(), and usrp_standard_tx::set_interp_rate().

void usrp_basic::set_verbose ( bool  on  )  [inline]

References d_verbose.

bool usrp_basic::start (  ) 

Start data transfers. Called in base class to derived class order.

Reimplemented in usrp_basic_rx, usrp_basic_tx, usrp_standard_rx, and usrp_standard_tx.

Referenced by usrp_basic_tx::start(), and usrp_basic_rx::start().

bool usrp_basic::stop (  ) 

Stop data transfers. Called in base class to derived class order.

Reimplemented in usrp_basic_rx, usrp_basic_tx, usrp_standard_rx, and usrp_standard_tx.

int usrp_basic::usb_data_rate (  )  const [inline]

Returns:
usb data rate in bytes/sec

References d_usb_data_rate.

bool usrp_basic::write_aux_dac ( int  slot,
int  which_dac,
int  value 
) [protected]

Write auxiliary digital to analog converter.

Parameters:
slot Which Tx or Rx slot to write. 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 [0,3] RX slots must use only 0 and 1. TX slots must use only 2 and 3.
value [0,4095]
Returns:
true iff successful

Reimplemented in usrp_basic_rx, and usrp_basic_tx.

References d_udh, and usrp_write_aux_dac().

bool usrp_basic::write_eeprom ( int  i2c_addr,
int  eeprom_offset,
const std::string  buf 
)

Write EEPROM on motherboard or any daughterboard.

Parameters:
i2c_addr I2C bus address of EEPROM
eeprom_offset byte offset in EEPROM to begin writing
buf the data to write
Returns:
true iff sucessful

References d_udh, and usrp_eeprom_write().

bool usrp_basic::write_i2c ( int  i2c_addr,
const std::string  buf 
)

Write to I2C peripheral.

Parameters:
i2c_addr I2C bus address (7-bits)
buf the data to write
Returns:
true iff successful Writes are limited to a maximum of of 64 bytes.

References d_udh, and usrp_i2c_write().


Member Data Documentation

unsigned int usrp_basic::d_fpga_shadows[MAX_REGS] [protected]

struct usb_dev_handle* usrp_basic::d_udh [read, protected]

int usrp_basic::d_usb_data_rate [protected]

Referenced by set_usb_data_rate(), and usb_data_rate().

bool usrp_basic::d_verbose [protected]

const int usrp_basic::MAX_REGS = 128 [static, protected]

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

magic value used on alternate register read interfaces

Referenced by _read_9862(), _read_fpga_reg(), usrp_basic_tx::pga(), usrp_basic_rx::pga(), read_aux_adc(), usrp_basic_tx::read_io(), and usrp_basic_rx::read_io().


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

Generated on Thu Mar 5 09:04:25 2009 for Universal Software Radio Peripheral by  doxygen 1.5.8