#include <usrp1_sink_base.h>
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 |
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 | ( | ) |
int usrp1_sink_base::_read_9862 | ( | int | which_codec, | |
int | regno | |||
) | const |
Read AD9862 register.
which_codec | 0 or 1 | |
regno | 6-bit register number |
int usrp1_sink_base::_read_fpga_reg | ( | int | regno | ) |
Read FPGA register.
regno | 7-bit register number |
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.
which_codec | 0 or 1 | |
regno | 6-bit register number | |
value | 8-bit value |
bool usrp1_sink_base::_write_fpga_reg | ( | int | regno, | |
int | value | |||
) |
Write FPGA register.
regno | 7-bit register number | |
value | 32-bit value |
bool usrp1_sink_base::_write_oe | ( | int | which_dboard, | |
int | value, | |||
int | mask | |||
) |
Write direction register (output enables) for pins that go to daughterboard.
which_dboard | [0,1] which d'board | |
value | value to write into register | |
mask | which bits of value to write into reg |
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.
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 |
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
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].
-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.
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.
which_dboard | [0,1] which d'board | |
which_adc | [0,1] |
std::string usrp1_sink_base::read_eeprom | ( | int | i2c_addr, | |
int | eeprom_offset, | |||
int | len | |||
) |
Write 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 usrp1_sink_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 usrp1_sink_base::read_io | ( | int | which_dboard | ) |
Read daughterboard i/o pin value.
which_dboard | [0,1] which d'board |
std::string usrp1_sink_base::serial_number | ( | ) |
return the usrp's serial number.
bool usrp1_sink_base::set_adc_buffer_bypass | ( | int | which, | |
bool | bypass | |||
) |
bool usrp1_sink_base::set_adc_offset | ( | int | which, | |
int | offset | |||
) |
Set ADC offset correction.
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.
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).
which | which D/A [0,3] | |
gain_in_db | gain value (linear in dB) |
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] |
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.
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] |
bool usrp1_sink_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 usrp1_sink_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 usrp1_sink_base::write_io | ( | int | which_dboard, | |
int | value, | |||
int | mask | |||
) |
Write daughterboard i/o pin value.
which_dboard | [0,1] which d'board | |
value | value to write into register | |
mask | which bits of value to write into reg |
const int usrp1_sink_base::READ_FAILED = -99999 [static] |
magic value used on alternate register read interfaces