summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-04-30 17:11:46 -0700
committerJosh Blum <josh@joshknows.com>2011-04-30 17:11:46 -0700
commit493ed897f24fff5265b766ee634916b002cadf94 (patch)
tree09082fa8be0c71b92ca668083dd1519a452b679d /host/lib/usrp/usrp2
parent7b509d6fe4ac4cfcafc63f11f5b298d3e0237acd (diff)
parent1e57d1c0496ca6263652cd84c9eeacafde833915 (diff)
downloaduhd-493ed897f24fff5265b766ee634916b002cadf94.tar.gz
uhd-493ed897f24fff5265b766ee634916b002cadf94.tar.bz2
uhd-493ed897f24fff5265b766ee634916b002cadf94.zip
Merge branch 'master' into next
Conflicts: host/lib/usrp/usrp2/usrp2_regs.cpp
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp14
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp44
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp28
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp7
-rw-r--r--host/lib/usrp/usrp2/usrp2_regs.hpp1
6 files changed, 75 insertions, 21 deletions
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 3f41cddcf..8c6379d66 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -38,11 +38,14 @@ void usrp2_mboard_impl::dboard_init(void){
//read the dboard eeprom to extract the dboard ids
_rx_db_eeprom.load(*_iface, USRP2_I2C_ADDR_RX_DB);
_tx_db_eeprom.load(*_iface, USRP2_I2C_ADDR_TX_DB);
+ _gdb_eeprom.load(*_iface, USRP2_I2C_ADDR_TX_DB ^ 5);
//create a new dboard interface and manager
_dboard_iface = make_usrp2_dboard_iface(_iface, _clock_ctrl);
_dboard_manager = dboard_manager::make(
- _rx_db_eeprom.id, _tx_db_eeprom.id, _dboard_iface
+ _rx_db_eeprom.id,
+ ((_gdb_eeprom.id == dboard_id_t::none())? _tx_db_eeprom : _gdb_eeprom).id,
+ _dboard_iface
);
//load dboards
@@ -137,6 +140,10 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _tx_db_eeprom;
return;
+ case DBOARD_PROP_GBOARD_EEPROM:
+ val = _gdb_eeprom;
+ return;
+
case DBOARD_PROP_DBOARD_IFACE:
val = _dboard_iface;
return;
@@ -166,6 +173,11 @@ void usrp2_mboard_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
_tx_db_eeprom.store(*_iface, USRP2_I2C_ADDR_TX_DB);
return;
+ case DBOARD_PROP_GBOARD_EEPROM:
+ _gdb_eeprom = val.as<dboard_eeprom_t>();
+ _gdb_eeprom.store(*_iface, USRP2_I2C_ADDR_TX_DB ^ 5);
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 07cbd2432..005be7ce4 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -228,9 +228,9 @@ void usrp2_impl::io_impl::recv_pirate_loop(
zero_copy_if::sptr err_xport,
size_t index
){
+ recv_pirate_crew_raiding = true;
spawn_barrier.wait();
set_thread_priority_safe();
- recv_pirate_crew_raiding = true;
//store a reference to the flow control monitor (offset by max dsps)
flow_control_monitor &fc_mon = *(this->fc_mons[index*usrp2_mboard_impl::MAX_NUM_DSPS]);
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 29e0535f8..ae098dba6 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -26,6 +26,8 @@
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/algorithm.hpp>
+#include <uhd/types/sensors.hpp>
+#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
#include <iostream>
@@ -100,11 +102,11 @@ usrp2_mboard_impl::usrp2_mboard_impl(
//contruct the interfaces to mboard perifs
_clock_ctrl = usrp2_clock_ctrl::make(_iface);
_codec_ctrl = usrp2_codec_ctrl::make(_iface);
-// _gps_ctrl = gps_ctrl::make(
-// _iface->get_gps_write_fn(),
-// _iface->get_gps_read_fn());
-
- //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl;
+ if (_iface->mb_eeprom["gpsdo"] == "internal"){
+ _gps_ctrl = gps_ctrl::make(
+ _iface->get_gps_write_fn(),
+ _iface->get_gps_read_fn());
+ }
//init the dsp stuff (before setting update packets)
dsp_init();
@@ -363,10 +365,42 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
val = this->get_master_clock_freq();
return;
+ case SUBDEV_PROP_SENSOR_NAMES:{
+ prop_names_t names = boost::assign::list_of("mimo_locked")("ref_locked");
+ if (_gps_ctrl.get()) names.push_back("gps_time");
+ val = names;
+ }
+ return;
+
+ case MBOARD_PROP_SENSOR:
+ if(key.name == "mimo_locked") {
+ val = sensor_value_t("MIMO", this->get_mimo_locked(), "locked", "unlocked");
+ return;
+ }
+ else if(key.name == "ref_locked") {
+ val = sensor_value_t("Ref", this->get_ref_locked(), "locked", "unlocked");
+ return;
+ }
+ else if(key.name == "gps_time" and _gps_ctrl.get()) {
+ val = sensor_value_t("GPS time", int(_gps_ctrl->get_epoch_time()), "seconds");
+ }
+ else {
+ UHD_THROW_PROP_GET_ERROR();
+ }
+ break;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
+bool usrp2_mboard_impl::get_mimo_locked(void) {
+ return bool((_iface->peek32(_iface->regs.irq_rb) & (1<<10)) > 0);
+}
+
+bool usrp2_mboard_impl::get_ref_locked(void) {
+ return bool((_iface->peek32(_iface->regs.irq_rb) & (1<<11)) > 0);
+}
+
/***********************************************************************
* MBoard Set Properties
**********************************************************************/
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index cb92b1921..48443bba4 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -105,33 +105,37 @@ static device_addrs_t usrp2_find(const device_addr_t &hint_){
size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem));
//std::cout << len << "\n";
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 compatibility mismatch.
- //In this case, the discovered device will be ignored.
try{
mboard_eeprom_t mb_eeprom = usrp2_iface::make(udp_simple::make_connected(
new_addr["addr"], boost::lexical_cast<std::string>(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()
- );
+ catch(const std::exception &){
+ //set these values as empty string so the device may still be found
+ //and the filter's below can still operate on the discovered device
+ new_addr["name"] = "";
+ new_addr["serial"] = "";
}
+
+ //filter the discovered device below by matching optional keys
+ 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);
+ }
+
//dont break here, it will exit the while loop
//just continue on to the next loop iteration
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 0676cecf2..ccaf0c9a8 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -147,7 +147,7 @@ private:
void tx_dboard_get(const wax::obj &, wax::obj &);
void tx_dboard_set(const wax::obj &, const wax::obj &);
wax_obj_proxy::sptr _tx_dboard_proxy;
- uhd::usrp::dboard_eeprom_t _tx_db_eeprom;
+ uhd::usrp::dboard_eeprom_t _tx_db_eeprom, _gdb_eeprom;
//methods and shadows for the dsps
UHD_PIMPL_DECL(dsp_impl) _dsp_impl;
@@ -163,7 +163,10 @@ private:
void duc_get(const wax::obj &, wax::obj &, size_t);
void duc_set(const wax::obj &, const wax::obj &, size_t);
uhd::dict<std::string, wax_obj_proxy::sptr> _tx_dsp_proxies;
-
+
+ //sensors methods for mboard
+ bool get_mimo_locked(void);
+ bool get_ref_locked(void);
};
/*!
diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp
index e7803d9ee..b50f8b506 100644
--- a/host/lib/usrp/usrp2/usrp2_regs.hpp
+++ b/host/lib/usrp/usrp2/usrp2_regs.hpp
@@ -40,6 +40,7 @@ typedef struct {
int time64_secs_rb_pps;
int time64_ticks_rb_pps;
int compat_num_rb;
+ int irq_rb;
int dsp_tx_freq;
int dsp_tx_scale_iq;
int dsp_tx_interp_rate;