From b71d0cbea9e1e107eeb1da51ef14fe6b9e983ee6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 27 Mar 2010 14:27:55 -0700 Subject: refactored types.hpp into types directory --- host/test/gain_handler_test.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'host/test/gain_handler_test.cpp') diff --git a/host/test/gain_handler_test.cpp b/host/test/gain_handler_test.cpp index 47acb30f0..e13063e06 100644 --- a/host/test/gain_handler_test.cpp +++ b/host/test/gain_handler_test.cpp @@ -17,9 +17,9 @@ #include #include -#include +#include +#include #include -#include #include #include @@ -84,7 +84,7 @@ private: //handle the get request conditioned on the key switch(key.as()){ case PROP_GAIN_VALUE: - _gain_values[name] = val.as(); + _gain_values[name] = val.as(); return; case PROP_GAIN_RANGE: @@ -94,7 +94,7 @@ private: } gain_handler::sptr _gain_handler; - uhd::dict _gain_values; + uhd::dict _gain_values; uhd::dict _gain_ranges; }; @@ -104,18 +104,18 @@ BOOST_AUTO_TEST_CASE(test_gain_handler){ gainful_obj go0; BOOST_CHECK_THROW( - go0[named_prop_t(PROP_GAIN_VALUE, "fail")].as(), + go0[named_prop_t(PROP_GAIN_VALUE, "fail")].as(), std::exception ); std::cout << "verifying the overall min, max, step" << std::endl; gain_range_t gain = go0[PROP_GAIN_RANGE].as(); - BOOST_CHECK_EQUAL(gain.min, gain_t(-10)); - BOOST_CHECK_EQUAL(gain.max, gain_t(100)); - BOOST_CHECK_EQUAL(gain.step, gain_t(1.5)); + BOOST_CHECK_EQUAL(gain.min, float(-10)); + BOOST_CHECK_EQUAL(gain.max, float(100)); + BOOST_CHECK_EQUAL(gain.step, float(1.5)); std::cout << "verifying the overall gain" << std::endl; - go0[named_prop_t(PROP_GAIN_VALUE, "g0")] = gain_t(-5); - go0[named_prop_t(PROP_GAIN_VALUE, "g1")] = gain_t(30); - BOOST_CHECK_EQUAL(go0[PROP_GAIN_VALUE].as(), gain_t(25)); + go0[named_prop_t(PROP_GAIN_VALUE, "g0")] = float(-5); + go0[named_prop_t(PROP_GAIN_VALUE, "g1")] = float(30); + BOOST_CHECK_EQUAL(go0[PROP_GAIN_VALUE].as(), float(25)); } -- cgit v1.2.3 From 7fc320448f30a6c7c327834f80764e5657c04995 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 28 Mar 2010 01:18:27 -0800 Subject: minor fix to wax test to get unit testing working on windows, added missing config include to static.hpp to compile under windows --- host/include/uhd/utils/static.hpp | 2 ++ host/test/gain_handler_test.cpp | 4 ++-- host/test/wax_test.cpp | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'host/test/gain_handler_test.cpp') diff --git a/host/include/uhd/utils/static.hpp b/host/include/uhd/utils/static.hpp index 63db5a247..c61f10884 100644 --- a/host/include/uhd/utils/static.hpp +++ b/host/include/uhd/utils/static.hpp @@ -18,6 +18,8 @@ #ifndef INCLUDED_UHD_UTILS_STATIC_HPP #define INCLUDED_UHD_UTILS_STATIC_HPP +#include + /*! * Defines a function that implements the "construct on first use" idiom * \param _t the type definition for the instance diff --git a/host/test/gain_handler_test.cpp b/host/test/gain_handler_test.cpp index e13063e06..a7c6e1e82 100644 --- a/host/test/gain_handler_test.cpp +++ b/host/test/gain_handler_test.cpp @@ -46,8 +46,8 @@ public: ); _gain_values["g0"] = 0; _gain_values["g1"] = 0; - _gain_ranges["g0"] = gain_range_t(-10, 0, .1); - _gain_ranges["g1"] = gain_range_t(0, 100, 1.5); + _gain_ranges["g0"] = gain_range_t(-10, 0, float(.1)); + _gain_ranges["g1"] = gain_range_t(0, 100, float(1.5)); } ~gainful_obj(void){} diff --git a/host/test/wax_test.cpp b/host/test/wax_test.cpp index cb3b12052..731f470ed 100644 --- a/host/test/wax_test.cpp +++ b/host/test/wax_test.cpp @@ -16,6 +16,7 @@ // #include +#include #include #include @@ -32,26 +33,29 @@ BOOST_AUTO_TEST_CASE(test_enums){ * demo class for wax framework **********************************************************************/ class wax_demo : public wax::obj{ -private: - std::vector d_nums; - std::vector d_subs; public: + typedef boost::shared_ptr sptr; + wax_demo(size_t sub_demos, size_t len){ d_nums = std::vector(len); if (sub_demos != 0){ for (size_t i = 0; i < len; i++){ - d_subs.push_back(wax_demo(sub_demos-1, len)); + d_subs.push_back(sptr(new wax_demo(sub_demos-1, len))); } } } ~wax_demo(void){ /* NOP */ } +private: + std::vector d_nums; + std::vector d_subs; + void get(const wax::obj &key, wax::obj &value){ if (d_subs.size() == 0){ value = d_nums[key.as()]; }else{ - value = d_subs[key.as()].get_link(); + value = d_subs[key.as()]->get_link(); } } void set(const wax::obj &key, const wax::obj &value){ @@ -63,9 +67,8 @@ public: } }; -static wax_demo wd(2, 10); - BOOST_AUTO_TEST_CASE(test_chaining){ + wax_demo wd(2, 1); std::cout << "chain 1" << std::endl; wd[size_t(0)]; std::cout << "chain 2" << std::endl; @@ -75,6 +78,7 @@ BOOST_AUTO_TEST_CASE(test_chaining){ } BOOST_AUTO_TEST_CASE(test_set_get){ + wax_demo wd(2, 10); std::cout << "set and get all" << std::endl; for (size_t i = 0; i < 10; i++){ for (size_t j = 0; j < 10; j++){ @@ -89,6 +93,7 @@ BOOST_AUTO_TEST_CASE(test_set_get){ } BOOST_AUTO_TEST_CASE(test_proxy){ + wax_demo wd(2, 1); std::cout << "store proxy" << std::endl; wax::obj p = wd[size_t(0)][size_t(0)]; p[size_t(0)] = float(5); -- cgit v1.2.3 From 86fffe7f9ed78a682879dd56c26628256f89e6ae Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 29 Mar 2010 00:45:26 -0700 Subject: Added tune helper to utils. Takes a subdevice and dxc properties object and tunes them. Made use of tune helper in simple device. Moved gain handler into utils header dir. --- host/include/uhd/CMakeLists.txt | 1 - host/include/uhd/gain_handler.hpp | 90 ----------------------- host/include/uhd/utils/CMakeLists.txt | 2 + host/include/uhd/utils/gain_handler.hpp | 90 +++++++++++++++++++++++ host/include/uhd/utils/tune_helper.hpp | 79 ++++++++++++++++++++ host/lib/CMakeLists.txt | 1 + host/lib/gain_handler.cpp | 2 +- host/lib/simple_device.cpp | 74 +------------------ host/lib/tune_helper.cpp | 125 ++++++++++++++++++++++++++++++++ host/lib/usrp/dboard_manager.cpp | 2 +- host/test/gain_handler_test.cpp | 2 +- 11 files changed, 303 insertions(+), 165 deletions(-) delete mode 100644 host/include/uhd/gain_handler.hpp create mode 100644 host/include/uhd/utils/gain_handler.hpp create mode 100644 host/include/uhd/utils/tune_helper.hpp create mode 100644 host/lib/tune_helper.cpp (limited to 'host/test/gain_handler_test.cpp') diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 0cebea095..b364f78cd 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -24,7 +24,6 @@ ADD_SUBDIRECTORY(utils) INSTALL(FILES config.hpp device.hpp - gain_handler.hpp props.hpp simple_device.hpp wax.hpp diff --git a/host/include/uhd/gain_handler.hpp b/host/include/uhd/gain_handler.hpp deleted file mode 100644 index 65d6cecf9..000000000 --- a/host/include/uhd/gain_handler.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_UHD_GAIN_HANDLER_HPP -#define INCLUDED_UHD_GAIN_HANDLER_HPP - -#include -#include -#include -#include - -namespace uhd{ - -class UHD_API gain_handler{ -public: - typedef boost::shared_ptr sptr; - typedef boost::function is_equal_t; - - /*! - * A set of properties for dealing with gains. - */ - struct UHD_API props_t{ - wax::obj value, range, names; - props_t(void); //default constructor - }; - - /*! - * Make a new gain handler. - * The construction arguments are agnostic to the property type. - * It is up to the caller to provide an "is_equal" function that - * can tell weather two properties (in a wax obj) are equal. - * \param link a link to the wax obj with properties - * \param props a struct of properties keys - * \param is_equal the function that tests for equal properties - */ - static sptr make( - const wax::obj &link, - const props_t &props, - is_equal_t is_equal - ); - - /*! - * Intercept gets for overall gain, min, max, step. - * Ensures that the gain name is valid. - * \return true for handled, false to pass on - */ - virtual bool intercept_get(const wax::obj &key, wax::obj &val) = 0; - - /*! - * Intercept sets for overall gain. - * Ensures that the gain name is valid. - * Ensures that the new gain is within range. - * \return true for handled, false to pass on - */ - virtual bool intercept_set(const wax::obj &key, const wax::obj &val) = 0; - - /*! - * Function template to test if two wax types are equal: - * The constructor will bind an instance of this for a specific type. - * This bound equals functions allows the intercept methods to be non-templated. - */ - template static bool is_equal(const wax::obj &a, const wax::obj &b){ - try{ - return a.as() == b.as(); - } - catch(const wax::bad_cast &){ - return false; - } - } - -}; - -} //namespace uhd - -#endif /* INCLUDED_UHD_GAIN_HANDLER_HPP */ - diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index f6ed87701..1b673f44a 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -18,7 +18,9 @@ INSTALL(FILES algorithm.hpp assert.hpp + gain_handler.hpp safe_main.hpp static.hpp + tune_helper.hpp DESTINATION ${INCLUDE_DIR}/uhd/utils ) diff --git a/host/include/uhd/utils/gain_handler.hpp b/host/include/uhd/utils/gain_handler.hpp new file mode 100644 index 000000000..f4629e6a7 --- /dev/null +++ b/host/include/uhd/utils/gain_handler.hpp @@ -0,0 +1,90 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_UTILS_GAIN_HANDLER_HPP +#define INCLUDED_UHD_UTILS_GAIN_HANDLER_HPP + +#include +#include +#include +#include + +namespace uhd{ + +class UHD_API gain_handler{ +public: + typedef boost::shared_ptr sptr; + typedef boost::function is_equal_t; + + /*! + * A set of properties for dealing with gains. + */ + struct UHD_API props_t{ + wax::obj value, range, names; + props_t(void); //default constructor + }; + + /*! + * Make a new gain handler. + * The construction arguments are agnostic to the property type. + * It is up to the caller to provide an "is_equal" function that + * can tell weather two properties (in a wax obj) are equal. + * \param link a link to the wax obj with properties + * \param props a struct of properties keys + * \param is_equal the function that tests for equal properties + */ + static sptr make( + const wax::obj &link, + const props_t &props, + is_equal_t is_equal + ); + + /*! + * Intercept gets for overall gain, min, max, step. + * Ensures that the gain name is valid. + * \return true for handled, false to pass on + */ + virtual bool intercept_get(const wax::obj &key, wax::obj &val) = 0; + + /*! + * Intercept sets for overall gain. + * Ensures that the gain name is valid. + * Ensures that the new gain is within range. + * \return true for handled, false to pass on + */ + virtual bool intercept_set(const wax::obj &key, const wax::obj &val) = 0; + + /*! + * Function template to test if two wax types are equal: + * The constructor will bind an instance of this for a specific type. + * This bound equals functions allows the intercept methods to be non-templated. + */ + template static bool is_equal(const wax::obj &a, const wax::obj &b){ + try{ + return a.as() == b.as(); + } + catch(const wax::bad_cast &){ + return false; + } + } + +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_UTILS_GAIN_HANDLER_HPP */ + diff --git a/host/include/uhd/utils/tune_helper.hpp b/host/include/uhd/utils/tune_helper.hpp new file mode 100644 index 000000000..828575c99 --- /dev/null +++ b/host/include/uhd/utils/tune_helper.hpp @@ -0,0 +1,79 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_UTILS_TUNE_HELPER_HPP +#define INCLUDED_UHD_UTILS_TUNE_HELPER_HPP + +#include +#include +#include + +namespace uhd{ + +/*! + * Tune a rx chain to the desired frequency: + * The IF of the subdevice is set as close as possible to + * the given target frequency + the LO offset (when applicable). + * The ddc cordic is setup to bring the IF down to baseband. + * \param subdev the dboard subdevice object with properties + * \param ddc the ddc properties object (with "rate", "decim", "freq") + * \param target_freq the desired center frequency + * \param lo_offset an offset for the subdevice IF from center + * \return a tune result struct + */ +UHD_API tune_result_t tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, + double target_freq, double lo_offset +); + +/*! + * Tune a rx chain to the desired frequency: + * Same as the above, except the LO offset + * is calculated based on the subdevice and BW. + */ +UHD_API tune_result_t tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, double target_freq +); + +/*! + * Tune a tx chain to the desired frequency: + * The IF of the subdevice is set as close as possible to + * the given target frequency + the LO offset (when applicable). + * The duc cordic is setup to bring the baseband up to IF. + * \param subdev the dboard subdevice object with properties + * \param duc the duc properties object (with "rate", "interp", "freq") + * \param target_freq the desired center frequency + * \param lo_offset an offset for the subdevice IF from center + * \return a tune result struct + */ +UHD_API tune_result_t tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, + double target_freq, double lo_offset +); + +/*! + * Tune a tx chain to the desired frequency: + * Same as the above, except the LO offset + * is calculated based on the subdevice and BW. + */ +UHD_API tune_result_t tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, double target_freq +); + +} //namespace uhd + +#endif /* INCLUDED_UHD_UTILS_TUNE_HELPER_HPP */ diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 1eceb53ea..55034c780 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -23,6 +23,7 @@ SET(libuhd_sources gain_handler.cpp load_modules.cpp simple_device.cpp + tune_helper.cpp types.cpp wax.cpp transport/if_addrs.cpp diff --git a/host/lib/gain_handler.cpp b/host/lib/gain_handler.cpp index a6ae06c50..daf629f0b 100644 --- a/host/lib/gain_handler.cpp +++ b/host/lib/gain_handler.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . // -#include +#include #include #include #include diff --git a/host/lib/simple_device.cpp b/host/lib/simple_device.cpp index 95bc8fecc..d507762a9 100644 --- a/host/lib/simple_device.cpp +++ b/host/lib/simple_device.cpp @@ -16,8 +16,8 @@ // #include +#include #include -#include #include #include #include @@ -26,64 +26,6 @@ using namespace uhd; -/*********************************************************************** - * Tune Helper Function - **********************************************************************/ -static tune_result_t tune( - double target_freq, - double lo_offset, - wax::obj subdev, - wax::obj dxc, - bool is_tx -){ - wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ]; - bool subdev_quadrature = subdev[SUBDEV_PROP_QUADRATURE].as(); - bool subdev_spectrum_inverted = subdev[SUBDEV_PROP_SPECTRUM_INVERTED].as(); - wax::obj dxc_freq_proxy = dxc[std::string("freq")]; - double dxc_sample_rate = dxc[std::string("rate")].as(); - - // Ask the d'board to tune as closely as it can to target_freq+lo_offset - double target_inter_freq = target_freq + lo_offset; - subdev_freq_proxy = target_inter_freq; - double actual_inter_freq = subdev_freq_proxy.as(); - - // Calculate the DDC setting that will downconvert the baseband from the - // daughterboard to our target frequency. - double delta_freq = target_freq - actual_inter_freq; - double delta_sign = std::signum(delta_freq); - delta_freq *= delta_sign; - delta_freq = fmod(delta_freq, dxc_sample_rate); - bool inverted = delta_freq > dxc_sample_rate/2.0; - double target_dxc_freq = inverted? (delta_freq - dxc_sample_rate) : (-delta_freq); - target_dxc_freq *= delta_sign; - - // If the spectrum is inverted, and the daughterboard doesn't do - // quadrature downconversion, we can fix the inversion by flipping the - // sign of the dxc_freq... (This only happens using the basic_rx board) - if (subdev_spectrum_inverted){ - inverted = not inverted; - } - if (inverted and not subdev_quadrature){ - target_dxc_freq *= -1.0; - inverted = not inverted; - } - // down conversion versus up conversion, fight! - // your mother is ugly and your going down... - target_dxc_freq *= (is_tx)? -1.0 : +1.0; - - dxc_freq_proxy = target_dxc_freq; - double actual_dxc_freq = dxc_freq_proxy.as(); - - //return some kind of tune result tuple/struct - tune_result_t tune_result; - tune_result.target_inter_freq = target_inter_freq; - tune_result.actual_inter_freq = actual_inter_freq; - tune_result.target_dxc_freq = target_dxc_freq; - tune_result.actual_dxc_freq = actual_dxc_freq; - tune_result.spectrum_inverted = inverted; - return tune_result; -} - /*********************************************************************** * Helper Functions **********************************************************************/ @@ -190,12 +132,7 @@ public: } tune_result_t set_rx_freq(double target_freq){ - double lo_offset = 0.0; - //if the local oscillator will be in the passband, use an offset - if (_rx_subdev[SUBDEV_PROP_LO_INTERFERES].as()){ - lo_offset = get_rx_rate()*2.0; - } - return tune(target_freq, lo_offset, _rx_subdev, _rx_ddc, false/* not tx */); + return tune_rx_subdev_and_ddc(_rx_subdev, _rx_ddc, target_freq); } freq_range_t get_rx_freq_range(void){ @@ -246,12 +183,7 @@ public: } tune_result_t set_tx_freq(double target_freq){ - double lo_offset = 0.0; - //if the local oscillator will be in the passband, use an offset - if (_tx_subdev[SUBDEV_PROP_LO_INTERFERES].as()){ - lo_offset = get_tx_rate()*2.0; - } - return tune(target_freq, lo_offset, _tx_subdev, _tx_duc, true/* is tx */); + return tune_tx_subdev_and_duc(_tx_subdev, _tx_duc, target_freq); } freq_range_t get_tx_freq_range(void){ diff --git a/host/lib/tune_helper.cpp b/host/lib/tune_helper.cpp new file mode 100644 index 000000000..eeda0b6be --- /dev/null +++ b/host/lib/tune_helper.cpp @@ -0,0 +1,125 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include + +using namespace uhd; + +/*********************************************************************** + * Tune Helper Function + **********************************************************************/ +static tune_result_t tune_xx_subdev_and_dxc( + bool is_tx, + wax::obj subdev, wax::obj dxc, + double target_freq, double lo_offset +){ + wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ]; + bool subdev_quadrature = subdev[SUBDEV_PROP_QUADRATURE].as(); + bool subdev_spectrum_inverted = subdev[SUBDEV_PROP_SPECTRUM_INVERTED].as(); + wax::obj dxc_freq_proxy = dxc[std::string("freq")]; + double dxc_sample_rate = dxc[std::string("rate")].as(); + + // Ask the d'board to tune as closely as it can to target_freq+lo_offset + double target_inter_freq = target_freq + lo_offset; + subdev_freq_proxy = target_inter_freq; + double actual_inter_freq = subdev_freq_proxy.as(); + + // Calculate the DDC setting that will downconvert the baseband from the + // daughterboard to our target frequency. + double delta_freq = target_freq - actual_inter_freq; + double delta_sign = std::signum(delta_freq); + delta_freq *= delta_sign; + delta_freq = std::fmod(delta_freq, dxc_sample_rate); + bool inverted = delta_freq > dxc_sample_rate/2.0; + double target_dxc_freq = inverted? (delta_freq - dxc_sample_rate) : (-delta_freq); + target_dxc_freq *= delta_sign; + + // If the spectrum is inverted, and the daughterboard doesn't do + // quadrature downconversion, we can fix the inversion by flipping the + // sign of the dxc_freq... (This only happens using the basic_rx board) + if (subdev_spectrum_inverted){ + inverted = not inverted; + } + if (inverted and not subdev_quadrature){ + target_dxc_freq *= -1.0; + inverted = not inverted; + } + // down conversion versus up conversion, fight! + // your mother is ugly and your going down... + target_dxc_freq *= (is_tx)? -1.0 : +1.0; + + dxc_freq_proxy = target_dxc_freq; + double actual_dxc_freq = dxc_freq_proxy.as(); + + //return some kind of tune result tuple/struct + tune_result_t tune_result; + tune_result.target_inter_freq = target_inter_freq; + tune_result.actual_inter_freq = actual_inter_freq; + tune_result.target_dxc_freq = target_dxc_freq; + tune_result.actual_dxc_freq = actual_dxc_freq; + tune_result.spectrum_inverted = inverted; + return tune_result; +} + +/*********************************************************************** + * RX Tune + **********************************************************************/ +tune_result_t uhd::tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, + double target_freq, double lo_offset +){ + bool is_tx = false; + return tune_xx_subdev_and_dxc(is_tx, subdev, ddc, target_freq, lo_offset); +} + +tune_result_t uhd::tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, + double target_freq +){ + double lo_offset = 0.0; + //if the local oscillator will be in the passband, use an offset + if (subdev[SUBDEV_PROP_LO_INTERFERES].as()){ + lo_offset = 2.0*ddc[std::string("rate")].as()/ddc[std::string("decim")].as(); + } + return tune_rx_subdev_and_ddc(subdev, ddc, target_freq, lo_offset); +} + +/*********************************************************************** + * TX Tune + **********************************************************************/ +tune_result_t uhd::tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, + double target_freq, double lo_offset +){ + bool is_tx = true; + return tune_xx_subdev_and_dxc(is_tx, subdev, duc, target_freq, lo_offset); +} + +tune_result_t uhd::tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, + double target_freq +){ + double lo_offset = 0.0; + //if the local oscillator will be in the passband, use an offset + if (subdev[SUBDEV_PROP_LO_INTERFERES].as()){ + lo_offset = 2.0*duc[std::string("rate")].as()/duc[std::string("interp")].as(); + } + return tune_tx_subdev_and_duc(subdev, duc, target_freq, lo_offset); +} diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index bc9bfbf14..f86545696 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -16,7 +16,7 @@ // #include -#include +#include #include #include #include diff --git a/host/test/gain_handler_test.cpp b/host/test/gain_handler_test.cpp index a7c6e1e82..76b065ce2 100644 --- a/host/test/gain_handler_test.cpp +++ b/host/test/gain_handler_test.cpp @@ -16,7 +16,7 @@ // #include -#include +#include #include #include #include -- cgit v1.2.3