diff options
author | Josh Blum <josh@joshknows.com> | 2011-06-06 10:21:45 +0100 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-06-06 10:21:45 +0100 |
commit | 8da2d8426e2a668b9fde31773a9e313a4ce1c2bb (patch) | |
tree | 4f047a32a431d24928992425c3f2d08bc06d001e /host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | |
parent | f239b8517b238923aacc161664857a7d7b830ab0 (diff) | |
download | uhd-8da2d8426e2a668b9fde31773a9e313a4ce1c2bb.tar.gz uhd-8da2d8426e2a668b9fde31773a9e313a4ce1c2bb.tar.bz2 uhd-8da2d8426e2a668b9fde31773a9e313a4ce1c2bb.zip |
usrp-e100: bring up the clock as the first thing
We init the clock as the app wants it as the first thing we do.
This greatly simplifies logic, no need to conditionally init.
Clock config: perform soft reset, and removed ignore sync work
Added open/close to iface so we can open and close w/o re-making.
Other misc tweaks involving prints, etc...
Diffstat (limited to 'host/lib/usrp/usrp_e100/usrp_e100_iface.cpp')
-rw-r--r-- | host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index a1a6cdb85..93c8cc7b5 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -18,6 +18,7 @@ #include "usrp_e100_iface.hpp" #include "usrp_e100_regs.hpp" #include <uhd/exception.hpp> +#include <uhd/utils/msg.hpp> #include <sys/ioctl.h> //ioctl #include <fcntl.h> //open, close #include <linux/usrp_e.h> //ioctl structures and constants @@ -100,12 +101,9 @@ public: return _node_fd; } - /******************************************************************* - * Structors - ******************************************************************/ - usrp_e100_iface_impl(const std::string &node): - _i2c_dev_iface(i2c_dev_iface("/dev/i2c-3")) - { + void open(const std::string &node){ + UHD_MSG(status) << "Opening device node " << node << "..." << std::endl; + //open the device node and check file descriptor if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ throw uhd::io_error("Failed to open " + node); @@ -114,18 +112,30 @@ public: //check the module compatibility number int module_compat_num = ::ioctl(_node_fd, USRP_E_GET_COMPAT_NUMBER, NULL); if (module_compat_num != USRP_E_COMPAT_NUMBER){ - throw uhd::runtime_error(str(boost::format( - "Expected module compatibility number 0x%x, but got 0x%x:\n" - "The module build is not compatible with the host code build." - ) % USRP_E_COMPAT_NUMBER % module_compat_num)); + throw uhd::runtime_error(str(boost::format( + "Expected module compatibility number 0x%x, but got 0x%x:\n" + "The module build is not compatible with the host code build." + ) % USRP_E_COMPAT_NUMBER % module_compat_num)); + } + } + + void close(void){ + ::close(_node_fd); + _node_fd = -1; } + /******************************************************************* + * Structors + ******************************************************************/ + usrp_e100_iface_impl(void): + _node_fd(-1), + _i2c_dev_iface(i2c_dev_iface("/dev/i2c-3")) + { mb_eeprom = mboard_eeprom_t(get_i2c_dev_iface(), mboard_eeprom_t::MAP_E100); } ~usrp_e100_iface_impl(void){ - //close the device node file descriptor - ::close(_node_fd); + if (_node_fd >= 0) this->close(); } /******************************************************************* @@ -378,6 +388,6 @@ private: /*********************************************************************** * Public Make Function **********************************************************************/ -usrp_e100_iface::sptr usrp_e100_iface::make(const std::string &node){ - return sptr(new usrp_e100_iface_impl(node)); +usrp_e100_iface::sptr usrp_e100_iface::make(void){ + return sptr(new usrp_e100_iface_impl()); } |