summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-10-25 19:22:51 -0700
committerJosh Blum <josh@joshknows.com>2010-10-25 19:22:51 -0700
commit0168bff835371140c0d75cc381e3228f8093fe70 (patch)
treee3e40ef76ed24db2ce5bcd7337227c4ddc736879 /host/lib/usrp
parent01f670e81c615a16fb5a931d3842f92b56cc6c09 (diff)
downloaduhd-0168bff835371140c0d75cc381e3228f8093fe70.tar.gz
uhd-0168bff835371140c0d75cc381e3228f8093fe70.tar.bz2
uhd-0168bff835371140c0d75cc381e3228f8093fe70.zip
usrp: rework lo offset logic to use bandwidth, add test case
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/tune_helper.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp
index a6b615926..fa40a8a26 100644
--- a/host/lib/usrp/tune_helper.cpp
+++ b/host/lib/usrp/tune_helper.cpp
@@ -19,6 +19,7 @@
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dsp_props.hpp>
#include <uhd/usrp/dboard_iface.hpp> //unit_t
+#include <uhd/utils/algorithm.hpp>
#include <boost/math/special_functions/sign.hpp>
#include <cmath>
@@ -43,9 +44,11 @@ static tune_result_t tune_xx_subdev_and_dsp(
//------------------------------------------------------------------
double lo_offset = 0.0;
if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){
- //if the local oscillator will be in the passband, use an offset
- //TODO make this nicer, use bandwidth property to clip bounds
- lo_offset = 2.0*dsp[DSP_PROP_HOST_RATE].as<double>();
+ //If the local oscillator will be in the passband, use an offset.
+ //But constrain the LO offset by the width of the filter bandwidth.
+ double rate = dsp[DSP_PROP_HOST_RATE].as<double>();
+ double bw = subdev[SUBDEV_PROP_BANDWIDTH].as<double>();
+ if (bw > rate) lo_offset = std::min((bw - rate)/2, rate/2);
}
//------------------------------------------------------------------