aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
Diffstat (limited to 'mpm')
-rw-r--r--mpm/include/mpm/ad937x/ad937x_ctrl.hpp7
-rw-r--r--mpm/lib/mykonos/ad937x_device.cpp43
-rw-r--r--mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp1
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/magnesium.py12
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/mg_init.py4
-rw-r--r--mpm/python/usrp_mpm/rpc_server.py2
6 files changed, 57 insertions, 12 deletions
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
index 787bc41b5..936655405 100644
--- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
+++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
@@ -184,7 +184,12 @@ public:
*/
virtual std::string get_arm_version() = 0;
- //! set the BW filter for the frontend which
+ /*! \brief set the BW filter for the frontend which
+ *
+ * \param which frontend string (rx, tx, dx)
+ * \param value target rf bandwidth value
+ * return actual rf bandwidth value
+ */
virtual double set_bw_filter(const std::string& which, const double value) = 0;
/*! \brief set the gain for the frontend which
diff --git a/mpm/lib/mykonos/ad937x_device.cpp b/mpm/lib/mykonos/ad937x_device.cpp
index b476922f2..fba065983 100644
--- a/mpm/lib/mykonos/ad937x_device.cpp
+++ b/mpm/lib/mykonos/ad937x_device.cpp
@@ -10,6 +10,7 @@
#include "adi/mykonos_gpio.h"
#include "config/ad937x_config_t.hpp"
#include "config/ad937x_default_config.hpp"
+#include <uhd/utils/algorithm.hpp>
#include <boost/format.hpp>
#include <cmath>
#include <fstream>
@@ -39,6 +40,23 @@ static const uint32_t AD9371_PRODUCT_ID = 0x3;
static const uint32_t AD9371_XBCZ_PRODUCT_ID = 0x1;
static const size_t ARM_BINARY_SIZE = 98304;
+/* Values derived from AD937x filter wizard tool
+ * https://github.com/analogdevicesinc/ad937x-filter-wizard/blob/
+ * 3e407b059be92fe65c4a32d5368fe4cdc491b1a1/profilegen/generate_RxORxPFIR.m#L130
+ * https://github.com/analogdevicesinc/ad937x-filter-wizard/blob/
+ * 3e407b059be92fe65c4a32d5368fe4cdc491b1a1/profilegen/generate_TxPFIR.m#L42
+ */
+static constexpr double AD9371_RX_MIN_BANDWIDTH = 8e6; // Hz
+static constexpr double AD9371_RX_MAX_BANDWIDTH = 100e6; // Hz
+static constexpr double AD9371_RX_BBF_MIN_CORNER = 20e6; // Hz
+static constexpr double AD9371_RX_BBF_MAX_CORNER = 100e6; // Hz
+static constexpr double AD9371_TX_MIN_BANDWIDTH = 20e6; // Hz
+static constexpr double AD9371_TX_MAX_BANDWIDTH = 125e6; // Hz
+static constexpr double AD9371_TX_BBF_MIN_CORNER = 20e6; // Hz
+static constexpr double AD9371_TX_BBF_MAX_CORNER = 125e6; // Hz
+static constexpr double AD9371_TX_DAC_FILT_MIN_CORNER = 92.0e6; // Hz
+static constexpr double AD9371_TX_DAC_FILT_MAX_CORNER = 187.0e6; // Hz
+
static const uint32_t PLL_LOCK_TIMEOUT_MS = 200;
// Amount of time to average samples for RX DC offset
@@ -548,26 +566,31 @@ double ad937x_device::tune(
double ad937x_device::set_bw_filter(const direction_t direction, const double value)
{
+ auto bw = value;
switch (direction) {
case TX_DIRECTION: {
- mykonos_config.device->tx->txProfile->rfBandwidth_Hz = value;
- mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = value / 1000;
- mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = value / 1000;
+ bw = uhd::clip(value, AD9371_TX_MIN_BANDWIDTH, AD9371_TX_MAX_BANDWIDTH);
+ const auto bbf =
+ uhd::clip(bw, AD9371_TX_BBF_MIN_CORNER, AD9371_TX_BBF_MAX_CORNER);
+ mykonos_config.device->tx->txProfile->rfBandwidth_Hz = bw;
+ mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = bbf / 1000;
+ const auto dacCorner = uhd::clip(
+ bw, AD9371_TX_DAC_FILT_MIN_CORNER, AD9371_TX_DAC_FILT_MAX_CORNER);
+ mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = dacCorner / 1000;
break;
}
case RX_DIRECTION: {
- mykonos_config.device->rx->rxProfile->rfBandwidth_Hz = value;
- mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = value / 1000;
+ bw = uhd::clip(value, AD9371_RX_MIN_BANDWIDTH, AD9371_RX_MAX_BANDWIDTH);
+ const auto bbf =
+ uhd::clip(bw, AD9371_RX_BBF_MIN_CORNER, AD9371_RX_BBF_MAX_CORNER);
+ mykonos_config.device->rx->rxProfile->rfBandwidth_Hz = bw;
+ mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = bbf / 1000;
break;
}
}
- const auto state = _move_to_config_state();
- CALL_API(MYKONOS_writeArmProfile(mykonos_config.device));
- _restore_from_config_state(state);
- return value; // TODO: what is coercer value?
+ return bw;
}
-
double ad937x_device::set_gain(
const direction_t direction, const chain_t chain, const double value)
{
diff --git a/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp b/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp
index 4719f486e..9aa07631b 100644
--- a/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp
+++ b/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp
@@ -6,6 +6,7 @@
//
#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
namespace py = pybind11;
#define LIBMPM_PYTHON
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
index c4e2f4131..d5cc525dc 100644
--- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py
+++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
@@ -480,6 +480,18 @@ class Magnesium(BfrfsEEPROM, DboardManagerBase):
'value': str(lock_status).lower(),
}
+ ##########################################################################
+ # Filter API
+ ##########################################################################
+ def set_bandwidth(self, which, bw):
+ if which.lower()[0:2] in ('tx', 'dx'):
+ self.log.debug("ad9371 set_tx_bandwidth bw: {}".format(bw))
+ self._init_args['tx_bw'] = bw
+ if which.lower()[0:2] in ('rx', 'dx'):
+ self.log.debug("ad9371 set_rx_bandwidth bw: {}".format(bw))
+ self._init_args['rx_bw'] = bw
+ self._reinit(self.master_clock_rate)
+ return bw
##########################################################################
# Debug
diff --git a/mpm/python/usrp_mpm/dboard_manager/mg_init.py b/mpm/python/usrp_mpm/dboard_manager/mg_init.py
index 00a2eab7d..02658abb9 100644
--- a/mpm/python/usrp_mpm/dboard_manager/mg_init.py
+++ b/mpm/python/usrp_mpm/dboard_manager/mg_init.py
@@ -464,6 +464,10 @@ class MagnesiumInitManager(object):
jesdcore.send_sysref_pulse()
time.sleep(0.001) # 17us... ish.
jesdcore.send_sysref_pulse()
+ if args.get('tx_bw'):
+ self.mykonos.set_bw_filter('TX', args.get('tx_bw'))
+ if args.get('rx_bw'):
+ self.mykonos.set_bw_filter('RX', args.get('rx_bw'))
async_exec(self.mykonos, "finish_initialization")
# According to the AD9371 user guide, p.57, the RF cal must come before
# the framer/deframer init. We tried otherwise, and failed. So don't
diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py
index 77b4d5a15..78b76ab19 100644
--- a/mpm/python/usrp_mpm/rpc_server.py
+++ b/mpm/python/usrp_mpm/rpc_server.py
@@ -32,7 +32,7 @@ from usrp_mpm.sys_utils import net
TIMEOUT_INTERVAL = 5.0 # Seconds before claim expires (default value)
TOKEN_LEN = 16 # Length of the token string
# Compatibility number for MPM
-MPM_COMPAT_NUM = (4, 0)
+MPM_COMPAT_NUM = (4, 1)
def no_claim(func):
" Decorator for functions that require no token check "