Universal Software Radio Peripheral
|
#include "usrp_primsi.h"
#include "usrp_commands.h"
#include "usrp_ids.h"
#include "usrp_i2c_addr.h"
#include "fpga_regs_common.h"
#include "fpga_regs_standard.h"
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <algorithm>
#include <ad9862.h>
#include <assert.h>
#include "std_paths.h"
#include "md5.h"
Defines | |
#define | VERBOSE 0 |
Functions | |
int | usrp_hw_rev (libusb_device *q) |
bool | usrp_usrp_p (libusb_device *q) |
bool | usrp_fx2_p (libusb_device *q) |
bool | usrp_usrp0_p (libusb_device *q) |
bool | usrp_usrp1_p (libusb_device *q) |
bool | usrp_usrp2_p (libusb_device *q) |
bool | usrp_unconfigured_usrp_p (libusb_device *q) |
bool | usrp_configured_usrp_p (libusb_device *q) |
libusb_device_handle * | usrp_open_cmd_interface (libusb_device *dev) |
given a libusb_device return an instance of the appropriate libusb_device_handle | |
libusb_device_handle * | usrp_open_rx_interface (libusb_device *dev) |
libusb_device_handle * | usrp_open_tx_interface (libusb_device *dev) |
bool | usrp_set_led (libusb_device_handle *udh, int which, bool on) |
bool | usrp_set_hash (libusb_device_handle *udh, int which, const unsigned char hash[USRP_HASH_SIZE]) |
copy the given hash into the USRP hash slot which . The usrp implements two hash slots, 0 and 1. | |
bool | usrp_get_hash (libusb_device_handle *udh, int which, unsigned char hash[USRP_HASH_SIZE]) |
retrieve the hash from the USRP hash slot which . The usrp implements two hash slots, 0 and 1. | |
bool | usrp_write_fpga_reg (libusb_device_handle *udh, int reg, int value) |
bool | usrp_read_fpga_reg (libusb_device_handle *udh, int reg, int *value) |
bool | usrp_set_fpga_reset (libusb_device_handle *udh, bool on) |
bool | usrp_set_fpga_tx_enable (libusb_device_handle *udh, bool on) |
bool | usrp_set_fpga_rx_enable (libusb_device_handle *udh, bool on) |
bool | usrp_set_fpga_tx_reset (libusb_device_handle *udh, bool on) |
bool | usrp_set_fpga_rx_reset (libusb_device_handle *udh, bool on) |
usrp_load_status_t | usrp_load_firmware (libusb_device_handle *udh, const char *filename, bool force) |
load intel hex format file into USRP/Cypress FX2 (8051). | |
usrp_load_status_t | usrp_load_fpga (libusb_device_handle *udh, const char *filename, bool force) |
load fpga configuration bitstream | |
usrp_load_status_t | usrp_load_firmware_nth (int nth, const char *filename, bool force, libusb_context *ctx) |
load intel hex format file into USRP FX2 (8051). | |
bool | usrp_load_standard_bits (int nth, bool force, const std::string fpga_filename, const std::string firmware_filename, libusb_context *ctx) |
load the regular firmware and fpga bitstream in the Nth USRP. | |
bool | _usrp_get_status (libusb_device_handle *udh, int which, bool *trouble) |
bool | usrp_check_rx_overrun (libusb_device_handle *udh, bool *overrun_p) |
bool | usrp_check_tx_underrun (libusb_device_handle *udh, bool *underrun_p) |
bool | usrp_i2c_write (libusb_device_handle *udh, int i2c_addr, const void *buf, int len) |
bool | usrp_i2c_read (libusb_device_handle *udh, int i2c_addr, void *buf, int len) |
bool | usrp_spi_write (libusb_device_handle *udh, int optional_header, int enables, int format, const void *buf, int len) |
bool | usrp_spi_read (libusb_device_handle *udh, int optional_header, int enables, int format, void *buf, int len) |
bool | usrp_9862_write (libusb_device_handle *udh, int which_codec, int regno, int value) |
bool | usrp_9862_read (libusb_device_handle *udh, int which_codec, int regno, unsigned char *value) |
bool | usrp_9862_write_many (libusb_device_handle *udh, int which_codec, const unsigned char *buf, int len) |
Write multiple 9862 regs at once. | |
bool | usrp_9862_write_many_all (libusb_device_handle *udh, const unsigned char *buf, int len) |
write specified regs to all 9862's in the system | |
bool | usrp_eeprom_write (libusb_device_handle *udh, int i2c_addr, int eeprom_offset, const void *buf, int len) |
bool | usrp_eeprom_read (libusb_device_handle *udh, int i2c_addr, int eeprom_offset, void *buf, int len) |
bool | usrp_write_aux_dac (libusb_device_handle *udh, int slot, int which_dac, int value) |
write to the specified aux dac. | |
bool | usrp_read_aux_adc (libusb_device_handle *udh, int slot, int which_adc, int *value) |
Read the specified aux adc. | |
usrp_dbeeprom_status_t | usrp_read_dboard_eeprom (libusb_device_handle *udh, int slot_id, usrp_dboard_eeprom *eeprom) |
Read and return parsed daughterboard eeprom. | |
bool | usrp_write_dboard_offsets (libusb_device_handle *udh, int slot_id, short offset0, short offset1) |
write ADC/DAC offset calibration constants to d'board eeprom | |
std::string | usrp_serial_number (libusb_device_handle *udh) |
return a usrp's serial number. |
#define VERBOSE 0 |
bool _usrp_get_status | ( | libusb_device_handle * | udh, |
int | which, | ||
bool * | trouble | ||
) |
References write_cmd().
Referenced by usrp_check_rx_overrun(), and usrp_check_tx_underrun().
bool usrp_9862_read | ( | libusb_device_handle * | udh, |
int | which_codec, | ||
int | regno, | ||
unsigned char * | value | ||
) |
References usrp_spi_read().
Referenced by usrp_basic::_read_9862(), main(), and usrp_read_aux_adc().
bool usrp_9862_write | ( | libusb_device_handle * | udh, |
int | which_codec, | ||
int | regno, | ||
int | value | ||
) |
References usrp_spi_write().
Referenced by usrp_basic::_write_9862(), main(), usrp_9862_write_many(), usrp_basic_rx::usrp_basic_rx(), usrp_basic_tx::usrp_basic_tx(), usrp_read_aux_adc(), and usrp_write_aux_dac().
bool usrp_9862_write_many | ( | libusb_device_handle * | udh, |
int | which_codec, | ||
const unsigned char * | buf, | ||
int | len | ||
) |
Write multiple 9862 regs at once.
buf
contains alternating register_number, register_value pairs. len
must be even and is the length of buf in bytes.
References usrp_9862_write().
Referenced by usrp_9862_write_many_all().
bool usrp_9862_write_many_all | ( | libusb_device_handle * | udh, |
const unsigned char * | buf, | ||
int | len | ||
) |
write specified regs to all 9862's in the system
References usrp_9862_write_many().
Referenced by usrp_basic::usrp_basic(), usrp_basic_rx::usrp_basic_rx(), usrp_basic_tx::usrp_basic_tx(), usrp_standard_tx::usrp_standard_tx(), usrp_basic_rx::~usrp_basic_rx(), and usrp_basic_tx::~usrp_basic_tx().
bool usrp_check_rx_overrun | ( | libusb_device_handle * | udh, |
bool * | overrun_p | ||
) |
References _usrp_get_status().
Referenced by usrp_basic_rx::read().
bool usrp_check_tx_underrun | ( | libusb_device_handle * | udh, |
bool * | underrun_p | ||
) |
References _usrp_get_status().
Referenced by usrp_basic_tx::write().
bool usrp_configured_usrp_p | ( | libusb_device * | q | ) |
References usrp_usrp_p().
bool usrp_eeprom_read | ( | libusb_device_handle * | udh, |
int | i2c_addr, | ||
int | eeprom_offset, | ||
void * | buf, | ||
int | len | ||
) |
References usrp_i2c_read(), and usrp_i2c_write().
Referenced by usrp_basic::read_eeprom().
bool usrp_eeprom_write | ( | libusb_device_handle * | udh, |
int | i2c_addr, | ||
int | eeprom_offset, | ||
const void * | buf, | ||
int | len | ||
) |
References usrp_i2c_write().
Referenced by usrp_write_dboard_offsets(), and usrp_basic::write_eeprom().
bool usrp_fx2_p | ( | libusb_device * | q | ) |
References _get_usb_device_descriptor().
Referenced by main(), and usrp_find_device().
bool usrp_get_hash | ( | libusb_device_handle * | udh, |
int | which, | ||
unsigned char | hash[USRP_HASH_SIZE] | ||
) |
retrieve the hash
from the USRP hash slot which
. The usrp implements two hash slots, 0 and 1.
References _usb_control_transfer().
Referenced by main().
int usrp_hw_rev | ( | libusb_device * | q | ) |
References _get_usb_device_descriptor().
Referenced by usrp_basic::usrp_basic(), usrp_load_standard_bits(), usrp_read_fpga_reg(), usrp_usrp0_p(), usrp_usrp1_p(), usrp_usrp2_p(), and usrp_write_fpga_reg().
bool usrp_i2c_read | ( | libusb_device_handle * | udh, |
int | i2c_addr, | ||
void * | buf, | ||
int | len | ||
) |
References write_cmd().
Referenced by main(), usrp_basic::read_i2c(), and usrp_eeprom_read().
bool usrp_i2c_write | ( | libusb_device_handle * | udh, |
int | i2c_addr, | ||
const void * | buf, | ||
int | len | ||
) |
References write_cmd().
Referenced by main(), usrp_eeprom_read(), usrp_eeprom_write(), and usrp_basic::write_i2c().
usrp_load_status_t usrp_load_firmware | ( | libusb_device_handle * | udh, |
const char * | filename, | ||
bool | force | ||
) |
load intel hex format file into USRP/Cypress FX2 (8051).
The filename extension is typically *.ihx
Note that loading firmware may cause the device to renumerate. I.e., change its configuration, invalidating the current device handle.
Referenced by main(), and usrp_load_firmware_nth().
usrp_load_status_t usrp_load_firmware_nth | ( | int | nth, |
const char * | filename, | ||
bool | force, | ||
libusb_context * | ctx = NULL |
||
) |
load intel hex format file into USRP FX2 (8051).
The filename extension is typically *.ihx
Note that loading firmware may cause the device to renumerate. I.e., change its configuration, invalidating the current device handle. If the result is ULS_OK, usrp_load_firmware_nth delays 1 second then rescans the busses and devices.
References ULS_ALREADY_LOADED, ULS_ERROR, ULS_OK, usrp_close_interface(), usrp_load_firmware(), and usrp_rescan().
Referenced by usrp_load_standard_bits().
usrp_load_status_t usrp_load_fpga | ( | libusb_device_handle * | udh, |
const char * | filename, | ||
bool | force | ||
) |
load fpga configuration bitstream
Referenced by main(), and usrp_load_standard_bits().
bool usrp_load_standard_bits | ( | int | nth, |
bool | force, | ||
const std::string | fpga_filename = "" , |
||
const std::string | firmware_filename = "" , |
||
libusb_context * | ctx = NULL |
||
) |
load the regular firmware and fpga bitstream in the Nth USRP.
This is the normal starting point...
References ULS_ERROR, ULS_OK, usrp_close_interface(), usrp_find_device(), usrp_hw_rev(), usrp_load_firmware_nth(), and usrp_load_fpga().
Referenced by main(), and usrp_basic::usrp_basic().
libusb_device_handle* usrp_open_cmd_interface | ( | libusb_device * | dev | ) |
given a libusb_device return an instance of the appropriate libusb_device_handle
These routines claim the specified interface and select the correct alternate interface. (USB nomenclature is totally screwed!)
If interface can't be opened, or is already claimed by some other process, 0 is returned.
References usrp_open_interface().
Referenced by main().
libusb_device_handle* usrp_open_rx_interface | ( | libusb_device * | dev | ) |
References usrp_open_interface().
libusb_device_handle* usrp_open_tx_interface | ( | libusb_device * | dev | ) |
References usrp_open_interface().
bool usrp_read_aux_adc | ( | libusb_device_handle * | udh, |
int | slot, | ||
int | which_adc, | ||
int * | value | ||
) |
Read the specified aux adc.
slot:
which Tx or Rx slot to read aux dac which_adc:
[0,1] which of the two adcs to read *value
: return value, 12-bit straight binary.
References AUX_ADC_CTRL_REFSEL_A, AUX_ADC_CTRL_REFSEL_B, AUX_ADC_CTRL_SELECT_A1, AUX_ADC_CTRL_SELECT_A2, AUX_ADC_CTRL_SELECT_B1, AUX_ADC_CTRL_SELECT_B2, AUX_ADC_CTRL_START_A, AUX_ADC_CTRL_START_B, usrp_9862_read(), and usrp_9862_write().
Referenced by usrp_basic::_read_aux_adc().
usrp_dbeeprom_status_t usrp_read_dboard_eeprom | ( | libusb_device_handle * | udh, |
int | slot_id, | ||
usrp_dboard_eeprom * | eeprom | ||
) |
Read and return parsed daughterboard eeprom.
References usrp_dboard_eeprom::id, usrp_dboard_eeprom::oe, usrp_dboard_eeprom::offset, and UDBE_OK.
Referenced by usrp_basic_rx::probe_rx_slots(), and usrp_basic_tx::probe_tx_slots().
bool usrp_read_fpga_reg | ( | libusb_device_handle * | udh, |
int | reg, | ||
int * | value | ||
) |
References _get_usb_device(), and usrp_hw_rev().
Referenced by usrp_basic::_read_fpga_reg().
std::string usrp_serial_number | ( | libusb_device_handle * | udh | ) |
return a usrp's serial number.
Note that this only works on a configured usrp.
References _get_usb_device(), _get_usb_device_descriptor(), and _get_usb_string_descriptor().
Referenced by usrp_basic::serial_number().
bool usrp_set_fpga_reset | ( | libusb_device_handle * | udh, |
bool | on | ||
) |
Referenced by main().
bool usrp_set_fpga_rx_enable | ( | libusb_device_handle * | udh, |
bool | on | ||
) |
Referenced by main(), and usrp_basic_rx::set_rx_enable().
bool usrp_set_fpga_rx_reset | ( | libusb_device_handle * | udh, |
bool | on | ||
) |
Referenced by usrp_basic_rx::usrp_basic_rx().
bool usrp_set_fpga_tx_enable | ( | libusb_device_handle * | udh, |
bool | on | ||
) |
Referenced by main(), and usrp_basic_tx::set_tx_enable().
bool usrp_set_fpga_tx_reset | ( | libusb_device_handle * | udh, |
bool | on | ||
) |
Referenced by usrp_basic_tx::usrp_basic_tx().
bool usrp_set_hash | ( | libusb_device_handle * | udh, |
int | which, | ||
const unsigned char | hash[USRP_HASH_SIZE] | ||
) |
copy the given hash
into the USRP hash slot which
. The usrp implements two hash slots, 0 and 1.
References _usb_control_transfer().
Referenced by main().
bool usrp_set_led | ( | libusb_device_handle * | udh, |
int | which, | ||
bool | on | ||
) |
References write_cmd().
Referenced by usrp_basic::_set_led(), and main().
bool usrp_spi_read | ( | libusb_device_handle * | udh, |
int | optional_header, | ||
int | enables, | ||
int | format, | ||
void * | buf, | ||
int | len | ||
) |
References write_cmd().
Referenced by usrp_basic::_read_spi(), and usrp_9862_read().
bool usrp_spi_write | ( | libusb_device_handle * | udh, |
int | optional_header, | ||
int | enables, | ||
int | format, | ||
const void * | buf, | ||
int | len | ||
) |
References write_cmd().
Referenced by usrp_basic::_write_spi(), and usrp_9862_write().
bool usrp_unconfigured_usrp_p | ( | libusb_device * | q | ) |
References usrp_usrp_p().
Referenced by main().
bool usrp_usrp0_p | ( | libusb_device * | q | ) |
References usrp_hw_rev(), and usrp_usrp_p().
bool usrp_usrp1_p | ( | libusb_device * | q | ) |
References usrp_hw_rev(), and usrp_usrp_p().
bool usrp_usrp2_p | ( | libusb_device * | q | ) |
References usrp_hw_rev(), and usrp_usrp_p().
bool usrp_usrp_p | ( | libusb_device * | q | ) |
References _get_usb_device_descriptor().
Referenced by usrp_basic::usrp_basic(), usrp_configured_usrp_p(), usrp_find_device(), usrp_unconfigured_usrp_p(), usrp_usrp0_p(), usrp_usrp1_p(), and usrp_usrp2_p().
bool usrp_write_aux_dac | ( | libusb_device_handle * | uhd, |
int | slot, | ||
int | which_dac, | ||
int | value | ||
) |
write to the specified aux dac.
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.
AUX DAC 3 is really the 9862 sigma delta output.
value
to write to aux dac. All dacs take straight binary values. Although dacs 0, 1 and 2 are 8-bit and dac 3 is 12-bit, the interface is in terms of 12-bit values [0,4095]
References usrp_9862_write().
Referenced by usrp_basic::_write_aux_dac().
bool usrp_write_dboard_offsets | ( | libusb_device_handle * | udh, |
int | slot_id, | ||
short | offset0, | ||
short | offset1 | ||
) |
write ADC/DAC offset calibration constants to d'board eeprom
References UDBE_OK, and usrp_eeprom_write().
bool usrp_write_fpga_reg | ( | libusb_device_handle * | udh, |
int | reg, | ||
int | value | ||
) |
References _get_usb_device(), and usrp_hw_rev().
Referenced by usrp_basic::_write_fpga_reg(), usrp_basic::_write_fpga_reg_masked(), and main().