diff options
author | Josh Blum <josh@joshknows.com> | 2010-08-17 17:16:54 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-08-17 17:16:54 +0000 |
commit | 1aa1404ebb59594a8c81b31f9b56ad35bd832a26 (patch) | |
tree | 5de014f592095c659e0e90f2264925210817df6c /host/lib/usrp | |
parent | 1b47702245f0c1f4dda3e0eff487bbe664d48855 (diff) | |
parent | 7d110e73e6b0651f73e8e5b165244f59e66fed87 (diff) | |
download | uhd-1aa1404ebb59594a8c81b31f9b56ad35bd832a26.tar.gz uhd-1aa1404ebb59594a8c81b31f9b56ad35bd832a26.tar.bz2 uhd-1aa1404ebb59594a8c81b31f9b56ad35bd832a26.zip |
Merge branch 'next' of ettus.sourcerepo.com:ettus/uhdpriv into usrp_e_merge
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/CMakeLists.txt | 3 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_basic_and_lf.cpp | 12 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_dbsrx.cpp | 60 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_rfx.cpp | 26 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_unknown.cpp | 12 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_wbx.cpp | 32 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_xcvr2450.cpp | 32 | ||||
-rw-r--r-- | host/lib/usrp/dsp_utils.cpp | 124 | ||||
-rw-r--r-- | host/lib/usrp/dsp_utils.hpp | 187 | ||||
-rw-r--r-- | host/lib/usrp/misc_utils.cpp | 35 | ||||
-rw-r--r-- | host/lib/usrp/misc_utils.hpp | 54 | ||||
-rw-r--r-- | host/lib/usrp/subdev_spec.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/codec_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dboard_iface.cpp | 7 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dboard_impl.cpp | 22 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dsp_impl.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/mboard_impl.cpp | 24 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 5 |
18 files changed, 259 insertions, 400 deletions
diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt index 4a45c263e..39acd7f2b 100644 --- a/host/lib/usrp/CMakeLists.txt +++ b/host/lib/usrp/CMakeLists.txt @@ -22,10 +22,9 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_eeprom.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_id.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_manager.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/dsp_utils.hpp + ${CMAKE_SOURCE_DIR}/lib/usrp/dsp_utils.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/mimo_usrp.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/misc_utils.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/misc_utils.hpp ${CMAKE_SOURCE_DIR}/lib/usrp/simple_usrp.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/subdev_spec.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/tune_helper.cpp diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 9180828d8..f8236d598 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -95,8 +95,7 @@ basic_rx::~basic_rx(void){ } void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -161,8 +160,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ } void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -194,8 +192,7 @@ basic_tx::~basic_tx(void){ } void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -252,8 +249,7 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){ } void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 03e6b6255..06cf91d3b 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -61,7 +61,7 @@ static const uhd::dict<std::string, gain_range_t> dbsrx_gain_ranges = map_list_o **********************************************************************/ class dbsrx : public rx_dboard_base{ public: - dbsrx(ctor_args_t args, boost::uint8_t max2118_addr); + dbsrx(ctor_args_t args); ~dbsrx(void); void rx_get(const wax::obj &key, wax::obj &val); @@ -73,7 +73,9 @@ private: uhd::dict<std::string, float> _gains; max2118_write_regs_t _max2118_write_regs; max2118_read_regs_t _max2118_read_regs; - boost::uint8_t _max2118_addr; //0x67 or 0x65 depending on which side + boost::uint8_t _max2118_addr(void){ + return (this->get_iface()->get_special_props().mangle_i2c_addrs)? 0x65 : 0x67; + }; void set_lo_freq(double target_freq); void set_gain(float gain, const std::string &name); @@ -102,7 +104,7 @@ private: //send the data this->get_iface()->write_i2c( - _max2118_addr, regs_vector + _max2118_addr(), regs_vector ); } } @@ -120,7 +122,7 @@ private: //read from i2c regs_vector = this->get_iface()->read_i2c( - _max2118_addr, num_bytes + _max2118_addr(), num_bytes ); for(boost::uint8_t i=0; i < num_bytes; i++){ @@ -156,10 +158,8 @@ private: /*********************************************************************** * Register the DBSRX dboard **********************************************************************/ -// FIXME 0x67 is the default i2c address on USRP2 -// need to handle which side for USRP1 with different address static dboard_base::sptr make_dbsrx(dboard_base::ctor_args_t args){ - return dboard_base::sptr(new dbsrx(args, 0x67)); + return dboard_base::sptr(new dbsrx(args)); } //dbid for USRP2 version @@ -177,27 +177,27 @@ UHD_STATIC_BLOCK(reg_dbsrx_on_usrp1_dboard){ /*********************************************************************** * Structors **********************************************************************/ -dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(args){ +dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ //warn user about incorrect DBID on USRP1, requires R193 populated - if (this->get_iface()->get_mboard_name() == "usrp1" and this->get_rx_id() == 0x000D) + if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D) uhd::print_warning( str(boost::format( "DBSRX: incorrect dbid\n" - "%s expects dbid 0x0002 and R193\n" + "Expected dbid 0x0002 and R193\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string())) + ) % this->get_rx_id().to_pp_string()) ); //warn user about incorrect DBID on non-USRP1, requires R194 populated - if (this->get_iface()->get_mboard_name() != "usrp1" and this->get_rx_id() == 0x0002) + if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002) uhd::print_warning( str(boost::format( "DBSRX: incorrect dbid\n" - "%s expects dbid 0x000D and R194\n" + "Expected dbid 0x000D and R194\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string())) + ) % this->get_rx_id().to_pp_string()) ); //enable only the clocks we need @@ -207,9 +207,6 @@ dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(arg this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, 0x0); // All unused in atr this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0x0); // All Inputs - //set the i2c address for the max2118 - _max2118_addr = max2118_addr; - //send initial register settings this->send_reg(0x0, 0x5); @@ -503,8 +500,7 @@ void dbsrx::set_bandwidth(float bandwidth){ * RX Get and Set **********************************************************************/ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -517,13 +513,13 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_gains.keys(), name, "dbsrx gain name"); - val = _gains[name]; + assert_has(_gains.keys(), key.name, "dbsrx gain name"); + val = _gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(dbsrx_gain_ranges.keys(), name, "dbsrx gain name"); - val = dbsrx_gain_ranges[name]; + assert_has(dbsrx_gain_ranges.keys(), key.name, "dbsrx gain name"); + val = dbsrx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -546,19 +542,6 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ val = dbsrx_antennas; return; -/* - case SUBDEV_PROP_QUADRATURE: - val = true; - return; - - case SUBDEV_PROP_IQ_SWAPPED: - val = false; - return; - - case SUBDEV_PROP_SPECTRUM_INVERTED: - val = false; - return; -*/ case SUBDEV_PROP_CONNECTION: val = SUBDEV_CONN_COMPLEX_IQ; return; @@ -586,8 +569,7 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ } void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -597,7 +579,7 @@ void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_gain(val.as<float>(), name); + this->set_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index b6b44199a..c3ab96e59 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -398,8 +398,7 @@ double rfx_xcvr::set_lo_freq( * RX Get and Set **********************************************************************/ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -412,13 +411,13 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), name, "rfx rx gain name"); - val = _rx_gains[name]; + assert_has(_rx_gains.keys(), key.name, "rfx rx gain name"); + val = _rx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); - val = _rx_gain_ranges[name]; + assert_has(_rx_gain_ranges.keys(), key.name, "rfx rx gain name"); + val = _rx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -458,8 +457,7 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ } void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -469,7 +467,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as<float>(), name); + this->set_rx_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_ANTENNA: @@ -484,8 +482,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ * TX Get and Set **********************************************************************/ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -499,7 +496,7 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ case SUBDEV_PROP_GAIN: case SUBDEV_PROP_GAIN_RANGE: - assert_has(rfx_tx_gain_ranges.keys(), name, "rfx tx gain name"); + assert_has(rfx_tx_gain_ranges.keys(), key.name, "rfx tx gain name"); //no controllable tx gains, will not get here return; @@ -540,8 +537,7 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ } void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -551,7 +547,7 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as<float>(), name); + this->set_tx_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_ANTENNA: diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp index 9dd9b550b..f6f4f4a61 100644 --- a/host/lib/usrp/dboard/db_unknown.cpp +++ b/host/lib/usrp/dboard/db_unknown.cpp @@ -78,8 +78,7 @@ unknown_rx::~unknown_rx(void){ } void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -136,8 +135,7 @@ void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){ } void unknown_rx::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -169,8 +167,7 @@ unknown_tx::~unknown_tx(void){ } void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -227,8 +224,7 @@ void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){ } void unknown_tx::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp index 3038ce30b..ccd897674 100644 --- a/host/lib/usrp/dboard/db_wbx.cpp +++ b/host/lib/usrp/dboard/db_wbx.cpp @@ -467,8 +467,7 @@ double wbx_xcvr::set_lo_freq( * RX Get and Set **********************************************************************/ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -481,13 +480,13 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), name, "wbx rx gain name"); - val = _rx_gains[name]; + 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(), name, "wbx rx gain name"); - val = wbx_rx_gain_ranges[name]; + 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: @@ -527,8 +526,7 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ } void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -538,7 +536,7 @@ void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as<float>(), name); + this->set_rx_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_ANTENNA: @@ -553,8 +551,7 @@ void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ * TX Get and Set **********************************************************************/ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -567,13 +564,13 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_tx_gains.keys(), name, "wbx tx gain name"); - val = _tx_gains[name]; + assert_has(_tx_gains.keys(), key.name, "wbx tx gain name"); + val = _tx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_tx_gain_ranges.keys(), name, "wbx tx gain name"); - val = wbx_tx_gain_ranges[name]; + assert_has(wbx_tx_gain_ranges.keys(), key.name, "wbx tx gain name"); + val = wbx_tx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -613,8 +610,7 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ } void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -624,7 +620,7 @@ void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as<float>(), name); + this->set_tx_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_ANTENNA: diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 2c94bcd2d..798ff74a3 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -438,8 +438,7 @@ void xcvr2450::set_rx_gain(float gain, const std::string &name){ * RX Get and Set **********************************************************************/ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -452,13 +451,13 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), name, "xcvr rx gain name"); - val = _rx_gains[name]; + assert_has(_rx_gains.keys(), key.name, "xcvr rx gain name"); + val = _rx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(xcvr_rx_gain_ranges.keys(), name, "xcvr rx gain name"); - val = xcvr_rx_gain_ranges[name]; + assert_has(xcvr_rx_gain_ranges.keys(), key.name, "xcvr rx gain name"); + val = xcvr_rx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -502,8 +501,7 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ } void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -513,7 +511,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as<float>(), name); + this->set_rx_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_ANTENNA: @@ -528,8 +526,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ * TX Get and Set **********************************************************************/ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -542,13 +539,13 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_tx_gains.keys(), name, "xcvr tx gain name"); - val = _tx_gains[name]; + assert_has(_tx_gains.keys(), key.name, "xcvr tx gain name"); + val = _tx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(xcvr_tx_gain_ranges.keys(), name, "xcvr tx gain name"); - val = xcvr_tx_gain_ranges[name]; + assert_has(xcvr_tx_gain_ranges.keys(), key.name, "xcvr tx gain name"); + val = xcvr_tx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -588,8 +585,7 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ } void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -599,7 +595,7 @@ void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as<float>(), name); + this->set_tx_gain(val.as<float>(), key.name); return; case SUBDEV_PROP_ANTENNA: diff --git a/host/lib/usrp/dsp_utils.cpp b/host/lib/usrp/dsp_utils.cpp new file mode 100644 index 000000000..fe1313af1 --- /dev/null +++ b/host/lib/usrp/dsp_utils.cpp @@ -0,0 +1,124 @@ +// +// 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/>. +// + +#include <uhd/usrp/dsp_utils.hpp> +#include <uhd/types/dict.hpp> +#include <uhd/utils/assert.hpp> +#include <boost/assign/list_of.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/math/special_functions/round.hpp> +#include <cmath> + +using namespace uhd; +using namespace uhd::usrp; + +template <class T> T ceil_log2(T num){ + return std::ceil(std::log(num)/std::log(T(2))); +} + +boost::uint32_t dsp_type1::calc_rx_mux_word(subdev_conn_t subdev_conn){ + switch(subdev_conn){ + case SUBDEV_CONN_COMPLEX_IQ: return (0x1 << 2) | (0x0 << 0); //DDC0Q=ADC1, DDC0I=ADC0 + case SUBDEV_CONN_COMPLEX_QI: return (0x0 << 2) | (0x1 << 0); //DDC0Q=ADC0, DDC0I=ADC1 + case SUBDEV_CONN_REAL_I: return (0x3 << 2) | (0x0 << 0); //DDC0Q=ZERO, DDC0I=ADC0 + case SUBDEV_CONN_REAL_Q: return (0x1 << 2) | (0x3 << 0); //DDC0Q=ADC1, DDC0I=ZERO + default: UHD_THROW_INVALID_CODE_PATH(); + } +} + +boost::uint32_t dsp_type1::calc_tx_mux_word(subdev_conn_t subdev_conn){ + switch(subdev_conn){ + case SUBDEV_CONN_COMPLEX_IQ: return (0x1 << 4) | (0x0 << 0); //DAC1=DUC0Q, DAC0=DUC0I + case SUBDEV_CONN_COMPLEX_QI: return (0x0 << 4) | (0x1 << 0); //DAC1=DUC0I, DAC0=DUC0Q + case SUBDEV_CONN_REAL_I: return (0xf << 4) | (0x0 << 0); //DAC1=ZERO, DAC0=DUC0I + case SUBDEV_CONN_REAL_Q: return (0x0 << 4) | (0xf << 0); //DAC1=DUC0I, DAC0=ZERO + default: UHD_THROW_INVALID_CODE_PATH(); + } +} + +boost::uint32_t dsp_type1::calc_cordic_word_and_update( + double &freq, + double codec_rate +){ + UHD_ASSERT_THROW(std::abs(freq) <= codec_rate/2.0); + static const double scale_factor = std::pow(2.0, 32); + + //calculate the freq register word (signed) + boost::int32_t freq_word = boost::int32_t(boost::math::round((freq / codec_rate) * scale_factor)); + + //update the actual frequency + freq = (double(freq_word) / scale_factor) * codec_rate; + + return boost::uint32_t(freq_word); +} + +boost::uint32_t dsp_type1::calc_cic_filter_word(unsigned rate){ + int hb0 = 0, hb1 = 0; + if (not (rate & 0x1)){ + hb0 = 1; + rate /= 2; + } + if (not (rate & 0x1)){ + hb1 = 1; + rate /= 2; + } + return (hb1 << 9) | (hb0 << 8) | (rate & 0xff); +} + +boost::uint32_t dsp_type1::calc_iq_scale_word( + boost::int16_t i, boost::int16_t q +){ + return (boost::uint32_t(i) << 16) | (boost::uint32_t(q) << 0); +} + +boost::uint32_t dsp_type1::calc_iq_scale_word(unsigned rate){ + // Calculate CIC interpolation (i.e., without halfband interpolators) + unsigned tmp_rate = calc_cic_filter_word(rate) & 0xff; + + // Calculate closest multiplier constant to reverse gain absent scale multipliers + double rate_cubed = std::pow(double(tmp_rate), 3); + boost::int16_t scale = boost::math::iround((4096*std::pow(2, ceil_log2(rate_cubed)))/(1.65*rate_cubed)); + return calc_iq_scale_word(scale, scale); +} + +boost::uint32_t dsp_type1::calc_stream_cmd_word( + const stream_cmd_t &stream_cmd, size_t num_samps_continuous +){ + UHD_ASSERT_THROW(stream_cmd.num_samps <= 0x3fffffff); + + //setup the mode to instruction flags + typedef boost::tuple<bool, bool, bool> inst_t; + static const uhd::dict<stream_cmd_t::stream_mode_t, inst_t> mode_to_inst = boost::assign::map_list_of + //reload, chain, samps + (stream_cmd_t::STREAM_MODE_START_CONTINUOUS, inst_t(true, true, false)) + (stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS, inst_t(false, false, false)) + (stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE, inst_t(false, false, true)) + (stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE, inst_t(false, true, true)) + ; + + //setup the instruction flag values + bool inst_reload, inst_chain, inst_samps; + boost::tie(inst_reload, inst_chain, inst_samps) = mode_to_inst[stream_cmd.stream_mode]; + + //calculate the word from flags and length + boost::uint32_t word = 0; + word |= boost::uint32_t((stream_cmd.stream_now)? 1 : 0) << 31; + word |= boost::uint32_t((inst_chain)? 1 : 0) << 30; + word |= boost::uint32_t((inst_reload)? 1 : 0) << 29; + word |= (inst_samps)? stream_cmd.num_samps : ((inst_chain)? num_samps_continuous : 1); + return word; +} diff --git a/host/lib/usrp/dsp_utils.hpp b/host/lib/usrp/dsp_utils.hpp deleted file mode 100644 index ebed12c41..000000000 --- a/host/lib/usrp/dsp_utils.hpp +++ /dev/null @@ -1,187 +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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_LIBUHD_USRP_DSP_UTILS_HPP -#define INCLUDED_LIBUHD_USRP_DSP_UTILS_HPP - -#include <uhd/config.hpp> -#include <uhd/types/dict.hpp> -#include <uhd/utils/assert.hpp> -#include <uhd/types/stream_cmd.hpp> -#include <uhd/usrp/subdev_props.hpp> -#include <boost/cstdint.hpp> -#include <boost/assign/list_of.hpp> -#include <boost/tuple/tuple.hpp> -#include <boost/math/special_functions/round.hpp> - -namespace uhd{ namespace usrp{ - -namespace dsp_type1{ - - template <class T> T ceil_log2(T num){ - return std::ceil(std::log(num)/std::log(T(2))); - } - - /*! - * Calculate the rx mux word from properties. - * \param subdev_conn the subdev connection type - * \param the 32-bit rx mux control word - */ - static inline boost::uint32_t calc_rx_mux_word( - subdev_conn_t subdev_conn - ){ - switch(subdev_conn){ - case SUBDEV_CONN_COMPLEX_IQ: return (0x1 << 2) | (0x0 << 0); //DDC0Q=ADC1, DDC0I=ADC0 - case SUBDEV_CONN_COMPLEX_QI: return (0x0 << 2) | (0x1 << 0); //DDC0Q=ADC0, DDC0I=ADC1 - case SUBDEV_CONN_REAL_I: return (0x3 << 2) | (0x0 << 0); //DDC0Q=ZERO, DDC0I=ADC0 - case SUBDEV_CONN_REAL_Q: return (0x1 << 2) | (0x3 << 0); //DDC0Q=ADC1, DDC0I=ZERO - default: UHD_THROW_INVALID_CODE_PATH(); - } - } - - /*! - * Calculate the tx mux word from properties. - * \param subdev_conn the subdev connection type - * \param the 32-bit tx mux control word - */ - static inline boost::uint32_t calc_tx_mux_word( - subdev_conn_t subdev_conn - ){ - switch(subdev_conn){ - case SUBDEV_CONN_COMPLEX_IQ: return (0x1 << 4) | (0x0 << 0); //DAC1=DUC0Q, DAC0=DUC0I - case SUBDEV_CONN_COMPLEX_QI: return (0x0 << 4) | (0x1 << 0); //DAC1=DUC0I, DAC0=DUC0Q - case SUBDEV_CONN_REAL_I: return (0xf << 4) | (0x0 << 0); //DAC1=ZERO, DAC0=DUC0I - case SUBDEV_CONN_REAL_Q: return (0x0 << 4) | (0xf << 0); //DAC1=DUC0I, DAC0=ZERO - default: UHD_THROW_INVALID_CODE_PATH(); - } - } - - /*! - * Calculate the cordic word from the frequency and clock rate. - * The frequency will be set to the actual (possible) frequency. - * - * \param freq the requested frequency in Hz - * \param codec_rate the dsp codec rate in Hz - * \param the 32-bit cordic control word - */ - static inline boost::uint32_t calc_cordic_word_and_update( - double &freq, - double codec_rate - ){ - UHD_ASSERT_THROW(std::abs(freq) <= codec_rate/2.0); - static const double scale_factor = std::pow(2.0, 32); - - //calculate the freq register word (signed) - boost::int32_t freq_word = boost::int32_t(boost::math::round((freq / codec_rate) * scale_factor)); - - //update the actual frequency - freq = (double(freq_word) / scale_factor) * codec_rate; - - return boost::uint32_t(freq_word); - } - - /*! - * Calculate the CIC filter word from the rate. - * Check if requested decim/interp rate is: - * multiple of 4, enable two halfband filters - * multiple of 2, enable one halfband filter - * handle remainder in CIC - * - * \param rate the requested rate in Sps - * \return the 32-bit cic filter control word - */ - template <typename dsp_rate_type> - static inline boost::uint32_t calc_cic_filter_word(dsp_rate_type rate){ - int hb0 = 0, hb1 = 0; - if (not (rate & 0x1)){ - hb0 = 1; - rate /= 2; - } - if (not (rate & 0x1)){ - hb1 = 1; - rate /= 2; - } - return (hb1 << 9) | (hb0 << 8) | (rate & 0xff); - } - - /*! - * Calculate the IQ scale factor word from I and Q components. - * \param i the I component of the scalar - * \param q the Q component of the scalar - * \return the 32-bit scale factor control word - */ - static inline boost::uint32_t calc_iq_scale_word( - boost::int16_t i, boost::int16_t q - ){ - return (boost::uint32_t(i) << 16) | (boost::uint32_t(q) << 0); - } - - /*! - * Calculate the IQ scale factor word from the rate. - * \param rate the requested rate in Sps - * \return the 32-bit scale factor control word - */ - template <typename dsp_rate_type> - static inline boost::uint32_t calc_iq_scale_word(dsp_rate_type rate){ - // Calculate CIC interpolation (i.e., without halfband interpolators) - dsp_rate_type tmp_rate = calc_cic_filter_word(rate) & 0xff; - - // Calculate closest multiplier constant to reverse gain absent scale multipliers - double rate_cubed = std::pow(double(tmp_rate), 3); - boost::int16_t scale = boost::math::iround((4096*std::pow(2, ceil_log2(rate_cubed)))/(1.65*rate_cubed)); - return calc_iq_scale_word(scale, scale); - } - - /*! - * Calculate the stream command word from the stream command struct. - * \param stream_cmd the requested stream command with mode, flags, timestamp - * \param num_samps_continuous number of samples to request in continuous mode - * \return the 32-bit stream command word - */ - static inline boost::uint32_t calc_stream_cmd_word( - const stream_cmd_t &stream_cmd, size_t num_samps_continuous - ){ - UHD_ASSERT_THROW(stream_cmd.num_samps <= 0x3fffffff); - - //setup the mode to instruction flags - typedef boost::tuple<bool, bool, bool> inst_t; - static const uhd::dict<stream_cmd_t::stream_mode_t, inst_t> mode_to_inst = boost::assign::map_list_of - //reload, chain, samps - (stream_cmd_t::STREAM_MODE_START_CONTINUOUS, inst_t(true, true, false)) - (stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS, inst_t(false, false, false)) - (stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE, inst_t(false, false, true)) - (stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE, inst_t(false, true, true)) - ; - - //setup the instruction flag values - bool inst_reload, inst_chain, inst_samps; - boost::tie(inst_reload, inst_chain, inst_samps) = mode_to_inst[stream_cmd.stream_mode]; - - //calculate the word from flags and length - boost::uint32_t word = 0; - word |= boost::uint32_t((stream_cmd.stream_now)? 1 : 0) << 31; - word |= boost::uint32_t((inst_chain)? 1 : 0) << 30; - word |= boost::uint32_t((inst_reload)? 1 : 0) << 29; - word |= (inst_samps)? stream_cmd.num_samps : ((inst_chain)? num_samps_continuous : 1); - return word; - } - -} //namespace dsp_type1 - -}} //namespace - -#endif /* INCLUDED_LIBUHD_USRP_DSP_UTILS_HPP */ diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp index da22d79f1..46094ba32 100644 --- a/host/lib/usrp/misc_utils.cpp +++ b/host/lib/usrp/misc_utils.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#include "misc_utils.hpp" +#include <uhd/usrp/misc_utils.hpp> #include <uhd/utils/assert.hpp> #include <uhd/utils/gain_group.hpp> #include <uhd/usrp/dboard_id.hpp> @@ -29,9 +29,6 @@ using namespace uhd; using namespace uhd::usrp; -static const size_t subdev_gain_priority = 1; //higher, closer to the antenna -static const size_t codec_gain_priority = 0; - /*********************************************************************** * codec gain group helper functions: * do this so we dont have to bind a templated function @@ -80,7 +77,15 @@ static void set_subdev_gain(wax::obj subdev, const std::string &name, float gain /*********************************************************************** * gain group factory function for usrp **********************************************************************/ -gain_group::sptr usrp::make_gain_group(wax::obj subdev, wax::obj codec){ +gain_group::sptr usrp::make_gain_group( + wax::obj subdev, wax::obj codec, + gain_group_policy_t gain_group_policy +){ + const size_t subdev_gain_priority = 1; + const size_t codec_gain_priority = (gain_group_policy == GAIN_GROUP_POLICY_RX)? + (subdev_gain_priority - 1): //RX policy, codec gains fill last (lower priority) + (subdev_gain_priority + 1); //TX policy, codec gains fill first (higher priority) + gain_group::sptr gg = gain_group::make(); gain_fcns_t fcns; //add all the subdev gains first (antenna to dsp order) @@ -127,14 +132,17 @@ static void verify_xx_subdev_spec( wax::obj mboard, std::string xx_type ){ + prop_names_t dboard_names = mboard[dboard_names_prop].as<prop_names_t>(); + UHD_ASSERT_THROW(dboard_names.size() > 0); //well i hope there is a dboard + //the subdevice specification is empty: handle automatic if (subdev_spec.empty()){ - BOOST_FOREACH(const std::string &db_name, mboard[dboard_names_prop].as<prop_names_t>()){ + BOOST_FOREACH(const std::string &db_name, dboard_names){ wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)]; //if the dboard slot is populated, take the first subdevice if (dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>() != dboard_id_t::none()){ - std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().at(0); + std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front(); subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name)); break; } @@ -142,16 +150,23 @@ static void verify_xx_subdev_spec( //didnt find any populated dboards: add the first subdevice if (subdev_spec.empty()){ - std::string db_name = mboard[dboard_names_prop].as<prop_names_t>().at(0); + std::string db_name = dboard_names.front(); wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)]; - std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().at(0); + std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front(); subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name)); } } //sanity check that the dboard/subdevice names exist for this mboard BOOST_FOREACH(const subdev_spec_pair_t &pair, subdev_spec){ - uhd::assert_has(mboard[dboard_names_prop].as<prop_names_t>(), pair.db_name, xx_type + " dboard name"); + //empty db name means select dboard automatically + if (pair.db_name.empty()){ + if (dboard_names.size() != 1) throw std::runtime_error( + "A daughterboard name must be provided for multi-slot boards: " + subdev_spec.to_string() + ); + pair.db_name == dboard_names.front(); + } + uhd::assert_has(dboard_names, pair.db_name, xx_type + " dboard name"); wax::obj dboard = mboard[named_prop_t(dboard_prop, pair.db_name)]; uhd::assert_has(dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>(), pair.sd_name, xx_type + " subdev name"); } diff --git a/host/lib/usrp/misc_utils.hpp b/host/lib/usrp/misc_utils.hpp deleted file mode 100644 index e5d3bd849..000000000 --- a/host/lib/usrp/misc_utils.hpp +++ /dev/null @@ -1,54 +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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_LIBUHD_USRP_MISC_UTILS_HPP -#define INCLUDED_LIBUHD_USRP_MISC_UTILS_HPP - -#include <uhd/config.hpp> -#include <uhd/wax.hpp> -#include <uhd/usrp/subdev_spec.hpp> -#include <uhd/utils/gain_group.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * Create a gain group that represents the subdevice and its codec. - */ - gain_group::sptr make_gain_group(wax::obj subdev, wax::obj codec); - - /*! - * Verify the rx subdevice specification. - * If the subdev spec if empty, automatically fill it. - * \param subdev_spec the subdev spec to verify/fill - * \param mboard the motherboard properties object - * \throw exception when the subdev spec is invalid - */ - void verify_rx_subdev_spec(subdev_spec_t &subdev_spec, wax::obj mboard); - - /*! - * Verify the tx subdevice specification. - * If the subdev spec if empty, automatically fill it. - * \param subdev_spec the subdev spec to verify/fill - * \param mboard the motherboard properties object - * \throw exception when the subdev spec is invalid - */ - void verify_tx_subdev_spec(subdev_spec_t &subdev_spec, wax::obj mboard); - -}} //namespace - -#endif /* INCLUDED_LIBUHD_USRP_MISC_UTILS_HPP */ - diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp index 765eecb3d..7a3e72867 100644 --- a/host/lib/usrp/subdev_spec.cpp +++ b/host/lib/usrp/subdev_spec.cpp @@ -53,13 +53,9 @@ std::string subdev_spec_t::to_pp_string(void) const{ size_t count = 0; ss << "Subdevice Specification:" << std::endl; BOOST_FOREACH(const subdev_spec_pair_t &pair, *this){ - std::string db_name = pair.db_name; - if (db_name == "") db_name = "0"; - std::string sd_name = pair.sd_name; - if (sd_name == "") sd_name = "0"; ss << boost::format( " Channel %d: Daughterboard %s, Subdevice %s" - ) % (count++) % db_name % sd_name << std::endl; + ) % (count++) % pair.db_name % pair.sd_name << std::endl; } return ss.str(); } diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp index b9d51abf5..fc917b102 100644 --- a/host/lib/usrp/usrp2/codec_impl.cpp +++ b/host/lib/usrp/usrp2/codec_impl.cpp @@ -40,9 +40,7 @@ void usrp2_mboard_impl::codec_init(void){ /*********************************************************************** * RX Codec Properties **********************************************************************/ -void usrp2_mboard_impl::rx_codec_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); +void usrp2_mboard_impl::rx_codec_get(const wax::obj &key, wax::obj &val){ //handle the get request conditioned on the key switch(key.as<codec_prop_t>()){ @@ -69,9 +67,7 @@ void usrp2_mboard_impl::rx_codec_set(const wax::obj &, const wax::obj &){ /*********************************************************************** * TX Codec Properties **********************************************************************/ -void usrp2_mboard_impl::tx_codec_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); +void usrp2_mboard_impl::tx_codec_get(const wax::obj &key, wax::obj &val){ //handle the get request conditioned on the key switch(key.as<codec_prop_t>()){ diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 1b9a4bb97..8bded1ea3 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -37,7 +37,12 @@ public: usrp2_dboard_iface(usrp2_iface::sptr iface, usrp2_clock_ctrl::sptr clock_ctrl); ~usrp2_dboard_iface(void); - std::string get_mboard_name(void){return "usrp2";} + special_props_t get_special_props(void){ + special_props_t props; + props.soft_clock_divider = false; + props.mangle_i2c_addrs = false; + return props; + } void write_aux_dac(unit_t, aux_dac_t, float); float read_aux_adc(unit_t, aux_adc_t); diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 075f22388..a462b93c2 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -17,8 +17,8 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" -#include "../dsp_utils.hpp" -#include "../misc_utils.hpp" +#include <uhd/usrp/misc_utils.hpp> +#include <uhd/usrp/dsp_utils.hpp> #include <uhd/usrp/subdev_props.hpp> #include <uhd/usrp/dboard_props.hpp> #include <uhd/utils/assert.hpp> @@ -59,8 +59,7 @@ void usrp2_mboard_impl::dboard_init(void){ * RX DBoard Properties **********************************************************************/ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<dboard_prop_t>()){ @@ -69,7 +68,7 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ return; case DBOARD_PROP_SUBDEV: - val = _dboard_manager->get_rx_subdev(name); + val = _dboard_manager->get_rx_subdev(key.name); return; case DBOARD_PROP_SUBDEV_NAMES: @@ -90,7 +89,9 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ case DBOARD_PROP_GAIN_GROUP: val = make_gain_group( - _dboard_manager->get_rx_subdev(name), _rx_codec_proxy->get_link() + _dboard_manager->get_rx_subdev(key.name), + _rx_codec_proxy->get_link(), + GAIN_GROUP_POLICY_RX ); return; @@ -114,8 +115,7 @@ void usrp2_mboard_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){ * TX DBoard Properties **********************************************************************/ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<dboard_prop_t>()){ @@ -124,7 +124,7 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ return; case DBOARD_PROP_SUBDEV: - val = _dboard_manager->get_tx_subdev(name); + val = _dboard_manager->get_tx_subdev(key.name); return; case DBOARD_PROP_SUBDEV_NAMES: @@ -145,7 +145,9 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ case DBOARD_PROP_GAIN_GROUP: val = make_gain_group( - _dboard_manager->get_tx_subdev(name), _tx_codec_proxy->get_link() + _dboard_manager->get_tx_subdev(key.name), + _tx_codec_proxy->get_link(), + GAIN_GROUP_POLICY_TX ); return; diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp index 7d9cdc441..347ec38af 100644 --- a/host/lib/usrp/usrp2/dsp_impl.cpp +++ b/host/lib/usrp/usrp2/dsp_impl.cpp @@ -17,9 +17,10 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" -#include "../dsp_utils.hpp" +#include <uhd/usrp/dsp_utils.hpp> #include <uhd/usrp/dsp_props.hpp> #include <boost/bind.hpp> +#include <cmath> using namespace uhd; using namespace uhd::usrp; @@ -30,10 +31,9 @@ static const size_t default_interp = 16; /*********************************************************************** * DDC Helper Methods **********************************************************************/ -template <class rate_t> static rate_t -pick_closest_rate(double exact_rate, const std::vector<rate_t> &rates){ - rate_t closest_match = rates.at(0); - BOOST_FOREACH(rate_t possible_rate, rates){ +static unsigned pick_closest_rate(double exact_rate, const std::vector<unsigned> &rates){ + unsigned closest_match = rates.front(); + BOOST_FOREACH(unsigned possible_rate, rates){ if(std::abs(exact_rate - possible_rate) < std::abs(exact_rate - closest_match)) closest_match = possible_rate; } diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index fe3ec6785..d5785f326 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -17,14 +17,15 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" -#include "../misc_utils.hpp" -#include "../dsp_utils.hpp" +#include <uhd/usrp/misc_utils.hpp> +#include <uhd/usrp/dsp_utils.hpp> #include <uhd/usrp/mboard_props.hpp> #include <uhd/utils/assert.hpp> #include <uhd/utils/algorithm.hpp> #include <uhd/types/mac_addr.hpp> #include <uhd/types/dict.hpp> #include <boost/bind.hpp> +#include <boost/assign/list_of.hpp> #include <boost/asio/ip/address_v4.hpp> #include <iostream> @@ -186,12 +187,13 @@ void usrp2_mboard_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){ /*********************************************************************** * MBoard Get Properties **********************************************************************/ +static const std::string dboard_name = "0"; + void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the other props - if (key.type() == typeid(std::string)){ + if (key_.type() == typeid(std::string)){ if (key.as<std::string>() == "mac-addr"){ byte_vector_t bytes = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, 6); val = mac_addr_t::from_bytes(bytes).to_string(); @@ -222,25 +224,25 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_RX_DBOARD: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(key.name == dboard_name); val = _rx_dboard_proxy->get_link(); return; case MBOARD_PROP_RX_DBOARD_NAMES: - val = prop_names_t(1, ""); + val = prop_names_t(1, dboard_name); return; case MBOARD_PROP_TX_DBOARD: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(key.name == dboard_name); val = _tx_dboard_proxy->get_link(); return; case MBOARD_PROP_TX_DBOARD_NAMES: - val = prop_names_t(1, ""); + val = prop_names_t(1, dboard_name); return; case MBOARD_PROP_RX_DSP: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(key.name == ""); val = _rx_dsp_proxy->get_link(); return; @@ -249,7 +251,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_TX_DSP: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(key.name == ""); val = _tx_dsp_proxy->get_link(); return; diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 45362c20f..568c87a22 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -201,8 +201,7 @@ usrp2_impl::~usrp2_impl(void){ * Device Properties **********************************************************************/ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as<device_prop_t>()){ @@ -212,7 +211,7 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){ return; case DEVICE_PROP_MBOARD: - val = _mboard_dict[name]->get_link(); + val = _mboard_dict[key.name]->get_link(); return; case DEVICE_PROP_MBOARD_NAMES: |