Revision 94e7cec6 host/lib/usrp/dboard/db_rfx.cpp
| b/host/lib/usrp/dboard/db_rfx.cpp | ||
|---|---|---|
| 241 | 241 |
/*********************************************************************** |
| 242 | 242 |
* Gain Handling |
| 243 | 243 |
**********************************************************************/ |
| 244 |
static float rx_pga0_gain_to_dac_volts(float &gain){
|
|
| 244 |
static float rx_pga0_gain_to_dac_volts(float &gain, float range){
|
|
| 245 | 245 |
//voltage level constants (negative slope) |
| 246 | 246 |
static const float max_volts = float(.2), min_volts = float(1.2); |
| 247 |
static const float slope = (max_volts-min_volts)/45;
|
|
| 247 |
static const float slope = (max_volts-min_volts)/(range);
|
|
| 248 | 248 |
|
| 249 | 249 |
//calculate the voltage for the aux dac |
| 250 | 250 |
float dac_volts = std::clip<float>(gain*slope + min_volts, max_volts, min_volts); |
| ... | ... | |
| 263 | 263 |
void rfx_xcvr::set_rx_gain(float gain, const std::string &name){
|
| 264 | 264 |
assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); |
| 265 | 265 |
if(name == "PGA0"){
|
| 266 |
float dac_volts = rx_pga0_gain_to_dac_volts(gain); |
|
| 266 |
float dac_volts = rx_pga0_gain_to_dac_volts(gain, |
|
| 267 |
(_rx_gain_ranges["PGA0"].max - _rx_gain_ranges["PGA0"].min)); |
|
| 267 | 268 |
_rx_gains[name] = gain; |
| 268 | 269 |
|
| 269 | 270 |
//write the new voltage to the aux dac |
Also available in: Unified diff