diff options
author | Jason Abele <jason@ettus.com> | 2010-06-01 16:33:45 -0700 |
---|---|---|
committer | Jason Abele <jason@ettus.com> | 2010-06-01 16:33:45 -0700 |
commit | 00b33d97487602960f70506ea59cc504d31d91f6 (patch) | |
tree | 1a8be054f3b8c2846a748d1dbef187fe89c8426b /host/lib/usrp/dboard/db_rfx.cpp | |
parent | e78b3c6b142cdda00a1d2042c56b47c5e31cfb27 (diff) | |
download | uhd-00b33d97487602960f70506ea59cc504d31d91f6.tar.gz uhd-00b33d97487602960f70506ea59cc504d31d91f6.tar.bz2 uhd-00b33d97487602960f70506ea59cc504d31d91f6.zip |
Refactor WBX and RFX to use conventions more like XCVR
Diffstat (limited to 'host/lib/usrp/dboard/db_rfx.cpp')
-rw-r--r-- | host/lib/usrp/dboard/db_rfx.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 89e707718..5b90bbbad 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -91,7 +91,7 @@ private: uhd::dict<dboard_iface::unit_t, bool> _div2; double _rx_lo_freq, _tx_lo_freq; std::string _rx_ant; - float _rx_pga0_gain; + uhd::dict<std::string, float> _rx_gains; void set_rx_lo_freq(double freq); void set_tx_lo_freq(double freq); @@ -100,8 +100,6 @@ private: void set_rx_gain(float gain, const std::string &name); void set_tx_gain(float gain, const std::string &name); - void set_rx_pga0_gain(float gain); - /*! * Set the LO frequency for the particular dboard unit. * \param unit which unit rx or tx @@ -198,7 +196,10 @@ rfx_xcvr::rfx_xcvr( set_rx_lo_freq((_freq_range.min + _freq_range.max)/2.0); set_tx_lo_freq((_freq_range.min + _freq_range.max)/2.0); set_rx_ant("RX2"); - set_rx_pga0_gain(0); + + BOOST_FOREACH(const std::string &name, rfx_rx_gain_ranges.keys()){ + set_rx_gain(rfx_rx_gain_ranges[name].min, name); + } } rfx_xcvr::~rfx_xcvr(void){ @@ -230,6 +231,20 @@ void rfx_xcvr::set_tx_ant(const std::string &ant){ /*********************************************************************** * Gain Handling **********************************************************************/ +static float rx_pga0_gain_to_dac_volts(float &gain){ + //voltage level constants (negative slope) + static const float max_volts = float(.2), min_volts = float(1.2); + static const float slope = (max_volts-min_volts)/45; + + //calculate the voltage for the aux dac + float dac_volts = std::clip<float>(gain*slope + min_volts, max_volts, min_volts); + + //the actual gain setting + gain = (dac_volts - min_volts)/slope; + + return dac_volts; +} + void rfx_xcvr::set_tx_gain(float, const std::string &name){ assert_has(rfx_tx_gain_ranges.keys(), name, "rfx tx gain name"); UHD_ASSERT_THROW(false); //no gains to set @@ -238,26 +253,15 @@ void rfx_xcvr::set_tx_gain(float, const std::string &name){ void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ assert_has(rfx_rx_gain_ranges.keys(), name, "rfx rx gain name"); if(name == "PGA0"){ - this->set_rx_pga0_gain(gain); + float dac_volts = rx_pga0_gain_to_dac_volts(gain); + _rx_gains[name] = gain; + + //write the new voltage to the aux dac + this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, 1, dac_volts); } else UHD_ASSERT_THROW(false); } -void rfx_xcvr::set_rx_pga0_gain(float gain){ - //voltage level constants (negative slope) - static const float max_volts = float(.2), min_volts = float(1.2); - static const float slope = (max_volts-min_volts)/45; - - //calculate the voltage for the aux dac - float dac_volts = std::clip<float>(gain*slope + min_volts, max_volts, min_volts); - - //write the new voltage to the aux dac - this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, 1, dac_volts); - - //shadow the actual gain setting - _rx_pga0_gain = (dac_volts - min_volts)/slope; -} - /*********************************************************************** * Tuning **********************************************************************/ @@ -397,8 +401,8 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - UHD_ASSERT_THROW(name == "PGA0"); - val = _rx_pga0_gain; + assert_has(_rx_gains.keys(), name, "rfx rx gain name"); + val = _rx_gains[name]; return; case SUBDEV_PROP_GAIN_RANGE: |