summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-11-10 12:15:35 -0800
committerNick Foster <nick@nerdnetworks.org>2010-11-10 12:15:35 -0800
commitfb0cdbc553d288402ee7939dc72f4368eb9e8e1b (patch)
treee20003155af08428448a7834a82d259f3b68717d /host/lib/usrp/usrp2
parent8fe1e7b29aacce7f75ae36e81706bbde02749b97 (diff)
parent8c434f7d63aca25b55d6d13dffcc1d7037261d4f (diff)
downloaduhd-fb0cdbc553d288402ee7939dc72f4368eb9e8e1b.tar.gz
uhd-fb0cdbc553d288402ee7939dc72f4368eb9e8e1b.tar.bz2
uhd-fb0cdbc553d288402ee7939dc72f4368eb9e8e1b.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp2p-next
Conflicts: firmware/microblaze/lib/u2_init.c host/lib/usrp/usrp2/clock_ctrl.cpp host/lib/usrp/usrp2/fw_common.h host/lib/usrp/usrp2/mboard_impl.cpp host/lib/usrp/usrp2/usrp2_iface.cpp host/lib/usrp/usrp2/usrp2_iface.hpp
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.cpp1
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp8
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp89
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.hpp3
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp45
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp15
7 files changed, 78 insertions, 85 deletions
diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index 04bbd6ba3..8eaafe680 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -22,6 +22,7 @@
#include "usrp2_clk_regs.hpp"
#include <uhd/utils/assert.hpp>
#include <boost/cstdint.hpp>
+#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace uhd;
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index bbe9c273f..83b70bddc 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -236,6 +236,11 @@ size_t usrp2_impl::get_max_recv_samps_per_packet(void) const{
return bpp/_rx_otw_type.get_sample_size();
}
+static void handle_overflow(std::vector<usrp2_mboard_impl::sptr> &mboards, size_t chan){
+ std::cerr << "O" << std::flush;
+ mboards.at(chan/mboards.size())->handle_overflow();
+}
+
size_t usrp2_impl::recv(
const std::vector<void *> &buffs, size_t num_samps,
rx_metadata_t &metadata, const io_type_t &io_type,
@@ -248,6 +253,7 @@ size_t usrp2_impl::recv(
io_type, _rx_otw_type, //input and output types to convert
_mboards.front()->get_master_clock_freq(), //master clock tick rate
uhd::transport::vrt::if_hdr_unpack_be,
- boost::bind(&usrp2_impl::io_impl::get_recv_buffs, _io_impl.get(), _1, timeout)
+ boost::bind(&usrp2_impl::io_impl::get_recv_buffs, _io_impl.get(), _1, timeout),
+ boost::bind(&handle_overflow, _mboards, _1)
);
}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 9ccf90bbb..eb5b79b20 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -23,11 +23,7 @@
#include "mboard_rev.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>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -44,11 +40,9 @@ usrp2_mboard_impl::usrp2_mboard_impl(
size_t recv_frame_size
):
_index(index),
- _recv_frame_size(recv_frame_size)
+ _recv_frame_size(recv_frame_size),
+ _iface(usrp2_iface::make(ctrl_transport))
{
- //make a new interface for usrp2 stuff
- _iface = usrp2_iface::make(ctrl_transport);
-
//contruct the interfaces to mboard perifs
_clock_ctrl = usrp2_clock_ctrl::make(_iface);
_codec_ctrl = usrp2_codec_ctrl::make(_iface);
@@ -188,7 +182,15 @@ void usrp2_mboard_impl::set_time_spec(const time_spec_t &time_spec, bool now){
_iface->poke32(_iface->regs.time64_secs, boost::uint32_t(time_spec.get_full_secs()));
}
+void usrp2_mboard_impl::handle_overflow(void){
+ _iface->poke32(_iface->regs.rx_ctrl_clear_overrun, 1);
+ if (_continuous_streaming){ //re-issue the stream command if already continuous
+ this->issue_ddc_stream_cmd(stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+ }
+}
+
void usrp2_mboard_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
+ _continuous_streaming = stream_cmd.stream_mode == stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
_iface->poke32(_iface->regs.rx_ctrl_stream_cmd, dsp_type1::calc_stream_cmd_word(
stream_cmd, _recv_frame_size
));
@@ -203,42 +205,14 @@ static const std::string dboard_name = "0";
void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
named_prop_t key = named_prop_t::extract(key_);
-
- //handle the other props
- 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();
- return;
- }
-
- if (key.as<std::string>() == "ip-addr"){
- boost::asio::ip::address_v4::bytes_type bytes;
- std::copy(_iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_IP_ADDR, 4), bytes);
- val = boost::asio::ip::address_v4(bytes).to_string();
- return;
- }
-
- if (key.as<std::string>() == "hw-rev"){
- //extract the mboard rev number
- val = _iface->get_hw_rev().to_string();
- return;
- }
- }
-
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
case MBOARD_PROP_NAME:
- val = str(boost::format("usrp2 mboard%d - rev %s") % _index % _iface->get_hw_rev().to_string());
+ val = str(boost::format("usrp2 mboard%d - rev %s") % _index % _iface->mb_eeprom["rev"]);
return;
- case MBOARD_PROP_OTHERS:{
- prop_names_t others = boost::assign::list_of
- ("mac-addr")
- ("ip-addr")
- ;
- val = others;
- }
+ case MBOARD_PROP_OTHERS:
+ val = prop_names_t();
return;
case MBOARD_PROP_RX_DBOARD:
@@ -299,6 +273,10 @@ void usrp2_mboard_impl::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();
}
}
@@ -307,32 +285,6 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
* MBoard Set Properties
**********************************************************************/
void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
- //handle the other props
- if (key.type() == typeid(std::string)){
- if (key.as<std::string>() == "mac-addr"){
- byte_vector_t bytes = mac_addr_t::from_string(val.as<std::string>()).to_bytes();
- _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, bytes);
- return;
- }
-
- if (key.as<std::string>() == "ip-addr"){
- byte_vector_t bytes(4);
- std::copy(boost::asio::ip::address_v4::from_string(val.as<std::string>()).to_bytes(), bytes);
- _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_IP_ADDR, bytes);
- return;
- }
-
- if (key.as<std::string>() == "hw-rev"){
- mboard_rev_t rev = mboard_rev_t::from_string(val.as<std::string>());
- byte_vector_t rev_bytes(2);
- rev_bytes[1] = rev.to_uint16() >> 8;
- rev_bytes[0] = rev.to_uint16() & 0xff;
- _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV, rev_bytes);
- _iface->set_hw_rev(rev); //so the iface knows what rev it is
- return;
- }
- }
-
//handle the set request conditioned on the key
switch(key.as<mboard_prop_t>()){
@@ -375,6 +327,13 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
));
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_N100);
+ _iface->mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_N100);
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index d5ac14155..52adb5373 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -30,6 +30,7 @@
#include <algorithm>
using namespace uhd;
+using namespace uhd::usrp;
using namespace uhd::transport;
/*!
@@ -65,6 +66,7 @@ public:
) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num));
}
+ mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_N100);
}
~usrp2_iface_impl(void){
diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp
index fee3b23af..88bff5913 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.hpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.hpp
@@ -20,6 +20,7 @@
#include <uhd/transport/udp_simple.hpp>
#include <uhd/types/serial.hpp>
+#include <uhd/usrp/mboard_eeprom.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/cstdint.hpp>
@@ -128,6 +129,8 @@ public:
* Hardware revision as returned by the device.
*/
mboard_rev_t hw_rev;
+ //motherboard eeprom map structure
+ uhd::usrp::mboard_eeprom_t mb_eeprom;
};
#endif /* INCLUDED_USRP2_IFACE_HPP */
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index a680708ad..5f549c4fd 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -21,6 +21,7 @@
#include <uhd/usrp/device_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
+#include <uhd/utils/warning.hpp>
#include <uhd/utils/algorithm.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
@@ -61,7 +62,7 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){
if (if_addrs.inet == asio::ip::address_v4::loopback().to_string()) continue;
//create a new hint with this broadcast address
- device_addr_t new_hint;
+ device_addr_t new_hint = hint;
new_hint["addr"] = if_addrs.bcast;
//call discover with the new hint and append results
@@ -101,19 +102,37 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){
while(true){
size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem), DISCOVERY_TIMEOUT_MS);
//std::cout << len << "\n";
- if (len > offsetof(usrp2_ctrl_data_t, data)){
- //handle the received data
- switch(ntohl(ctrl_data_in->id)){
- case USRP2_CTRL_ID_WAZZUP_DUDE:
- //make a boost asio ipv4 with the raw addr in host byte order
- boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
- device_addr_t new_addr;
- new_addr["type"] = "usrp2";
- new_addr["addr"] = ip_addr.to_string();
- usrp2_addrs.push_back(new_addr);
- //dont break here, it will exit the while loop
- //just continue on to the next loop iteration
+ if (len > offsetof(usrp2_ctrl_data_t, data) and ntohl(ctrl_data_in->id) == USRP2_CTRL_ID_WAZZUP_DUDE){
+ //make a boost asio ipv4 with the raw addr in host byte order
+ boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
+ device_addr_t new_addr;
+ new_addr["type"] = "usrp2";
+ new_addr["addr"] = ip_addr.to_string();
+ //Attempt to read the name from the EEPROM and perform filtering.
+ //This operation can throw due to COMPAT mismatch. That is OK.
+ //We will allow the device to be found and the COMPAT mismatch
+ //will be thrown as an exception in the factory function.
+ try{
+ mboard_eeprom_t mb_eeprom = usrp2_iface::make(
+ udp_simple::make_connected(new_addr["addr"], num2str(USRP2_UDP_CTRL_PORT))
+ )->mb_eeprom;
+ new_addr["name"] = mb_eeprom["name"];
+ new_addr["serial"] = mb_eeprom["serial"];
+ if (
+ (not hint.has_key("name") or hint["name"] == new_addr["name"]) and
+ (not hint.has_key("serial") or hint["serial"] == new_addr["serial"])
+ ){
+ usrp2_addrs.push_back(new_addr);
+ }
}
+ catch(const std::exception &e){
+ uhd::warning::post(
+ std::string("Ignoring discovered device\n")
+ + e.what()
+ );
+ }
+ //dont break here, it will exit the while loop
+ //just continue on to the next loop iteration
}
if (len == 0) break; //timeout
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 1ebd90ca4..738c398d9 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -33,7 +33,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
-#include <uhd/transport/udp_simple.hpp> //mtu
+#include <uhd/transport/udp_simple.hpp>
#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <uhd/usrp/subdev_spec.hpp>
@@ -93,14 +93,12 @@ public:
return _clock_ctrl->get_master_clock_rate();
}
+ void handle_overflow(void);
+
private:
size_t _index;
const size_t _recv_frame_size;
-
- //properties for this mboard
- void get(const wax::obj &, wax::obj &);
- void set(const wax::obj &, const wax::obj &);
- uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec;
+ bool _continuous_streaming;
//interfaces
usrp2_iface::sptr _iface;
@@ -109,6 +107,11 @@ private:
usrp2_serdes_ctrl::sptr _serdes_ctrl;
usrp2_gps_ctrl::sptr _gps_ctrl;
+ //properties for this mboard
+ void get(const wax::obj &, wax::obj &);
+ void set(const wax::obj &, const wax::obj &);
+ uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec;
+
//rx and tx dboard methods and objects
uhd::usrp::dboard_manager::sptr _dboard_manager;
uhd::usrp::dboard_iface::sptr _dboard_iface;