diff options
author | Nick Foster <nick@nerdnetworks.org> | 2010-09-30 11:57:40 -0700 |
---|---|---|
committer | Nick Foster <nick@nerdnetworks.org> | 2010-09-30 11:57:40 -0700 |
commit | 046d8a9a5a5b0addb7e6c8bfde7973f3051d48b1 (patch) | |
tree | d25ee63a046193d1c87b8b8b15153cf02e749e37 /host/lib/usrp | |
parent | 56751efbe6e0751a2b8cd0f7a31d5dfd07fec5dd (diff) | |
download | uhd-046d8a9a5a5b0addb7e6c8bfde7973f3051d48b1.tar.gz uhd-046d8a9a5a5b0addb7e6c8bfde7973f3051d48b1.tar.bz2 uhd-046d8a9a5a5b0addb7e6c8bfde7973f3051d48b1.zip |
TVRX: Fixed to properly calculate alias frequencies.
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/dboard/db_tvrx.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index 6b71a3c6e..1cb74c5ae 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -373,11 +373,29 @@ void tvrx::set_freq(double freq) { } /*********************************************************************** + * Get the alias frequency of frequency freq when sampled at fs. + * \param freq the frequency of interest + * \param fs the sample rate + * \return the alias frequency + **********************************************************************/ + +static double get_alias(double freq, double fs) { + double alias; + freq = fmod(freq, fs); + if(freq >= (fs/2)) { + alias = fs - freq; + } else { + alias = freq; + } + return alias; +} + +/*********************************************************************** * RX Get and Set **********************************************************************/ void tvrx::rx_get(const wax::obj &key_, wax::obj &val){ named_prop_t key = named_prop_t::extract(key_); - int codec_rate; + double codec_rate; //handle the get request conditioned on the key switch(key.as<subdev_prop_t>()){ @@ -410,9 +428,7 @@ void tvrx::rx_get(const wax::obj &key_, wax::obj &val){ * or if it will fall within Nyquist. */ codec_rate = this->get_iface()->get_codec_rate(dboard_iface::UNIT_RX); - if(codec_rate/2 > tvrx_if_freq) val = _lo_freq; - //ok take a deep breath i am positive there is an easier way to get this number - else val = _lo_freq - tvrx_if_freq - (tvrx_if_freq-codec_rate)*int(tvrx_if_freq / (codec_rate/2)); + val = (_lo_freq - tvrx_if_freq) + get_alias(tvrx_if_freq, codec_rate); return; case SUBDEV_PROP_FREQ_RANGE: |