aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Kiser <jon.kiser@ettus.com>2015-01-15 15:59:44 -0800
committerMartin Braun <martin.braun@ettus.com>2015-01-20 10:22:17 +0100
commit876269193db3392247e4af57bbfbdd7e8b433895 (patch)
treeb54bf67bf6340e7730fe07685372124a47d559f5
parentfd2e2156ea5c263bf8c6d098980e4873b55de18e (diff)
downloaduhd-876269193db3392247e4af57bbfbdd7e8b433895.tar.gz
uhd-876269193db3392247e4af57bbfbdd7e8b433895.tar.bz2
uhd-876269193db3392247e4af57bbfbdd7e8b433895.zip
ad9361: bugfix for ad9361 gain value truncation
-rw-r--r--host/lib/usrp/common/ad9361_driver/ad9361_device.cpp14
-rw-r--r--host/lib/usrp/common/ad9361_driver/ad9361_device.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
index 3abcdc157..7e574920a 100644
--- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
+++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
@@ -1872,10 +1872,10 @@ double ad9361_device_t::set_gain(direction_t direction, chain_t chain, const dou
gain_index = 0;
if (chain == CHAIN_1) {
- _rx1_gain = boost::uint32_t(value);
+ _rx1_gain = value;
_io_iface->poke8(0x109, gain_index);
} else {
- _rx2_gain = boost::uint32_t(value);
+ _rx2_gain = value;
_io_iface->poke8(0x10c, gain_index);
}
@@ -1888,15 +1888,19 @@ double ad9361_device_t::set_gain(direction_t direction, chain_t chain, const dou
/* Each gain step is -0.25dB. Calculate the attenuation necessary
* for the requested gain, convert it into gain steps, then write
- * the attenuation word. Max gain (so zero attenuation) is 89.75. */
+ * the attenuation word. Max gain (so zero attenuation) is 89.75.
+ * Ugly values will be written to the attenuation registers if
+ * "value" is out of bounds, so range checking must be performed
+ * outside this function.
+ */
double atten = AD9361_MAX_GAIN - value;
boost::uint32_t attenreg = boost::uint32_t(atten * 4);
if (chain == CHAIN_1) {
- _tx1_gain = boost::uint32_t(value);
+ _tx1_gain = value;
_io_iface->poke8(0x073, attenreg & 0xFF);
_io_iface->poke8(0x074, (attenreg >> 8) & 0x01);
} else {
- _tx2_gain = boost::uint32_t(value);
+ _tx2_gain = value;
_io_iface->poke8(0x075, attenreg & 0xFF);
_io_iface->poke8(0x076, (attenreg >> 8) & 0x01);
}
diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.h b/host/lib/usrp/common/ad9361_driver/ad9361_device.h
index bd93bd06b..fead90424 100644
--- a/host/lib/usrp/common/ad9361_driver/ad9361_device.h
+++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.h
@@ -116,7 +116,7 @@ private: //Members
double _req_clock_rate, _req_coreclk;
boost::uint16_t _rx_bbf_tunediv;
boost::uint8_t _curr_gain_table;
- boost::uint32_t _rx1_gain, _rx2_gain, _tx1_gain, _tx2_gain;
+ double _rx1_gain, _rx2_gain, _tx1_gain, _tx2_gain;
boost::int32_t _tfir_factor;
boost::int32_t _rfir_factor;
//Register soft-copies