aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Tucker <ryan.tucker@nuand.com>2017-07-20 16:13:03 -0400
committerDimitri Stolnikov <horiz0n@gmx.net>2018-08-15 19:53:26 +0200
commitc8e69edb7b4dbebfe60e7be3702664d29dfd7dec (patch)
treed43f66f3ff348288c80291bc70cc8830114df6ab
parent68ba383fd5f9b35d47dbc398cc4202a90a1a4c3c (diff)
bladerf: add set_rx_mux_mode functionality
Also plumb through as rxmux= device argument
-rw-r--r--lib/bladerf/bladerf_common.cc40
-rw-r--r--lib/bladerf/bladerf_common.h1
2 files changed, 40 insertions, 1 deletions
diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc
index d099c29..1b6c1db 100644
--- a/lib/bladerf/bladerf_common.cc
+++ b/lib/bladerf/bladerf_common.cc
@@ -205,6 +205,31 @@ void bladerf_common::set_loopback_mode(const std::string &loopback)
}
}
+void bladerf_common::set_rx_mux_mode(const std::string &rxmux)
+{
+ int status;
+ bladerf_rx_mux mode;
+
+ if (rxmux == "baseband") {
+ mode = BLADERF_RX_MUX_BASEBAND;
+ } else if (rxmux == "12bit") {
+ mode = BLADERF_RX_MUX_12BIT_COUNTER;
+ } else if (rxmux == "32bit") {
+ mode = BLADERF_RX_MUX_32BIT_COUNTER;
+ } else if (rxmux == "digital") {
+ mode = BLADERF_RX_MUX_DIGITAL_LOOPBACK;
+ } else {
+ throw std::runtime_error(_pfx + "Unknown RX mux mode: " + rxmux);
+ }
+
+ status = bladerf_set_rx_mux(_dev.get(), mode);
+ if (status != 0) {
+ // TODO: handle BLADERF_ERR_UNSUPPORTED more gingerly
+ throw std::runtime_error(_pfx + "Failed to set RX mux mode: " +
+ bladerf_strerror(status));
+ }
+}
+
void bladerf_common::set_verbosity(const std::string &verbosity)
{
bladerf_log_level l;
@@ -413,11 +438,24 @@ void bladerf_common::init(dict_t &dict, bladerf_direction direction)
} else if (direction == BLADERF_TX && dict.count("loopback")) {
std::cerr << _pfx
<< "Warning: 'loopback' has been specified on a bladeRF "
- << "sink, and will have no effect. This parameter should "
+ << "sink, and will have no effect. This parameter should "
<< "be specified on the associated bladeRF source."
<< std::endl;
}
+ if (direction == BLADERF_RX) {
+ if (dict.count("rxmux")) {
+ set_rx_mux_mode(dict["rxmux"]);
+ } else {
+ set_rx_mux_mode("baseband");
+ }
+ } else if (direction == BLADERF_TX && dict.count("rxmux")) {
+ std::cerr << _pfx
+ << "Warning: 'rxmux' has been specified on a bladeRF sink, "
+ << "and will have no effect."
+ << std::endl;
+ }
+
if (dict.count("xb200")) {
if (bladerf_expansion_attach(_dev.get(), BLADERF_XB_200)) {
std::cerr << _pfx << "Could not attach XB-200" << std::endl;
diff --git a/lib/bladerf/bladerf_common.h b/lib/bladerf/bladerf_common.h
index 629709a..34a5ea0 100644
--- a/lib/bladerf/bladerf_common.h
+++ b/lib/bladerf/bladerf_common.h
@@ -137,6 +137,7 @@ private:
void set_verbosity(const std::string &verbosity);
void set_loopback_mode(const std::string &loopback);
+ void set_rx_mux_mode(const std::string &rxmux);
static boost::mutex _devs_mutex;
static std::list < boost::weak_ptr < struct bladerf >>_devs;