aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-04 21:13:53 +0000
committerJosh Blum <josh@joshknows.com>2010-06-04 21:13:53 +0000
commit9fa97e153d01985bc7bdf9db8a97d79a328a3e61 (patch)
tree68606b25eff9d2d88878bbd89c794fc86ac18fb5
parent685cf432a373ee7556db507f7958f51e6ccf581a (diff)
parent4f0736ef7ce93d58f0768d99257b2624d5711490 (diff)
downloaduhd-9fa97e153d01985bc7bdf9db8a97d79a328a3e61.tar.gz
uhd-9fa97e153d01985bc7bdf9db8a97d79a328a3e61.tar.bz2
uhd-9fa97e153d01985bc7bdf9db8a97d79a328a3e61.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp_e
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.cpp14
-rw-r--r--host/lib/usrp/usrp2/clock_ctrl.hpp10
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp10
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.hpp4
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp13
-rw-r--r--host/lib/usrp/usrp2/serdes_ctrl.cpp10
-rw-r--r--host/lib/usrp/usrp2/serdes_ctrl.hpp4
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp20
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.hpp6
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp15
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp12
11 files changed, 60 insertions, 58 deletions
diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index 4c5207203..d9baa66cf 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -25,9 +25,9 @@ using namespace uhd;
/*!
* A usrp2 clock control specific to the ad9510 ic.
*/
-class clock_ctrl_impl : public clock_ctrl{
+class usrp2_clock_ctrl_impl : public usrp2_clock_ctrl{
public:
- clock_ctrl_impl(usrp2_iface::sptr iface){
+ usrp2_clock_ctrl_impl(usrp2_iface::sptr iface){
_iface = iface;
_ad9510_regs.cp_current_setting = ad9510_regs_t::CP_CURRENT_SETTING_3_0MA;
@@ -68,7 +68,7 @@ public:
}
- ~clock_ctrl_impl(void){
+ ~usrp2_clock_ctrl_impl(void){
/* private clock enables, must be set here */
this->enable_dac_clock(false);
this->enable_adc_clock(false);
@@ -110,6 +110,10 @@ public:
this->update_regs();
}
+ double get_master_clock_rate(void){
+ return 100e6;
+ }
+
private:
/*!
* Write a single register to the spi regs.
@@ -158,6 +162,6 @@ private:
/***********************************************************************
* Public make function for the ad9510 clock control
**********************************************************************/
-clock_ctrl::sptr clock_ctrl::make(usrp2_iface::sptr iface){
- return sptr(new clock_ctrl_impl(iface));
+usrp2_clock_ctrl::sptr usrp2_clock_ctrl::make(usrp2_iface::sptr iface){
+ return sptr(new usrp2_clock_ctrl_impl(iface));
}
diff --git a/host/lib/usrp/usrp2/clock_ctrl.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp
index 706bf4246..0ad8d9532 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.hpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.hpp
@@ -22,9 +22,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-class clock_ctrl : boost::noncopyable{
+class usrp2_clock_ctrl : boost::noncopyable{
public:
- typedef boost::shared_ptr<clock_ctrl> sptr;
+ typedef boost::shared_ptr<usrp2_clock_ctrl> sptr;
/*!
* Make a clock config for the ad9510 ic.
@@ -34,6 +34,12 @@ public:
static sptr make(usrp2_iface::sptr iface);
/*!
+ * Get the master clock frequency for the fpga.
+ * \return the clock frequency in Hz
+ */
+ virtual double get_master_clock_rate(void) = 0;
+
+ /*!
* Enable/disable the rx dboard clock.
* \param enb true to enable
*/
diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp
index d698216ba..abd840027 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.cpp
@@ -29,9 +29,9 @@ using namespace uhd;
/*!
* A usrp2 codec control specific to the ad9777 ic.
*/
-class codec_ctrl_impl : public codec_ctrl{
+class usrp2_codec_ctrl_impl : public usrp2_codec_ctrl{
public:
- codec_ctrl_impl(usrp2_iface::sptr iface){
+ usrp2_codec_ctrl_impl(usrp2_iface::sptr iface){
_iface = iface;
//setup the ad9777 dac
@@ -60,7 +60,7 @@ public:
_iface->poke32(FR_MISC_CTRL_ADC, FRF_MISC_CTRL_ADC_ON);
}
- ~codec_ctrl_impl(void){
+ ~usrp2_codec_ctrl_impl(void){
//power-down dac
_ad9777_regs.power_down_mode = 1;
this->send_ad9777_reg(0);
@@ -86,6 +86,6 @@ private:
/***********************************************************************
* Public make function for the usrp2 codec control
**********************************************************************/
-codec_ctrl::sptr codec_ctrl::make(usrp2_iface::sptr iface){
- return sptr(new codec_ctrl_impl(iface));
+usrp2_codec_ctrl::sptr usrp2_codec_ctrl::make(usrp2_iface::sptr iface){
+ return sptr(new usrp2_codec_ctrl_impl(iface));
}
diff --git a/host/lib/usrp/usrp2/codec_ctrl.hpp b/host/lib/usrp/usrp2/codec_ctrl.hpp
index 0ee52f476..ad014e0e1 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.hpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.hpp
@@ -22,9 +22,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-class codec_ctrl : boost::noncopyable{
+class usrp2_codec_ctrl : boost::noncopyable{
public:
- typedef boost::shared_ptr<codec_ctrl> sptr;
+ typedef boost::shared_ptr<usrp2_codec_ctrl> sptr;
/*!
* Make a codec control for the DAC and ADC.
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index 2621d43b4..feee0a970 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -33,7 +33,7 @@ using namespace boost::assign;
class usrp2_dboard_iface : public dboard_iface{
public:
- usrp2_dboard_iface(usrp2_iface::sptr iface, clock_ctrl::sptr clock_ctrl);
+ usrp2_dboard_iface(usrp2_iface::sptr iface, usrp2_clock_ctrl::sptr clock_ctrl);
~usrp2_dboard_iface(void);
void write_aux_dac(unit_t, int, float);
@@ -68,7 +68,7 @@ public:
private:
usrp2_iface::sptr _iface;
- clock_ctrl::sptr _clock_ctrl;
+ usrp2_clock_ctrl::sptr _clock_ctrl;
boost::uint32_t _ddr_shadow;
boost::uint32_t _gpio_shadow;
@@ -81,7 +81,7 @@ private:
**********************************************************************/
dboard_iface::sptr make_usrp2_dboard_iface(
usrp2_iface::sptr iface,
- clock_ctrl::sptr clock_ctrl
+ usrp2_clock_ctrl::sptr clock_ctrl
){
return dboard_iface::sptr(new usrp2_dboard_iface(iface, clock_ctrl));
}
@@ -89,7 +89,10 @@ dboard_iface::sptr make_usrp2_dboard_iface(
/***********************************************************************
* Structors
**********************************************************************/
-usrp2_dboard_iface::usrp2_dboard_iface(usrp2_iface::sptr iface, clock_ctrl::sptr clock_ctrl){
+usrp2_dboard_iface::usrp2_dboard_iface(
+ usrp2_iface::sptr iface,
+ usrp2_clock_ctrl::sptr clock_ctrl
+){
_iface = iface;
_clock_ctrl = clock_ctrl;
_ddr_shadow = 0;
@@ -114,7 +117,7 @@ usrp2_dboard_iface::~usrp2_dboard_iface(void){
* Clocks
**********************************************************************/
double usrp2_dboard_iface::get_clock_rate(unit_t){
- return _iface->get_master_clock_freq();
+ return _clock_ctrl->get_master_clock_rate();
}
void usrp2_dboard_iface::set_clock_enabled(unit_t unit, bool enb){
diff --git a/host/lib/usrp/usrp2/serdes_ctrl.cpp b/host/lib/usrp/usrp2/serdes_ctrl.cpp
index dde22b499..31708d377 100644
--- a/host/lib/usrp/usrp2/serdes_ctrl.cpp
+++ b/host/lib/usrp/usrp2/serdes_ctrl.cpp
@@ -23,14 +23,14 @@ using namespace uhd;
/*!
* A usrp2 serdes control implementation
*/
-class serdes_ctrl_impl : public serdes_ctrl{
+class usrp2_serdes_ctrl_impl : public usrp2_serdes_ctrl{
public:
- serdes_ctrl_impl(usrp2_iface::sptr iface){
+ usrp2_serdes_ctrl_impl(usrp2_iface::sptr iface){
_iface = iface;
_iface->poke32(FR_MISC_CTRL_SERDES, FRF_MISC_CTRL_SERDES_ENABLE | FRF_MISC_CTRL_SERDES_RXEN);
}
- ~serdes_ctrl_impl(void){
+ ~usrp2_serdes_ctrl_impl(void){
_iface->poke32(FR_MISC_CTRL_SERDES, 0); //power-down
}
@@ -41,6 +41,6 @@ private:
/***********************************************************************
* Public make function for the usrp2 serdes control
**********************************************************************/
-serdes_ctrl::sptr serdes_ctrl::make(usrp2_iface::sptr iface){
- return sptr(new serdes_ctrl_impl(iface));
+usrp2_serdes_ctrl::sptr usrp2_serdes_ctrl::make(usrp2_iface::sptr iface){
+ return sptr(new usrp2_serdes_ctrl_impl(iface));
}
diff --git a/host/lib/usrp/usrp2/serdes_ctrl.hpp b/host/lib/usrp/usrp2/serdes_ctrl.hpp
index 586238739..3c909c531 100644
--- a/host/lib/usrp/usrp2/serdes_ctrl.hpp
+++ b/host/lib/usrp/usrp2/serdes_ctrl.hpp
@@ -22,9 +22,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-class serdes_ctrl : boost::noncopyable{
+class usrp2_serdes_ctrl : boost::noncopyable{
public:
- typedef boost::shared_ptr<serdes_ctrl> sptr;
+ typedef boost::shared_ptr<usrp2_serdes_ctrl> sptr;
/*!
* Make a serdes control object for the usrp2 serdes port.
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index e43b9678e..6e0d3266a 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -146,18 +146,19 @@ public:
_ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t)));
//loop until we get the packet or timeout
+ boost::uint8_t usrp2_ctrl_data_in_mem[1500]; //allocate MTU bytes for recv
+ usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);
while(true){
- usrp2_ctrl_data_t in_data;
- size_t len = _ctrl_transport->recv(boost::asio::buffer(&in_data, sizeof(in_data)));
- if(len >= sizeof(boost::uint32_t) and ntohl(in_data.proto_ver) != USRP2_PROTO_VERSION){
+ size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem));
+ if(len >= sizeof(boost::uint32_t) and ntohl(ctrl_data_in->proto_ver) != USRP2_PROTO_VERSION){
throw std::runtime_error(str(
boost::format("Expected protocol version %d, but got %d\n"
"The firmware build does not match the host code build."
- ) % int(USRP2_PROTO_VERSION) % ntohl(in_data.proto_ver)
+ ) % int(USRP2_PROTO_VERSION) % ntohl(ctrl_data_in->proto_ver)
));
}
- if (len >= sizeof(usrp2_ctrl_data_t) and ntohl(in_data.seq) == _ctrl_seq_num){
- return in_data;
+ if (len >= sizeof(usrp2_ctrl_data_t) and ntohl(ctrl_data_in->seq) == _ctrl_seq_num){
+ return *ctrl_data_in;
}
if (len == 0) break; //timeout
//didnt get seq or bad packet, continue looking...
@@ -165,13 +166,6 @@ public:
throw std::runtime_error("usrp2 no control response");
}
-/***********************************************************************
- * Master Clock! Ahhhhh
- **********************************************************************/
- double get_master_clock_freq(void){
- return 100e6;
- }
-
private:
//this lovely lady makes it all possible
transport::udp_simple::sptr _ctrl_transport;
diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp
index caf6623e2..7b2a3a89d 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.hpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.hpp
@@ -108,12 +108,6 @@ public:
size_t num_bits,
bool readback
) = 0;
-
- /*!
- * Get the master clock frequency.
- * \return the frequency in Hz
- */
- virtual double get_master_clock_freq(void) = 0;
};
#endif /* INCLUDED_USRP2_IFACE_HPP */
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index af3ec216a..58f0696b5 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -76,16 +76,17 @@ uhd::device_addrs_t usrp2::find(const device_addr_t &hint){
udp_transport->send(boost::asio::buffer(&ctrl_data_out, sizeof(ctrl_data_out)));
//loop and recieve until the timeout
+ boost::uint8_t usrp2_ctrl_data_in_mem[1500]; //allocate MTU bytes for recv
+ usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);
while(true){
- usrp2_ctrl_data_t ctrl_data_in;
- size_t len = udp_transport->recv(asio::buffer(&ctrl_data_in, sizeof(ctrl_data_in)));
+ size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem));
//std::cout << len << "\n";
if (len >= sizeof(usrp2_ctrl_data_t)){
//handle the received data
- switch(ntohl(ctrl_data_in.id)){
+ switch(ntohl(ctrl_data_in->id)){
case USRP2_CTRL_ID_WAZZUP_DUDE:
//make a boost asio ipv4 with the raw addr in host byte order
- boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in.data.ip_addr));
+ boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
device_addr_t new_addr;
new_addr["name"] = "USRP2";
new_addr["addr"] = ip_addr.to_string();
@@ -147,9 +148,9 @@ usrp2_impl::usrp2_impl(
//make a new interface for usrp2 stuff
_iface = usrp2_iface::make(ctrl_transport);
- _clock_ctrl = clock_ctrl::make(_iface);
- _codec_ctrl = codec_ctrl::make(_iface);
- _serdes_ctrl = serdes_ctrl::make(_iface);
+ _clock_ctrl = usrp2_clock_ctrl::make(_iface);
+ _codec_ctrl = usrp2_codec_ctrl::make(_iface);
+ _serdes_ctrl = usrp2_serdes_ctrl::make(_iface);
//load the allowed decim/interp rates
//_USRP2_RATES = range(4, 128+1, 1) + range(130, 256+1, 2) + range(260, 512+1, 4)
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 40c193866..6ad151a0a 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -43,7 +43,7 @@
*/
uhd::usrp::dboard_iface::sptr make_usrp2_dboard_iface(
usrp2_iface::sptr iface,
- clock_ctrl::sptr clk_ctrl
+ usrp2_clock_ctrl::sptr clk_ctrl
);
/*!
@@ -124,8 +124,8 @@ public:
);
private:
- double get_master_clock_freq(void){
- return _iface->get_master_clock_freq();
+ inline double get_master_clock_freq(void){
+ return _clock_ctrl->get_master_clock_rate();
}
//device properties interface
@@ -134,9 +134,9 @@ private:
//interfaces
usrp2_iface::sptr _iface;
- clock_ctrl::sptr _clock_ctrl;
- codec_ctrl::sptr _codec_ctrl;
- serdes_ctrl::sptr _serdes_ctrl;
+ usrp2_clock_ctrl::sptr _clock_ctrl;
+ usrp2_codec_ctrl::sptr _codec_ctrl;
+ usrp2_serdes_ctrl::sptr _serdes_ctrl;
/*******************************************************************
* Deal with the rx and tx packet sizes