diff options
author | Trung N Tran <trung.tran@ettus.com> | 2017-11-15 13:49:39 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:06 -0800 |
commit | db7039f8be4240b60cf2688d7ae6b41613fc8a5a (patch) | |
tree | 7f1de9ea37847d8071814f6c75c2da50ae5e7ff6 | |
parent | 9ea0d6da9e3756af91c7d1e99ee35e56bf2270d6 (diff) | |
download | uhd-db7039f8be4240b60cf2688d7ae6b41613fc8a5a.tar.gz uhd-db7039f8be4240b60cf2688d7ae6b41613fc8a5a.tar.bz2 uhd-db7039f8be4240b60cf2688d7ae6b41613fc8a5a.zip |
mpm: enable RX external LO set through args
This change allow user to set RX LO of ad9371 to external or internal from args
constructor of usrp device.
new args is rx_lo_source value can be either internal or external:
If there's no rx_lo_source specified or invalid value, default rx_lo is used; which is internal LO.
Usage example:
usrp_application --args "rx_lo_source=external"
-rw-r--r-- | mpm/include/mpm/ad937x/ad937x_ctrl.hpp | 16 | ||||
-rw-r--r-- | mpm/lib/mykonos/ad937x_ctrl.cpp | 16 | ||||
-rw-r--r-- | mpm/lib/mykonos/ad937x_device.cpp | 15 | ||||
-rw-r--r-- | mpm/lib/mykonos/ad937x_device.hpp | 6 | ||||
-rw-r--r-- | mpm/lib/mykonos/config/ad937x_config_t.cpp | 13 | ||||
-rw-r--r-- | mpm/lib/mykonos/config/ad937x_config_t.hpp | 5 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/magnesium.py | 11 |
7 files changed, 75 insertions, 7 deletions
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp index 22029a135..4710af445 100644 --- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp +++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp @@ -107,14 +107,22 @@ public: mpm::ad937x::gpio::gain_pins_t gain_pins); virtual ~ad937x_ctrl(void) {} + //! Update rx lo source to either external or internal. 1 is external; 0 is internal + virtual void update_rx_lo_source(uint8_t rx_pll_use_external_lo) = 0; + //! Update tx lo source to either external or internal. 1 is external; 0 is internal + virtual void update_tx_lo_source(uint8_t tx_pll_use_external_lo) = 0; + //! Get rx lo source: 1 is external; 0 is internal + virtual uint8_t get_rx_lo_source() = 0 ; + //! Get tx lo source: 1 is external; 0 is internal + virtual uint8_t get_tx_lo_source() = 0 ; //! initializes the AD9371, checks basic functionality, and prepares the chip to receive a SYSREF pulse virtual void begin_initialization() = 0; //! finishes initialization of the AD9371 by loading the ARM binary and setting a default RF configuration virtual void finish_initialization() = 0; - + /*! \setup initialization and tracking calibration - * + * *\param init_cals_mask bit masking field for init calibration default to 0x4DFF * NOTE: this init cals mask need to be at least 0x4F. *\param tracking_cals_mask bit masking field for tracking calibration default to 0xC3 @@ -262,6 +270,10 @@ void export_mykonos(){ bp::class_<ad937x_ctrl, boost::noncopyable, std::shared_ptr<ad937x_ctrl>>("ad937x_ctrl", bp::no_init) .def("begin_initialization", &ad937x_ctrl::begin_initialization) .def("finish_initialization", &ad937x_ctrl::finish_initialization) + .def("update_rx_lo_source", &ad937x_ctrl::update_rx_lo_source) + .def("update_tx_lo_source", &ad937x_ctrl::update_tx_lo_source) + .def("get_rx_lo_source", &ad937x_ctrl::get_rx_lo_source) + .def("get_tx_lo_source", &ad937x_ctrl::get_tx_lo_source) .def("setup_cal", &ad937x_ctrl::setup_cal) .def("start_jesd_rx", &ad937x_ctrl::start_jesd_rx) .def("start_jesd_tx", &ad937x_ctrl::start_jesd_tx) diff --git a/mpm/lib/mykonos/ad937x_ctrl.cpp b/mpm/lib/mykonos/ad937x_ctrl.cpp index 0e76daac0..2594ac920 100644 --- a/mpm/lib/mykonos/ad937x_ctrl.cpp +++ b/mpm/lib/mykonos/ad937x_ctrl.cpp @@ -189,7 +189,23 @@ public: { /* nop */ } + virtual void update_rx_lo_source(uint8_t rx_lo_source){ + std::lock_guard<std::mutex> lock(*spi_mutex); + device.update_rx_lo_source(rx_lo_source); + } + virtual void update_tx_lo_source(uint8_t tx_lo_source){ + std::lock_guard<std::mutex> lock(*spi_mutex); + device.update_tx_lo_source(tx_lo_source); + } + virtual uint8_t get_rx_lo_source(){ + std::lock_guard<std::mutex> lock(*spi_mutex); + return device.get_rx_lo_source(); + } + virtual uint8_t get_tx_lo_source(){ + std::lock_guard<std::mutex> lock(*spi_mutex); + return device.get_tx_lo_source(); + } virtual void begin_initialization() { std::lock_guard<std::mutex> lock(*spi_mutex); diff --git a/mpm/lib/mykonos/ad937x_device.cpp b/mpm/lib/mykonos/ad937x_device.cpp index de3671849..ac7070df4 100644 --- a/mpm/lib/mykonos/ad937x_device.cpp +++ b/mpm/lib/mykonos/ad937x_device.cpp @@ -272,7 +272,20 @@ ad937x_device::ad937x_device( gain_ctrl(gain_pins) { } - +void ad937x_device::update_rx_lo_source(uint8_t rx_lo_source){ + mykonos_config.set_rx_pll_use_external_lo(rx_lo_source); + //TODO: should we re-init after this ? +} +void ad937x_device::update_tx_lo_source(uint8_t tx_lo_source){ + mykonos_config.set_tx_pll_use_external_lo(tx_lo_source); + //TODO: should we re-init after this ? +} +uint8_t ad937x_device::get_rx_lo_source(){ + return mykonos_config.get_rx_pll_use_external_lo(); +} +uint8_t ad937x_device::get_tx_lo_source(){ + return mykonos_config.get_tx_pll_use_external_lo(); +} void ad937x_device::_setup_rf(){ // TODO: add setRfPllLoopFilter here diff --git a/mpm/lib/mykonos/ad937x_device.hpp b/mpm/lib/mykonos/ad937x_device.hpp index 8dae6f2d3..c816680c4 100644 --- a/mpm/lib/mykonos/ad937x_device.hpp +++ b/mpm/lib/mykonos/ad937x_device.hpp @@ -51,7 +51,6 @@ public: mpm::types::regs_iface* iface, mpm::ad937x::gpio::gain_pins_t gain_pins ); - void begin_initialization(); void finish_initialization(); void setup_cal(uint32_t init_cals_mask, uint32_t tracking_cals_mask, uint32_t timeout); @@ -91,7 +90,10 @@ public: void set_enable_gain_pins(uhd::direction_t direction, mpm::ad937x::device::chain_t chain, bool enable); void set_gain_pin_step_sizes(uhd::direction_t direction, mpm::ad937x::device::chain_t chain, double inc_step, double dec_step); - + void update_rx_lo_source(uint8_t rxPllUseExternalLo); + void update_tx_lo_source(uint8_t rxPllUseExternalLo); + uint8_t get_rx_lo_source(); + uint8_t get_tx_lo_source(); const static double MIN_FREQ; const static double MAX_FREQ; const static double MIN_RX_GAIN; diff --git a/mpm/lib/mykonos/config/ad937x_config_t.cpp b/mpm/lib/mykonos/config/ad937x_config_t.cpp index 8a7ca76c3..68d1f27bf 100644 --- a/mpm/lib/mykonos/config/ad937x_config_t.cpp +++ b/mpm/lib/mykonos/config/ad937x_config_t.cpp @@ -83,7 +83,18 @@ ad937x_config_t::ad937x_config_t(spiSettings_t* sps) : device = &_device; } - +void ad937x_config_t::set_rx_pll_use_external_lo(uint8_t val){ + _rx.rxPllUseExternalLo = val; +} +uint8_t ad937x_config_t::get_rx_pll_use_external_lo(){ + return _rx.rxPllUseExternalLo; +} +void ad937x_config_t::set_tx_pll_use_external_lo(uint8_t val){ + _tx.txPllUseExternalLo = val; +} +uint8_t ad937x_config_t::get_tx_pll_use_external_lo(){ + return _tx.txPllUseExternalLo; +} // This function sets up all the pointers in all of our local members that represent the device struct // This function should only be called during construction. void ad937x_config_t::_init_pointers() diff --git a/mpm/lib/mykonos/config/ad937x_config_t.hpp b/mpm/lib/mykonos/config/ad937x_config_t.hpp index 9eba4992f..e44039ebe 100644 --- a/mpm/lib/mykonos/config/ad937x_config_t.hpp +++ b/mpm/lib/mykonos/config/ad937x_config_t.hpp @@ -20,7 +20,6 @@ #include "../adi/t_mykonos.h" #include "ad937x_fir.hpp" #include <boost/noncopyable.hpp> - // Allocates and links the entire mykonos config struct in a single class class ad937x_config_t : public boost::noncopyable { @@ -41,6 +40,10 @@ public: static const int16_t DEFAULT_RX_FIR[DEFAULT_RX_FIR_SIZE]; static const int16_t DEFAULT_OBSRX_FIR[DEFAULT_RX_FIR_SIZE]; static const int16_t DEFAULT_SNIFFER_FIR[DEFAULT_RX_FIR_SIZE]; + void set_rx_pll_use_external_lo(uint8_t val); + uint8_t get_rx_pll_use_external_lo(); + void set_tx_pll_use_external_lo(uint8_t val); + uint8_t get_tx_pll_use_external_lo(); private: // The top level device struct is non-const and contains all other structs, so everything is "public" diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py index d69b8ad23..570887870 100644 --- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -557,6 +557,17 @@ class Magnesium(DboardManagerBase): self.log.trace("Pulsing Mykonos Hard Reset...") self.cpld.reset_mykonos() self.log.trace("Initializing Mykonos...") + rx_lo_source = args.get('rx_lo_source', "internal") + rx_lo = -1 + if rx_lo_source == "internal": + rx_lo = 0 + if rx_lo_source == "external": + rx_lo = 1 + if rx_lo == -1: + self.log.warning("Please specify rx LO either \"internal\" or \"external\" ") + else: + self.mykonos.update_rx_lo_source(rx_lo) + self.log.debug("RX LO SOURCE is {}".format(self.mykonos.get_rx_lo_source())) self.mykonos.begin_initialization() # Multi-chip Sync requires two SYSREF pulses at least 17us apart. self.jesdcore.send_sysref_pulse() |