Skip to content

Commit

Permalink
bladeRF: set feature added to device string
Browse files Browse the repository at this point in the history
A bladeRF feature can now be assigned using the device string.

Ex: "bladerf=0,feature=oversample"
  • Loading branch information
rthomp10 authored and rghilduta committed Feb 14, 2023
1 parent af95b97 commit 75e4d53
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/bladerf/bladerf_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,28 @@ void bladerf_common::init(dict_t const &dict, bladerf_direction direction)
_stream_timeout = boost::lexical_cast<unsigned int>(_get(dict, "stream_timeout_ms"));
}

/* Set feature */
if (dict.count("feature")) {
if (_get(dict, "feature") == "oversample") {
_feature = BLADERF_FEATURE_OVERSAMPLE;
} else if (_get(dict, "feature") == "default") {
_feature = BLADERF_FEATURE_DEFAULT;
} else {
BLADERF_THROW("Specified feature invalid. Valid formats: [default|oversample]");
}
} else {
_feature = BLADERF_FEATURE_DEFAULT;
BLADERF_DEBUG( "Feature not provided. Feature left on DEFAULT");
}

status = bladerf_set_feature(_dev.get(), _feature);
if (status != 0) {
BLADERF_THROW_STATUS(status, "Unabled to set feature");
} else {
std::string feature_text = (_feature == BLADERF_FEATURE_OVERSAMPLE) ? "OVERSAMPLE" : "DEFAULT";
BLADERF_INFO(feature_text + " feature enabled");
}

/* Explicately set sample_format */
if (dict.count("sample_format")) {
if (_get(dict, "sample_format") == "16" || _get(dict, "sample_format") == "16bit") {
Expand Down
1 change: 1 addition & 0 deletions lib/bladerf/bladerf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class bladerf_common
size_t _num_transfers; /**< number of active backend transfers */
unsigned int _stream_timeout; /**< timeout for backend transfers */

bladerf_feature _feature; /**< feature assigned to board */
bladerf_format _format; /**< sample format to use */

bladerf_channel_map _chanmap; /**< map of antennas to channels */
Expand Down
5 changes: 5 additions & 0 deletions lib/bladerf/bladerf_source_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ bool bladerf_source_c::start()

gr::thread::scoped_lock guard(d_mutex);

status = bladerf_set_feature(_dev.get(), _feature);
if (status != 0) {
BLADERF_THROW_STATUS(status, "bladeRF set_feature failed");
}

status = bladerf_sync_config(_dev.get(), _layout, _format, _num_buffers,
_samples_per_buffer, _num_transfers,
_stream_timeout);
Expand Down

0 comments on commit 75e4d53

Please sign in to comment.