diff options
author | Josh Blum <josh@joshknows.com> | 2010-11-09 18:38:39 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-11-09 18:38:39 -0800 |
commit | 3bca8c492514564a065e34d3284cb468873fcc8c (patch) | |
tree | 73f11afc14eb62ac1c1ff5374dce9c3cb33c0278 /host/lib/usrp/usrp1 | |
parent | 073518083f2c7044d4b0c16948a192c5623d0752 (diff) | |
parent | c0dfc2cf47b98734c4218427c7c6f5eb92025a9c (diff) | |
download | uhd-3bca8c492514564a065e34d3284cb468873fcc8c.tar.gz uhd-3bca8c492514564a065e34d3284cb468873fcc8c.tar.bz2 uhd-3bca8c492514564a065e34d3284cb468873fcc8c.zip |
Merge branch 'master' into usrp_e_next
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r-- | host/lib/usrp/usrp1/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/mboard_impl.cpp | 35 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_iface.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_iface.hpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.cpp | 19 |
5 files changed, 32 insertions, 31 deletions
diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt index 67487f99e..022015231 100644 --- a/host/lib/usrp/usrp1/CMakeLists.txt +++ b/host/lib/usrp/usrp1/CMakeLists.txt @@ -40,7 +40,7 @@ ENDIF(ENABLE_USRP1 AND NOT HAVE_USB_SUPPORT) IF(ENABLE_USRP1) MESSAGE(STATUS " Building USRP1 support.") - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../firmware/fx2/include) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../firmware/fx2/common) LIBUHD_APPEND_SOURCES( ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.cpp diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 669b20efa..c1f0f1d38 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -262,24 +262,10 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val) { named_prop_t key = named_prop_t::extract(key_); - if(key_.type() == typeid(std::string)) { - if(key.as<std::string>() == "serial") { - uhd::byte_vector_t buf; - buf.insert(buf.begin(), 248); - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - _iface->write_i2c(I2C_DEV_EEPROM, buf); - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - buf = _iface->read_i2c(I2C_DEV_EEPROM, 8); - val = std::string(buf.begin(), buf.end()); - } - - return; - } - //handle the get request conditioned on the key switch(key.as<mboard_prop_t>()){ case MBOARD_PROP_NAME: - val = std::string("usrp1 mboard - " + (*_mboard_proxy)[std::string("serial")].as<std::string>()); + val = std::string("usrp1 mboard - " + _iface->mb_eeprom["serial"]); return; case MBOARD_PROP_OTHERS: @@ -336,6 +322,10 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val) val = _tx_subdev_spec; return; + case MBOARD_PROP_EEPROM_MAP: + val = _iface->mb_eeprom; + return; + default: UHD_THROW_PROP_GET_ERROR(); } } @@ -351,14 +341,6 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) std::cout << "USRP1 EEPROM image: " << usrp1_eeprom_image << std::endl; _ctrl_transport->usrp_load_eeprom(val.as<std::string>()); } - - if(key.as<std::string>() == "serial") { - std::string sernum = val.as<std::string>(); - uhd::byte_vector_t buf(sernum.begin(), sernum.end()); - buf.insert(buf.begin(), 248); - _iface->write_i2c(I2C_DEV_EEPROM, buf); - } - return; } @@ -395,6 +377,13 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) _iface->poke32(FR_TX_MUX, calc_tx_mux(_tx_subdev_spec, _mboard_proxy->get_link())); return; + case MBOARD_PROP_EEPROM_MAP: + // Step1: commit the map, writing only those values set. + // Step2: readback the entire eeprom map into the iface. + val.as<mboard_eeprom_t>().commit(*_iface, mboard_eeprom_t::MAP_B1XX); + _iface->mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_B1XX); + return; + default: UHD_THROW_PROP_SET_ERROR(); } } diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 64ced2905..691c51fe8 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -25,6 +25,7 @@ #include <iomanip> using namespace uhd; +using namespace uhd::usrp; using namespace uhd::transport; static const bool iface_debug = false; @@ -36,7 +37,8 @@ public: ******************************************************************/ usrp1_iface_impl(usrp_ctrl::sptr ctrl_transport) { - _ctrl_transport = ctrl_transport; + _ctrl_transport = ctrl_transport; + mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_B1XX); } ~usrp1_iface_impl(void) diff --git a/host/lib/usrp/usrp1/usrp1_iface.hpp b/host/lib/usrp/usrp1/usrp1_iface.hpp index 3f608584a..34a2330b5 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.hpp +++ b/host/lib/usrp/usrp1/usrp1_iface.hpp @@ -18,6 +18,7 @@ #ifndef INCLUDED_USRP1_IFACE_HPP #define INCLUDED_USRP1_IFACE_HPP +#include <uhd/usrp/mboard_eeprom.hpp> #include <uhd/types/serial.hpp> #include <boost/shared_ptr.hpp> #include <boost/utility.hpp> @@ -81,6 +82,8 @@ public: boost::uint16_t index, unsigned char* buff, boost::uint16_t length) = 0; + + uhd::usrp::mboard_eeprom_t mb_eeprom; }; #endif /* INCLUDED_USRP1_IFACE_HPP */ diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 314384e72..6016b0979 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -56,12 +56,14 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) //return an empty list of addresses when type is set to non-usrp1 if (hint.has_key("type") and hint["type"] != "usrp1") return usrp1_addrs; + //Return an empty list of addresses when an address is specified, + //since an address is intended for a different, non-USB, device. + if (hint.has_key("addr")) return usrp1_addrs; + //extract the firmware path for the USRP1 std::string usrp1_fw_image; try{ - usrp1_fw_image = find_image_path( - hint.has_key("fw")? hint["fw"] : "usrp1_fw.ihx" - ); + usrp1_fw_image = find_image_path(hint.get("fw", "usrp1_fw.ihx")); } catch(...){ uhd::warning::post( @@ -91,11 +93,16 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) pid = USRP1_PRODUCT_ID; BOOST_FOREACH(usb_device_handle::sptr handle, usb_device_handle::get_device_list(vid, pid)) { + usrp1_iface::sptr iface = usrp1_iface::make(usrp_ctrl::make(usb_control::make(handle))); device_addr_t new_addr; new_addr["type"] = "usrp1"; + new_addr["name"] = iface->mb_eeprom["name"]; new_addr["serial"] = handle->get_serial(); - //this is a found usrp1 when a hint serial is not specified or it matches - if (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]){ + //this is a found usrp1 when the hint serial and name match or blank + if ( + (not hint.has_key("name") or hint["name"] == new_addr["name"]) and + (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]) + ){ usrp1_addrs.push_back(new_addr); } } @@ -110,7 +117,7 @@ static device::sptr usrp1_make(const device_addr_t &device_addr){ //extract the FPGA path for the USRP1 std::string usrp1_fpga_image = find_image_path( - device_addr.has_key("fpga")? device_addr["fpga"] : "usrp1_fpga.rbf" + device_addr.get("fpga", "usrp1_fpga.rbf") ); //std::cout << "USRP1 FPGA image: " << usrp1_fpga_image << std::endl; |