aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-26 16:43:11 -0700
committerJosh Blum <josh@joshknows.com>2010-08-26 16:43:11 -0700
commiteeb724169569d79390478ca4b6d7a2da60987128 (patch)
tree8154c3a8eecc62c14212e30e3bb35e7e65b311d2 /host
parent2cb0e2b594679cb6cead54321300ea6e2f545458 (diff)
downloaduhd-eeb724169569d79390478ca4b6d7a2da60987128.tar.gz
uhd-eeb724169569d79390478ca4b6d7a2da60987128.tar.bz2
uhd-eeb724169569d79390478ca4b6d7a2da60987128.zip
usrp1: codec pga gain control fix
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index 6751b9b7e..e4417e7fd 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -154,22 +154,23 @@ usrp1_codec_ctrl_impl::~usrp1_codec_ctrl_impl(void)
/***********************************************************************
* Codec Control Gain Control Methods
**********************************************************************/
-void usrp1_codec_ctrl_impl::set_tx_pga_gain(float gain)
-{
- int gain_word = int(255*(gain - tx_pga_gain_range.min)/(tx_pga_gain_range.max - tx_pga_gain_range.min));
- _ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, 255);
+static const int mtpgw = 255; //maximum tx pga gain word
+
+void usrp1_codec_ctrl_impl::set_tx_pga_gain(float gain){
+ int gain_word = int(mtpgw*(gain - tx_pga_gain_range.min)/(tx_pga_gain_range.max - tx_pga_gain_range.min));
+ _ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, mtpgw);
this->send_reg(16);
}
-float usrp1_codec_ctrl_impl::get_tx_pga_gain(void)
-{
- return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.max - tx_pga_gain_range.min)/63) + tx_pga_gain_range.min;
+float usrp1_codec_ctrl_impl::get_tx_pga_gain(void){
+ return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.max - tx_pga_gain_range.min)/mtpgw) + tx_pga_gain_range.min;
}
-void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which)
-{
- int gain_word = int(0x14*(gain - rx_pga_gain_range.min)/(rx_pga_gain_range.max - rx_pga_gain_range.min));
- gain_word = std::clip(gain_word, 0, 0x14);
+static const int mrpgw = 0x14; //maximum rx pga gain word
+
+void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){
+ int gain_word = int(mrpgw*(gain - rx_pga_gain_range.min)/(rx_pga_gain_range.max - rx_pga_gain_range.min));
+ gain_word = std::clip(gain_word, 0, mrpgw);
switch(which){
case 'A':
_ad9862_regs.rx_pga_a = gain_word;
@@ -183,15 +184,14 @@ void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which)
}
}
-float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which)
-{
+float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){
int gain_word;
switch(which){
case 'A': gain_word = _ad9862_regs.rx_pga_a; break;
case 'B': gain_word = _ad9862_regs.rx_pga_b; break;
default: UHD_THROW_INVALID_CODE_PATH();
}
- return (gain_word*(rx_pga_gain_range.max - rx_pga_gain_range.min)/0x14) + rx_pga_gain_range.min;
+ return (gain_word*(rx_pga_gain_range.max - rx_pga_gain_range.min)/mrpgw) + rx_pga_gain_range.min;
}
/***********************************************************************