![]() |
libbladeRF
2.5.0
Nuand bladeRF library
|
This group of functions presents synchronous, blocking calls (with optional timeouts) for transmitting and receiving samples.
The synchronous interface is built atop the asynchronous interface, and is generally less complex and easier to work with. It alleviates the need to explicitly spawn threads (it is done under the hood) and manually manage sample buffers.
Under the hood, this interface spawns worker threads to handle an asynchronous stream and perform thread-safe buffer management.
These functions are thread-safe.
The following pages provide additional information and example usage:
Functions | |
API_EXPORT int CALL_CONV | bladerf_sync_config (struct bladerf *dev, bladerf_channel_layout layout, bladerf_format format, unsigned int num_buffers, unsigned int buffer_size, unsigned int num_transfers, unsigned int stream_timeout) |
API_EXPORT int CALL_CONV | bladerf_sync_tx (struct bladerf *dev, const void *samples, unsigned int num_samples, struct bladerf_metadata *metadata, unsigned int timeout_ms) |
API_EXPORT int CALL_CONV | bladerf_sync_rx (struct bladerf *dev, void *samples, unsigned int num_samples, struct bladerf_metadata *metadata, unsigned int timeout_ms) |
API_EXPORT int CALL_CONV bladerf_sync_config | ( | struct bladerf * | dev, |
bladerf_channel_layout | layout, | ||
bladerf_format | format, | ||
unsigned int | num_buffers, | ||
unsigned int | buffer_size, | ||
unsigned int | num_transfers, | ||
unsigned int | stream_timeout | ||
) |
(Re)Configure a device for synchronous transmission or reception
This function sets up the device for the specified format and initializes the underlying asynchronous stream parameters
This function does not call bladerf_enable_module(). The API user is responsible for enabling/disable streams when desired.
Note that (re)configuring the TX direction does not affect the RX direction, and vice versa. This call configures each direction independently.
Memory allocated by this function will be deallocated when bladerf_close() is called.
buffers_size
, num_transfers
, and stream_timeout
.num_buffers
parameter should generally be increased as the amount of work done between bladerf_sync_rx() or bladerf_sync_tx() calls increases.dev | Device to configure | |
[in] | layout | Stream direction and layout |
[in] | format | Format to use in synchronous data transfers |
[in] | num_buffers | The number of buffers to use in the underlying data stream. This must be greater than the num_xfers parameter. |
[in] | buffer_size | The size of the underlying stream buffers, in samples. This value must be a multiple of 1024. Note that samples are only transferred when a buffer of this size is filled. |
[in] | num_transfers | The number of active USB transfers that may be in-flight at any given time. If unsure of what to use here, try values of 4, 8, or 16. |
[in] | stream_timeout | Timeout (milliseconds) for transfers in the underlying data stream. |
API_EXPORT int CALL_CONV bladerf_sync_rx | ( | struct bladerf * | dev, |
void * | samples, | ||
unsigned int | num_samples, | ||
struct bladerf_metadata * | metadata, | ||
unsigned int | timeout_ms | ||
) |
Receive IQ samples.
Under the hood, this call starts up an underlying asynchronous stream as needed. This stream can be stopped by disabling the RX channel. (See bladerf_enable_module for more details.)
dev | Device handle | |
[out] | samples | Buffer to store samples in. The caller is responsible for ensuring this buffer is sufficiently large for the number of samples requested, considering the size of the sample format being used. |
[in] | num_samples | Number of samples to read |
[out] | metadata | Sample metadata. This must be provided when using the BLADERF_FORMAT_SC16_Q11_META format, but may be NULL when the interface is configured for the BLADERF_FORMAT_SC16_Q11 format. |
[in] | timeout_ms | Timeout (milliseconds) for this call to complete. Zero implies "infinite." |
API_EXPORT int CALL_CONV bladerf_sync_tx | ( | struct bladerf * | dev, |
const void * | samples, | ||
unsigned int | num_samples, | ||
struct bladerf_metadata * | metadata, | ||
unsigned int | timeout_ms | ||
) |
Transmit IQ samples.
Under the hood, this call starts up an underlying asynchronous stream as needed. This stream can be stopped by disabling the TX channel. (See bladerf_enable_module for more details.)
Samples will only be sent to the FPGA when a buffer have been filled. The number of samples required to fill a buffer corresponds to the buffer_size
parameter passed to bladerf_sync_config().
dev | Device handle | |
[in] | samples | Array of samples |
[in] | num_samples | Number of samples to write |
[in] | metadata | Sample metadata. This must be provided when using the BLADERF_FORMAT_SC16_Q11_META format, but may be NULL when the interface is configured for the BLADERF_FORMAT_SC16_Q11 format. |
[in] | timeout_ms | Timeout (milliseconds) for this call to complete. Zero implies "infinite." |