#include <usrp_basic.h>
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_handle * | d_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 |
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.
int usrp_basic::_read_9862 | ( | int | which_codec, | |
int | regno | |||
) | const |
Read AD9862 register.
which_codec | 0 or 1 | |
regno | 6-bit register number |
References _read_9862(), and READ_FAILED.
bool usrp_basic::_read_9862 | ( | int | which_codec, | |
int | regno, | |||
unsigned char * | value | |||
) | const |
Read AD9862 register.
which_codec | 0 or 1 | |
regno | 6-bit register number | |
value | 8-bit value |
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.
regno | 7-bit register number |
References _read_fpga_reg(), and READ_FAILED.
bool usrp_basic::_read_fpga_reg | ( | int | regno, | |
int * | value | |||
) |
Read FPGA register.
regno | 7-bit register number | |
value | 32-bit value |
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.
which_codec | 0 or 1 | |
regno | 6-bit register number | |
value | 8-bit value |
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 | |||
) |
Write FPGA register.
regno | 7-bit register number | |
value | 32-bit value |
References d_fpga_shadows, d_udh, d_verbose, MAX_REGS, and usrp_write_fpga_reg().
Referenced by usrp_basic_tx::_write_oe(), usrp_basic_rx::_write_oe(), usrp_basic_rx::probe_rx_slots(), usrp_basic_tx::probe_tx_slots(), set_adc_offset(), usrp_basic_rx::set_dc_offset_cl_enable(), usrp_standard_rx::set_ddc_phase(), usrp_standard_rx::set_decim_rate(), usrp_standard_rx::set_format(), usrp_standard_rx::set_fpga_mode(), usrp_basic_rx::set_fpga_rx_sample_rate_divisor(), usrp_basic_tx::set_fpga_tx_sample_rate_divisor(), usrp_standard_tx::set_interp_rate(), usrp_standard_rx::set_rx_freq(), usrp_basic(), usrp_basic_rx::usrp_basic_rx(), usrp_basic_tx::usrp_basic_tx(), usrp_standard_tx::write_hw_mux_reg(), usrp_standard_rx::write_hw_mux_reg(), usrp_basic_tx::write_io(), and usrp_basic_rx::write_io().
bool usrp_basic::_write_fpga_reg_masked | ( | int | regno, | |
int | value, | |||
int | mask | |||
) |
Write FPGA register with mask.
regno | 7-bit register number | |
value | 16-bit value | |
mask | 16-bit value |
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.
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
.
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.
slot | 2-bit slot number. E.g., SLOT_TX_A | |
which_adc | [0,1] |
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.
slot | 2-bit slot number. E.g., SLOT_TX_A | |
which_adc | [0,1] | |
value | return 12-bit value [0,4095] |
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.
i2c_addr | I2C bus address of EEPROM | |
eeprom_offset | byte offset in EEPROM to begin reading | |
len | number of bytes to read |
References d_udh, and usrp_eeprom_read().
std::string usrp_basic::read_i2c | ( | int | i2c_addr, | |
int | len | |||
) |
Read from I2C peripheral.
i2c_addr | I2C bus address (7-bits) | |
len | number of bytes to read |
References d_udh, and usrp_i2c_read().
std::string usrp_basic::serial_number | ( | ) |
return the usrp's serial number.
References d_udh, and usrp_serial_number().
bool usrp_basic::set_adc_buffer_bypass | ( | int | which, | |
bool | bypass | |||
) |
Control ADC input buffer.
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.
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.
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.
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] |
bool usrp_basic::write_aux_dac | ( | int | slot, | |
int | which_dac, | |||
int | value | |||
) | [protected] |
Write auxiliary digital to analog converter.
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] |
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.
i2c_addr | I2C bus address of EEPROM | |
eeprom_offset | byte offset in EEPROM to begin writing | |
buf | the data to write |
References d_udh, and usrp_eeprom_write().
bool usrp_basic::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 |
References d_udh, and usrp_i2c_write().
int usrp_basic::d_bytes_per_poll [protected] |
Referenced by usrp_basic_rx::read(), set_usb_data_rate(), and usrp_basic_tx::write().
unsigned int usrp_basic::d_fpga_shadows[MAX_REGS] [protected] |
struct usb_dev_handle* usrp_basic::d_udh [read, protected] |
Referenced by _read_9862(), _read_fpga_reg(), _read_spi(), _set_led(), _write_9862(), _write_fpga_reg(), _write_fpga_reg_masked(), _write_spi(), usrp_basic_rx::probe_rx_slots(), usrp_basic_tx::probe_tx_slots(), usrp_basic_rx::read(), read_aux_adc(), read_eeprom(), read_i2c(), serial_number(), usrp_basic_rx::set_rx_enable(), usrp_basic_tx::set_tx_enable(), usrp_basic(), usrp_basic_rx::usrp_basic_rx(), usrp_basic_tx::usrp_basic_tx(), usrp_standard_tx::usrp_standard_tx(), usrp_basic_tx::write(), write_aux_dac(), write_eeprom(), write_i2c(), ~usrp_basic(), usrp_basic_rx::~usrp_basic_rx(), and usrp_basic_tx::~usrp_basic_tx().
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] |
Referenced by _write_fpga_reg(), and _write_fpga_reg_masked().
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().