aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/codec_ctrl.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-11 17:40:01 -0800
committerJosh Blum <josh@joshknows.com>2010-11-11 17:40:01 -0800
commit476afe68f5c37a3e10a1208b0150732d7770a023 (patch)
tree73ea72533375d32ac35bcfff578ac0d774a89343 /host/lib/usrp/usrp2/codec_ctrl.cpp
parent478f8174601350ad0edd52bb985657037b181a2d (diff)
downloaduhd-476afe68f5c37a3e10a1208b0150732d7770a023.tar.gz
uhd-476afe68f5c37a3e10a1208b0150732d7770a023.tar.bz2
uhd-476afe68f5c37a3e10a1208b0150732d7770a023.zip
usrp2: made enums for the rev types and implemented in code
Diffstat (limited to 'host/lib/usrp/usrp2/codec_ctrl.cpp')
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp85
1 files changed, 58 insertions, 27 deletions
diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp
index 8680c285a..ad1ae1acb 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.cpp
@@ -59,15 +59,23 @@ public:
}
//power-up adc
- if(!_iface->is_usrp2p()) { //if we're on a USRP2
- _iface->poke32(_iface->regs.misc_ctrl_adc, U2_FLAG_MISC_CTRL_ADC_ON);
- } else { //we're on a USRP2+
- _ads62p44_regs.reset = 1;
- this->send_ads62p44_reg(0x00); //issue a reset to the ADC
- //everything else should be pretty much default, i think
-// _ads62p44_regs.decimation = DECIMATION_DECIMATE_1;
- _ads62p44_regs.power_down = ads62p44_regs_t::POWER_DOWN_NORMAL;
- this->send_ads62p44_reg(0x14);
+ switch(_iface->get_rev()){
+ case usrp2_iface::USRP2_REV3:
+ case usrp2_iface::USRP2_REV4:
+ _iface->poke32(_iface->regs.misc_ctrl_adc, U2_FLAG_MISC_CTRL_ADC_ON);
+ break;
+
+ case usrp2_iface::USRP_N200:
+ case usrp2_iface::USRP_N210:
+ _ads62p44_regs.reset = 1;
+ this->send_ads62p44_reg(0x00); //issue a reset to the ADC
+ //everything else should be pretty much default, i think
+ //_ads62p44_regs.decimation = DECIMATION_DECIMATE_1;
+ _ads62p44_regs.power_down = ads62p44_regs_t::POWER_DOWN_NORMAL;
+ this->send_ads62p44_reg(0x14);
+ break;
+
+ case usrp2_iface::USRP_NXXX: break;
}
}
@@ -77,34 +85,57 @@ public:
this->send_ad9777_reg(0);
//power-down adc
- if(!_iface->is_usrp2p()) { //if we're on a USRP2
- _iface->poke32(_iface->regs.misc_ctrl_adc, U2_FLAG_MISC_CTRL_ADC_OFF);
- } else { //we're on a USRP2+
- //send a global power-down to the ADC here... it will get lifted on reset
- _ads62p44_regs.power_down = ads62p44_regs_t::POWER_DOWN_GLOBAL_PD;
- this->send_ads62p44_reg(0x14);
+ switch(_iface->get_rev()){
+ case usrp2_iface::USRP2_REV3:
+ case usrp2_iface::USRP2_REV4:
+ _iface->poke32(_iface->regs.misc_ctrl_adc, U2_FLAG_MISC_CTRL_ADC_OFF);
+ break;
+
+ case usrp2_iface::USRP_N200:
+ case usrp2_iface::USRP_N210:
+ //send a global power-down to the ADC here... it will get lifted on reset
+ _ads62p44_regs.power_down = ads62p44_regs_t::POWER_DOWN_GLOBAL_PD;
+ this->send_ads62p44_reg(0x14);
+ break;
+
+ case usrp2_iface::USRP_NXXX: break;
}
}
void set_rx_digital_gain(float gain) { //fine digital gain
- if(_iface->is_usrp2p()) {
- _ads62p44_regs.fine_gain = int(gain/0.5);
- this->send_ads62p44_reg(0x17);
- } else UHD_THROW_INVALID_CODE_PATH(); //should never have been called for USRP2
+ switch(_iface->get_rev()){
+ case usrp2_iface::USRP_N200:
+ case usrp2_iface::USRP_N210:
+ _ads62p44_regs.fine_gain = int(gain/0.5);
+ this->send_ads62p44_reg(0x17);
+ break;
+
+ default: UHD_THROW_INVALID_CODE_PATH();
+ }
}
void set_rx_digital_fine_gain(float gain) { //gain correction
- if(_iface->is_usrp2p()) {
- _ads62p44_regs.gain_correction = int(gain / 0.05);
- this->send_ads62p44_reg(0x1A);
- } else UHD_THROW_INVALID_CODE_PATH(); //should never have been called for USRP2
+ switch(_iface->get_rev()){
+ case usrp2_iface::USRP_N200:
+ case usrp2_iface::USRP_N210:
+ _ads62p44_regs.gain_correction = int(gain / 0.05);
+ this->send_ads62p44_reg(0x1A);
+ break;
+
+ default: UHD_THROW_INVALID_CODE_PATH();
+ }
}
void set_rx_analog_gain(bool gain) { //turns on/off analog 3.5dB preamp
- if(_iface->is_usrp2p()) {
- _ads62p44_regs.coarse_gain = gain ? ads62p44_regs_t::COARSE_GAIN_3_5DB : ads62p44_regs_t::COARSE_GAIN_0DB;
- this->send_ads62p44_reg(0x14);
- } else UHD_THROW_INVALID_CODE_PATH();
+ switch(_iface->get_rev()){
+ case usrp2_iface::USRP_N200:
+ case usrp2_iface::USRP_N210:
+ _ads62p44_regs.coarse_gain = gain ? ads62p44_regs_t::COARSE_GAIN_3_5DB : ads62p44_regs_t::COARSE_GAIN_0DB;
+ this->send_ads62p44_reg(0x14);
+ break;
+
+ default: UHD_THROW_INVALID_CODE_PATH();
+ }
}
private: