From 94e7cec66a2d3efe6be5f12455644c4547b61a9c Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Mon, 2 Aug 2010 17:40:30 -0700 Subject: Propogate gain range into RX pga0 helper for RFX boards --- host/lib/usrp/dboard/db_rfx.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'host/lib') diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 664b406d9..b6b44199a 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -241,10 +241,10 @@ void rfx_xcvr::set_tx_ant(const std::string &ant){ /*********************************************************************** * Gain Handling **********************************************************************/ -static float rx_pga0_gain_to_dac_volts(float &gain){ +static float rx_pga0_gain_to_dac_volts(float &gain, float range){ //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; + static const float slope = (max_volts-min_volts)/(range); //calculate the voltage for the aux dac float dac_volts = std::clip(gain*slope + min_volts, max_volts, min_volts); @@ -263,7 +263,8 @@ 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(_rx_gain_ranges.keys(), name, "rfx rx gain name"); if(name == "PGA0"){ - float dac_volts = rx_pga0_gain_to_dac_volts(gain); + float dac_volts = rx_pga0_gain_to_dac_volts(gain, + (_rx_gain_ranges["PGA0"].max - _rx_gain_ranges["PGA0"].min)); _rx_gains[name] = gain; //write the new voltage to the aux dac -- cgit v1.2.3