Revision eeb72416

b/host/lib/usrp/usrp1/codec_ctrl.cpp
154 154
/***********************************************************************
155 155
 * Codec Control Gain Control Methods
156 156
 **********************************************************************/
157
void usrp1_codec_ctrl_impl::set_tx_pga_gain(float gain)
158
{
159
    int gain_word = int(255*(gain - tx_pga_gain_range.min)/(tx_pga_gain_range.max - tx_pga_gain_range.min));
160
    _ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, 255);
157
static const int mtpgw = 255; //maximum tx pga gain word
158

  
159
void usrp1_codec_ctrl_impl::set_tx_pga_gain(float gain){
160
    int gain_word = int(mtpgw*(gain - tx_pga_gain_range.min)/(tx_pga_gain_range.max - tx_pga_gain_range.min));
161
    _ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, mtpgw);
161 162
    this->send_reg(16);
162 163
}
163 164

  
164
float usrp1_codec_ctrl_impl::get_tx_pga_gain(void)
165
{
166
    return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.max - tx_pga_gain_range.min)/63) + tx_pga_gain_range.min;
165
float usrp1_codec_ctrl_impl::get_tx_pga_gain(void){
166
    return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.max - tx_pga_gain_range.min)/mtpgw) + tx_pga_gain_range.min;
167 167
}
168 168

  
169
void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which)
170
{
171
    int gain_word = int(0x14*(gain - rx_pga_gain_range.min)/(rx_pga_gain_range.max - rx_pga_gain_range.min));
172
    gain_word = std::clip(gain_word, 0, 0x14);
169
static const int mrpgw = 0x14; //maximum rx pga gain word
170

  
171
void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){
172
    int gain_word = int(mrpgw*(gain - rx_pga_gain_range.min)/(rx_pga_gain_range.max - rx_pga_gain_range.min));
173
    gain_word = std::clip(gain_word, 0, mrpgw);
173 174
    switch(which){
174 175
    case 'A':
175 176
        _ad9862_regs.rx_pga_a = gain_word;
......
183 184
    }
184 185
}
185 186

  
186
float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which)
187
{
187
float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){
188 188
    int gain_word;
189 189
    switch(which){
190 190
    case 'A': gain_word = _ad9862_regs.rx_pga_a; break;
191 191
    case 'B': gain_word = _ad9862_regs.rx_pga_b; break;
192 192
    default: UHD_THROW_INVALID_CODE_PATH();
193 193
    }
194
    return (gain_word*(rx_pga_gain_range.max - rx_pga_gain_range.min)/0x14) + rx_pga_gain_range.min;
194
    return (gain_word*(rx_pga_gain_range.max - rx_pga_gain_range.min)/mrpgw) + rx_pga_gain_range.min;
195 195
}
196 196

  
197 197
/***********************************************************************

Also available in: Unified diff