libbladeRF  1.7.2
Nuand bladeRF library
Data Structures | Macros | Enumerations | Functions
Sampling control

Description

This section presents functionality pertaining to configuring the sample rate and mode of the device's RX and TX modules.

These functions are thread-safe.

Data Structures

struct  bladerf_rational_rate
 

Macros

#define BLADERF_SAMPLERATE_MIN   80000u
 
#define BLADERF_SAMPLERATE_REC_MAX   40000000u
 

Enumerations

enum  bladerf_rx_mux {
  BLADERF_RX_MUX_INVALID = -1, BLADERF_RX_MUX_BASEBAND_LMS = 0x0, BLADERF_RX_MUX_12BIT_COUNTER = 0x1, BLADERF_RX_MUX_32BIT_COUNTER = 0x2,
  BLADERF_RX_MUX_DIGITAL_LOOPBACK = 0x4
}
 
enum  bladerf_sampling { BLADERF_SAMPLING_UNKNOWN, BLADERF_SAMPLING_INTERNAL, BLADERF_SAMPLING_EXTERNAL }
 

Functions

API_EXPORT int CALL_CONV bladerf_set_sample_rate (struct bladerf *dev, bladerf_module module, unsigned int rate, unsigned int *actual)
 
API_EXPORT int CALL_CONV bladerf_set_rational_sample_rate (struct bladerf *dev, bladerf_module module, struct bladerf_rational_rate *rate, struct bladerf_rational_rate *actual)
 
API_EXPORT int CALL_CONV bladerf_get_sample_rate (struct bladerf *dev, bladerf_module module, unsigned int *rate)
 
API_EXPORT int CALL_CONV bladerf_get_rational_sample_rate (struct bladerf *dev, bladerf_module module, struct bladerf_rational_rate *rate)
 
API_EXPORT int CALL_CONV bladerf_set_sampling (struct bladerf *dev, bladerf_sampling sampling)
 
API_EXPORT int CALL_CONV bladerf_set_rx_mux (struct bladerf *dev, bladerf_rx_mux mux)
 
API_EXPORT int CALL_CONV bladerf_get_rx_mux (struct bladerf *dev, bladerf_rx_mux *mode)
 
API_EXPORT int CALL_CONV bladerf_get_sampling (struct bladerf *dev, bladerf_sampling *sampling)
 

Macro Definition Documentation

#define BLADERF_SAMPLERATE_MIN   80000u

Minimum sample rate, in Hz

Definition at line 721 of file libbladeRF.h.

#define BLADERF_SAMPLERATE_REC_MAX   40000000u

Maximum recommended sample rate, in Hz.

The max sample rate of the LMS6002D is 40 MHz, but this API allows for larger values to allow users to leverage FPGA customizations (e.g., to generate test samples or mux other data into the sample stream).

If you are not performing such customizations, treat this as the max allowed values.

Definition at line 733 of file libbladeRF.h.

Enumeration Type Documentation

RX Mux modes

These values describe the source of samples to the RX FIFOs in the FPGA. They map directly to rx_mux_mode_t inside the FPGA's source code.

Enumerator
BLADERF_RX_MUX_INVALID 

Invalid RX Mux mode selection

BLADERF_RX_MUX_BASEBAND_LMS 

Read baseband samples from the LMS6002D. This is the default mode of operation.

BLADERF_RX_MUX_12BIT_COUNTER 

Read samples from 12 bit counters.

The I channel counts up while the Q channel counts down.

BLADERF_RX_MUX_32BIT_COUNTER 

Read samples from a 32 bit up-counter.

I and Q form a little-endian value.

BLADERF_RX_MUX_DIGITAL_LOOPBACK 

Read samples from the baseband TX input to the FPGA (from the host)

Definition at line 741 of file libbladeRF.h.

Sampling connection

Enumerator
BLADERF_SAMPLING_UNKNOWN 

Unable to determine connection type

BLADERF_SAMPLING_INTERNAL 

Sample from RX/TX connector

BLADERF_SAMPLING_EXTERNAL 

Sample from J60 or J61

Definition at line 789 of file libbladeRF.h.

Function Documentation

API_EXPORT int CALL_CONV bladerf_get_rational_sample_rate ( struct bladerf *  dev,
bladerf_module  module,
struct bladerf_rational_rate rate 
)

Read the device's sample rate in rational Hz

Parameters
[in]devDevice handle
[in]moduleModule to query
[out]ratePointer to returned rational sample rate
Returns
0 on success, value from Error codes list upon failure
API_EXPORT int CALL_CONV bladerf_get_rx_mux ( struct bladerf *  dev,
bladerf_rx_mux mode 
)

Gets the current RX Mux mode

Parameters
[in]devDevice handle
[out]modeCurrent RX Mux mode
Returns
0 on success, value from Error codes list on failure.
API_EXPORT int CALL_CONV bladerf_get_sample_rate ( struct bladerf *  dev,
bladerf_module  module,
unsigned int *  rate 
)

Read the device's sample rate in Hz

Parameters
[in]devDevice handle
[in]moduleModule to query
[out]ratePointer to returned sample rate
Returns
0 on success, value from Error codes list upon failure
API_EXPORT int CALL_CONV bladerf_get_sampling ( struct bladerf *  dev,
bladerf_sampling sampling 
)

Read the device's current state of RXVGA2 and ADC pin connection to figure out which sampling mode it is currently configured in.

Parameters
[in]devDevice handle
[out]samplingSampling connection
Returns
0 on success, value from Error codes list on failure
API_EXPORT int CALL_CONV bladerf_set_rational_sample_rate ( struct bladerf *  dev,
bladerf_module  module,
struct bladerf_rational_rate rate,
struct bladerf_rational_rate actual 
)

Configure the device's sample rate as a rational fraction of Hz. Sample rates are in the form of integer + num/denom.

Parameters
[in]devDevice handle
[in]moduleModule to change
[in]rateRational sample rate
[out]actualIf non-NULL, this is written with the actual rational sample rate achieved.

The sample rate must be greater than or equal to BLADERF_SAMPLERATE_MIN. Values above BLADERF_SAMPLERATE_REC_MAX are allowed, but not recommended. Setting the sample rates higher than recommended max may yield errors and unexpected results.

Returns
0 on success, BLADERF_ERR_INVAL for an invalid sample rate, or a value from Error codes list on other failures
API_EXPORT int CALL_CONV bladerf_set_rx_mux ( struct bladerf *  dev,
bladerf_rx_mux  mux 
)

Set the current RX Mux mode

Parameters
devDevice handle
muxMux mode.
Returns
0 on success, value from Error codes list on failure.
API_EXPORT int CALL_CONV bladerf_set_sample_rate ( struct bladerf *  dev,
bladerf_module  module,
unsigned int  rate,
unsigned int *  actual 
)

Configure the device's sample rate, in Hz. Note this requires the sample rate is an integer value of Hz. Use bladerf_set_rational_sample_rate() for more arbitrary values.

The sample rate must be greater than or equal to BLADERF_SAMPLERATE_MIN. Values above BLADERF_SAMPLERATE_REC_MAX are allowed, but not recommended. Setting the sample rates higher than recommended max may yield errors and unexpected results.

Parameters
[in]devDevice handle
[in]moduleModule to change
[in]rateSample rate
[out]actualIf non-NULL. this is written with the actual sample rate achieved.
Returns
0 on success, BLADERF_ERR_INVAL for an invalid sample rate, or a value from Error codes list on other failures
API_EXPORT int CALL_CONV bladerf_set_sampling ( struct bladerf *  dev,
bladerf_sampling  sampling 
)

Configure the sampling of the LMS6002D to be either internal or external. Internal sampling will read from the RXVGA2 driver internal to the chip. External sampling will connect the ADC inputs to the external inputs for direct sampling.

Parameters
[in]devDevice handle
[in]samplingSampling connection
Returns
0 on success, value from Error codes list on failure