aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/lib/mykonos
diff options
context:
space:
mode:
Diffstat (limited to 'mpm/lib/mykonos')
-rw-r--r--mpm/lib/mykonos/ad937x_ctrl.cpp57
-rw-r--r--mpm/lib/mykonos/ad937x_device.cpp37
-rw-r--r--mpm/lib/mykonos/ad937x_device.hpp2
-rw-r--r--mpm/lib/mykonos/config/ad937x_config_t.cpp13
-rw-r--r--mpm/lib/mykonos/config/ad937x_config_t.hpp6
5 files changed, 67 insertions, 48 deletions
diff --git a/mpm/lib/mykonos/ad937x_ctrl.cpp b/mpm/lib/mykonos/ad937x_ctrl.cpp
index d6062c228..2642e3858 100644
--- a/mpm/lib/mykonos/ad937x_ctrl.cpp
+++ b/mpm/lib/mykonos/ad937x_ctrl.cpp
@@ -189,23 +189,6 @@ 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);
@@ -223,6 +206,46 @@ public:
std::lock_guard<std::mutex> lock(*spi_mutex);
device.setup_cal(init_cals_mask, tracking_cals_mask, timeout);
}
+
+ virtual std::string set_lo_source(const std::string &which, const std::string &source){
+ auto dir = _get_direction_from_antenna(which);
+
+ uint8_t pll_source = 0 ;
+ if (source == "internal"){
+ pll_source = 0;
+ }
+ else if (source == "external") {
+ pll_source = 1;
+ }
+ else {
+ throw mpm::runtime_error("invalid LO source");
+ }
+
+ std::lock_guard<std::mutex> lock(*spi_mutex);
+ uint8_t retval = device.set_lo_source(dir, pll_source);
+ if (retval == 0){
+ return "internal";
+ } else if (retval == 1){
+ return "external";
+ }else{
+ throw mpm::runtime_error("invalid return from set LO source");
+ }
+ }
+
+ virtual std::string get_lo_source(const std::string &which){
+ auto dir = _get_direction_from_antenna(which);
+
+ std::lock_guard<std::mutex> lock(*spi_mutex);
+ uint8_t retval = device.get_lo_source(dir);
+ if (retval == 0){
+ return "internal";
+ } else if (retval == 1){
+ return "external";
+ }else{
+ throw mpm::runtime_error("invalid return from get LO source");
+ }
+ }
+
virtual void start_jesd_rx()
{
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 1d4a80c48..a6abc9329 100644
--- a/mpm/lib/mykonos/ad937x_device.cpp
+++ b/mpm/lib/mykonos/ad937x_device.cpp
@@ -274,20 +274,6 @@ 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
@@ -332,6 +318,29 @@ void ad937x_device::setup_cal(uint32_t init_cals_mask, uint32_t tracking_cals_ma
// ready for radioOn
}
+uint8_t ad937x_device::set_lo_source(const uhd::direction_t direction, const uint8_t pll_source){
+ switch (direction){
+ case TX_DIRECTION:
+ mykonos_config.device->tx->txPllUseExternalLo = pll_source;
+ return pll_source;
+ case RX_DIRECTION:
+ mykonos_config.device->rx->rxPllUseExternalLo = pll_source;
+ return pll_source;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ }
+}
+
+uint8_t ad937x_device::get_lo_source(const uhd::direction_t direction) const {
+ switch (direction){
+ case TX_DIRECTION:
+ return mykonos_config.device->tx->txPllUseExternalLo;
+ case RX_DIRECTION:
+ return mykonos_config.device->rx->rxPllUseExternalLo;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ }
+}
void ad937x_device::begin_initialization()
{
CALL_API(MYKONOS_initialize(mykonos_config.device));
diff --git a/mpm/lib/mykonos/ad937x_device.hpp b/mpm/lib/mykonos/ad937x_device.hpp
index 60f78d2e5..9abd2942b 100644
--- a/mpm/lib/mykonos/ad937x_device.hpp
+++ b/mpm/lib/mykonos/ad937x_device.hpp
@@ -55,6 +55,8 @@ public:
void begin_initialization();
void finish_initialization();
void setup_cal(uint32_t init_cals_mask, uint32_t tracking_cals_mask, uint32_t timeout);
+ uint8_t set_lo_source(const uhd::direction_t direction, const uint8_t pll_source);
+ uint8_t get_lo_source(const uhd::direction_t direction) const;
void start_jesd_rx();
void start_jesd_tx();
void start_radio();
diff --git a/mpm/lib/mykonos/config/ad937x_config_t.cpp b/mpm/lib/mykonos/config/ad937x_config_t.cpp
index a9455502c..595fda925 100644
--- a/mpm/lib/mykonos/config/ad937x_config_t.cpp
+++ b/mpm/lib/mykonos/config/ad937x_config_t.cpp
@@ -105,18 +105,7 @@ 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 41d9e9b61..bbd80cc28 100644
--- a/mpm/lib/mykonos/config/ad937x_config_t.hpp
+++ b/mpm/lib/mykonos/config/ad937x_config_t.hpp
@@ -43,11 +43,7 @@ public:
static const int16_t DEFAULT_OBSRX_FIR[DEFAULT_RX_FIR_SIZE];
static const int16_t DEFAULT_OBSRX_FIR_15366[DEFAULT_RX_FIR_SIZE];
static const int16_t DEFAULT_SNIFFER_FIR[DEFAULT_RX_FIR_SIZE];
- static const int16_t DEFAULT_SNIFFER_FIR_15366[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();
+ static const int16_t DEFAULT_SNIFFER_FIR_15366[DEFAULT_RX_FIR_SIZE];
private:
// The top level device struct is non-const and contains all other structs, so everything is "public"