aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2015-01-20 10:37:49 +0100
committerMartin Braun <martin.braun@ettus.com>2015-01-20 10:37:49 +0100
commit28373cc1f7eddfb11748674316ffd4c52eeec3d9 (patch)
treed4afed980a4c9e8476f32be8811014157324aae8 /host/lib/usrp/common/ad9361_driver/ad9361_device.cpp
parentadb20365db6dec7c7a4e23cd8b2feb78e83a7a33 (diff)
parent876269193db3392247e4af57bbfbdd7e8b433895 (diff)
downloaduhd-28373cc1f7eddfb11748674316ffd4c52eeec3d9.tar.gz
uhd-28373cc1f7eddfb11748674316ffd4c52eeec3d9.tar.bz2
uhd-28373cc1f7eddfb11748674316ffd4c52eeec3d9.zip
Merge branch 'maint'
Conflicts: host/include/uhd/types/direction.hpp
Diffstat (limited to 'host/lib/usrp/common/ad9361_driver/ad9361_device.cpp')
-rw-r--r--host/lib/usrp/common/ad9361_driver/ad9361_device.cpp14
1 files changed, 9 insertions, 5 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);
}