bladerf: add set_rx_mux_mode functionality

Also plumb through as rxmux= device argument
This commit is contained in:
Ryan Tucker 2017-07-20 16:13:03 -04:00 committed by Dimitri Stolnikov
parent 68ba383fd5
commit c8e69edb7b
2 changed files with 40 additions and 1 deletions

View File

@ -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;
@ -418,6 +443,19 @@ void bladerf_common::init(dict_t &dict, bladerf_direction direction)
<< 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;

View File

@ -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;