From 59d8fcaff2fcafd9b45adfaf5b25b6b42103f88e Mon Sep 17 00:00:00 2001 From: Mark Meserve Date: Tue, 28 Mar 2017 11:48:02 -0500 Subject: ad9371: cleanup ctrl remove device forward declaration make helper functions local to ad9371_ctrl.cpp fix UHD include paths --- mpm/include/mpm/ad937x/ad937x_ctrl.hpp | 6 --- mpm/lib/mykonos/ad937x_ctrl.cpp | 98 +++++++++++++++++----------------- mpm/lib/mykonos/ad937x_device.hpp | 1 - mpm/lib/mykonos/adi_ctrl.cpp | 5 +- 4 files changed, 51 insertions(+), 59 deletions(-) (limited to 'mpm') diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp index 663424b06..10cbb0717 100644 --- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp +++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp @@ -19,7 +19,6 @@ #include "mpm/spi/spi_lock.hpp" -// TODO: fix path of UHD includes #include #include #include @@ -29,7 +28,6 @@ #include #include #include -class ad937x_device; class ad937x_ctrl : public boost::noncopyable { @@ -63,10 +61,6 @@ public: virtual std::vector get_fir(const std::string &which, int8_t &gain) = 0; virtual int16_t get_temperature() = 0; - -protected: - static uhd::direction_t _get_direction_from_antenna(const std::string& antenna); - static std::set _get_valid_fir_lengths(const std::string& which); }; #ifdef LIBMPM_PYTHON diff --git a/mpm/lib/mykonos/ad937x_ctrl.cpp b/mpm/lib/mykonos/ad937x_ctrl.cpp index 71cd251e8..047c8ba46 100644 --- a/mpm/lib/mykonos/ad937x_ctrl.cpp +++ b/mpm/lib/mykonos/ad937x_ctrl.cpp @@ -16,18 +16,65 @@ // #include "ad937x_device.hpp" -#include "mpm/mykonos/ad937x_ctrl.hpp" #include "adi/mykonos.h" +#include + #include #include #include +static uhd::direction_t _get_direction_from_antenna(const std::string& antenna) +{ + auto sub = antenna.substr(0, 2); + if (sub == "RX") { + return uhd::direction_t::RX_DIRECTION; + } + else if (sub == "TX") { + return uhd::direction_t::TX_DIRECTION; + } + else { + throw uhd::runtime_error("ad937x_ctrl got an invalid channel string."); + } + return uhd::direction_t::RX_DIRECTION; +} + +static ad937x_device::chain_t _get_chain_from_antenna(const std::string& antenna) +{ + auto sub = antenna.substr(2, 1); + if (sub == "1") { + return ad937x_device::chain_t::ONE; + } + else if (sub == "2") { + return ad937x_device::chain_t::TWO; + } + else { + throw uhd::runtime_error("ad937x_ctrl got an invalid channel string."); + } + return ad937x_device::chain_t::ONE; +} + +std::set _get_valid_fir_lengths(const std::string& which) +{ + auto dir = _get_direction_from_antenna(which); + switch (dir) + { + case uhd::direction_t::RX_DIRECTION: + return{ 24, 48, 72 }; + case uhd::direction_t::TX_DIRECTION: + return{ 16, 32, 48, 64, 80, 96 }; + default: + UHD_THROW_INVALID_CODE_PATH(); + return std::set(); + } +} + uhd::meta_range_t ad937x_ctrl::get_rf_freq_range(void) { return uhd::meta_range_t(ad937x_device::MIN_FREQ, ad937x_device::MAX_FREQ); } + uhd::meta_range_t ad937x_ctrl::get_bw_filter_range(void) { // TODO: fix @@ -55,36 +102,6 @@ uhd::meta_range_t ad937x_ctrl::get_gain_range(const std::string &which) } } -std::set ad937x_ctrl::_get_valid_fir_lengths(const std::string& which) -{ - auto dir = _get_direction_from_antenna(which); - switch (dir) - { - case uhd::direction_t::RX_DIRECTION: - return { 24, 48, 72 }; - case uhd::direction_t::TX_DIRECTION: - return { 16, 32, 48, 64, 80, 96 }; - default: - UHD_THROW_INVALID_CODE_PATH(); - return std::set(); - } -} - -uhd::direction_t ad937x_ctrl::_get_direction_from_antenna(const std::string& antenna) -{ - auto sub = antenna.substr(0, 2); - if (sub == "RX") { - return uhd::direction_t::RX_DIRECTION; - } - else if (sub == "TX") { - return uhd::direction_t::TX_DIRECTION; - } - else { - throw uhd::runtime_error("ad937x_ctrl got an invalid channel string."); - } - return uhd::direction_t::RX_DIRECTION; -} - class ad937x_ctrl_impl : public ad937x_ctrl { public: @@ -95,23 +112,6 @@ public: } - static ad937x_device::chain_t _get_chain_from_antenna(const std::string& antenna) - { - auto sub = antenna.substr(2, 1); - if (sub == "1") { - return ad937x_device::chain_t::ONE; - } - else if (sub == "2") { - return ad937x_device::chain_t::TWO; - } - else { - throw uhd::runtime_error("ad937x_ctrl got an invalid channel string."); - } - return ad937x_device::chain_t::ONE; - } - - - virtual uint8_t get_product_id() { std::lock_guard lock(*spi_l); @@ -241,7 +241,7 @@ public: device.set_fir(dir, chain, gain, fir); } - std::vector get_fir(const std::string &which, int8_t &gain) + virtual std::vector get_fir(const std::string &which, int8_t &gain) { auto dir = _get_direction_from_antenna(which); auto chain = _get_chain_from_antenna(which); diff --git a/mpm/lib/mykonos/ad937x_device.hpp b/mpm/lib/mykonos/ad937x_device.hpp index 704c84e21..f3b192a01 100644 --- a/mpm/lib/mykonos/ad937x_device.hpp +++ b/mpm/lib/mykonos/ad937x_device.hpp @@ -23,7 +23,6 @@ #include "adi/t_mykonos_gpio.h" #include "mpm/spi/adi_ctrl.hpp" -// TODO: fix path of UHD includes #include #include #include diff --git a/mpm/lib/mykonos/adi_ctrl.cpp b/mpm/lib/mykonos/adi_ctrl.cpp index fb781ea4c..287d17f5f 100644 --- a/mpm/lib/mykonos/adi_ctrl.cpp +++ b/mpm/lib/mykonos/adi_ctrl.cpp @@ -15,12 +15,11 @@ // along with this program. If not, see . // - #include "adi/common.h" + #include +#include -// TODO: fix path of UHD includes -#include <../../host/include/uhd/exception.hpp> #include #include #include -- cgit v1.2.3