aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/clock_ctrl.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-09-24 15:53:03 -0700
committerJosh Blum <josh@joshknows.com>2010-09-24 15:53:03 -0700
commit192663bcc919a794a24eabb38d12519f445b7a47 (patch)
treeba55269010c4484bef12d4019c691d9e469165d7 /host/lib/usrp/usrp2/clock_ctrl.cpp
parent77cdb4a9695e71e64e1d87cfad2cb4d8717f971e (diff)
parent5d6d25b49cc783ef012410064bc9eb0e66e50227 (diff)
downloaduhd-192663bcc919a794a24eabb38d12519f445b7a47.tar.gz
uhd-192663bcc919a794a24eabb38d12519f445b7a47.tar.bz2
uhd-192663bcc919a794a24eabb38d12519f445b7a47.zip
Merge branch 'master' into usrp_e
Conflicts: host/CMakeLists.txt
Diffstat (limited to 'host/lib/usrp/usrp2/clock_ctrl.cpp')
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index 02227afad..1e1c9b7b8 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -20,6 +20,7 @@
#include "usrp2_regs.hpp" //spi slave constants
#include <uhd/utils/assert.hpp>
#include <boost/cstdint.hpp>
+#include <iostream>
using namespace uhd;
@@ -67,12 +68,60 @@ public:
this->enable_dac_clock(true);
this->enable_adc_clock(true);
+ /* always driving the mimo reference */
+ this->enable_mimo_clock_out(true);
}
~usrp2_clock_ctrl_impl(void){
- /* private clock enables, must be set here */
+ //power down clock outputs
+ this->enable_external_ref(false);
+ this->enable_rx_dboard_clock(false);
+ this->enable_tx_dboard_clock(false);
this->enable_dac_clock(false);
this->enable_adc_clock(false);
+ this->enable_mimo_clock_out(false);
+ }
+
+ void enable_mimo_clock_out(bool enb){
+ //FIXME TODO put this revision read in a common place
+ boost::uint8_t rev_hi = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV_MSB, 1).at(0);
+
+ //calculate the low and high dividers
+ size_t divider = size_t(this->get_master_clock_rate()/10e6);
+ size_t high = divider/2;
+ size_t low = divider - high;
+
+ switch(rev_hi){
+ case 3: //clock 2
+ _ad9510_regs.power_down_lvpecl_out2 = enb?
+ ad9510_regs_t::POWER_DOWN_LVPECL_OUT2_NORMAL :
+ ad9510_regs_t::POWER_DOWN_LVPECL_OUT2_SAFE_PD;
+ _ad9510_regs.output_level_lvpecl_out2 = ad9510_regs_t::OUTPUT_LEVEL_LVPECL_OUT2_810MV;
+ //set the registers (divider - 1)
+ _ad9510_regs.divider_low_cycles_out2 = low - 1;
+ _ad9510_regs.divider_high_cycles_out2 = high - 1;
+ _ad9510_regs.bypass_divider_out2 = 0;
+ this->write_reg(0x3e);
+ this->write_reg(0x4c);
+ break;
+
+ case 4: //clock 5
+ _ad9510_regs.power_down_lvds_cmos_out5 = enb? 0 : 1;
+ _ad9510_regs.lvds_cmos_select_out5 = ad9510_regs_t::LVDS_CMOS_SELECT_OUT5_LVDS;
+ _ad9510_regs.output_level_lvds_out5 = ad9510_regs_t::OUTPUT_LEVEL_LVDS_OUT5_1_75MA;
+ //set the registers (divider - 1)
+ _ad9510_regs.divider_low_cycles_out5 = low - 1;
+ _ad9510_regs.divider_high_cycles_out5 = high - 1;
+ _ad9510_regs.bypass_divider_out5 = 0;
+ this->write_reg(0x41);
+ this->write_reg(0x52);
+ break;
+
+ //TODO FIXME do i want to throw, what about uninitialized boards?
+ //default: throw std::runtime_error("unknown rev hi in mboard eeprom");
+ default: std::cerr << "unknown rev hi: " << rev_hi << std::endl;
+ }
+ this->update_regs();
}
//uses output clock 7 (cmos)