diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/usrp/dboard_iface.hpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/usrp/dboard/twinrx/twinrx_io.hpp | 7 | ||||
-rw-r--r-- | host/lib/usrp/dboard_iface.cpp | 31 |
4 files changed, 41 insertions, 4 deletions
diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp index 52d226004..7c730f59d 100644 --- a/host/include/uhd/usrp/dboard_iface.hpp +++ b/host/include/uhd/usrp/dboard_iface.hpp @@ -26,6 +26,7 @@ #include <uhd/usrp/gpio_defs.hpp> #include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> +#include <boost/thread/thread.hpp> #include <string> #include <vector> @@ -297,6 +298,11 @@ public: */ virtual void set_command_time(const uhd::time_spec_t& t) = 0; + /*! + * Sleep for a set time + * \param time time to sleep in nanoseconds + */ + virtual void sleep(const boost::chrono::nanoseconds& time); }; }} //namespace diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt index dde4f02c3..d20cc966b 100644 --- a/host/lib/usrp/CMakeLists.txt +++ b/host/lib/usrp/CMakeLists.txt @@ -24,6 +24,7 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/dboard_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dboard_eeprom.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dboard_id.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dboard_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mboard_eeprom.cpp diff --git a/host/lib/usrp/dboard/twinrx/twinrx_io.hpp b/host/lib/usrp/dboard/twinrx/twinrx_io.hpp index 8b504b549..5d099e361 100644 --- a/host/lib/usrp/dboard/twinrx/twinrx_io.hpp +++ b/host/lib/usrp/dboard/twinrx/twinrx_io.hpp @@ -108,10 +108,9 @@ public: _db_iface->set_gpio_out(dboard_iface::UNIT_BOTH, (cpld::get_reg(addr) << shift(CPLD_FULL_ADDR)) | (data << shift(CPLD_DATA)), mask<boost::uint32_t>(CPLD_FULL_ADDR)|mask<boost::uint32_t>(CPLD_DATA)); - //Sleep for 166ns to ensure that we don't toggle the enables to quickly - //nanosleep is not really accurate in userland and it is also not very - //cross-platform. So just sleep for the minimum amount of time in us. - boost::this_thread::sleep(boost::posix_time::microseconds(0)); + //Sleep for 166ns to ensure that we don't toggle the enables too quickly + //The underlying sleep function rounds to microsecond precision. + _db_iface->sleep(boost::chrono::nanoseconds(166)); //Step 2: Write the reg offset and data, and assert the necessary enable _db_iface->set_gpio_out(dboard_iface::UNIT_BOTH, (static_cast<boost::uint32_t>(addr) << shift(CPLD_FULL_ADDR)) | (data << shift(CPLD_DATA)), diff --git a/host/lib/usrp/dboard_iface.cpp b/host/lib/usrp/dboard_iface.cpp new file mode 100644 index 000000000..2a04095e8 --- /dev/null +++ b/host/lib/usrp/dboard_iface.cpp @@ -0,0 +1,31 @@ +// +// Copyright 2016 Ettus Research +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#include <uhd/usrp/dboard_iface.hpp> + +using namespace uhd::usrp; + +void dboard_iface::sleep(const boost::chrono::nanoseconds& time) +{ + //nanosleep is not really accurate in userland and it is also not very + //cross-platform. So just sleep for the minimum amount of time in us. + if (time < boost::chrono::microseconds(1)) { + boost::this_thread::sleep_for(boost::chrono::microseconds(1)); + } else { + boost::this_thread::sleep_for(time); + } +} |