usrp1_sink_base Class Reference

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

#include <usrp1_sink_base.h>

Inheritance diagram for usrp1_sink_base:

Inheritance graph
[legend]
Collaboration diagram for usrp1_sink_base:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~usrp1_sink_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_interp_rate (unsigned int rate)
 Set interpolator rate. rate must be in [4, 1024] and a multiple of 4.
bool set_nchannels (int nchan)
bool set_mux (int mux)
bool set_tx_freq (int channel, double freq)
 set the frequency of the digital up converter.
void set_verbose (bool verbose)
bool set_pga (int which, double gain_in_db)
 Set Programmable Gain Amplifier (PGA).
double pga (int which) const
 Return programmable gain amplifier gain 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).
long fpga_master_clock_freq () const
long converter_rate () const
long dac_rate () const
long dac_freq () const
unsigned int interp_rate () const
int nchannels () const
int mux () const
double tx_freq (int channel) const
int nunderruns () 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 _write_fpga_reg (int regno, int value)
 Write FPGA register.
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 Attributes

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

Protected Member Functions

 usrp1_sink_base (const std::string &name, gr_io_signature_sptr input_signature, int which_board, unsigned int interp_rate, int nchan, int mux, int fusb_block_size, int fusb_nblocks, const std::string fpga_filename, const std::string firmware_filename) throw (std::runtime_error)
virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items, int input_index, int input_items_available, int &input_items_consumed, void *usrp_buffer, int usrp_buffer_length, int &bytes_written)=0
 convert between input item format and usrp native format


Detailed Description

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

Constructor & Destructor Documentation

usrp1_sink_base::usrp1_sink_base ( const std::string &  name,
gr_io_signature_sptr  input_signature,
int  which_board,
unsigned int  interp_rate,
int  nchan,
int  mux,
int  fusb_block_size,
int  fusb_nblocks,
const std::string  fpga_filename,
const std::string  firmware_filename 
) throw (std::runtime_error) [protected]

usrp1_sink_base::~usrp1_sink_base (  ) 


Member Function Documentation

int usrp1_sink_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_sink_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_sink_base::_read_spi ( int  optional_header,
int  enables,
int  format,
int  len 
)

bool usrp1_sink_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_sink_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_sink_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_sink_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_sink_base::converter_rate (  )  const

Referenced by dac_freq(), and dac_rate().

virtual void usrp1_sink_base::copy_to_usrp_buffer ( gr_vector_const_void_star input_items,
int  input_index,
int  input_items_available,
int &  input_items_consumed,
void *  usrp_buffer,
int  usrp_buffer_length,
int &  bytes_written 
) [protected, pure virtual]

convert between input item format and usrp native format

Parameters:
input_items[in] stream(s) of input items
input_index[in] starting index in input_items
input_items_available[in] number of items available starting at item[index]
input_items_consumed[out] number of input items consumed by copy
usrp_buffer[out] destination buffer
usrp_buffer_length[in] usrp_buffer length in bytes
bytes_written[out] number of bytes written into usrp_buffer

Implemented in usrp1_sink_c, and usrp1_sink_s.

long usrp1_sink_base::dac_freq (  )  const [inline]

References converter_rate().

long usrp1_sink_base::dac_rate (  )  const [inline]

References converter_rate().

int usrp1_sink_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

long usrp1_sink_base::fpga_master_clock_freq (  )  const

unsigned int usrp1_sink_base::interp_rate (  )  const

int usrp1_sink_base::mux (  )  const

int usrp1_sink_base::nchannels (  )  const

int usrp1_sink_base::nunderruns (  )  const [inline]

double usrp1_sink_base::pga ( int  which  )  const

Return programmable gain amplifier gain in dB.

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

double usrp1_sink_base::pga_db_per_step (  )  const

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

double usrp1_sink_base::pga_max (  )  const

Return maximum legal PGA gain in dB.

double usrp1_sink_base::pga_min (  )  const

Return minimum legal PGA gain in dB.

int usrp1_sink_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_sink_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_sink_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_sink_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

std::string usrp1_sink_base::serial_number (  ) 

return the usrp's serial number.

Returns:
non-zero length string iff successful.

bool usrp1_sink_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_sink_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_sink_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_sink_base::set_interp_rate ( unsigned int  rate  ) 

Set interpolator rate. rate must be in [4, 1024] and a multiple of 4.

The final complex sample rate across the USB is dac_freq () / interp_rate () * nchannels ()

bool usrp1_sink_base::set_mux ( int  mux  ) 

bool usrp1_sink_base::set_nchannels ( int  nchan  ) 

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

Set Programmable Gain Amplifier (PGA).

Parameters:
which which D/A [0,3]
gain_in_db gain value (linear in dB)
gain is rounded to closest setting supported by hardware. Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3. Setting DAC 0 affects DAC 1 and vice versa. Same with DAC 2 and DAC 3.

Returns:
true iff sucessful.
See also:
pga_min(), pga_max(), pga_db_per_step()

bool usrp1_sink_base::set_tx_freq ( int  channel,
double  freq 
)

set the frequency of the digital up converter.

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

void usrp1_sink_base::set_verbose ( bool  verbose  ) 

bool usrp1_sink_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_sink_base::stop (  )  [virtual]

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

Reimplemented from gr_block.

double usrp1_sink_base::tx_freq ( int  channel  )  const

int usrp1_sink_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_sink_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_sink_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_sink_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_sink_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_sink_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:27 2009 for GNU Radio 3.1.3 by  doxygen 1.5.8