aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp
diff options
context:
space:
mode:
authorThomas Vogel <thomas.vogel@ni.com>2019-07-01 17:12:08 +0200
committerBrent Stapleton <brent.stapleton@ettus.com>2019-07-24 11:16:37 -0700
commite76988c579e5e154416d94c27be89bd5f6dc56fa (patch)
treefb4b9fc6ca91c8a3778b296b2890e3dd08e5252d /host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp
parent8b294082d4804198c45b0acb1ad6393e4f6ef0da (diff)
downloaduhd-e76988c579e5e154416d94c27be89bd5f6dc56fa.tar.gz
uhd-e76988c579e5e154416d94c27be89bd5f6dc56fa.tar.bz2
uhd-e76988c579e5e154416d94c27be89bd5f6dc56fa.zip
n310: add capability to control RF filter bypass and freq.band limits
With the keywords "rx_gain_profile", "tx_gain_profile" and the new values "default_bypass_always_off" and "default_bypass_always_on" the customer can control whether the filter bypass shall be applied as defined in the gain-table or whether to switch the bypass to ON or OFF for all gains. With the keywords "rx_band_map" and "tx_band_map" the user can define custom frequency borders for the band mapping. These new keywords can be used in the uhd.con, e.g.: [type=n3xx] rx_gain_profile=default_bypass_always_off tx_gain_profile=default_bypass_always_on rx_band_map=431e6;601e6;1051e6;1601e6;2101e6;2701e6 tx_band_map=723.18e6;1623.18e6;3323.18e6
Diffstat (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp
index 1370fde3a..b66bd2efd 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp
@@ -7,6 +7,7 @@
#include "magnesium_constants.hpp"
#include "magnesium_gain_table.hpp"
#include "magnesium_radio_ctrl_impl.hpp"
+#include <uhd/exception.hpp>
#include <uhd/utils/log.hpp>
using namespace uhd;
@@ -27,23 +28,36 @@ double magnesium_radio_ctrl_impl::_set_all_gain(
<< chan
<< ", "
"dir="
- << dir);
+ << dir << ")");
const size_t ad9371_chan = chan;
auto chan_sel = static_cast<magnesium_cpld_ctrl::chan_sel_t>(chan);
- gain_tuple_t gain_tuple = (dir == RX_DIRECTION)
- ? get_rx_gain_tuple(gain, _map_freq_to_rx_band(freq))
- : get_tx_gain_tuple(gain, _map_freq_to_tx_band(freq));
+ gain_tuple_t gain_tuple;
+ std::string gp = _gain_profile[dir];
- if (_gain_profile[dir] == "manual") {
+ UHD_LOG_TRACE(unique_id(), "Gain profile: " << gp);
+ if (gp == "manual") {
UHD_LOG_TRACE(unique_id(), "Manual gain mode. Getting gain from property tree.");
gain_tuple = {DSA_MAX_GAIN - _dsa_att[dir],
((dir == RX_DIRECTION) ? AD9371_MAX_RX_GAIN : AD9371_MAX_TX_GAIN)
- _ad9371_att[dir],
_amp_bypass[dir]};
- } else if (_gain_profile[dir] == "default") {
+ } else if (gp.find("default") != gp.npos) {
UHD_LOG_TRACE(unique_id(), "Getting gain from gain table.");
+ gain_tuple =
+ (dir == RX_DIRECTION)
+ ? get_rx_gain_tuple(gain, _map_freq_to_rx_band(_rx_band_map, freq))
+ : get_tx_gain_tuple(gain, _map_freq_to_tx_band(_tx_band_map, freq));
+ if (gp == "default_rf_filter_bypass_always_on") {
+ UHD_LOG_TRACE(unique_id(), "Enable filter bypass for all gains");
+ gain_tuple.bypass = true;
+ } else if (gp == "default_rf_filter_bypass_always_off") {
+ UHD_LOG_TRACE(unique_id(), "Disable filter bypass for all gains");
+ gain_tuple.bypass = false;
+ }
} else {
- UHD_LOG_ERROR(unique_id(), "Unsupported gain mode: " << _gain_profile[dir])
+ UHD_LOG_ERROR(unique_id(), "Unsupported gain mode: " << gp);
+ throw uhd::value_error(
+ str(boost::format("[%s] Unsupported gain mode: %s") % unique_id() % gp));
}
const double ad9371_gain =
((dir == RX_DIRECTION) ? AD9371_MAX_RX_GAIN : AD9371_MAX_TX_GAIN)
@@ -89,8 +103,7 @@ double magnesium_radio_ctrl_impl::_dsa_set_att(
const double att, const size_t chan, const direction_t dir)
{
UHD_LOG_TRACE(unique_id(),
- __func__ << "(att="
- << "att dB, chan=" << chan << ", dir=" << dir << ")")
+ __func__ << "(att=" << att << "dB, chan=" << chan << ", dir=" << dir << ")")
const uint32_t dsa_val = 2 * att;
_set_dsa_val(chan, dir, dsa_val);