diff options
Diffstat (limited to 'host/lib')
| -rw-r--r-- | host/lib/gain_group.cpp | 3 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/codec_ctrl.cpp | 12 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/codec_ctrl.hpp | 10 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/codec_impl.cpp | 11 | 
4 files changed, 26 insertions, 10 deletions
| diff --git a/host/lib/gain_group.cpp b/host/lib/gain_group.cpp index 5a14fa96f..d5d7730fd 100644 --- a/host/lib/gain_group.cpp +++ b/host/lib/gain_group.cpp @@ -21,7 +21,6 @@  #include <uhd/utils/assert.hpp>  #include <boost/foreach.hpp>  #include <boost/bind.hpp> -#include <boost/math/special_functions/round.hpp>  #include <algorithm>  #include <vector>  #include <iostream> @@ -109,7 +108,7 @@ public:          //fill in the largest step sizes first that are less than the remainder          BOOST_FOREACH(size_t i, indexes_step_size_dec){              const gain_range_t range = all_fcns.at(i).get_range(); -            float additional_gain = range.step*rint( +            float additional_gain = range.step*int(                  std::clip(gain_bucket.at(i) + gain_left_to_distribute, range.min, range.max              )/range.step) - gain_bucket.at(i);              gain_bucket.at(i) += additional_gain; diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp index 2e645dcec..e5be62205 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.cpp +++ b/host/lib/usrp/usrp2/codec_ctrl.cpp @@ -86,12 +86,16 @@ public:          }      } -    void set_rx_digital_gain(float gain) {  //combine fine/correction digital gains +    void set_rx_digital_gain(float gain) {  //fine digital gain        if(_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV) { -        int fine_gain = int(gain/0.5); -        _ads62p44_regs.fine_gain = fine_gain; //hey what about when it calls for 6.5dB? -        _ads62p44_regs.gain_correction = (gain - (double(fine_gain) * 0.5)) / 0.05; +        _ads62p44_regs.fine_gain = int(gain/0.5);          this->send_ads62p44_reg(0x17); +      } else UHD_THROW_INVALID_CODE_PATH(); //should never have been called for USRP2 +    } + +    void set_rx_digital_fine_gain(float gain) { //gain correction       +      if(_iface->get_hw_rev() >= USRP2P_FIRST_HW_REV) { +        _ads62p44_regs.gain_correction = int(gain / 0.05);          this->send_ads62p44_reg(0x1A);        } else UHD_THROW_INVALID_CODE_PATH(); //should never have been called for USRP2      } diff --git a/host/lib/usrp/usrp2/codec_ctrl.hpp b/host/lib/usrp/usrp2/codec_ctrl.hpp index d485690f6..57a37b94b 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.hpp +++ b/host/lib/usrp/usrp2/codec_ctrl.hpp @@ -42,10 +42,18 @@ public:      /*!       * Set the digital gain on the USRP2+ ADC (ADS62P44). -     * \param gain from 0-6.5dB +     * \param gain from 0-6dB       */      virtual void set_rx_digital_gain(float gain) = 0; + +    /*! +     * Set the digital gain correction on the USRP2+ ADC (ADS62P44). +     * \param gain from 0-0.5dB +     */ + +    virtual void set_rx_digital_fine_gain(float gain) = 0; +  };  #endif /* INCLUDED_CODEC_CTRL_HPP */ diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp index 5cc7a47ec..969b5b4b9 100644 --- a/host/lib/usrp/usrp2/codec_impl.cpp +++ b/host/lib/usrp/usrp2/codec_impl.cpp @@ -30,8 +30,9 @@ using namespace boost::assign;  //this only applies to USRP2P  static const uhd::dict<std::string, gain_range_t> codec_rx_gain_ranges = map_list_of -                                  ("analog", gain_range_t(0, 3.5, float(3.5))) -                                  ("digital", gain_range_t(0, 6.45, float(0.05))); +                                  ("analog", gain_range_t(0, 3.5, 3.5)) +                                  ("digital", gain_range_t(0, 6.0, 0.5)) +				  ("digital-fine", gain_range_t(0, 0.5, 0.05));  /*********************************************************************** @@ -99,7 +100,7 @@ void usrp2_mboard_impl::rx_codec_set(const wax::obj &key_, const wax::obj &val){        if(_iface->get_hw_rev() < USRP2P_FIRST_HW_REV) UHD_THROW_PROP_SET_ERROR();//this capability is only found in USRP2P        gain = val.as<float>(); -      this->rx_codec_set_gain(gain, name); //okay. we can either have ONE gain and let codec_ctrl do the sorting between analog/digital gains, or we can have TWO gains and do the priority somewhere else. +      this->rx_codec_set_gain(gain, name);        return;      default: @@ -124,6 +125,10 @@ void usrp2_mboard_impl::rx_codec_set_gain(float gain, const std::string &name){      _codec_ctrl->set_rx_digital_gain(gain);      return;    } +  if(name == "digital-fine") { +    _codec_ctrl->set_rx_digital_fine_gain(gain); +    return; +  }    UHD_THROW_PROP_SET_ERROR();  } | 
