GNU Radio 3.3.0 C++ API
|
standard C++ interface to USRP2 More...
#include <usrp2.h>
Classes | |
class | impl |
Public Types | |
typedef boost::shared_ptr< usrp2 > | sptr |
Public Member Functions | |
~usrp2 () | |
std::string | mac_addr () |
std::string | interface_name () |
bool | set_rx_antenna (int ant) |
bool | set_rx_gain (double gain) |
double | rx_gain_min () |
return minimum Rx gain | |
double | rx_gain_max () |
return maximum Rx gain | |
double | rx_gain_db_per_step () |
return Rx gain db_per_step | |
bool | set_rx_lo_offset (double frequency) |
Set receive daughterboard LO offset frequency. | |
bool | set_rx_center_freq (double frequency, tune_result *result) |
double | rx_freq_min () |
return minimum Rx center frequency | |
double | rx_freq_max () |
return maximum Rx center frequency | |
bool | set_rx_decim (int decimation_factor) |
int | rx_decim () |
Return current decimation factor. | |
bool | set_rx_scale_iq (int scale_i, int scale_q) |
bool | start_rx_streaming (unsigned int channel=0, unsigned int items_per_frame=0) |
bool | start_rx_streaming_at (unsigned int channel=0, unsigned int items_per_frame=0, unsigned int time=0) |
bool | sync_and_start_rx_streaming_at (unsigned int channel=0, unsigned int items_per_frame=0, uint32_t time=0) |
bool | stop_rx_streaming (unsigned int channel=0) |
bool | rx_samples (unsigned int channel, rx_sample_handler *handler) |
Receive data from the specified channel This method is used to receive all data: streaming or discrete. | |
unsigned int | rx_overruns () |
unsigned int | rx_missing () |
bool | set_tx_antenna (int ant) |
bool | set_tx_gain (double gain) |
double | tx_gain_min () |
return minimum Tx gain | |
double | tx_gain_max () |
return maximum Tx gain | |
double | tx_gain_db_per_step () |
return Tx gain db_per_step | |
bool | set_tx_lo_offset (double frequency) |
bool | set_tx_center_freq (double frequency, tune_result *result) |
double | tx_freq_min () |
return minimum Tx center frequency | |
double | tx_freq_max () |
return maximum Tx center frequency | |
bool | set_tx_interp (int interpolation_factor) |
int | tx_interp () |
Return current interpolation factor. | |
void | default_tx_scale_iq (int interpolation_factor, int *scale_i, int *scale_q) |
bool | set_tx_scale_iq (int scale_i, int scale_q) |
bool | tx_32fc (unsigned int channel, const std::complex< float > *samples, size_t nsamples, const tx_metadata *metadata) |
transmit complex<float> samples to USRP2 | |
bool | tx_16sc (unsigned int channel, const std::complex< int16_t > *samples, size_t nsamples, const tx_metadata *metadata) |
transmit complex<int16_t> samples to USRP2 | |
bool | tx_raw (unsigned int channel, const uint32_t *items, size_t nitems, const tx_metadata *metadata) |
transmit raw uint32_t data items to USRP2 | |
bool | config_mimo (int flags) |
MIMO configuration. | |
bool | fpga_master_clock_freq (long *freq) |
Get frequency of master oscillator in Hz. | |
bool | adc_rate (long *rate) |
bool | dac_rate (long *rate) |
bool | tx_daughterboard_id (int *dbid) |
Get Tx daughterboard ID. | |
bool | rx_daughterboard_id (int *dbid) |
Get Rx daughterboard ID. | |
bool | burn_mac_addr (const std::string &new_addr) |
bool | sync_to_pps () |
bool | sync_every_pps (bool enable) |
std::vector< uint32_t > | peek32 (uint32_t addr, uint32_t words) |
bool | poke32 (uint32_t addr, const std::vector< uint32_t > &data) |
bool | set_gpio_ddr (int bank, uint16_t value, uint16_t mask) |
bool | set_gpio_sels (int bank, std::string sels) |
bool | write_gpio (int bank, uint16_t value, uint16_t mask) |
bool | read_gpio (int bank, uint16_t *value) |
bool | enable_gpio_streaming (int bank, int enable) |
Static Public Member Functions | |
static sptr | make (const std::string &ifc, const std::string &addr="", size_t rx_bufsize=0) |
Static Public Attributes | |
static const unsigned int | MAX_CHAN = 30 |
standard C++ interface to USRP2
typedef boost::shared_ptr<usrp2> usrp2::usrp2::sptr |
Shared pointer to this class
usrp2::usrp2::~usrp2 | ( | ) |
Class destructor
bool usrp2::usrp2::adc_rate | ( | long * | rate | ) |
bool usrp2::usrp2::burn_mac_addr | ( | const std::string & | new_addr | ) |
Burn new mac address into EEPROM on USRP2
new_addr | Network mac address, e.g., "01:23:45:67:89:ab" or "89:ab". If addr is HH:HH, it's treated as if it were 00:50:c2:85:HH:HH |
bool usrp2::usrp2::config_mimo | ( | int | flags | ) |
MIMO configuration.
flags | from usrp2_mimo_config.h |
one of these:
MC_WE_DONT_LOCK MC_WE_LOCK_TO_SMA MC_WE_LOCK_TO_MIMO
and optionally this:
MC_PROVIDE_CLK_TO_MIMO
bool usrp2::usrp2::dac_rate | ( | long * | rate | ) |
void usrp2::usrp2::default_tx_scale_iq | ( | int | interpolation_factor, |
int * | scale_i, | ||
int * | scale_q | ||
) |
bool usrp2::usrp2::enable_gpio_streaming | ( | int | bank, |
int | enable | ||
) |
Set GPIO streaming mode
Individually enables streaming GPIO pins through LSBs of DSP samples.
On receive, io_rx[15] replaces I[0], io_rx[14] replaces Q[0] On transmit, I[0] maps to io_tx[15], Q[0] maps to io_tx[14] (Transmit streaming is not yet implemented.)
The selected GPIO pins must have been set as inputs or outputs and, for transmit, set to software control.
When enabled, the replaced DSP sample LSBs become 0.
bank | GPIO_TX_BANK or GPIO_RX_BANK |
enable | enable[0] controls I channel LSB enable[1] controls Q channel LSB |
WARNING: Improper usage of this function may result in damage to the USRP2
bool usrp2::usrp2::fpga_master_clock_freq | ( | long * | freq | ) |
Get frequency of master oscillator in Hz.
std::string usrp2::usrp2::interface_name | ( | ) |
Returns the GbE interface name associated with this USRP
std::string usrp2::usrp2::mac_addr | ( | ) |
Returns the MAC address associated with this USRP
static sptr usrp2::usrp2::make | ( | const std::string & | ifc, |
const std::string & | addr = "" , |
||
size_t | rx_bufsize = 0 |
||
) | [static] |
Static function to return an instance of usrp2 as a shared pointer
ifc | Network interface name, e.g., "eth0" |
addr | Network mac address, e.g., "01:23:45:67:89:ab", "89:ab" or "". If addr is HH:HH, it's treated as if it were 00:50:c2:85:HH:HH "" will autoselect a USRP2 if there is only a single one on the local ethernet. |
rx_bufsize | is the length in bytes of the kernel networking buffer to allocate. |
std::vector<uint32_t> usrp2::usrp2::peek32 | ( | uint32_t | addr, |
uint32_t | words | ||
) |
Read memory from Wishbone bus as 32-bit words. Handles endian swapping if needed.
addr | 32-bit aligned address. Only the lower 16-bits are significant. |
words | Number of 32-bit words |
WARNING: Attempts to read memory from addresses that do not correspond to RAM or memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle.
bool usrp2::usrp2::poke32 | ( | uint32_t | addr, |
const std::vector< uint32_t > & | data | ||
) |
Write memory to Wishbone bus as 32-bit words. Handles endian swapping if needed.
addr | 32-bit aligned address. Only the lower 16-bits are significant |
data | Vector of 32-bit values to write. |
WARNING: Attempts to read memory from addresses that do not correspond to RAM or memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle.
Read daughterboard GPIO pin values
bank | GPIO_TX_BANK or GPIO_RX_BANK |
value | pointer to uint16_t to hold read results |
bool usrp2::usrp2::rx_daughterboard_id | ( | int * | dbid | ) |
Get Rx daughterboard ID.
[out] | dbid | returns the daughterboard id. |
daughterboard id >= 0 if successful, -1 if no daugherboard installed, -2 if invalid EEPROM on daughterboard.
int usrp2::usrp2::rx_decim | ( | ) |
Return current decimation factor.
double usrp2::usrp2::rx_freq_max | ( | ) |
return maximum Rx center frequency
double usrp2::usrp2::rx_freq_min | ( | ) |
return minimum Rx center frequency
double usrp2::usrp2::rx_gain_db_per_step | ( | ) |
return Rx gain db_per_step
double usrp2::usrp2::rx_gain_max | ( | ) |
return maximum Rx gain
double usrp2::usrp2::rx_gain_min | ( | ) |
return minimum Rx gain
unsigned int usrp2::usrp2::rx_missing | ( | ) |
Returns total number of missing frames from overruns.
unsigned int usrp2::usrp2::rx_overruns | ( | ) |
Returns number of times receive overruns have occurred
bool usrp2::usrp2::rx_samples | ( | unsigned int | channel, |
rx_sample_handler * | handler | ||
) |
Receive data from the specified channel This method is used to receive all data: streaming or discrete.
Set daughterboard GPIO data direction register.
bank | GPIO_TX_BANK or GPIO_RX_BANK |
value | 16-bits, 0=FPGA input, 1=FPGA output |
mask | 16-bits, 0=ignore, 1=set |
WARNING: Improper usage of this function may result in damage to the USRP2
bool usrp2::usrp2::set_gpio_sels | ( | int | bank, |
std::string | sels | ||
) |
Set daughterboard GPIO output selection register. For those GPIO pins that are configured as outputs in the DDR, this settings configures the source of the pin value.
bank | GPIO_TX_BANK or GPIO_RX_BANK |
sels | Exactly 16 character MSB->LSB string. For each position: '.' = ignore this bit, i.e., leave current value 'a' = Output ATR value 's' = Output host software controlled value '0' = Output FPGA debug bus 0 value '1' = Output FPGA debug bus 1 value |
WARNING: Improper usage of this function may result in damage to the USRP2
bool usrp2::usrp2::set_rx_antenna | ( | int | ant | ) |
Set the rx antenna
bool usrp2::usrp2::set_rx_center_freq | ( | double | frequency, |
tune_result * | result | ||
) |
Set receiver center frequency
bool usrp2::usrp2::set_rx_decim | ( | int | decimation_factor | ) |
Set receiver sample rate decimation
bool usrp2::usrp2::set_rx_gain | ( | double | gain | ) |
Set receiver gain
gain | in dB (more or less) |
bool usrp2::usrp2::set_rx_lo_offset | ( | double | frequency | ) |
Set receive daughterboard LO offset frequency.
bool usrp2::usrp2::set_rx_scale_iq | ( | int | scale_i, |
int | scale_q | ||
) |
Set receiver IQ magnitude scaling
bool usrp2::usrp2::set_tx_antenna | ( | int | ant | ) |
Set the tx antenna
bool usrp2::usrp2::set_tx_center_freq | ( | double | frequency, |
tune_result * | result | ||
) |
Set transmitter center frequency
bool usrp2::usrp2::set_tx_gain | ( | double | gain | ) |
Set transmitter gain
bool usrp2::usrp2::set_tx_interp | ( | int | interpolation_factor | ) |
Set transmitter sample rate interpolation
bool usrp2::usrp2::set_tx_lo_offset | ( | double | frequency | ) |
bool usrp2::usrp2::set_tx_scale_iq | ( | int | scale_i, |
int | scale_q | ||
) |
Set transmit IQ magnitude scaling
bool usrp2::usrp2::start_rx_streaming | ( | unsigned int | channel = 0 , |
unsigned int | items_per_frame = 0 |
||
) |
Set received sample format
domain: complex or real type: floating, fixed point, or raw depth: bits per sample
Sets format over the wire for samples from USRP2.
Start streaming receive mode. USRP2 will send a continuous stream of DSP pipeline samples to host. Call rx_samples(...) to access.
channel | Stream channel number (0-30) |
items_per_frame | Number of 32-bit items per frame. |
bool usrp2::usrp2::start_rx_streaming_at | ( | unsigned int | channel = 0 , |
unsigned int | items_per_frame = 0 , |
||
unsigned int | time = 0 |
||
) |
Start streaming receive mode at specified timestamp. USRP2 will send a continuous stream of DSP pipeline samples to host. Call rx_samples(...) to access.
channel | Stream channel number (0-30) |
items_per_frame | Number of 32-bit items per frame. |
time | Timestamp to start streaming at |
bool usrp2::usrp2::stop_rx_streaming | ( | unsigned int | channel = 0 | ) |
Stop streaming receive mode.
bool usrp2::usrp2::sync_and_start_rx_streaming_at | ( | unsigned int | channel = 0 , |
unsigned int | items_per_frame = 0 , |
||
uint32_t | time = 0 |
||
) |
Sync to PPS and start streaming receive mode at specified timestamp. Just like calling sync_to_pps() and start_rx_streaming_at().
channel | Stream channel number (0-30) |
items_per_frame | Number of 32-bit items per frame. |
time | Timestamp to start streaming at |
bool usrp2::usrp2::sync_to_pps | ( | ) |
Reset master time to 0 at next PPS edge
bool usrp2::usrp2::tx_16sc | ( | unsigned int | channel, |
const std::complex< int16_t > * | samples, | ||
size_t | nsamples, | ||
const tx_metadata * | metadata | ||
) |
transmit complex<int16_t> samples to USRP2
channel | specifies the channel to send them to |
samples | are the samples to transmit |
nsamples | is the number of samples to transmit |
metadata | provides the timestamp and flags |
The complex<int16_t> samples are converted to the appropriate "on the wire" representation, depending on the current USRP2 configuration. Typically, this is big-endian 16-bit I & Q.
bool usrp2::usrp2::tx_32fc | ( | unsigned int | channel, |
const std::complex< float > * | samples, | ||
size_t | nsamples, | ||
const tx_metadata * | metadata | ||
) |
transmit complex<float> samples to USRP2
Set transmit sample format
domain: complex or real type: floating, fixed point, or raw depth: bits per sample
Sets format over the wire for samples to USRP2.
channel | specifies the channel to send them to |
samples | are the samples to transmit. They should be in the range [-1.0, +1.0] |
nsamples | is the number of samples to transmit |
metadata | provides the timestamp and flags |
The complex<float> samples are converted to the appropriate "on the wire" representation, depending on the current USRP2 configuration. Typically, this is big-endian 16-bit I & Q.
bool usrp2::usrp2::tx_daughterboard_id | ( | int * | dbid | ) |
Get Tx daughterboard ID.
[out] | dbid | returns the daughterboard id. |
daughterboard id >= 0 if successful, -1 if no daugherboard installed, -2 if invalid EEPROM on daughterboard.
double usrp2::usrp2::tx_freq_max | ( | ) |
return maximum Tx center frequency
double usrp2::usrp2::tx_freq_min | ( | ) |
return minimum Tx center frequency
double usrp2::usrp2::tx_gain_db_per_step | ( | ) |
return Tx gain db_per_step
double usrp2::usrp2::tx_gain_max | ( | ) |
return maximum Tx gain
double usrp2::usrp2::tx_gain_min | ( | ) |
return minimum Tx gain
int usrp2::usrp2::tx_interp | ( | ) |
Return current interpolation factor.
bool usrp2::usrp2::tx_raw | ( | unsigned int | channel, |
const uint32_t * | items, | ||
size_t | nitems, | ||
const tx_metadata * | metadata | ||
) |
transmit raw uint32_t data items to USRP2
The caller is responsible for ensuring that the items are formatted appropriately for the USRP2 and its configuration. This method is used primarily by the system itself. Users should call tx_32fc or tx_16sc instead.
channel | specifies the channel to send them to |
items | are the data items to transmit |
nitems | is the number of items to transmit |
metadata | provides the timestamp and flags |
Set daughterboard GPIO pin values.
bank | GPIO_TX_BANK or GPIO_RX_BANK |
value | 16 bits, 0=low, 1=high |
mask | 16 bits, 0=ignore, 1=set |
WARNING: Improper usage of this function may result in damage to the USRP2
const unsigned int usrp2::usrp2::MAX_CHAN = 30 [static] |