aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2015-01-13 09:45:55 +0100
committerMartin Braun <martin.braun@ettus.com>2015-01-13 09:45:55 +0100
commitbe5f9613311d944b8971570bff444c5af094f0f5 (patch)
tree6e97e48801fe10a61244c2f4e36ef7f28a6e3c57
parentd15fe9bc22efe4d0499a9108659e32c93e0a2848 (diff)
parent23729861a2020359b9c920347bd2d7c43d96ebf8 (diff)
downloaduhd-be5f9613311d944b8971570bff444c5af094f0f5.tar.gz
uhd-be5f9613311d944b8971570bff444c5af094f0f5.tar.bz2
uhd-be5f9613311d944b8971570bff444c5af094f0f5.zip
Merge branch 'maint'
-rw-r--r--host/examples/init_usrp/CMakeLists.txt9
-rw-r--r--host/lib/usrp/b200/b200_impl.cpp4
-rw-r--r--host/lib/usrp/common/ad9361_ctrl.cpp11
-rw-r--r--host/lib/usrp/common/ad9361_ctrl.hpp6
-rw-r--r--host/lib/usrp/common/ad9361_driver/ad9361_device.cpp22
-rw-r--r--host/lib/usrp/common/ad9361_driver/ad9361_device.h3
-rw-r--r--host/lib/usrp/e300/e300_impl.cpp5
-rw-r--r--host/lib/usrp/e300/e300_network.cpp3
-rw-r--r--host/lib/usrp/e300/e300_remote_codec_ctrl.cpp14
-rw-r--r--host/lib/usrp/e300/e300_remote_codec_ctrl.hpp2
10 files changed, 74 insertions, 5 deletions
diff --git a/host/examples/init_usrp/CMakeLists.txt b/host/examples/init_usrp/CMakeLists.txt
index afbf73027..420e79993 100644
--- a/host/examples/init_usrp/CMakeLists.txt
+++ b/host/examples/init_usrp/CMakeLists.txt
@@ -24,6 +24,14 @@ set(BOOST_REQUIRED_COMPONENTS
system
thread
)
+if(MSVC)
+ set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
+ if(BOOST_ALL_DYN_LINK)
+ add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
+ else(BOOST_ALL_DYN_LINK)
+ set(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
+ endif(BOOST_ALL_DYN_LINK)
+endif(MSVC)
find_package(Boost "1.46" REQUIRED ${BOOST_REQUIRED_COMPONENTS})
# To add UHD as a dependency to this project, add a line such as this:
@@ -37,6 +45,7 @@ include_directories(
${Boost_INCLUDE_DIRS}
${UHD_INCLUDE_DIRS}
)
+link_directories(${Boost_LIBRARY_DIRS})
### Make the executable #######################################################
add_executable(init_usrp init_usrp.cpp)
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp
index 9b323cb13..1523f1858 100644
--- a/host/lib/usrp/b200/b200_impl.cpp
+++ b/host/lib/usrp/b200/b200_impl.cpp
@@ -709,7 +709,7 @@ void b200_impl::setup_radio(const size_t dspno)
_tree->create<meta_range_t>(rf_fe_path / "freq" / "range")
.publish(boost::bind(&ad9361_ctrl::get_rf_freq_range));
- //setup antenna stuff
+ //setup RX related stuff
if (key[0] == 'R')
{
static const std::vector<std::string> ants = boost::assign::list_of("TX/RX")("RX2");
@@ -717,6 +717,8 @@ void b200_impl::setup_radio(const size_t dspno)
_tree->create<std::string>(rf_fe_path / "antenna" / "value")
.subscribe(boost::bind(&b200_impl::update_antenna_sel, this, dspno, _1))
.set("RX2");
+ _tree->create<sensor_value_t>(rf_fe_path / "sensors" / "rssi")
+ .publish(boost::bind(&ad9361_ctrl::get_rssi, _codec_ctrl, key));
}
if (key[0] == 'T')
{
diff --git a/host/lib/usrp/common/ad9361_ctrl.cpp b/host/lib/usrp/common/ad9361_ctrl.cpp
index c84fcee39..f94536ed9 100644
--- a/host/lib/usrp/common/ad9361_ctrl.cpp
+++ b/host/lib/usrp/common/ad9361_ctrl.cpp
@@ -148,7 +148,7 @@ public:
return _device.tune(direction, value);
}
- //! turn on/off Catalina's data port loopback
+ //! turn on/off data port loopback
void data_port_loopback(const bool on)
{
boost::lock_guard<boost::mutex> lock(_mutex);
@@ -156,6 +156,15 @@ public:
_device.data_port_loopback(on);
}
+ //! read internal RSSI sensor
+ sensor_value_t get_rssi(const std::string &which)
+ {
+ boost::lock_guard<boost::mutex> lock(_mutex);
+
+ ad9361_device_t::chain_t chain =_get_chain_from_antenna(which);
+ return sensor_value_t("RSSI", _device.get_rssi(chain), "dB");
+ }
+
private:
static ad9361_device_t::direction_t _get_direction_from_antenna(const std::string& antenna)
{
diff --git a/host/lib/usrp/common/ad9361_ctrl.hpp b/host/lib/usrp/common/ad9361_ctrl.hpp
index 93d697349..16e1d23eb 100644
--- a/host/lib/usrp/common/ad9361_ctrl.hpp
+++ b/host/lib/usrp/common/ad9361_ctrl.hpp
@@ -21,6 +21,7 @@
#include <uhd/transport/zero_copy.hpp>
#include <uhd/types/ranges.hpp>
#include <uhd/types/serial.hpp>
+#include <uhd/types/sensors.hpp>
#include <boost/shared_ptr.hpp>
#include <ad9361_device.h>
#include <string>
@@ -94,8 +95,11 @@ public:
//! tune the given frontend, return the exact value
virtual double tune(const std::string &which, const double value) = 0;
- //! turn on/off Catalina's data port loopback
+ //! turn on/off data port loopback
virtual void data_port_loopback(const bool on) = 0;
+
+ //! read internal RSSI sensor
+ virtual sensor_value_t get_rssi(const std::string &which) = 0;
};
}}
diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
index d56cedec9..b5e116a70 100644
--- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
+++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
@@ -1911,4 +1911,26 @@ void ad9361_device_t::data_port_loopback(const bool loopback_enabled)
_io_iface->poke8(0x3F5, (loopback_enabled ? 0x01 : 0x00));
}
+/* Read back the internal RSSI measurement data. The result is in dB
+ * but not in absolute units. If absolute units are required
+ * a bench calibration should be done.
+ * -0.25dB / bit 9bit resolution.*/
+double ad9361_device_t::get_rssi(chain_t chain)
+{
+ boost::uint32_t reg_rssi = 0;
+ boost::uint8_t lsb_bit_pos = 0;
+ if (chain == CHAIN_1) {
+ reg_rssi = 0x1A7;
+ lsb_bit_pos = 0;
+ }else {
+ reg_rssi = 0x1A9;
+ lsb_bit_pos = 1;
+ }
+ boost::uint8_t msbs = _io_iface->peek8(reg_rssi);
+ boost::uint8_t lsb = ((_io_iface->peek8(0x1AB)) >> lsb_bit_pos) & 0x01;
+ boost::uint16_t val = ((msbs << 1) | lsb);
+ double rssi = (-0.25f * ((double)val)); //-0.25dB/lsb (See Gain Control Users Guide p. 25)
+ return rssi;
+}
+
}}
diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.h b/host/lib/usrp/common/ad9361_driver/ad9361_device.h
index 41af2eeea..8c163572c 100644
--- a/host/lib/usrp/common/ad9361_driver/ad9361_device.h
+++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.h
@@ -63,6 +63,9 @@ public:
/* Turn on/off AD9361's TX port --> RX port loopback. */
void data_port_loopback(const bool loopback_enabled);
+ /* Read back the internal RSSI measurement data. */
+ double get_rssi(chain_t chain);
+
//Constants
static const double AD9361_MAX_GAIN;
static const double AD9361_MAX_CLOCK_RATE;
diff --git a/host/lib/usrp/e300/e300_impl.cpp b/host/lib/usrp/e300/e300_impl.cpp
index 8807a56e4..43a9b7b26 100644
--- a/host/lib/usrp/e300/e300_impl.cpp
+++ b/host/lib/usrp/e300/e300_impl.cpp
@@ -1097,14 +1097,15 @@ void e300_impl::_setup_radio(const size_t dspno)
_tree->create<meta_range_t>(rf_fe_path / "freq" / "range")
.publish(boost::bind(&ad9361_ctrl::get_rf_freq_range));
- //setup antenna stuff
+ //setup RX related stuff
if (key[0] == 'R') {
static const std::vector<std::string> ants = boost::assign::list_of("TX/RX")("RX2");
_tree->create<std::vector<std::string> >(rf_fe_path / "antenna" / "options").set(ants);
_tree->create<std::string>(rf_fe_path / "antenna" / "value")
.subscribe(boost::bind(&e300_impl::_update_antenna_sel, this, dspno, _1))
.set("RX2");
-
+ _tree->create<sensor_value_t>(rf_fe_path / "sensors" / "rssi")
+ .publish(boost::bind(&ad9361_ctrl::get_rssi, _codec_ctrl, key));
}
if (key[0] == 'T') {
static const std::vector<std::string> ants(1, "TX/RX");
diff --git a/host/lib/usrp/e300/e300_network.cpp b/host/lib/usrp/e300/e300_network.cpp
index 59e1eec86..189dba838 100644
--- a/host/lib/usrp/e300/e300_network.cpp
+++ b/host/lib/usrp/e300/e300_network.cpp
@@ -224,6 +224,9 @@ static void e300_codec_ctrl_tunnel(
_codec_ctrl->data_port_loopback(
uhd::ntohx<boost::uint32_t>(in->bits) & 1);
break;
+ case codec_xact_t::ACTION_GET_RSSI:
+ out->rssi = _codec_ctrl->get_rssi(which_str).to_real();
+ break;
default:
UHD_MSG(status) << "Got unknown request?!" << std::endl;
//Zero out actions to fail this request on client
diff --git a/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp b/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp
index bcc8ee4cf..ed8131e2f 100644
--- a/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp
+++ b/host/lib/usrp/e300/e300_remote_codec_ctrl.cpp
@@ -106,6 +106,20 @@ public:
_transact();
}
+ sensor_value_t get_rssi(const std::string &which)
+ {
+ _clear();
+ _args.action = uhd::htonx<boost::uint32_t>(transaction_t::ACTION_GET_RSSI);
+ if (which == "RX1") _args.which = uhd::htonx<boost::uint32_t>(transaction_t::CHAIN_RX1);
+ else if (which == "RX2") _args.which = uhd::htonx<boost::uint32_t>(transaction_t::CHAIN_RX2);
+ else throw std::runtime_error("e300_remote_codec_ctrl_impl incorrect chain string.");
+ _args.bits = uhd::htonx<boost::uint32_t>(0);
+
+ _transact();
+
+ return sensor_value_t("RSSI", _retval.rssi, "dB");
+ }
+
private:
void _transact() {
{
diff --git a/host/lib/usrp/e300/e300_remote_codec_ctrl.hpp b/host/lib/usrp/e300/e300_remote_codec_ctrl.hpp
index 015ad8323..cbc4b52d2 100644
--- a/host/lib/usrp/e300/e300_remote_codec_ctrl.hpp
+++ b/host/lib/usrp/e300/e300_remote_codec_ctrl.hpp
@@ -33,6 +33,7 @@ public:
double rate;
double gain;
double freq;
+ double rssi;
boost::uint64_t bits;
};
@@ -42,6 +43,7 @@ public:
static const boost::uint32_t ACTION_SET_ACTIVE_CHANS = 12;
static const boost::uint32_t ACTION_TUNE = 13;
static const boost::uint32_t ACTION_SET_LOOPBACK = 14;
+ static const boost::uint32_t ACTION_GET_RSSI = 15;
//Values for "which"
static const boost::uint32_t CHAIN_NONE = 0;