aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp23
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp20
2 files changed, 38 insertions, 5 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index c90f4a2db..869a38478 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -74,10 +74,17 @@ static const uhd::dict<std::string, boost::uint8_t> USRP_N100_OFFSETS = boost::a
("mac-addr", 0x02)
("ip-addr", 0x0C)
//leave space here for other addresses (perhaps)
+ ("gpsdo", 0x17)
("serial", 0x18)
("name", 0x18 + SERIAL_LEN)
;
+enum n200_gpsdo_type{
+ N200_GPSDO_NONE = 0,
+ N200_GPSDO_INTERNAL = 1,
+ N200_GPSDO_ONBOARD = 2
+};
+
static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
//extract the revision number
byte_vector_t rev_lsb_msb = iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["rev-lsb-msb"], 2);
@@ -93,6 +100,14 @@ static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
byte_copy(iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], 4), ip_addr_bytes);
mb_eeprom["ip-addr"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
+ //gpsdo capabilities
+ boost::uint8_t gpsdo_byte = iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["gpsdo"], 1).at(0);
+ switch(n200_gpsdo_type(gpsdo_byte)){
+ case N200_GPSDO_INTERNAL: mb_eeprom["gpsdo"] = "internal"; break;
+ case N200_GPSDO_ONBOARD: mb_eeprom["gpsdo"] = "onboard"; break;
+ default: mb_eeprom["gpsdo"] = "none";
+ }
+
//extract the serial
mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
N100_EEPROM_ADDR, USRP_N100_OFFSETS["serial"], SERIAL_LEN
@@ -136,6 +151,14 @@ static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], ip_addr_bytes);
}
+ //gpsdo capabilities
+ if (mb_eeprom.has_key("gpsdo")){
+ boost::uint8_t gpsdo_byte = N200_GPSDO_NONE;
+ if (mb_eeprom["gpsdo"] == "internal") gpsdo_byte = N200_GPSDO_INTERNAL;
+ if (mb_eeprom["gpsdo"] == "onboard") gpsdo_byte = N200_GPSDO_ONBOARD;
+ iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["gpsdo"], byte_vector_t(1, gpsdo_byte));
+ }
+
//store the serial
if (mb_eeprom.has_key("serial")) iface.write_eeprom(
N100_EEPROM_ADDR, USRP_N100_OFFSETS["serial"],
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 62cc3c403..ae098dba6 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -27,6 +27,7 @@
#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>
@@ -101,9 +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 (_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();
@@ -361,7 +364,14 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
case MBOARD_PROP_CLOCK_RATE:
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");
@@ -371,7 +381,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
val = sensor_value_t("Ref", this->get_ref_locked(), "locked", "unlocked");
return;
}
- else if(key.name == "gps_time") {
+ else if(key.name == "gps_time" and _gps_ctrl.get()) {
val = sensor_value_t("GPS time", int(_gps_ctrl->get_epoch_time()), "seconds");
}
else {