aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-07-15 11:43:17 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-07-15 11:43:17 +0200
commit7149658fbbee12114429183f8015effd5f59a5f6 (patch)
tree62e75341dc133dad46950be665fa603886d0415f
parent416ac19e94d684111517df7f371810fbc469603c (diff)
downloaduhd-lea-m8f-003_009_004.tar.gz
uhd-lea-m8f-003_009_004.tar.bz2
uhd-lea-m8f-003_009_004.zip
Autoconfigure refclk frequency if LEA-M8F detectedlea-m8f-003_009_004
This should make this branch compatible with both Ettus GPSDO using 10MHz refclk and the LEA-M8F using 30.72MHz
-rw-r--r--host/lib/usrp/b200/b200_cores.cpp7
-rw-r--r--host/lib/usrp/b200/b200_cores.hpp1
-rw-r--r--host/lib/usrp/b200/b200_impl.cpp7
-rw-r--r--host/lib/usrp/common/adf4001_ctrl.cpp20
-rw-r--r--host/lib/usrp/common/adf4001_ctrl.hpp1
5 files changed, 34 insertions, 2 deletions
diff --git a/host/lib/usrp/b200/b200_cores.cpp b/host/lib/usrp/b200/b200_cores.cpp
index 19e637ef4..734e4cb2f 100644
--- a/host/lib/usrp/b200/b200_cores.cpp
+++ b/host/lib/usrp/b200/b200_cores.cpp
@@ -74,6 +74,13 @@ void b200_ref_pll_ctrl::set_lock_to_ext_ref(bool external)
_spi->restore_perif();
}
+bool b200_ref_pll_ctrl::set_refclk_frequency(int refclk_kHz)
+{
+ _spi->change_perif(b200_local_spi_core::PLL);
+ bool success = adf4001_ctrl::set_refclk_frequency(refclk_kHz);
+ _spi->restore_perif();
+ return success;
+}
b200_local_spi_core::sptr b200_local_spi_core::make(
uhd::wb_iface::sptr iface, b200_local_spi_core::perif_t default_perif)
diff --git a/host/lib/usrp/b200/b200_cores.hpp b/host/lib/usrp/b200/b200_cores.hpp
index 32e583794..b34baa24c 100644
--- a/host/lib/usrp/b200/b200_cores.hpp
+++ b/host/lib/usrp/b200/b200_cores.hpp
@@ -58,6 +58,7 @@ public:
b200_ref_pll_ctrl(b200_local_spi_core::sptr spi);
virtual void set_lock_to_ext_ref(bool external);
+ virtual bool set_refclk_frequency(int refclk_kHz);
private:
b200_local_spi_core::sptr _spi;
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp
index 4b17b27f0..a4d43f6b9 100644
--- a/host/lib/usrp/b200/b200_impl.cpp
+++ b/host/lib/usrp/b200/b200_impl.cpp
@@ -722,6 +722,13 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s
//GPS installed: use external ref, time, and init time spec
if (_gps and _gps->gps_detected())
{
+ if (_gps->gps_detected_lea_m8f()) {
+ // Switch REFCLK Frequency to 30.72MHz before setting clock_source to gpsdo
+ if (not _adf4001_iface->set_refclk_frequency(30720)) {
+ throw uhd::value_error("Could not set refclk frequency to 30.72MHz for LEA-M8F!");
+ }
+ }
+
UHD_MSG(status) << "Setting references to the internal GPSDO" << std::endl;
_tree->access<std::string>(mb_path / "time_source" / "value").set("gpsdo");
_tree->access<std::string>(mb_path / "clock_source" / "value").set("gpsdo");
diff --git a/host/lib/usrp/common/adf4001_ctrl.cpp b/host/lib/usrp/common/adf4001_ctrl.cpp
index 076385050..e38142f93 100644
--- a/host/lib/usrp/common/adf4001_ctrl.cpp
+++ b/host/lib/usrp/common/adf4001_ctrl.cpp
@@ -101,8 +101,8 @@ adf4001_ctrl::adf4001_ctrl(uhd::spi_iface::sptr _spi, int slaveno):
spi_config.mosi_edge = spi_config_t::EDGE_RISE;
//set defaults
- adf4001_regs.ref_counter = 96;
- adf4001_regs.n = 125;
+ adf4001_regs.ref_counter = 1;
+ adf4001_regs.n = 4;
adf4001_regs.charge_pump_current_1 = 7;
adf4001_regs.charge_pump_current_2 = 7;
adf4001_regs.muxout = adf4001_regs_t::MUXOUT_DLD;
@@ -125,6 +125,22 @@ void adf4001_ctrl::set_lock_to_ext_ref(bool external) {
program_regs();
}
+bool adf4001_ctrl::set_refclk_frequency(int refclk_kHz)
+{
+ if (refclk_kHz == 30720) {
+ adf4001_regs.ref_counter = 96;
+ adf4001_regs.n = 125;
+ } else if (refclk_kHz == 10000) {
+ adf4001_regs.ref_counter = 1;
+ adf4001_regs.n = 4;
+ } else {
+ return false;
+ }
+
+ program_regs();
+ return true;
+}
+
void adf4001_ctrl::program_regs(void) {
//no control over CE, only LE, therefore we use the initialization latch method
write_reg(3);
diff --git a/host/lib/usrp/common/adf4001_ctrl.hpp b/host/lib/usrp/common/adf4001_ctrl.hpp
index e801ae0c4..66c289f7d 100644
--- a/host/lib/usrp/common/adf4001_ctrl.hpp
+++ b/host/lib/usrp/common/adf4001_ctrl.hpp
@@ -125,6 +125,7 @@ class adf4001_ctrl {
public:
adf4001_ctrl(uhd::spi_iface::sptr _spi, int slaveno);
virtual void set_lock_to_ext_ref(bool external);
+ virtual bool set_refclk_frequency(int refclk_kHz);
private:
uhd::spi_iface::sptr spi_iface;