Skip to content

Commit 75e4d53

Browse files
rthomp10rghilduta
authored andcommitted
bladeRF: set feature added to device string
A bladeRF feature can now be assigned using the device string. Ex: "bladerf=0,feature=oversample"
1 parent af95b97 commit 75e4d53

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

lib/bladerf/bladerf_common.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,28 @@ void bladerf_common::init(dict_t const &dict, bladerf_direction direction)
313313
_stream_timeout = boost::lexical_cast<unsigned int>(_get(dict, "stream_timeout_ms"));
314314
}
315315

316+
/* Set feature */
317+
if (dict.count("feature")) {
318+
if (_get(dict, "feature") == "oversample") {
319+
_feature = BLADERF_FEATURE_OVERSAMPLE;
320+
} else if (_get(dict, "feature") == "default") {
321+
_feature = BLADERF_FEATURE_DEFAULT;
322+
} else {
323+
BLADERF_THROW("Specified feature invalid. Valid formats: [default|oversample]");
324+
}
325+
} else {
326+
_feature = BLADERF_FEATURE_DEFAULT;
327+
BLADERF_DEBUG( "Feature not provided. Feature left on DEFAULT");
328+
}
329+
330+
status = bladerf_set_feature(_dev.get(), _feature);
331+
if (status != 0) {
332+
BLADERF_THROW_STATUS(status, "Unabled to set feature");
333+
} else {
334+
std::string feature_text = (_feature == BLADERF_FEATURE_OVERSAMPLE) ? "OVERSAMPLE" : "DEFAULT";
335+
BLADERF_INFO(feature_text + " feature enabled");
336+
}
337+
316338
/* Explicately set sample_format */
317339
if (dict.count("sample_format")) {
318340
if (_get(dict, "sample_format") == "16" || _get(dict, "sample_format") == "16bit") {

lib/bladerf/bladerf_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ class bladerf_common
252252
size_t _num_transfers; /**< number of active backend transfers */
253253
unsigned int _stream_timeout; /**< timeout for backend transfers */
254254

255+
bladerf_feature _feature; /**< feature assigned to board */
255256
bladerf_format _format; /**< sample format to use */
256257

257258
bladerf_channel_map _chanmap; /**< map of antennas to channels */

lib/bladerf/bladerf_source_c.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ bool bladerf_source_c::start()
230230

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

233+
status = bladerf_set_feature(_dev.get(), _feature);
234+
if (status != 0) {
235+
BLADERF_THROW_STATUS(status, "bladeRF set_feature failed");
236+
}
237+
233238
status = bladerf_sync_config(_dev.get(), _layout, _format, _num_buffers,
234239
_samples_per_buffer, _num_transfers,
235240
_stream_timeout);

0 commit comments

Comments
 (0)