diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/dboard/db_basic_and_lf.cpp | 16 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_rfx.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_xcvr2450.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/dboard_base.cpp | 25 | ||||
-rw-r--r-- | host/lib/usrp/dboard_ctor_args.hpp | 32 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 24 |
6 files changed, 77 insertions, 40 deletions
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index b0fbbd2ec..ebe3b2616 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -34,7 +34,7 @@ using namespace boost::assign; **********************************************************************/ class basic_rx : public rx_dboard_base{ public: - basic_rx(ctor_args_t const& args, double max_freq); + basic_rx(ctor_args_t args, double max_freq); ~basic_rx(void); void rx_get(const wax::obj &key, wax::obj &val); @@ -46,7 +46,7 @@ private: class basic_tx : public tx_dboard_base{ public: - basic_tx(ctor_args_t const& args, double max_freq); + basic_tx(ctor_args_t args, double max_freq); ~basic_tx(void); void tx_get(const wax::obj &key, wax::obj &val); @@ -59,19 +59,19 @@ private: /*********************************************************************** * Register the basic and LF dboards **********************************************************************/ -static dboard_base::sptr make_basic_rx(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_basic_rx(dboard_base::ctor_args_t args){ return dboard_base::sptr(new basic_rx(args, 90e9)); } -static dboard_base::sptr make_basic_tx(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_basic_tx(dboard_base::ctor_args_t args){ return dboard_base::sptr(new basic_tx(args, 90e9)); } -static dboard_base::sptr make_lf_rx(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_lf_rx(dboard_base::ctor_args_t args){ return dboard_base::sptr(new basic_rx(args, 32e6)); } -static dboard_base::sptr make_lf_tx(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_lf_tx(dboard_base::ctor_args_t args){ return dboard_base::sptr(new basic_tx(args, 32e6)); } @@ -85,7 +85,7 @@ UHD_STATIC_BLOCK(reg_basic_and_lf_dboards){ /*********************************************************************** * Basic and LF RX dboard **********************************************************************/ -basic_rx::basic_rx(ctor_args_t const& args, double max_freq) : rx_dboard_base(args){ +basic_rx::basic_rx(ctor_args_t args, double max_freq) : rx_dboard_base(args){ _max_freq = max_freq; } @@ -187,7 +187,7 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ /*********************************************************************** * Basic and LF TX dboard **********************************************************************/ -basic_tx::basic_tx(ctor_args_t const& args, double max_freq) : tx_dboard_base(args){ +basic_tx::basic_tx(ctor_args_t args, double max_freq) : tx_dboard_base(args){ _max_freq = max_freq; } diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 175f55eab..07159cd09 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -63,7 +63,7 @@ static const float _max_rx_pga0_gain = 45; class rfx_xcvr : public xcvr_dboard_base{ public: rfx_xcvr( - ctor_args_t const& args, + ctor_args_t args, const freq_range_t &freq_range, bool rx_div2, bool tx_div2 ); @@ -108,23 +108,23 @@ private: /*********************************************************************** * Register the RFX dboards (min freq, max freq, rx div2, tx div2) **********************************************************************/ -static dboard_base::sptr make_rfx_flex400(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_rfx_flex400(dboard_base::ctor_args_t args){ return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(400e6, 500e6), false, true)); } -static dboard_base::sptr make_rfx_flex900(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_rfx_flex900(dboard_base::ctor_args_t args){ return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(750e6, 1050e6), true, true)); } -static dboard_base::sptr make_rfx_flex1800(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_rfx_flex1800(dboard_base::ctor_args_t args){ return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(1500e6, 2100e6), false, false)); } -static dboard_base::sptr make_rfx_flex1200(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_rfx_flex1200(dboard_base::ctor_args_t args){ return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(1150e6, 1450e6), true, true)); } -static dboard_base::sptr make_rfx_flex2400(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_rfx_flex2400(dboard_base::ctor_args_t args){ return dboard_base::sptr(new rfx_xcvr(args, freq_range_t(2300e6, 2900e6), false, false)); } @@ -149,7 +149,7 @@ UHD_STATIC_BLOCK(reg_rfx_dboards){ * Structors **********************************************************************/ rfx_xcvr::rfx_xcvr( - ctor_args_t const& args, + ctor_args_t args, const freq_range_t &freq_range, bool rx_div2, bool tx_div2 ) : xcvr_dboard_base(args){ diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 0dfef2a0a..9b0fcbc5c 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -89,7 +89,7 @@ static const uhd::dict<std::string, gain_range_t> xcvr_rx_gain_ranges = map_list **********************************************************************/ class xcvr2450 : public xcvr_dboard_base{ public: - xcvr2450(ctor_args_t const& args); + xcvr2450(ctor_args_t args); ~xcvr2450(void); void rx_get(const wax::obj &key, wax::obj &val); @@ -152,7 +152,7 @@ private: /*********************************************************************** * Register the XCVR 2450 dboard **********************************************************************/ -static dboard_base::sptr make_xcvr2450(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_xcvr2450(dboard_base::ctor_args_t args){ return dboard_base::sptr(new xcvr2450(args)); } @@ -165,7 +165,7 @@ UHD_STATIC_BLOCK(reg_xcvr2450_dboard){ /*********************************************************************** * Structors **********************************************************************/ -xcvr2450::xcvr2450(ctor_args_t const& args) : xcvr_dboard_base(args){ +xcvr2450::xcvr2450(ctor_args_t args) : xcvr_dboard_base(args){ //enable only the clocks we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); diff --git a/host/lib/usrp/dboard_base.cpp b/host/lib/usrp/dboard_base.cpp index bc94ca9ac..523da696a 100644 --- a/host/lib/usrp/dboard_base.cpp +++ b/host/lib/usrp/dboard_base.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include "dboard_ctor_args.hpp" #include <uhd/usrp/dboard_base.hpp> #include <boost/format.hpp> #include <stdexcept> @@ -25,14 +26,12 @@ using namespace uhd::usrp; * dboard_base dboard dboard_base class **********************************************************************/ struct dboard_base::dboard_base_impl{ - std::string sd_name; - dboard_iface::sptr db_iface; - dboard_id_t rx_id, tx_id; + ctor_args_impl args; + dboard_base_impl(ctor_args_t args) : args(*args){} }; -dboard_base::dboard_base(ctor_args_t const& args){ - _impl = new dboard_base_impl; - boost::tie(_impl->sd_name, _impl->db_iface, _impl->rx_id, _impl->tx_id) = args; +dboard_base::dboard_base(ctor_args_t args){ + _impl = new dboard_base_impl(args); } dboard_base::~dboard_base(void){ @@ -40,25 +39,25 @@ dboard_base::~dboard_base(void){ } std::string dboard_base::get_subdev_name(void){ - return _impl->sd_name; + return _impl->args.sd_name; } dboard_iface::sptr dboard_base::get_iface(void){ - return _impl->db_iface; + return _impl->args.db_iface; } dboard_id_t dboard_base::get_rx_id(void){ - return _impl->rx_id; + return _impl->args.rx_id; } dboard_id_t dboard_base::get_tx_id(void){ - return _impl->tx_id; + return _impl->args.tx_id; } /*********************************************************************** * xcvr dboard dboard_base class **********************************************************************/ -xcvr_dboard_base::xcvr_dboard_base(ctor_args_t const& args) : dboard_base(args){ +xcvr_dboard_base::xcvr_dboard_base(ctor_args_t args) : dboard_base(args){ if (get_rx_id() == dboard_id::NONE){ throw std::runtime_error(str(boost::format( "cannot create xcvr board when the rx id is \"%s\"" @@ -78,7 +77,7 @@ xcvr_dboard_base::~xcvr_dboard_base(void){ /*********************************************************************** * rx dboard dboard_base class **********************************************************************/ -rx_dboard_base::rx_dboard_base(ctor_args_t const& args) : dboard_base(args){ +rx_dboard_base::rx_dboard_base(ctor_args_t args) : dboard_base(args){ if (get_tx_id() != dboard_id::NONE){ throw std::runtime_error(str(boost::format( "cannot create rx board when the tx id is \"%s\"" @@ -102,7 +101,7 @@ void rx_dboard_base::tx_set(const wax::obj &, const wax::obj &){ /*********************************************************************** * tx dboard dboard_base class **********************************************************************/ -tx_dboard_base::tx_dboard_base(ctor_args_t const& args) : dboard_base(args){ +tx_dboard_base::tx_dboard_base(ctor_args_t args) : dboard_base(args){ if (get_rx_id() != dboard_id::NONE){ throw std::runtime_error(str(boost::format( "cannot create tx board when the rx id is \"%s\"" diff --git a/host/lib/usrp/dboard_ctor_args.hpp b/host/lib/usrp/dboard_ctor_args.hpp new file mode 100644 index 000000000..13abe79e8 --- /dev/null +++ b/host/lib/usrp/dboard_ctor_args.hpp @@ -0,0 +1,32 @@ +// +// 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 <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_DBOARD_CTOR_ARGS_HPP +#define INCLUDED_DBOARD_CTOR_ARGS_HPP + +#include <uhd/usrp/dboard_id.hpp> +#include <uhd/usrp/dboard_base.hpp> +#include <uhd/usrp/dboard_iface.hpp> +#include <string> + +struct uhd::usrp::dboard_base::ctor_args_impl{ + std::string sd_name; + dboard_iface::sptr db_iface; + dboard_id_t rx_id, tx_id; +}; + +#endif /* INCLUDED_DBOARD_CTOR_ARGS_HPP */ diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 85d651c0c..80bf2dccb 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include "dboard_ctor_args.hpp" #include <uhd/usrp/dboard_manager.hpp> #include <uhd/usrp/subdev_props.hpp> #include <uhd/utils/gain_handler.hpp> @@ -206,13 +207,18 @@ dboard_manager_impl::dboard_manager_impl( //initialize the gpio pins before creating subdevs set_nice_dboard_if(); + //dboard constructor args + dboard_base::ctor_args_impl db_ctor_args; + db_ctor_args.db_iface = iface; + db_ctor_args.rx_id = rx_dboard_id; + db_ctor_args.tx_id = tx_dboard_id; + //make xcvr subdevs (make one subdev for both rx and tx dboards) if (rx_dboard_ctor == tx_dboard_ctor){ UHD_ASSERT_THROW(rx_subdevs == tx_subdevs); BOOST_FOREACH(const std::string &subdev, rx_subdevs){ - dboard_base::sptr xcvr_dboard = rx_dboard_ctor( - dboard_base::ctor_args_t(subdev, iface, rx_dboard_id, tx_dboard_id) - ); + db_ctor_args.sd_name = subdev; + dboard_base::sptr xcvr_dboard = rx_dboard_ctor(&db_ctor_args); //create a rx proxy for this xcvr board _rx_dboards[subdev] = subdev_proxy::sptr( new subdev_proxy(xcvr_dboard, subdev_proxy::RX_TYPE) @@ -228,9 +234,9 @@ dboard_manager_impl::dboard_manager_impl( else{ //make the rx subdevs BOOST_FOREACH(const std::string &subdev, rx_subdevs){ - dboard_base::sptr rx_dboard = rx_dboard_ctor( - dboard_base::ctor_args_t(subdev, iface, rx_dboard_id, dboard_id::NONE) - ); + db_ctor_args.sd_name = subdev; + db_ctor_args.tx_id = dboard_id::NONE; + dboard_base::sptr rx_dboard = rx_dboard_ctor(&db_ctor_args); //create a rx proxy for this rx board _rx_dboards[subdev] = subdev_proxy::sptr( new subdev_proxy(rx_dboard, subdev_proxy::RX_TYPE) @@ -238,9 +244,9 @@ dboard_manager_impl::dboard_manager_impl( } //make the tx subdevs BOOST_FOREACH(const std::string &subdev, tx_subdevs){ - dboard_base::sptr tx_dboard = tx_dboard_ctor( - dboard_base::ctor_args_t(subdev, iface, dboard_id::NONE, tx_dboard_id) - ); + db_ctor_args.sd_name = subdev; + db_ctor_args.rx_id = dboard_id::NONE; + dboard_base::sptr tx_dboard = tx_dboard_ctor(&db_ctor_args); //create a tx proxy for this tx board _tx_dboards[subdev] = subdev_proxy::sptr( new subdev_proxy(tx_dboard, subdev_proxy::TX_TYPE) |