aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-04-20 17:32:19 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:46 -0800
commit5da05554a5a994c7ffde3ce20965d557fa33bc67 (patch)
treebabc15661b08343689400bd1dfae554d916104aa
parent60af7b1a1f6b105e63e5fe2945146ef401dd70b0 (diff)
downloaduhd-5da05554a5a994c7ffde3ce20965d557fa33bc67.tar.gz
uhd-5da05554a5a994c7ffde3ce20965d557fa33bc67.tar.bz2
uhd-5da05554a5a994c7ffde3ce20965d557fa33bc67.zip
mpm: LMK code now throws on incorrect chip ID
-rw-r--r--host/lib/usrp/common/lmk04828.cpp9
-rw-r--r--host/lib/usrp/common/lmk04828.hpp9
2 files changed, 14 insertions, 4 deletions
diff --git a/host/lib/usrp/common/lmk04828.cpp b/host/lib/usrp/common/lmk04828.cpp
index 9a9657ac8..edc65d280 100644
--- a/host/lib/usrp/common/lmk04828.cpp
+++ b/host/lib/usrp/common/lmk04828.cpp
@@ -28,7 +28,7 @@ lmk04828_iface::lmk04828_iface(write_fn_t write_fn, read_fn_t read_fn) : _write_
}
-void lmk04828_iface::verify_chip_id()
+bool lmk04828_iface::verify_chip_id()
{
// Check ID Device Type, ID Prod, and ID Maskrev registers
uint8_t id_device_type = get_chip_id();
@@ -38,7 +38,10 @@ void lmk04828_iface::verify_chip_id()
// assert(id_device_type == 6);
if (id_device_type != 6){
std::cout << "id_device_type is not 6!" << std::endl;
+ return false;
}
+
+ return true;
}
uint8_t lmk04828_iface::get_chip_id(){
@@ -69,7 +72,9 @@ void lmk04828_iface::init()
_write_fn(writes);
- verify_chip_id();
+ if (!verify_chip_id()) {
+ throw uhd::runtime_error("LMK ID not correct!");
+ }
}
void lmk04828_iface::enable_sysref_pulse()
diff --git a/host/lib/usrp/common/lmk04828.hpp b/host/lib/usrp/common/lmk04828.hpp
index 36266bbfe..f44786dad 100644
--- a/host/lib/usrp/common/lmk04828.hpp
+++ b/host/lib/usrp/common/lmk04828.hpp
@@ -32,7 +32,7 @@ class lmk04828_iface
{
public:
typedef boost::shared_ptr<lmk04828_iface> sptr;
- typedef boost::function<void(std::vector<uint32_t>)> write_fn_t;
+ typedef boost::function<void(std::vector<uint32_t>)> write_fn_t;
typedef boost::function<uint8_t(uint32_t)> read_fn_t;
//static sptr (write_fn_t write_fn, read_fn_t read_fn);
@@ -40,7 +40,12 @@ public:
~lmk04828_iface() {}
- void verify_chip_id();
+ //! Checks if the chip ID is what we expect
+ //
+ // Does not throw
+ //
+ // \returns false if chip ID is incorrect
+ bool verify_chip_id();
uint8_t get_chip_id();