aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/utils/byteswap.hpp27
-rw-r--r--host/lib/usrp/usrp2/fw_common.h4
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp14
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp24
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.hpp10
5 files changed, 67 insertions, 12 deletions
diff --git a/host/include/uhd/utils/byteswap.hpp b/host/include/uhd/utils/byteswap.hpp
index dd5dcbc09..26d60c2ab 100644
--- a/host/include/uhd/utils/byteswap.hpp
+++ b/host/include/uhd/utils/byteswap.hpp
@@ -37,6 +37,12 @@ namespace uhd{
//! perform a byteswap on a 64 bit integer
boost::uint64_t byteswap(boost::uint64_t);
+ //! network to host: short, long, or long-long
+ template<typename T> T ntohx(T);
+
+ //! host to network: short, long, or long-long
+ template<typename T> T htonx(T);
+
} //namespace uhd
/***********************************************************************
@@ -117,4 +123,25 @@ namespace uhd{
#endif
+/***********************************************************************
+ * Define the templated network to/from host conversions
+ **********************************************************************/
+#include <boost/detail/endian.hpp>
+
+template<typename T> UHD_INLINE T uhd::ntohx(T num){
+ #ifdef BOOST_BIG_ENDIAN
+ return num;
+ #else
+ return uhd::byteswap(num);
+ #endif
+}
+
+template<typename T> UHD_INLINE T uhd::htonx(T num){
+ #ifdef BOOST_BIG_ENDIAN
+ return num;
+ #else
+ return uhd::byteswap(num);
+ #endif
+}
+
#endif /* INCLUDED_UHD_UTILS_BYTESWAP_HPP */
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 12daa6286..4c66aa41e 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -111,7 +111,9 @@ typedef struct{
struct {
_SINS_ uint32_t addr;
_SINS_ uint32_t data;
- _SINS_ uint8_t num_bytes; //1, 2, 4
+ _SINS_ uint32_t addrhi;
+ _SINS_ uint32_t datahi;
+ _SINS_ uint8_t num_bytes; //1, 2, 4, 8
} poke_args;
} data;
} usrp2_ctrl_data_t;
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 36ac6275f..952954286 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -256,12 +256,14 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
val = _clock_config;
return;
- case MBOARD_PROP_TIME_NOW:
- val = time_spec_t(
- _iface->peek32(U2_REG_TIME64_SECS_RB),
- _iface->peek32(U2_REG_TIME64_TICKS_RB),
- get_master_clock_freq()
- );
+ case MBOARD_PROP_TIME_NOW:{
+ usrp2_iface::pair64 time64(
+ _iface->peek64(U2_REG_TIME64_SECS_RB, U2_REG_TIME64_TICKS_RB)
+ );
+ val = time_spec_t(
+ time64.first, time64.second, get_master_clock_freq()
+ );
+ }
return;
default: UHD_THROW_PROP_GET_ERROR();
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 66a1a57f6..faf4a5c7e 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -59,6 +59,20 @@ public:
return this->peek<boost::uint16_t>(addr);
}
+ pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi){
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO);
+ out_data.data.poke_args.addr = htonl(addrlo);
+ out_data.data.poke_args.addrhi = htonl(addrhi);
+ out_data.data.poke_args.num_bytes = sizeof(boost::uint64_t);
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
+ UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE);
+ return pair64(ntohl(in_data.data.poke_args.data), ntohl(in_data.data.poke_args.datahi));
+ }
+
/***********************************************************************
* SPI
**********************************************************************/
@@ -86,7 +100,7 @@ public:
//send and recv
usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
- UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE);
+ UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE);
return ntohl(in_data.data.spi_args.data);
}
@@ -109,7 +123,7 @@ public:
//send and recv
usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
- UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE);
+ UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE);
}
byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes){
@@ -124,7 +138,7 @@ public:
//send and recv
usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
- UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE);
+ UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE);
UHD_ASSERT_THROW(in_data.data.i2c_args.addr = num_bytes);
//copy out the data
@@ -187,7 +201,7 @@ private:
//send and recv
usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
- UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE);
+ UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE);
}
template <class T> T peek(boost::uint32_t addr){
@@ -199,7 +213,7 @@ private:
//send and recv
usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data);
- UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE);
+ UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE);
return T(ntohl(in_data.data.poke_args.data));
}
diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp
index 7b2a3a89d..9cc32104e 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.hpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.hpp
@@ -23,6 +23,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/cstdint.hpp>
+#include <utility>
#include "fw_common.h"
////////////////////////////////////////////////////////////////////////
@@ -49,6 +50,7 @@
class usrp2_iface : public uhd::i2c_iface, boost::noncopyable{
public:
typedef boost::shared_ptr<usrp2_iface> sptr;
+ typedef std::pair<boost::uint32_t, boost::uint32_t> pair64;
/*!
* Make a new usrp2 interface with the control transport.
@@ -65,6 +67,14 @@ public:
virtual usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &data) = 0;
/*!
+ * Read a dual register (64 bits)
+ * \param addrlo the address for the low-32 bits
+ * \param addrhi the address for the high-32 bits
+ * \return a pair of 32 bit integers lo, hi
+ */
+ virtual pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi) = 0;
+
+ /*!
* Write a register (32 bits)
* \param addr the address
* \param data the 32bit data