aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJulian Arnold <julian.arnold@ettus.com>2014-12-16 13:32:40 -0800
committerJulian Arnold <julian.arnold@ettus.com>2015-01-12 15:38:53 -0800
commit9d0750df6c90099eabd6d4108f51ebbee85ded21 (patch)
tree6a082a5c9832f89fb44c9e7e0c20631e62e79061 /host/lib
parent12e86cc384b150a8fbc1ce22533df62cba58df10 (diff)
downloaduhd-9d0750df6c90099eabd6d4108f51ebbee85ded21.tar.gz
uhd-9d0750df6c90099eabd6d4108f51ebbee85ded21.tar.bz2
uhd-9d0750df6c90099eabd6d4108f51ebbee85ded21.zip
ad9361: rssi readout
Diffstat (limited to 'host/lib')
-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
4 files changed, 40 insertions, 2 deletions
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;