From aa0513375eb60a594f323b82d6f06c7b69c574fc Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Oct 2011 12:58:43 -0700 Subject: wbx: squashed Ben's WBX work --- host/lib/usrp/dboard/db_wbx_simple.cpp | 47 ++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'host/lib/usrp/dboard/db_wbx_simple.cpp') diff --git a/host/lib/usrp/dboard/db_wbx_simple.cpp b/host/lib/usrp/dboard/db_wbx_simple.cpp index 990bacbc8..789146854 100644 --- a/host/lib/usrp/dboard/db_wbx_simple.cpp +++ b/host/lib/usrp/dboard/db_wbx_simple.cpp @@ -32,15 +32,17 @@ using namespace uhd; using namespace uhd::usrp; using namespace boost::assign; + /*********************************************************************** * The WBX Simple dboard constants **********************************************************************/ -static const freq_range_t wbx_freq_range(68.75e6, 2.2e9); - static const prop_names_t wbx_tx_antennas = list_of("TX/RX"); static const prop_names_t wbx_rx_antennas = list_of("TX/RX")("RX2"); +//this will get set by a version-specific function call +static freq_range_t wbx_freq_range(0.0, 0.0); + /*********************************************************************** * The WBX simple implementation **********************************************************************/ @@ -72,13 +74,19 @@ static dboard_base::sptr make_wbx_simple(dboard_base::ctor_args_t args){ return dboard_base::sptr(new wbx_simple(args)); } +/*********************************************************************** + * ID Numbers for WBX daughterboard combinations. + **********************************************************************/ UHD_STATIC_BLOCK(reg_wbx_simple_dboards){ dboard_manager::register_dboard(0x0053, 0x0052, &make_wbx_simple, "WBX"); dboard_manager::register_dboard(0x0053, 0x004f, &make_wbx_simple, "WBX + Simple GDB"); dboard_manager::register_dboard(0x0057, 0x0056, &make_wbx_simple, "WBX v3"); dboard_manager::register_dboard(0x0057, 0x004f, &make_wbx_simple, "WBX v3 + Simple GDB"); + dboard_manager::register_dboard(0x0063, 0x0062, &make_wbx_simple, "WBX v4"); + dboard_manager::register_dboard(0x0063, 0x004f, &make_wbx_simple, "WBX v4 + Simple GDB"); } + /*********************************************************************** * Structors **********************************************************************/ @@ -100,6 +108,9 @@ wbx_simple::wbx_simple(ctor_args_t args) : wbx_base(args){ this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, ANT_RX2, ANTSW_IO); this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, ANT_RX2, ANTSW_IO); + //get the frequency range of our WBX db + wbx_freq_range = this->get_freq_range(); + //set some default values set_rx_lo_freq((wbx_freq_range.start() + wbx_freq_range.stop())/2.0); set_tx_lo_freq((wbx_freq_range.start() + wbx_freq_range.stop())/2.0); @@ -149,11 +160,19 @@ void wbx_simple::rx_get(const wax::obj &key_, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ case SUBDEV_PROP_NAME: - if (is_v3()) - val = std::string("WBX v3 RX + Simple GDB"); - else + switch(get_rx_id().to_uint16()) { + case 0x053: val = std::string("WBX RX + Simple GDB"); - return; + return; + case 0x057: + val = std::string("WBX v3 RX + Simple GDB"); + return; + case 0x063: + val = std::string("WBX v4 RX + Simple GDB"); + return; + default: + UHD_THROW_INVALID_CODE_PATH(); + } case SUBDEV_PROP_FREQ: val = _rx_lo_freq; @@ -206,11 +225,19 @@ void wbx_simple::tx_get(const wax::obj &key_, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ case SUBDEV_PROP_NAME: - if (is_v3()) - val = std::string("WBX v3 TX + Simple GDB"); - else + switch(get_rx_id().to_uint16()) { + case 0x053: val = std::string("WBX TX + Simple GDB"); - return; + return; + case 0x057: + val = std::string("WBX v3 TX + Simple GDB"); + return; + case 0x063: + val = std::string("WBX v4 TX + Simple GDB"); + return; + default: + UHD_THROW_INVALID_CODE_PATH(); + } case SUBDEV_PROP_FREQ: val = _tx_lo_freq; -- cgit v1.2.3 From 3c07f1d606296c0a6813a3a577e918926e43c478 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Oct 2011 18:04:55 -0700 Subject: wbx: bring WBX into the tree --- host/lib/usrp/dboard/CMakeLists.txt | 10 +- host/lib/usrp/dboard/db_wbx_common.cpp | 190 +++++++------------------------ host/lib/usrp/dboard/db_wbx_common.hpp | 57 ++++------ host/lib/usrp/dboard/db_wbx_simple.cpp | 185 ++++-------------------------- host/lib/usrp/dboard/db_wbx_version2.cpp | 130 +++++---------------- host/lib/usrp/dboard/db_wbx_version3.cpp | 130 +++++---------------- host/lib/usrp/dboard/db_wbx_version4.cpp | 140 ++++++----------------- 7 files changed, 188 insertions(+), 654 deletions(-) (limited to 'host/lib/usrp/dboard/db_wbx_simple.cpp') diff --git a/host/lib/usrp/dboard/CMakeLists.txt b/host/lib/usrp/dboard/CMakeLists.txt index 50662a96e..b000c7f33 100644 --- a/host/lib/usrp/dboard/CMakeLists.txt +++ b/host/lib/usrp/dboard/CMakeLists.txt @@ -26,11 +26,11 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/db_sbx_common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/db_sbx_version3.cpp ${CMAKE_CURRENT_SOURCE_DIR}/db_sbx_version4.cpp - #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_common.cpp - #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_version2.cpp - #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_version3.cpp - #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_version4.cpp - #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_simple.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_version2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_version3.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_version4.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_simple.cpp ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx.cpp ${CMAKE_CURRENT_SOURCE_DIR}/db_unknown.cpp ${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx.cpp diff --git a/host/lib/usrp/dboard/db_wbx_common.cpp b/host/lib/usrp/dboard/db_wbx_common.cpp index 63f70e3d5..daf6dbc98 100644 --- a/host/lib/usrp/dboard/db_wbx_common.cpp +++ b/host/lib/usrp/dboard/db_wbx_common.cpp @@ -58,6 +58,44 @@ static int rx_pga0_gain_to_iobits(double &gain){ * WBX Common Implementation **********************************************************************/ wbx_base::wbx_base(ctor_args_t args) : xcvr_dboard_base(args){ + + //enable the clocks that we need + this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); + this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); + + //////////////////////////////////////////////////////////////////// + // Register RX properties + //////////////////////////////////////////////////////////////////// + this->get_rx_subtree()->create("sensors/lo_locked") + .publish(boost::bind(&wbx_base::get_locked, this, dboard_iface::UNIT_RX)); + BOOST_FOREACH(const std::string &name, wbx_rx_gain_ranges.keys()){ + this->get_rx_subtree()->create("gains/"+name+"/value") + .coerce(boost::bind(&wbx_base::set_rx_gain, this, _1, name)) + .set(wbx_rx_gain_ranges[name].start()); + this->get_rx_subtree()->create("gains/"+name+"/range") + .set(wbx_rx_gain_ranges[name]); + } + this->get_rx_subtree()->create("connection").set("IQ"); + this->get_rx_subtree()->create("enabled") + .subscribe(boost::bind(&wbx_base::set_rx_enabled, this, _1)) + .set(true); //start enabled + this->get_rx_subtree()->create("use_lo_offset").set(false); + this->get_rx_subtree()->create("bandwidth/value").set(2*20.0e6); //20MHz low-pass, we want complex double-sided + this->get_rx_subtree()->create("bandwidth/range") + .set(freq_range_t(2*20.0e6, 2*20.0e6)); + + //////////////////////////////////////////////////////////////////// + // Register TX properties + //////////////////////////////////////////////////////////////////// + this->get_tx_subtree()->create("sensors/lo_locked") + .publish(boost::bind(&wbx_base::get_locked, this, dboard_iface::UNIT_TX)); + this->get_tx_subtree()->create("connection").set("IQ"); + this->get_tx_subtree()->create("use_lo_offset").set(false); + this->get_tx_subtree()->create("bandwidth/value").set(2*20.0e6); //20MHz low-pass, we want complex double-sided + this->get_tx_subtree()->create("bandwidth/range") + .set(freq_range_t(2*20.0e6, 2*20.0e6)); + + // instantiate subclass foo switch(get_rx_id().to_uint16()) { case 0x053: db_actual = wbx_versionx_sptr(new wbx_version2(this)); @@ -72,6 +110,7 @@ wbx_base::wbx_base(ctor_args_t args) : xcvr_dboard_base(args){ /* We didn't recognize the version of the board... */ UHD_THROW_INVALID_CODE_PATH(); } + } @@ -88,18 +127,10 @@ void wbx_base::set_rx_enabled(bool enb){ ); } -void wbx_base::set_tx_enabled(bool enb){ - db_actual->set_tx_enabled(enb); -} - /*********************************************************************** * Gain Handling **********************************************************************/ -void wbx_base::set_tx_gain(double gain, const std::string &name){ - db_actual->set_tx_gain(gain, name); -} - -void wbx_base::set_rx_gain(double gain, const std::string &name){ +double wbx_base::set_rx_gain(double gain, const std::string &name){ assert_has(wbx_rx_gain_ranges.keys(), name, "wbx rx gain name"); if(name == "PGA0"){ boost::uint16_t io_bits = rx_pga0_gain_to_iobits(gain); @@ -109,150 +140,17 @@ void wbx_base::set_rx_gain(double gain, const std::string &name){ this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, io_bits, RX_ATTN_MASK); } else UHD_THROW_INVALID_CODE_PATH(); + return _rx_gains[name]; //returned shadowed } /*********************************************************************** * Tuning **********************************************************************/ -freq_range_t wbx_base::get_freq_range(void) { - return db_actual->get_freq_range(); -} - double wbx_base::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { return db_actual->set_lo_freq(unit, target_freq); } -bool wbx_base::get_locked(dboard_iface::unit_t unit){ - return (this->get_iface()->read_gpio(unit) & LOCKDET_MASK) != 0; +sensor_value_t wbx_base::get_locked(dboard_iface::unit_t unit){ + const bool locked = (this->get_iface()->read_gpio(unit) & LOCKDET_MASK) != 0; + return sensor_value_t("LO", locked, "locked", "unlocked"); } - - -/*********************************************************************** - * RX Get and Set - **********************************************************************/ -void wbx_base::rx_get(const wax::obj &key_, wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - case SUBDEV_PROP_NAME: - val = get_rx_id().to_pp_string(); - return; - - case SUBDEV_PROP_OTHERS: - val = prop_names_t(); //empty - return; - - case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), key.name, "wbx rx gain name"); - val = _rx_gains[key.name]; - return; - - case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_rx_gain_ranges.keys(), key.name, "wbx rx gain name"); - val = wbx_rx_gain_ranges[key.name]; - return; - - case SUBDEV_PROP_GAIN_NAMES: - val = prop_names_t(wbx_rx_gain_ranges.keys()); - return; - - case SUBDEV_PROP_FREQ: - val = 0.0; - return; - - case SUBDEV_PROP_FREQ_RANGE: - val = freq_range_t(0.0, 0.0, 0.0);; - return; - - case SUBDEV_PROP_ANTENNA: - val = std::string(""); - return; - - case SUBDEV_PROP_ANTENNA_NAMES: - val = prop_names_t(1, ""); - return; - - case SUBDEV_PROP_CONNECTION: - val = SUBDEV_CONN_COMPLEX_IQ; - return; - - case SUBDEV_PROP_ENABLED: - val = _rx_enabled; - return; - - case SUBDEV_PROP_USE_LO_OFFSET: - val = false; - return; - - case SUBDEV_PROP_SENSOR: - UHD_ASSERT_THROW(key.name == "lo_locked"); - val = sensor_value_t("LO", this->get_locked(dboard_iface::UNIT_RX), "locked", "unlocked"); - return; - - case SUBDEV_PROP_SENSOR_NAMES: - val = prop_names_t(1, "lo_locked"); - return; - - case SUBDEV_PROP_BANDWIDTH: - val = 2*20.0e6; //20MHz low-pass, we want complex double-sided - return; - - default: UHD_THROW_PROP_GET_ERROR(); - } -} - -void wbx_base::rx_set(const wax::obj &key_, const wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - - case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as(), key.name); - return; - - case SUBDEV_PROP_ENABLED: - _rx_enabled = val.as(); - this->set_rx_enabled(_rx_enabled); - return; - - case SUBDEV_PROP_BANDWIDTH: - UHD_MSG(warning) << "WBX: No tunable bandwidth, fixed filtered to 40MHz"; - return; - - default: UHD_THROW_PROP_SET_ERROR(); - } -} - -/*********************************************************************** - * TX Get and Set - **********************************************************************/ -void wbx_base::tx_get(const wax::obj &key_, wax::obj &val){ - db_actual->tx_get(key_, val); -} - -void wbx_base::tx_set(const wax::obj &key_, const wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - - case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as(), key.name); - return; - - case SUBDEV_PROP_ENABLED: - _tx_enabled = val.as(); - this->set_tx_enabled(_tx_enabled); - return; - - case SUBDEV_PROP_BANDWIDTH: - UHD_MSG(warning) << "WBX: No tunable bandwidth, fixed filtered to 40MHz"; - return; - - default: UHD_THROW_PROP_SET_ERROR(); - } -} - - diff --git a/host/lib/usrp/dboard/db_wbx_common.hpp b/host/lib/usrp/dboard/db_wbx_common.hpp index 57e2a0fe6..3e41e04b7 100644 --- a/host/lib/usrp/dboard/db_wbx_common.hpp +++ b/host/lib/usrp/dboard/db_wbx_common.hpp @@ -67,6 +67,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,7 @@ #include #include #include +#include namespace uhd{ namespace usrp{ @@ -95,23 +97,9 @@ public: virtual ~wbx_base(void); protected: - virtual void set_rx_gain(double gain, const std::string &name); - virtual void set_tx_gain(double gain, const std::string &name); + virtual double set_rx_gain(double gain, const std::string &name); virtual void set_rx_enabled(bool enb); - virtual void set_tx_enabled(bool enb); - - virtual void rx_get(const wax::obj &key, wax::obj &val); - virtual void rx_set(const wax::obj &key, const wax::obj &val); - - virtual void tx_get(const wax::obj &key, wax::obj &val); - virtual void tx_set(const wax::obj &key, const wax::obj &val); - - /*! - * Retrieve the frequency range of the board. - * \return the frequency range as a freq_range_t - */ - virtual freq_range_t get_freq_range(void); /*! * Set the LO frequency for the particular dboard unit. @@ -128,8 +116,7 @@ protected: * \param unit which unit rx or tx * \return true for locked */ - virtual bool get_locked(dboard_iface::unit_t unit); - + virtual sensor_value_t get_locked(dboard_iface::unit_t unit); /*! * Version-agnostic ABC that wraps version-specific implementations of the @@ -143,11 +130,20 @@ protected: wbx_versionx() {} ~wbx_versionx(void) {} - virtual void set_tx_gain(double gain, const std::string &name) = 0; + virtual double set_tx_gain(double gain, const std::string &name) = 0; virtual void set_tx_enabled(bool enb) = 0; - virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; - virtual freq_range_t get_freq_range(void) = 0; virtual double set_lo_freq(dboard_iface::unit_t unit, double target_freq) = 0; + + /*! This is the registered instance of the wrapper class, wbx_base. */ + wbx_base *self_base; + + property_tree::sptr get_rx_subtree(void){ + return self_base->get_rx_subtree(); + } + + property_tree::sptr get_tx_subtree(void){ + return self_base->get_tx_subtree(); + } }; @@ -161,14 +157,9 @@ protected: wbx_version2(wbx_base *_self_wbx_base); ~wbx_version2(void); - void set_tx_gain(double gain, const std::string &name); + double set_tx_gain(double gain, const std::string &name); void set_tx_enabled(bool enb); - void tx_get(const wax::obj &key, wax::obj &val); - freq_range_t get_freq_range(void); double set_lo_freq(dboard_iface::unit_t unit, double target_freq); - - /*! This is the registered instance of the wrapper class, wbx_base. */ - wbx_base *self_base; }; /*! @@ -181,14 +172,9 @@ protected: wbx_version3(wbx_base *_self_wbx_base); ~wbx_version3(void); - void set_tx_gain(double gain, const std::string &name); + double set_tx_gain(double gain, const std::string &name); void set_tx_enabled(bool enb); - void tx_get(const wax::obj &key, wax::obj &val); - freq_range_t get_freq_range(void); double set_lo_freq(dboard_iface::unit_t unit, double target_freq); - - /*! This is the registered instance of the wrapper class, wbx_base. */ - wbx_base *self_base; }; /*! @@ -201,14 +187,9 @@ protected: wbx_version4(wbx_base *_self_wbx_base); ~wbx_version4(void); - void set_tx_gain(double gain, const std::string &name); + double set_tx_gain(double gain, const std::string &name); void set_tx_enabled(bool enb); - void tx_get(const wax::obj &key, wax::obj &val); - freq_range_t get_freq_range(void); double set_lo_freq(dboard_iface::unit_t unit, double target_freq); - - /*! This is the registered instance of the wrapper class, wbx_base. */ - wbx_base *self_base; }; /*! diff --git a/host/lib/usrp/dboard/db_wbx_simple.cpp b/host/lib/usrp/dboard/db_wbx_simple.cpp index 789146854..1ac2a1704 100644 --- a/host/lib/usrp/dboard/db_wbx_simple.cpp +++ b/host/lib/usrp/dboard/db_wbx_simple.cpp @@ -40,9 +40,6 @@ static const prop_names_t wbx_tx_antennas = list_of("TX/RX"); static const prop_names_t wbx_rx_antennas = list_of("TX/RX")("RX2"); -//this will get set by a version-specific function call -static freq_range_t wbx_freq_range(0.0, 0.0); - /*********************************************************************** * The WBX simple implementation **********************************************************************/ @@ -51,17 +48,7 @@ public: wbx_simple(ctor_args_t args); ~wbx_simple(void); - void rx_get(const wax::obj &key, wax::obj &val); - void rx_set(const wax::obj &key, const wax::obj &val); - - void tx_get(const wax::obj &key, wax::obj &val); - void tx_set(const wax::obj &key, const wax::obj &val); - private: - void set_rx_lo_freq(double freq); - void set_tx_lo_freq(double freq); - double _rx_lo_freq, _tx_lo_freq; - void set_rx_ant(const std::string &ant); void set_tx_ant(const std::string &ant); std::string _rx_ant; @@ -86,12 +73,33 @@ UHD_STATIC_BLOCK(reg_wbx_simple_dboards){ dboard_manager::register_dboard(0x0063, 0x004f, &make_wbx_simple, "WBX v4 + Simple GDB"); } - /*********************************************************************** * Structors **********************************************************************/ wbx_simple::wbx_simple(ctor_args_t args) : wbx_base(args){ + //////////////////////////////////////////////////////////////////// + // Register RX properties + //////////////////////////////////////////////////////////////////// + this->get_rx_subtree()->access("name").set( + this->get_rx_subtree()->access("name").get() + " + Simple GDB"); + this->get_rx_subtree()->create("antenna/value") + .subscribe(boost::bind(&wbx_simple::set_rx_ant, this, _1)) + .set("RX2"); + this->get_rx_subtree()->create >("antenna/options") + .set(wbx_rx_antennas); + + //////////////////////////////////////////////////////////////////// + // Register TX properties + //////////////////////////////////////////////////////////////////// + this->get_tx_subtree()->access("name").set( + this->get_tx_subtree()->access("name").get() + " + Simple GDB"); + this->get_tx_subtree()->create("antenna/value") + .subscribe(boost::bind(&wbx_simple::set_tx_ant, this, _1)) + .set(wbx_tx_antennas.at(0)); + this->get_tx_subtree()->create >("antenna/options") + .set(wbx_tx_antennas); + //set the gpio directions and atr controls (antenna switches all under ATR) this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_TX, ANTSW_IO, ANTSW_IO); this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, ANTSW_IO, ANTSW_IO); @@ -107,14 +115,6 @@ wbx_simple::wbx_simple(ctor_args_t args) : wbx_base(args){ this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, ANT_TXRX, ANTSW_IO); this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, ANT_RX2, ANTSW_IO); this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, ANT_RX2, ANTSW_IO); - - //get the frequency range of our WBX db - wbx_freq_range = this->get_freq_range(); - - //set some default values - set_rx_lo_freq((wbx_freq_range.start() + wbx_freq_range.stop())/2.0); - set_tx_lo_freq((wbx_freq_range.start() + wbx_freq_range.stop())/2.0); - set_rx_ant("RX2"); } wbx_simple::~wbx_simple(void){ @@ -139,144 +139,3 @@ void wbx_simple::set_tx_ant(const std::string &ant){ assert_has(wbx_tx_antennas, ant, "wbx tx antenna name"); //only one antenna option, do nothing } - -/*********************************************************************** - * Tuning - **********************************************************************/ -void wbx_simple::set_rx_lo_freq(double freq){ - _rx_lo_freq = set_lo_freq(dboard_iface::UNIT_RX, wbx_freq_range.clip(freq)); -} - -void wbx_simple::set_tx_lo_freq(double freq){ - _tx_lo_freq = set_lo_freq(dboard_iface::UNIT_TX, wbx_freq_range.clip(freq)); -} - -/*********************************************************************** - * RX Get and Set - **********************************************************************/ -void wbx_simple::rx_get(const wax::obj &key_, wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - case SUBDEV_PROP_NAME: - switch(get_rx_id().to_uint16()) { - case 0x053: - val = std::string("WBX RX + Simple GDB"); - return; - case 0x057: - val = std::string("WBX v3 RX + Simple GDB"); - return; - case 0x063: - val = std::string("WBX v4 RX + Simple GDB"); - return; - default: - UHD_THROW_INVALID_CODE_PATH(); - } - - case SUBDEV_PROP_FREQ: - val = _rx_lo_freq; - return; - - case SUBDEV_PROP_FREQ_RANGE: - val = wbx_freq_range; - return; - - case SUBDEV_PROP_ANTENNA: - val = _rx_ant; - return; - - case SUBDEV_PROP_ANTENNA_NAMES: - val = wbx_rx_antennas; - return; - - default: - //call into the base class for other properties - wbx_base::rx_get(key_, val); - } -} - -void wbx_simple::rx_set(const wax::obj &key_, const wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - - case SUBDEV_PROP_FREQ: - this->set_rx_lo_freq(val.as()); - return; - - case SUBDEV_PROP_ANTENNA: - this->set_rx_ant(val.as()); - return; - - default: - //call into the base class for other properties - wbx_base::rx_set(key_, val); - } -} - -/*********************************************************************** - * TX Get and Set - **********************************************************************/ -void wbx_simple::tx_get(const wax::obj &key_, wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - case SUBDEV_PROP_NAME: - switch(get_rx_id().to_uint16()) { - case 0x053: - val = std::string("WBX TX + Simple GDB"); - return; - case 0x057: - val = std::string("WBX v3 TX + Simple GDB"); - return; - case 0x063: - val = std::string("WBX v4 TX + Simple GDB"); - return; - default: - UHD_THROW_INVALID_CODE_PATH(); - } - - case SUBDEV_PROP_FREQ: - val = _tx_lo_freq; - return; - - case SUBDEV_PROP_FREQ_RANGE: - val = wbx_freq_range; - return; - - case SUBDEV_PROP_ANTENNA: - val = std::string("TX/RX"); - return; - - case SUBDEV_PROP_ANTENNA_NAMES: - val = wbx_tx_antennas; - return; - - default: - //call into the base class for other properties - wbx_base::tx_get(key_, val); - } -} - -void wbx_simple::tx_set(const wax::obj &key_, const wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - - case SUBDEV_PROP_FREQ: - this->set_tx_lo_freq(val.as()); - return; - - case SUBDEV_PROP_ANTENNA: - this->set_tx_ant(val.as()); - return; - - default: - //call into the base class for other properties - wbx_base::tx_set(key_, val); - } -} diff --git a/host/lib/usrp/dboard/db_wbx_version2.cpp b/host/lib/usrp/dboard/db_wbx_version2.cpp index 0b57a6e2d..d8a2b7e93 100644 --- a/host/lib/usrp/dboard/db_wbx_version2.cpp +++ b/host/lib/usrp/dboard/db_wbx_version2.cpp @@ -75,9 +75,33 @@ wbx_base::wbx_version2::wbx_version2(wbx_base *_self_wbx_base) { //register our handle on the primary wbx_base instance self_base = _self_wbx_base; - //enable the clocks that we need - self_base->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); - self_base->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); + //////////////////////////////////////////////////////////////////// + // Register RX properties + //////////////////////////////////////////////////////////////////// + this->get_rx_subtree()->create("name").set("WBX RX v2"); + this->get_rx_subtree()->create("freq/value") + .coerce(boost::bind(&wbx_base::wbx_version2::set_lo_freq, this, dboard_iface::UNIT_RX, _1)) + .set((wbx_v2_freq_range.start() + wbx_v2_freq_range.stop())/2.0); + this->get_rx_subtree()->create("freq/range").set(wbx_v2_freq_range); + + //////////////////////////////////////////////////////////////////// + // Register TX properties + //////////////////////////////////////////////////////////////////// + this->get_tx_subtree()->create("name").set("WBX TX v2"); + BOOST_FOREACH(const std::string &name, wbx_v2_tx_gain_ranges.keys()){ + self_base->get_tx_subtree()->create("gains/"+name+"/value") + .coerce(boost::bind(&wbx_base::wbx_version2::set_tx_gain, this, _1, name)) + .set(wbx_v2_tx_gain_ranges[name].start()); + self_base->get_tx_subtree()->create("gains/"+name+"/range") + .set(wbx_v2_tx_gain_ranges[name]); + } + this->get_rx_subtree()->create("freq/value") + .coerce(boost::bind(&wbx_base::wbx_version2::set_lo_freq, this, dboard_iface::UNIT_TX, _1)) + .set((wbx_v2_freq_range.start() + wbx_v2_freq_range.stop())/2.0); + this->get_tx_subtree()->create("freq/range").set(wbx_v2_freq_range); + this->get_tx_subtree()->create("enabled") + .subscribe(boost::bind(&wbx_base::wbx_version2::set_tx_enabled, this, _1)) + .set(true); //start enabled //set attenuator control bits int v2_iobits = ADF4350_CE; @@ -99,17 +123,6 @@ wbx_base::wbx_version2::wbx_version2(wbx_base *_self_wbx_base) { self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); - - BOOST_FOREACH(const std::string &name, wbx_v2_tx_gain_ranges.keys()) { - set_tx_gain(wbx_v2_tx_gain_ranges[name].start(), name); - } - - BOOST_FOREACH(const std::string &name, wbx_rx_gain_ranges.keys()) { - self_base->set_rx_gain(wbx_rx_gain_ranges[name].start(), name); - } - - self_base->set_rx_enabled(false); - set_tx_enabled(false); } wbx_base::wbx_version2::~wbx_version2(void){ @@ -119,7 +132,6 @@ wbx_base::wbx_version2::~wbx_version2(void){ /*********************************************************************** * Enables **********************************************************************/ - void wbx_base::wbx_version2::set_tx_enabled(bool enb){ self_base->get_iface()->set_gpio_out(dboard_iface::UNIT_TX, (enb)? TX_POWER_UP | ADF4350_CE : TX_POWER_DOWN, TX_POWER_UP | TX_POWER_DOWN | ADF4350_CE); @@ -129,7 +141,7 @@ void wbx_base::wbx_version2::set_tx_enabled(bool enb){ /*********************************************************************** * Gain Handling **********************************************************************/ -void wbx_base::wbx_version2::set_tx_gain(double gain, const std::string &name){ +double wbx_base::wbx_version2::set_tx_gain(double gain, const std::string &name){ assert_has(wbx_v2_tx_gain_ranges.keys(), name, "wbx tx gain name"); if(name == "PGA0"){ double dac_volts = tx_pga0_gain_to_dac_volts(gain); @@ -139,16 +151,13 @@ void wbx_base::wbx_version2::set_tx_gain(double gain, const std::string &name){ self_base->get_iface()->write_aux_dac(dboard_iface::UNIT_TX, dboard_iface::AUX_DAC_A, dac_volts); } else UHD_THROW_INVALID_CODE_PATH(); + return self_base->_tx_gains[name]; //shadowed } /*********************************************************************** * Tuning **********************************************************************/ -freq_range_t wbx_base::wbx_version2::get_freq_range(void) { - return wbx_v2_freq_range; -} - double wbx_base::wbx_version2::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { UHD_LOGV(often) << boost::format( "WBX tune: target frequency %f Mhz" @@ -247,8 +256,8 @@ double wbx_base::wbx_version2::set_lo_freq(dboard_iface::unit_t unit, double tar UHD_LOGV(often) << boost::format("WBX Intermediates: ref=%0.2f, outdiv=%f, fbdiv=%f") % (ref_freq*(1+int(D))/(R*(1+int(T)))) % double(RFdiv*2) % double(N + double(FRAC)/double(MOD)) << std::endl - << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%d" - ) % R % BS % N % FRAC % MOD % T % D % RFdiv % self_base->get_locked(unit)<< std::endl + << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%s" + ) % R % BS % N % FRAC % MOD % T % D % RFdiv % self_base->get_locked(unit).to_pp_string() << std::endl << boost::format("WBX Frequencies (MHz): REQ=%0.2f, ACT=%0.2f, VCO=%0.2f, PFD=%0.2f, BAND=%0.2f" ) % (target_freq/1e6) % (actual_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) << std::endl; @@ -315,80 +324,3 @@ double wbx_base::wbx_version2::set_lo_freq(dboard_iface::unit_t unit, double tar ) % (actual_freq/1e6) << std::endl; return actual_freq; } - - -/*********************************************************************** - * TX Get and Set - **********************************************************************/ -void wbx_base::wbx_version2::tx_get(const wax::obj &key_, wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - case SUBDEV_PROP_NAME: - val = self_base->get_tx_id().to_pp_string(); - return; - - case SUBDEV_PROP_OTHERS: - val = prop_names_t(); //empty - return; - - case SUBDEV_PROP_GAIN: - assert_has(self_base->_tx_gains.keys(), key.name, "wbx tx gain name"); - val = self_base->_tx_gains[key.name]; - return; - - case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_v2_tx_gain_ranges.keys(), key.name, "wbx tx gain name"); - val = wbx_v2_tx_gain_ranges[key.name]; - return; - - case SUBDEV_PROP_GAIN_NAMES: - val = prop_names_t(wbx_v2_tx_gain_ranges.keys()); - return; - - case SUBDEV_PROP_FREQ: - val = 0.0; - return; - - case SUBDEV_PROP_FREQ_RANGE: - val = freq_range_t(0.0, 0.0, 0.0); - return; - - case SUBDEV_PROP_ANTENNA: - val = std::string(""); - return; - - case SUBDEV_PROP_ANTENNA_NAMES: - val = prop_names_t(1, ""); - return; - - case SUBDEV_PROP_CONNECTION: - val = SUBDEV_CONN_COMPLEX_IQ; - return; - - case SUBDEV_PROP_ENABLED: - val = self_base->_tx_enabled; - return; - - case SUBDEV_PROP_USE_LO_OFFSET: - val = false; - return; - - case SUBDEV_PROP_SENSOR: - UHD_ASSERT_THROW(key.name == "lo_locked"); - val = sensor_value_t("LO", self_base->get_locked(dboard_iface::UNIT_TX), "locked", "unlocked"); - return; - - case SUBDEV_PROP_SENSOR_NAMES: - val = prop_names_t(1, "lo_locked"); - return; - - case SUBDEV_PROP_BANDWIDTH: - val = 2*20.0e6; //20MHz low-pass, we want complex double-sided - return; - - default: UHD_THROW_PROP_GET_ERROR(); - } -} - diff --git a/host/lib/usrp/dboard/db_wbx_version3.cpp b/host/lib/usrp/dboard/db_wbx_version3.cpp index 3c5cdf5ba..4473bf1ae 100644 --- a/host/lib/usrp/dboard/db_wbx_version3.cpp +++ b/host/lib/usrp/dboard/db_wbx_version3.cpp @@ -81,9 +81,33 @@ wbx_base::wbx_version3::wbx_version3(wbx_base *_self_wbx_base) { //register our handle on the primary wbx_base instance self_base = _self_wbx_base; - //enable the clocks that we need - self_base->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); - self_base->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); + //////////////////////////////////////////////////////////////////// + // Register RX properties + //////////////////////////////////////////////////////////////////// + this->get_rx_subtree()->create("name").set("WBX RX v3"); + this->get_rx_subtree()->create("freq/value") + .coerce(boost::bind(&wbx_base::wbx_version3::set_lo_freq, this, dboard_iface::UNIT_RX, _1)) + .set((wbx_v3_freq_range.start() + wbx_v3_freq_range.stop())/2.0); + this->get_rx_subtree()->create("freq/range").set(wbx_v3_freq_range); + + //////////////////////////////////////////////////////////////////// + // Register TX properties + //////////////////////////////////////////////////////////////////// + this->get_tx_subtree()->create("name").set("WBX TX v3"); + BOOST_FOREACH(const std::string &name, wbx_v3_tx_gain_ranges.keys()){ + self_base->get_tx_subtree()->create("gains/"+name+"/value") + .coerce(boost::bind(&wbx_base::wbx_version3::set_tx_gain, this, _1, name)) + .set(wbx_v3_tx_gain_ranges[name].start()); + self_base->get_tx_subtree()->create("gains/"+name+"/range") + .set(wbx_v3_tx_gain_ranges[name]); + } + this->get_rx_subtree()->create("freq/value") + .coerce(boost::bind(&wbx_base::wbx_version3::set_lo_freq, this, dboard_iface::UNIT_TX, _1)) + .set((wbx_v3_freq_range.start() + wbx_v3_freq_range.stop())/2.0); + this->get_tx_subtree()->create("freq/range").set(wbx_v3_freq_range); + this->get_tx_subtree()->create("enabled") + .subscribe(boost::bind(&wbx_base::wbx_version3::set_tx_enabled, this, _1)) + .set(true); //start enabled //set attenuator control bits int v3_iobits = TX_ATTN_MASK; @@ -105,18 +129,6 @@ wbx_base::wbx_version3::wbx_version3(wbx_base *_self_wbx_base) { self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); - - //set some default values - BOOST_FOREACH(const std::string &name, wbx_v3_tx_gain_ranges.keys()){ - set_tx_gain(wbx_v3_tx_gain_ranges[name].start(), name); - } - - BOOST_FOREACH(const std::string &name, wbx_rx_gain_ranges.keys()){ - self_base->set_rx_gain(wbx_rx_gain_ranges[name].start(), name); - } - - self_base->set_rx_enabled(false); - set_tx_enabled(false); } wbx_base::wbx_version3::~wbx_version3(void){ @@ -136,7 +148,7 @@ void wbx_base::wbx_version3::set_tx_enabled(bool enb){ /*********************************************************************** * Gain Handling **********************************************************************/ -void wbx_base::wbx_version3::set_tx_gain(double gain, const std::string &name){ +double wbx_base::wbx_version3::set_tx_gain(double gain, const std::string &name){ assert_has(wbx_v3_tx_gain_ranges.keys(), name, "wbx tx gain name"); if(name == "PGA0"){ boost::uint16_t io_bits = tx_pga0_gain_to_iobits(gain); @@ -146,16 +158,13 @@ void wbx_base::wbx_version3::set_tx_gain(double gain, const std::string &name){ self_base->get_iface()->set_gpio_out(dboard_iface::UNIT_TX, io_bits, TX_ATTN_MASK); } else UHD_THROW_INVALID_CODE_PATH(); + return self_base->_tx_gains[name]; //shadow } /*********************************************************************** * Tuning **********************************************************************/ -freq_range_t wbx_base::wbx_version3::get_freq_range(void) { - return wbx_v3_freq_range; -} - double wbx_base::wbx_version3::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { UHD_LOGV(often) << boost::format( "WBX tune: target frequency %f Mhz" @@ -254,8 +263,8 @@ double wbx_base::wbx_version3::set_lo_freq(dboard_iface::unit_t unit, double tar UHD_LOGV(often) << boost::format("WBX Intermediates: ref=%0.2f, outdiv=%f, fbdiv=%f") % (ref_freq*(1+int(D))/(R*(1+int(T)))) % double(RFdiv*2) % double(N + double(FRAC)/double(MOD)) << std::endl - << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%d" - ) % R % BS % N % FRAC % MOD % T % D % RFdiv % self_base->get_locked(unit)<< std::endl + << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%s" + ) % R % BS % N % FRAC % MOD % T % D % RFdiv % self_base->get_locked(unit).to_pp_string() << std::endl << boost::format("WBX Frequencies (MHz): REQ=%0.2f, ACT=%0.2f, VCO=%0.2f, PFD=%0.2f, BAND=%0.2f" ) % (target_freq/1e6) % (actual_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) << std::endl; @@ -322,80 +331,3 @@ double wbx_base::wbx_version3::set_lo_freq(dboard_iface::unit_t unit, double tar ) % (actual_freq/1e6) << std::endl; return actual_freq; } - - -/*********************************************************************** - * TX Get and Set - **********************************************************************/ -void wbx_base::wbx_version3::tx_get(const wax::obj &key_, wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - case SUBDEV_PROP_NAME: - val = self_base->get_tx_id().to_pp_string(); - return; - - case SUBDEV_PROP_OTHERS: - val = prop_names_t(); //empty - return; - - case SUBDEV_PROP_GAIN: - assert_has(self_base->_tx_gains.keys(), key.name, "wbx tx gain name"); - val = self_base->_tx_gains[key.name]; - return; - - case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_v3_tx_gain_ranges.keys(), key.name, "wbx tx gain name"); - val = wbx_v3_tx_gain_ranges[key.name]; - return; - - case SUBDEV_PROP_GAIN_NAMES: - val = prop_names_t(wbx_v3_tx_gain_ranges.keys()); - return; - - case SUBDEV_PROP_FREQ: - val = 0.0; - return; - - case SUBDEV_PROP_FREQ_RANGE: - val = freq_range_t(0.0, 0.0, 0.0); - return; - - case SUBDEV_PROP_ANTENNA: - val = std::string(""); - return; - - case SUBDEV_PROP_ANTENNA_NAMES: - val = prop_names_t(1, ""); - return; - - case SUBDEV_PROP_CONNECTION: - val = SUBDEV_CONN_COMPLEX_IQ; - return; - - case SUBDEV_PROP_ENABLED: - val = self_base->_tx_enabled; - return; - - case SUBDEV_PROP_USE_LO_OFFSET: - val = false; - return; - - case SUBDEV_PROP_SENSOR: - UHD_ASSERT_THROW(key.name == "lo_locked"); - val = sensor_value_t("LO", self_base->get_locked(dboard_iface::UNIT_TX), "locked", "unlocked"); - return; - - case SUBDEV_PROP_SENSOR_NAMES: - val = prop_names_t(1, "lo_locked"); - return; - - case SUBDEV_PROP_BANDWIDTH: - val = 2*20.0e6; //20MHz low-pass, we want complex double-sided - return; - - default: UHD_THROW_PROP_GET_ERROR(); - } -} - diff --git a/host/lib/usrp/dboard/db_wbx_version4.cpp b/host/lib/usrp/dboard/db_wbx_version4.cpp index b5104c9f1..981e4f4d2 100644 --- a/host/lib/usrp/dboard/db_wbx_version4.cpp +++ b/host/lib/usrp/dboard/db_wbx_version4.cpp @@ -37,7 +37,7 @@ using namespace boost::assign; /*********************************************************************** * WBX Version 3 Constants **********************************************************************/ -static const uhd::dict wbx_v4_gain_ranges = map_list_of +static const uhd::dict wbx_v4_tx_gain_ranges = map_list_of ("PGA0", gain_range_t(0, 31, 1.0)) ; @@ -49,10 +49,10 @@ static const freq_range_t wbx_v4_freq_range(50.0e6, 2.2e9); **********************************************************************/ static int tx_pga0_gain_to_iobits(double &gain){ //clip the input - gain = wbx_v4_gain_ranges["PGA0"].clip(gain); + gain = wbx_v4_tx_gain_ranges["PGA0"].clip(gain); //convert to attenuation - double attn = wbx_v4_gain_ranges["PGA0"].stop() - gain; + double attn = wbx_v4_tx_gain_ranges["PGA0"].stop() - gain; //calculate the attenuation int attn_code = boost::math::iround(attn); @@ -69,7 +69,7 @@ static int tx_pga0_gain_to_iobits(double &gain){ ) % attn % attn_code % (iobits & TX_ATTN_MASK) % TX_ATTN_MASK << std::endl; //the actual gain setting - gain = wbx_v4_gain_ranges["PGA0"].stop() - double(attn_code); + gain = wbx_v4_tx_gain_ranges["PGA0"].stop() - double(attn_code); return iobits; } @@ -82,9 +82,33 @@ wbx_base::wbx_version4::wbx_version4(wbx_base *_self_wbx_base) { //register our handle on the primary wbx_base instance self_base = _self_wbx_base; - //enable the clocks that we need - self_base->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); - self_base->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); + //////////////////////////////////////////////////////////////////// + // Register RX properties + //////////////////////////////////////////////////////////////////// + this->get_rx_subtree()->create("name").set("WBX RX v4"); + this->get_rx_subtree()->create("freq/value") + .coerce(boost::bind(&wbx_base::wbx_version4::set_lo_freq, this, dboard_iface::UNIT_RX, _1)) + .set((wbx_v4_freq_range.start() + wbx_v4_freq_range.stop())/2.0); + this->get_rx_subtree()->create("freq/range").set(wbx_v4_freq_range); + + //////////////////////////////////////////////////////////////////// + // Register TX properties + //////////////////////////////////////////////////////////////////// + this->get_tx_subtree()->create("name").set("WBX TX v4"); + BOOST_FOREACH(const std::string &name, wbx_v4_tx_gain_ranges.keys()){ + self_base->get_tx_subtree()->create("gains/"+name+"/value") + .coerce(boost::bind(&wbx_base::wbx_version4::set_tx_gain, this, _1, name)) + .set(wbx_v4_tx_gain_ranges[name].start()); + self_base->get_tx_subtree()->create("gains/"+name+"/range") + .set(wbx_v4_tx_gain_ranges[name]); + } + this->get_rx_subtree()->create("freq/value") + .coerce(boost::bind(&wbx_base::wbx_version4::set_lo_freq, this, dboard_iface::UNIT_TX, _1)) + .set((wbx_v4_freq_range.start() + wbx_v4_freq_range.stop())/2.0); + this->get_tx_subtree()->create("freq/range").set(wbx_v4_freq_range); + this->get_tx_subtree()->create("enabled") + .subscribe(boost::bind(&wbx_base::wbx_version4::set_tx_enabled, this, _1)) + .set(true); //start enabled //set attenuator control bits int v4_iobits = TX_ATTN_MASK; @@ -106,18 +130,6 @@ wbx_base::wbx_version4::wbx_version4(wbx_base *_self_wbx_base) { self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); self_base->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, RX_MIXER_ENB, RX_MIXER_DIS | RX_MIXER_ENB); - - //set some default values - BOOST_FOREACH(const std::string &name, wbx_v4_gain_ranges.keys()){ - set_tx_gain(wbx_v4_gain_ranges[name].start(), name); - } - - BOOST_FOREACH(const std::string &name, wbx_rx_gain_ranges.keys()){ - self_base->set_rx_gain(wbx_rx_gain_ranges[name].start(), name); - } - - self_base->set_rx_enabled(false); - set_tx_enabled(false); } wbx_base::wbx_version4::~wbx_version4(void){ @@ -137,8 +149,8 @@ void wbx_base::wbx_version4::set_tx_enabled(bool enb) { /*********************************************************************** * Gain Handling **********************************************************************/ -void wbx_base::wbx_version4::set_tx_gain(double gain, const std::string &name) { - assert_has(wbx_v4_gain_ranges.keys(), name, "wbx tx gain name"); +double wbx_base::wbx_version4::set_tx_gain(double gain, const std::string &name) { + assert_has(wbx_v4_tx_gain_ranges.keys(), name, "wbx tx gain name"); if(name == "PGA0"){ boost::uint16_t io_bits = tx_pga0_gain_to_iobits(gain); self_base->_tx_gains[name] = gain; @@ -147,16 +159,13 @@ void wbx_base::wbx_version4::set_tx_gain(double gain, const std::string &name) { self_base->get_iface()->set_gpio_out(dboard_iface::UNIT_TX, io_bits, TX_ATTN_MASK); } else UHD_THROW_INVALID_CODE_PATH(); + return self_base->_tx_gains[name]; } /*********************************************************************** * Tuning **********************************************************************/ -freq_range_t wbx_base::wbx_version4::get_freq_range(void) { - return wbx_v4_freq_range; -} - double wbx_base::wbx_version4::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { UHD_LOGV(often) << boost::format( "WBX tune: target frequency %f Mhz" @@ -257,8 +266,8 @@ double wbx_base::wbx_version4::set_lo_freq(dboard_iface::unit_t unit, double tar UHD_LOGV(often) << boost::format("WBX Intermediates: ref=%0.2f, outdiv=%f, fbdiv=%f") % (ref_freq*(1+int(D))/(R*(1+int(T)))) % double(RFdiv*2) % double(N + double(FRAC)/double(MOD)) << std::endl - << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%d" - ) % R % BS % N % FRAC % MOD % T % D % RFdiv % self_base->get_locked(unit)<< std::endl + << boost::format("WBX tune: R=%d, BS=%d, N=%d, FRAC=%d, MOD=%d, T=%d, D=%d, RFdiv=%d, LD=%s" + ) % R % BS % N % FRAC % MOD % T % D % RFdiv % self_base->get_locked(unit).to_pp_string() << std::endl << boost::format("WBX Frequencies (MHz): REQ=%0.2f, ACT=%0.2f, VCO=%0.2f, PFD=%0.2f, BAND=%0.2f" ) % (target_freq/1e6) % (actual_freq/1e6) % (vco_freq/1e6) % (pfd_freq/1e6) % (pfd_freq/BS/1e6) << std::endl; @@ -325,80 +334,3 @@ double wbx_base::wbx_version4::set_lo_freq(dboard_iface::unit_t unit, double tar ) % (actual_freq/1e6) << std::endl; return actual_freq; } - - -/*********************************************************************** - * TX Get and Set - **********************************************************************/ -void wbx_base::wbx_version4::tx_get(const wax::obj &key_, wax::obj &val){ - named_prop_t key = named_prop_t::extract(key_); - - //handle the get request conditioned on the key - switch(key.as()){ - case SUBDEV_PROP_NAME: - val = self_base->get_tx_id().to_pp_string(); - return; - - case SUBDEV_PROP_OTHERS: - val = prop_names_t(); //empty - return; - - case SUBDEV_PROP_GAIN: - assert_has(self_base->_tx_gains.keys(), key.name, "wbx tx gain name"); - val = self_base->_tx_gains[key.name]; - return; - - case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_v4_gain_ranges.keys(), key.name, "wbx tx gain name"); - val = wbx_v4_gain_ranges[key.name]; - return; - - case SUBDEV_PROP_GAIN_NAMES: - val = prop_names_t(wbx_v4_gain_ranges.keys()); - return; - - case SUBDEV_PROP_FREQ: - val = 0.0; - return; - - case SUBDEV_PROP_FREQ_RANGE: - val = freq_range_t(0.0, 0.0, 0.0); - return; - - case SUBDEV_PROP_ANTENNA: - val = std::string(""); - return; - - case SUBDEV_PROP_ANTENNA_NAMES: - val = prop_names_t(1, ""); - return; - - case SUBDEV_PROP_CONNECTION: - val = SUBDEV_CONN_COMPLEX_IQ; - return; - - case SUBDEV_PROP_ENABLED: - val = self_base->_tx_enabled; - return; - - case SUBDEV_PROP_USE_LO_OFFSET: - val = false; - return; - - case SUBDEV_PROP_SENSOR: - UHD_ASSERT_THROW(key.name == "lo_locked"); - val = sensor_value_t("LO", self_base->get_locked(dboard_iface::UNIT_TX), "locked", "unlocked"); - return; - - case SUBDEV_PROP_SENSOR_NAMES: - val = prop_names_t(1, "lo_locked"); - return; - - case SUBDEV_PROP_BANDWIDTH: - val = 2*20.0e6; //20MHz low-pass, we want complex double-sided - return; - - default: UHD_THROW_PROP_GET_ERROR(); - } -} - -- cgit v1.2.3 From 902818f50bbd486138a7d4cd2ce9ba3661f4a732 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Nov 2011 16:53:47 -0800 Subject: uhd: removed wax and props utils --- host/include/uhd/CMakeLists.txt | 1 - host/include/uhd/deprecated.hpp | 170 --------------------------------- host/include/uhd/utils/CMakeLists.txt | 1 - host/include/uhd/utils/props.hpp | 81 ---------------- host/include/uhd/wax.hpp | 2 - host/lib/deprecated.cpp | 152 ----------------------------- host/lib/usrp/dboard/db_wbx_common.hpp | 1 - host/lib/usrp/dboard/db_wbx_simple.cpp | 4 +- host/lib/usrp/gps_ctrl.cpp | 3 +- host/lib/utils/CMakeLists.txt | 1 - host/lib/utils/props.cpp | 40 -------- 11 files changed, 3 insertions(+), 453 deletions(-) delete mode 100644 host/include/uhd/utils/props.hpp delete mode 100644 host/include/uhd/wax.hpp delete mode 100644 host/lib/utils/props.cpp (limited to 'host/lib/usrp/dboard/db_wbx_simple.cpp') diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 2b0c6ec14..1df04d577 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -32,7 +32,6 @@ INSTALL(FILES property_tree.hpp stream.hpp version.hpp - wax.hpp DESTINATION ${INCLUDE_DIR}/uhd COMPONENT headers ) diff --git a/host/include/uhd/deprecated.hpp b/host/include/uhd/deprecated.hpp index d918836f1..95cce58e9 100644 --- a/host/include/uhd/deprecated.hpp +++ b/host/include/uhd/deprecated.hpp @@ -2,176 +2,6 @@ //-- deprecated interfaces below, to be removed when the API is changed //---------------------------------------------------------------------- -// -// Copyright 2010-2011 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_WAX_HPP -#define INCLUDED_WAX_HPP - -#include -#include -#include -#include -#include - -/*! - * WAX - it's a metaphor! - * - * The WAX framework allows an object to have generic/anyobj properties. - * These properties can be addressed through generic/anyobj identifiers. - * - * The WAX object itself is an anytype container much like boost::any. - * To retrieve the value of the appropriate type, use my_obj.as(). - * - * Proprties may be referenced though the [] overloaded operator. - * The [] operator returns a special proxy that allows for assigment. - * Also, the [] operators may be chained as in the folowing examples: - * my_obj[prop1][prop2][prop3] = value; - * value = my_obj[prop1][prop2][prop3].as(); - * - * Property nesting occurs when a WAX object gets another object's link. - * This special link is obtained through a call to my_obj.get_link(). - * - * Note: Do not put a class derived from wax::obj into an stl container. - * MSVC will compile the code, but the binaries will crash at runtime. - * Rather, use pointers or smart pointers to instances of the derived class. - */ - -namespace wax{ - - /*! - * WAX object base class: - * - * A wax obj has two major purposes: - * 1) to act as a polymorphic container, just like boost any - * 2) to provide a nested set/get properties interface - * - * Internally, the polymorphic container is handled by a boost any. - * For properties, a subclass should override the set and get methods. - * For property nesting, wax obj subclasses return special links - * to other wax obj subclasses, and the api handles the magic. - */ - class UHD_API obj{ - public: - - /*! - * Default constructor: - * The contents will be empty. - */ - obj(void); - - /*! - * Copy constructor: - * The contents will be cloned. - * \param o another wax::obj - */ - obj(const obj &o); - - /*! - * Templated any type constructor: - * The contents can be anything. - * Uses the boost::any to handle the magic. - * \param o an object of any type - */ - template obj(const T &o){ - _contents = o; - } - - /*! - * Destructor. - */ - virtual ~obj(void); - - /*! - * The chaining operator: - * This operator allows access objs with properties. - * A call to the [] operator will return a new proxy obj. - * The proxy object is an obj with special proxy contents. - * Assignment and casting can be used on this special object - * to access the property referenced by the obj key. - * \param key a key to identify a property within this obj - * \return a special wax obj that proxies the obj and key - */ - obj operator[](const obj &key); - - /*! - * The assignment operator: - * This operator allows for assignment of new contents. - * In the special case where this obj contains a proxy, - * the value will be set to the proxy's property reference. - * \param val the new value to assign to the wax obj - * \return a reference to this obj (*this) - */ - obj & operator=(const obj &val); - - /*! - * Get a link in the chain: - * When a wax obj returns another wax obj as part of a get call, - * the return value should be set to the result of this method. - * Doing so will ensure chain-ability of the returned object. - * \return an obj containing a valid link to a wax obj - */ - obj get_link(void) const; - - /*! - * Get the type of the contents of this obj. - * \return a reference to the type_info - */ - const std::type_info & type(void) const; - - /*! - * Cast this obj into the desired type. - * Usage: myobj.as() - * - * \return an object of the desired type - * \throw wax::bad_cast when the cast fails - */ - template T as(void) const{ - try{ - return boost::any_cast(resolve()); - } - catch(const boost::bad_any_cast &e){ - throw uhd::type_error(std::string("") + "Cannot wax cast " + type().name() + " to " + typeid(T).name() + " " + e.what()); - } - } - - private: - //private interface (override in subclasses) - virtual void get(const obj &, obj &); - virtual void set(const obj &, const obj &); - - /*! - * Resolve the contents of this obj. - * In the case where this obj is a proxy, - * the referenced property will be resolved. - * Otherwise, just get the private contents. - * \return a boost any type with contents - */ - boost::any resolve(void) const; - - //private contents of this obj - boost::any _contents; - - }; - -} //namespace wax - -#endif /* INCLUDED_WAX_HPP */ - // // Copyright 2010 Ettus Research LLC // diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 0bf98fb67..48b8db885 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -26,7 +26,6 @@ INSTALL(FILES log.hpp msg.hpp pimpl.hpp - props.hpp safe_call.hpp safe_main.hpp static.hpp diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp deleted file mode 100644 index 81737423a..000000000 --- a/host/include/uhd/utils/props.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// -// Copyright 2010-2011 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_PROPS_HPP -#define INCLUDED_UHD_UTILS_PROPS_HPP - -#include -#include -#include -#include -#include - -namespace uhd{ - - //! The type for a vector of property names - typedef std::vector prop_names_t; - - /*! - * A named prop struct holds a key and a name. - * Allows properties to be sub-sectioned by name. - */ - struct UHD_API named_prop_t{ - const wax::obj key; - const std::string name; - - //! Convert the key to the specified type - template inline T as(void){ - return key.as(); - } - - /*! - * Utility function to convert generic key into a named prop. - * If the key was already a named prop, the prop will be split. - * Otherwise, the key will be the key, and the name will be used. - * \param key a reference to the prop object - * \param name a reference to the name object - * \return a named property struct with key and name - */ - static named_prop_t extract( - const wax::obj &key, const std::string &name = "" - ); - - /*! - * Create a new named prop from key and name. - * \param key the property key - * \param name the string name - */ - named_prop_t(const wax::obj &key, const std::string &name); - }; - - /*! - * Throw when getting a not-implemented or write-only property. - * Throw-site information will be included with this error. - */ - #define UHD_THROW_PROP_GET_ERROR() \ - throw uhd::key_error(UHD_THROW_SITE_INFO("cannot get this property")) - - /*! - * Throw when setting a not-implemented or read-only property. - * Throw-site information will be included with this error. - */ - #define UHD_THROW_PROP_SET_ERROR() \ - throw uhd::key_error(UHD_THROW_SITE_INFO("cannot set this property")) - -} //namespace uhd - -#endif /* INCLUDED_UHD_UTILS_PROPS_HPP */ diff --git a/host/include/uhd/wax.hpp b/host/include/uhd/wax.hpp deleted file mode 100644 index a55e5465d..000000000 --- a/host/include/uhd/wax.hpp +++ /dev/null @@ -1,2 +0,0 @@ -//The wax API has been deprecated in favor of the properties interface -#include diff --git a/host/lib/deprecated.cpp b/host/lib/deprecated.cpp index b659d1be5..0fc751eeb 100644 --- a/host/lib/deprecated.cpp +++ b/host/lib/deprecated.cpp @@ -2,158 +2,6 @@ //-- deprecated interfaces below, to be removed when the API is changed //---------------------------------------------------------------------- -// -// Copyright 2010-2011 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 - -/*! - * The link args for internal use within this cpp file: - * - * It contains a link (in this case a pointer) to a wax object. - * Only the methods in this file may create or parse link args. - * The get_link method is the creator of a link args object. - * The [] operator will resolve the link and make the [] call. - * - * TODO: register the link args with the wax obj that it links to. - * That way, if the obj destructs, the link can be invalidated. - * The operator() will throw, rather than dereferencing bad memory. - */ -class link_args_t{ -public: - link_args_t(const wax::obj *obj_ptr) : _obj_ptr(obj_ptr){ - /* NOP */ - } - wax::obj & operator()(void) const{ - //recursively resolve link args to get at original pointer - if (_obj_ptr->type() == typeid(link_args_t)){ - return _obj_ptr->as()(); - } - return *const_cast(_obj_ptr); - } -private: - const wax::obj *_obj_ptr; -}; - -/*! - * The proxy args for internal use within this cpp file: - * - * It contains a link and a key for setting/getting a property. - * Only the methods in this file may create or parse proxy args. - * Class methods have special handling for the case when the - * wax obj contains an instance of the proxy args. - */ -class proxy_args_t{ -public: - proxy_args_t(const wax::obj *obj_ptr, const wax::obj &key) : _key(key){ - _obj_link = obj_ptr->get_link(); - } - wax::obj & operator()(void) const{ - return _obj_link.as()(); - } - const wax::obj & key(void) const{ - return _key; - } -private: - wax::obj _obj_link; - const wax::obj _key; -}; - -/*********************************************************************** - * Structors - **********************************************************************/ -wax::obj::obj(void){ - /* NOP */ -} - -wax::obj::obj(const obj &o){ - _contents = o._contents; -} - -wax::obj::~obj(void){ - /* NOP */ -} - -/*********************************************************************** - * Special Operators - **********************************************************************/ -wax::obj wax::obj::operator[](const obj &key){ - if (_contents.type() == typeid(proxy_args_t)){ - obj val = resolve(); - //check if its a special link and call - if (val.type() == typeid(link_args_t)){ - return val.as()()[key]; - } - //unknown obj - throw uhd::type_error("cannot use [] on non wax::obj link"); - } - else{ - return proxy_args_t(this, key); - } -} - -wax::obj & wax::obj::operator=(const obj &val){ - if (_contents.type() == typeid(proxy_args_t)){ - proxy_args_t proxy_args = boost::any_cast(_contents); - proxy_args().set(proxy_args.key(), val); - } - else{ - _contents = val._contents; - } - return *this; -} - -/*********************************************************************** - * Public Methods - **********************************************************************/ -wax::obj wax::obj::get_link(void) const{ - return link_args_t(this); -} - -const std::type_info & wax::obj::type(void) const{ - return resolve().type(); -} - -/*********************************************************************** - * Private Methods - **********************************************************************/ -boost::any wax::obj::resolve(void) const{ - if (_contents.type() == typeid(proxy_args_t)){ - obj val; - proxy_args_t proxy_args = boost::any_cast(_contents); - proxy_args().get(proxy_args.key(), val); - return val.resolve(); - } - else{ - return _contents; - } -} - -void wax::obj::get(const obj &, obj &){ - throw uhd::type_error("Cannot call get on wax obj base class"); -} - -void wax::obj::set(const obj &, const obj &){ - throw uhd::type_error("Cannot call set on wax obj base class"); -} - #include #include #include diff --git a/host/lib/usrp/dboard/db_wbx_common.hpp b/host/lib/usrp/dboard/db_wbx_common.hpp index 3e41e04b7..e7eb3f31a 100644 --- a/host/lib/usrp/dboard/db_wbx_common.hpp +++ b/host/lib/usrp/dboard/db_wbx_common.hpp @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include diff --git a/host/lib/usrp/dboard/db_wbx_simple.cpp b/host/lib/usrp/dboard/db_wbx_simple.cpp index 1ac2a1704..f46ea70d1 100644 --- a/host/lib/usrp/dboard/db_wbx_simple.cpp +++ b/host/lib/usrp/dboard/db_wbx_simple.cpp @@ -36,9 +36,9 @@ using namespace boost::assign; /*********************************************************************** * The WBX Simple dboard constants **********************************************************************/ -static const prop_names_t wbx_tx_antennas = list_of("TX/RX"); +static const std::vector wbx_tx_antennas = list_of("TX/RX"); -static const prop_names_t wbx_rx_antennas = list_of("TX/RX")("RX2"); +static const std::vector wbx_rx_antennas = list_of("TX/RX")("RX2"); /*********************************************************************** * The WBX simple implementation diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index c645d2948..45fa1f39e 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -121,7 +120,7 @@ public: return sensor_value_t("GPS lock status", locked(), "locked", "unlocked"); } else { - UHD_THROW_PROP_GET_ERROR(); + throw uhd::value_error("gps ctrl get_sensor unknown key: " + key); } } diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index fd3249099..19dde9a56 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -134,7 +134,6 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp ${CMAKE_CURRENT_SOURCE_DIR}/msg.cpp ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/props.cpp ${CMAKE_CURRENT_SOURCE_DIR}/static.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tasks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/thread_priority.cpp diff --git a/host/lib/utils/props.cpp b/host/lib/utils/props.cpp deleted file mode 100644 index fc9f8e63f..000000000 --- a/host/lib/utils/props.cpp +++ /dev/null @@ -1,40 +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 . -// - -#include - -using namespace uhd; - -named_prop_t::named_prop_t( - const wax::obj &key, - const std::string &name -): - key(key), - name(name) -{ - /* NOP */ -} - -named_prop_t named_prop_t::extract( - const wax::obj &key, - const std::string &name -){ - if (key.type() == typeid(named_prop_t)){ - return key.as(); - } - return named_prop_t(key, name); -} -- cgit v1.2.3