aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mpm/include/mpm/ad937x/ad937x_ctrl.hpp25
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/magnesium.py14
2 files changed, 39 insertions, 0 deletions
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
index 6d28eccd1..cb4d0e060 100644
--- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
+++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
@@ -85,6 +85,7 @@ public:
// Async call handles
std::future<void> handle_finish_initialization;
std::future<void> handle_setup_cal;
+ std::future<double> handle_set_freq;
/*! \brief make a new AD9371 ctrl object using the specified SPI iface
*
@@ -344,6 +345,30 @@ void export_mykonos(py::module& top_module)
.def("set_clock_rate", &ad937x_ctrl::set_clock_rate)
.def("enable_channel", &ad937x_ctrl::enable_channel)
.def("set_freq", &ad937x_ctrl::set_freq)
+ .def("async__set_freq", +[](
+ ad937x_ctrl& self,
+ const std::string &which,
+ const double value,
+ const bool wait_for_lock
+ ){
+ self.handle_set_freq = std::async(std::launch::async,
+ &ad937x_ctrl::set_freq,
+ &self,
+ which,
+ value,
+ wait_for_lock
+ );
+ })
+ .def("await__set_freq", +[](
+ ad937x_ctrl& self
+ )->bool{
+ if (self.handle_set_freq.wait_for(std::chrono::seconds(0))
+ == std::future_status::ready){
+ self.handle_set_freq.get();
+ return true;
+ }
+ return false;
+ })
.def("get_freq", &ad937x_ctrl::get_freq)
.def("get_lo_locked", &ad937x_ctrl::get_lo_locked)
.def("set_fir", &ad937x_ctrl::set_fir)
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
index 13e621414..c4e2f4131 100644
--- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py
+++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
@@ -18,6 +18,7 @@ from usrp_mpm.cores import nijesdcore
from usrp_mpm.mpmlog import get_logger
from usrp_mpm.sys_utils.uio import open_uio
from usrp_mpm.user_eeprom import BfrfsEEPROM
+from usrp_mpm.mpmutils import async_exec
###############################################################################
# SPI Helpers
@@ -328,6 +329,19 @@ class Magnesium(BfrfsEEPROM, DboardManagerBase):
# The reference clock is handled elsewhere since it is a motherboard-
# level clock.
+ def set_freq(self, which, freq, wait_for_lock):
+ """
+ Perform asynchronous tuning. This will, under the hood, call set_freq()
+ on the AD937X object, but will spin it out into an asynchronous
+ execution. We do this because under some circumstances, the set_freq()
+ call can take a long time to execute, and we want to release the GIL
+ during that time.
+
+ Note: This overrides the set_freq() call provided from self.mykonos.
+ """
+ self.log.trace("Tuning {} {} {}".format(which, freq, wait_for_lock))
+ async_exec(self.mykonos, "set_freq", which, freq, wait_for_lock)
+ return self.mykonos.get_freq(which)
def _reinit(self, master_clock_rate):
"""