usrp1_source_base Class Reference

abstract interface to Universal Software Radio Peripheral Rx path (Rev 1) More...

#include <usrp1_source_base.h>

Inheritance diagram for usrp1_source_base:

Inheritance graph
[legend]
Collaboration diagram for usrp1_source_base:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~usrp1_source_base ()
int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
 just like gr_block::general_work, only this arranges to call consume_each for you
bool start ()
 Called to enable drivers, etc for i/o devices.
bool stop ()
 Called to disable drivers, etc for i/o devices.
bool set_decim_rate (unsigned int rate)
 Set decimator rate. rate must be EVEN and in [8, 256].
bool set_nchannels (int nchan)
bool set_mux (int mux)
bool set_rx_freq (int channel, double freq)
 set the center frequency of the digital down converter.
bool set_fpga_mode (int mode)
 set fpga special modes
void set_verbose (bool verbose)
bool set_ddc_phase (int channel, int phase)
 Set the digital down converter phase register.
bool set_pga (int which, double gain_in_db)
 Set Programmable Gain Amplifier (PGA).
double pga (int which) const
 Return programmable gain amplifier gain setting in dB.
double pga_min () const
 Return minimum legal PGA setting in dB.
double pga_max () const
 Return maximum legal PGA setting in dB.
double pga_db_per_step () const
 Return hardware step size of PGA (linear in dB).
long fpga_master_clock_freq () const
long converter_rate () const
long adc_rate () const
long adc_freq () const
unsigned int decim_rate () const
int nchannels () const
int mux () const
double rx_freq (int channel) const
int noverruns () const
int daughterboard_id (int which_dboard) const
 Return daughterboard ID for given Rx daughterboard slot [0,1].
bool write_aux_dac (int which_board, int which_dac, int value)
 Write auxiliary digital to analog converter.
int read_aux_adc (int which_dboard, int which_adc)
 Read auxiliary analog to digital converter.
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)
 Write 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 _write_oe (int which_dboard, int value, int mask)
 Write direction register (output enables) for pins that go to daughterboard.
bool write_io (int which_dboard, int value, int mask)
 Write daughterboard i/o pin value.
int read_io (int which_dboard)
 Read daughterboard i/o pin value.
bool set_dc_offset_cl_enable (int bits, int mask)
 Enable/disable automatic DC offset removal control loop in FPGA.
bool set_format (unsigned int format)
 Specify Rx data format.
unsigned int format () const
 return current format
bool _write_fpga_reg (int regno, int value)
 Write FPGA register.
bool _write_fpga_reg_masked (int regno, int value, int mask)
 Write FPGA register masked.
int _read_fpga_reg (int regno)
 Read FPGA register.
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)

Static Public Member Functions

static unsigned int make_format (int width=16, int shift=0, bool want_q=true, bool bypass_halfband=false)
static int format_width (unsigned int format)
static int format_shift (unsigned int format)
static bool format_want_q (unsigned int format)
static bool format_bypass_halfband (unsigned int format)

Static Public Attributes

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

Protected Member Functions

 usrp1_source_base (const std::string &name, gr_io_signature_sptr output_signature, int which_board, unsigned int decim_rate, int nchan, int mux, int mode, int fusb_block_size, int fusb_nblocks, const std::string fpga_filename, const std::string firmware_filename) throw (std::runtime_error)
virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items)=0
 return number of usrp input bytes required to produce noutput items.
unsigned int sizeof_basic_sample () const
 number of bytes in a low-level sample
virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items, int output_index, int output_items_available, int &output_items_produced, const void *usrp_buffer, int usrp_buffer_length, int &bytes_read)=0
 convert between native usrp format and output item format


Detailed Description

abstract interface to Universal Software Radio Peripheral Rx path (Rev 1)

Constructor & Destructor Documentation

usrp1_source_base::usrp1_source_base ( const std::string &  name,
gr_io_signature_sptr  output_signature,
int  which_board,
unsigned int  decim_rate,
int  nchan,
int  mux,
int  mode,
int  fusb_block_size,
int  fusb_nblocks,
const std::string  fpga_filename,
const std::string  firmware_filename 
) throw (std::runtime_error) [protected]

usrp1_source_base::~usrp1_source_base (  ) 


Member Function Documentation

int usrp1_source_base::_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

int usrp1_source_base::_read_fpga_reg ( int  regno  ) 

Read FPGA register.

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

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

bool usrp1_source_base::_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

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

Write FPGA register.

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

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

Write FPGA register masked.

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

bool usrp1_source_base::_write_oe ( int  which_dboard,
int  value,
int  mask 
)

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

Parameters:
which_dboard [0,1] which d'board
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 usrp1_source_base::_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.

long usrp1_source_base::adc_freq (  )  const [inline]

References converter_rate().

long usrp1_source_base::adc_rate (  )  const [inline]

References converter_rate().

long usrp1_source_base::converter_rate (  )  const

Referenced by adc_freq(), and adc_rate().

virtual void usrp1_source_base::copy_from_usrp_buffer ( gr_vector_void_star output_items,
int  output_index,
int  output_items_available,
int &  output_items_produced,
const void *  usrp_buffer,
int  usrp_buffer_length,
int &  bytes_read 
) [protected, pure virtual]

convert between native usrp format and output item format

Parameters:
output_items[out] stream(s) of output items
output_index[in] starting index in output_items
output_items_available[in] number of empty items available at item[index]
output_items_produced[out] number of items produced by copy
usrp_buffer[in] source buffer
usrp_buffer_length[in] number of bytes available in usrp_buffer
bytes_read[out] number of bytes read from usrp_buffer
The copy must consume all bytes available. That is, bytes_read must equal usrp_buffer_length.

Implemented in usrp1_source_c, and usrp1_source_s.

int usrp1_source_base::daughterboard_id ( int  which_dboard  )  const

Return daughterboard ID for given Rx daughterboard slot [0,1].

Returns:
daughterboard id >= 0 if successful

-1 if no daugherboard

-2 if invalid EEPROM on daughterboard

unsigned int usrp1_source_base::decim_rate (  )  const

unsigned int usrp1_source_base::format (  )  const

return current format

static bool usrp1_source_base::format_bypass_halfband ( unsigned int  format  )  [static]

static int usrp1_source_base::format_shift ( unsigned int  format  )  [static]

static bool usrp1_source_base::format_want_q ( unsigned int  format  )  [static]

static int usrp1_source_base::format_width ( unsigned int  format  )  [static]

long usrp1_source_base::fpga_master_clock_freq (  )  const

static unsigned int usrp1_source_base::make_format ( int  width = 16,
int  shift = 0,
bool  want_q = true,
bool  bypass_halfband = false 
) [static]

int usrp1_source_base::mux (  )  const

int usrp1_source_base::nchannels (  )  const

virtual int usrp1_source_base::ninput_bytes_reqd_for_noutput_items ( int  noutput_items  )  [protected, pure virtual]

return number of usrp input bytes required to produce noutput items.

Implemented in usrp1_source_c, and usrp1_source_s.

int usrp1_source_base::noverruns (  )  const [inline]

double usrp1_source_base::pga ( int  which  )  const

Return programmable gain amplifier gain setting in dB.

Parameters:
which which A/D [0,3]

double usrp1_source_base::pga_db_per_step (  )  const

Return hardware step size of PGA (linear in dB).

double usrp1_source_base::pga_max (  )  const

Return maximum legal PGA setting in dB.

double usrp1_source_base::pga_min (  )  const

Return minimum legal PGA setting in dB.

int usrp1_source_base::read_aux_adc ( int  which_dboard,
int  which_adc 
)

Read auxiliary analog to digital converter.

Parameters:
which_dboard [0,1] which d'board
which_adc [0,1]
Returns:
value in the range [0,4095] if successful, else READ_FAILED.

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

Write 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.

std::string usrp1_source_base::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 of 64 bytes.

int usrp1_source_base::read_io ( int  which_dboard  ) 

Read daughterboard i/o pin value.

Parameters:
which_dboard [0,1] which d'board
Returns:
register value if successful, else READ_FAILED

double usrp1_source_base::rx_freq ( int  channel  )  const

std::string usrp1_source_base::serial_number (  ) 

return the usrp's serial number.

Returns:
non-zero length string iff successful.

bool usrp1_source_base::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.

bool usrp1_source_base::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.

bool usrp1_source_base::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.

bool usrp1_source_base::set_dc_offset_cl_enable ( int  bits,
int  mask 
)

Enable/disable automatic DC offset removal control loop in FPGA.

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

bool usrp1_source_base::set_ddc_phase ( int  channel,
int  phase 
)

Set the digital down converter phase register.

Parameters:
channel which ddc channel [0, 3]
phase 32-bit integer phase value.

bool usrp1_source_base::set_decim_rate ( unsigned int  rate  ) 

Set decimator rate. rate must be EVEN and in [8, 256].

The final complex sample rate across the USB is adc_freq () / decim_rate ()

bool usrp1_source_base::set_format ( unsigned int  format  ) 

Specify Rx data format.

Parameters:
format format specifier
Rx data format control register

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) |B|Q| WIDTH | SHIFT | +-----------------------------------------+-+-+---------+-------+

SHIFT specifies arithmetic right shift [0, 15] WIDTH specifies bit-width of I & Q samples across the USB [1, 16] (not all valid) Q if set deliver both I & Q, else just I B if set bypass half-band filter.

Right now the acceptable values are:

B Q WIDTH SHIFT 0 1 16 0 0 1 8 8

More valid combos to come.

Default value is 0x00000300 16-bits, 0 shift, deliver both I & Q.

bool usrp1_source_base::set_fpga_mode ( int  mode  ) 

set fpga special modes

bool usrp1_source_base::set_mux ( int  mux  ) 

bool usrp1_source_base::set_nchannels ( int  nchan  ) 

bool usrp1_source_base::set_pga ( int  which,
double  gain_in_db 
)

Set Programmable Gain Amplifier (PGA).

Parameters:
which which A/D [0,3]
gain_in_db gain 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()

bool usrp1_source_base::set_rx_freq ( int  channel,
double  freq 
)

set the center frequency of the digital down converter.

channel must be 0. freq is the center frequency in Hz. It must be in the range [-FIXME, FIXME]. The frequency specified is quantized. Use rx_freq to retrieve the actual value used.

void usrp1_source_base::set_verbose ( bool  verbose  ) 

unsigned int usrp1_source_base::sizeof_basic_sample (  )  const [protected]

number of bytes in a low-level sample

bool usrp1_source_base::start (  )  [virtual]

Called to enable drivers, etc for i/o devices.

This allows a block to enable an associated driver to begin transfering data just before we start to execute the scheduler. The end result is that this reduces latency in the pipeline when dealing with audio devices, usrps, etc.

Reimplemented from gr_block.

bool usrp1_source_base::stop (  )  [virtual]

Called to disable drivers, etc for i/o devices.

Reimplemented from gr_block.

int usrp1_source_base::work ( int  noutput_items,
gr_vector_const_void_star input_items,
gr_vector_void_star output_items 
) [virtual]

just like gr_block::general_work, only this arranges to call consume_each for you

The user must override work to define the signal processing code

Implements gr_sync_block.

bool usrp1_source_base::write_aux_dac ( int  which_board,
int  which_dac,
int  value 
)

Write auxiliary digital to analog converter.

Parameters:
which_dboard [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 usrp1_source_base::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

bool usrp1_source_base::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.

bool usrp1_source_base::write_io ( int  which_dboard,
int  value,
int  mask 
)

Write daughterboard i/o pin value.

Parameters:
which_dboard [0,1] which d'board
value value to write into register
mask which bits of value to write into reg


Member Data Documentation

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

magic value used on alternate register read interfaces


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

Generated on Thu Mar 5 09:03:28 2009 for GNU Radio 3.1.3 by  doxygen 1.5.8