aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-22 09:50:35 +0000
committerJosh Blum <josh@joshknows.com>2010-03-22 09:50:35 +0000
commit6ba5135c96d81d23eafa4f0740ebbf113d8c798f (patch)
tree50dbe1ac4d36c1a00374718d478617dbb18cd2ef /host/lib/usrp/usrp2
parent10ee8022dd22f13f942d8bfeeca3b380224fff52 (diff)
parentd66efda608db9f6a1c2ab64659556b53810d87b7 (diff)
downloaduhd-6ba5135c96d81d23eafa4f0740ebbf113d8c798f.tar.gz
uhd-6ba5135c96d81d23eafa4f0740ebbf113d8c798f.tar.bz2
uhd-6ba5135c96d81d23eafa4f0740ebbf113d8c798f.zip
Merge branch 'master' of git@ettus.sourcerepo.com:ettus/uhd into u1e_uhd
Conflicts: host/include/uhd/usrp/dboard_id.hpp
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp4
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp4
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp84
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp54
5 files changed, 66 insertions, 82 deletions
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 60622ca47..66e02d469 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -45,11 +45,11 @@ void usrp2_impl::dboard_init(void){
);
//load dboards
- _rx_dboards[""] = wax_obj_proxy(
+ _rx_dboards[""] = wax_obj_proxy::make(
boost::bind(&usrp2_impl::rx_dboard_get, this, _1, _2),
boost::bind(&usrp2_impl::rx_dboard_set, this, _1, _2)
);
- _tx_dboards[""] = wax_obj_proxy(
+ _tx_dboards[""] = wax_obj_proxy::make(
boost::bind(&usrp2_impl::tx_dboard_get, this, _1, _2),
boost::bind(&usrp2_impl::tx_dboard_set, this, _1, _2)
);
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index 54ed45e41..34cce0afb 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -53,7 +53,7 @@ static boost::uint32_t calculate_iq_scale_word(boost::int16_t i, boost::int16_t
void usrp2_impl::init_ddc_config(void){
//create the ddc in the rx dsp dict
- _rx_dsps["ddc0"] = wax_obj_proxy(
+ _rx_dsps["ddc0"] = wax_obj_proxy::make(
boost::bind(&usrp2_impl::ddc_get, this, _1, _2),
boost::bind(&usrp2_impl::ddc_set, this, _1, _2)
);
@@ -201,7 +201,7 @@ void usrp2_impl::ddc_set(const wax::obj &key, const wax::obj &val){
**********************************************************************/
void usrp2_impl::init_duc_config(void){
//create the duc in the tx dsp dict
- _tx_dsps["duc0"] = wax_obj_proxy(
+ _tx_dsps["duc0"] = wax_obj_proxy::make(
boost::bind(&usrp2_impl::duc_get, this, _1, _2),
boost::bind(&usrp2_impl::duc_set, this, _1, _2)
);
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 4b15c7f3e..cbca8eec7 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -16,7 +16,6 @@
//
#include <uhd/utils.hpp>
-#include <boost/assign/list_of.hpp>
#include "usrp2_impl.hpp"
using namespace uhd;
@@ -25,7 +24,7 @@ using namespace uhd;
* Helper Methods
**********************************************************************/
void usrp2_impl::mboard_init(void){
- _mboards[""] = wax_obj_proxy(
+ _mboards[""] = wax_obj_proxy::make(
boost::bind(&usrp2_impl::mboard_get, this, _1, _2),
boost::bind(&usrp2_impl::mboard_set, this, _1, _2)
);
@@ -36,21 +35,27 @@ void usrp2_impl::mboard_init(void){
}
void usrp2_impl::init_clock_config(void){
+ //init the ref source clock config
+ _ref_source_dict = boost::assign::map_list_of
+ ("int", USRP2_REF_SOURCE_INT)
+ ("sma", USRP2_REF_SOURCE_SMA)
+ ("mimo", USRP2_REF_SOURCE_MIMO)
+ ;
+ _clock_config.ref_source = "int";
+
//init the pps source clock config
- _pps_source_dict["sma"] = USRP2_PPS_SOURCE_SMA;
- _pps_source_dict["mimo"] = USRP2_PPS_SOURCE_MIMO;
- _pps_source = "sma";
+ _pps_source_dict = boost::assign::map_list_of
+ ("sma", USRP2_PPS_SOURCE_SMA)
+ ("mimo", USRP2_PPS_SOURCE_MIMO)
+ ;
+ _clock_config.pps_source = "sma";
//init the pps polarity clock config
- _pps_polarity_dict["pos"] = USRP2_PPS_POLARITY_POS;
- _pps_polarity_dict["neg"] = USRP2_PPS_POLARITY_NEG;
- _pps_polarity = "neg";
-
- //init the ref source clock config
- _ref_source_dict["int"] = USRP2_REF_SOURCE_INT;
- _ref_source_dict["sma"] = USRP2_REF_SOURCE_SMA;
- _ref_source_dict["mimo"] = USRP2_REF_SOURCE_MIMO;
- _ref_source = "int";
+ _pps_polarity_dict = boost::assign::map_list_of
+ (clock_config_t::POLARITY_POS, USRP2_PPS_POLARITY_POS)
+ (clock_config_t::POLARITY_NEG, USRP2_PPS_POLARITY_NEG)
+ ;
+ _clock_config.pps_polarity = clock_config_t::POLARITY_NEG;
//update the clock config (sends a control packet)
update_clock_config();
@@ -60,9 +65,9 @@ void usrp2_impl::update_clock_config(void){
//setup the out data
usrp2_ctrl_data_t out_data;
out_data.id = htonl(USRP2_CTRL_ID_HERES_A_NEW_CLOCK_CONFIG_BRO);
- out_data.data.clock_config.pps_source = _pps_source_dict [_pps_source];
- out_data.data.clock_config.pps_polarity = _pps_polarity_dict[_pps_polarity];
- out_data.data.clock_config.ref_source = _ref_source_dict [_ref_source];
+ out_data.data.clock_config.ref_source = _ref_source_dict [_clock_config.ref_source];
+ out_data.data.clock_config.pps_source = _pps_source_dict [_clock_config.pps_source];
+ out_data.data.clock_config.pps_polarity = _pps_polarity_dict[_clock_config.pps_polarity];
//send and recv
usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
@@ -137,7 +142,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
case MBOARD_PROP_RX_DBOARD:
ASSERT_THROW(_rx_dboards.has_key(name));
- val = _rx_dboards[name].get_link();
+ val = _rx_dboards[name]->get_link();
return;
case MBOARD_PROP_RX_DBOARD_NAMES:
@@ -146,7 +151,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
case MBOARD_PROP_TX_DBOARD:
ASSERT_THROW(_tx_dboards.has_key(name));
- val = _tx_dboards[name].get_link();
+ val = _tx_dboards[name]->get_link();
return;
case MBOARD_PROP_TX_DBOARD_NAMES:
@@ -159,7 +164,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
case MBOARD_PROP_RX_DSP:
ASSERT_THROW(_rx_dsps.has_key(name));
- val = _rx_dsps[name].get_link();
+ val = _rx_dsps[name]->get_link();
return;
case MBOARD_PROP_RX_DSP_NAMES:
@@ -168,29 +173,21 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
case MBOARD_PROP_TX_DSP:
ASSERT_THROW(_tx_dsps.has_key(name));
- val = _tx_dsps[name].get_link();
+ val = _tx_dsps[name]->get_link();
return;
case MBOARD_PROP_TX_DSP_NAMES:
val = prop_names_t(_tx_dsps.get_keys());
return;
- case MBOARD_PROP_PPS_SOURCE:
- val = _pps_source;
+ case MBOARD_PROP_CLOCK_CONFIG:
+ val = _clock_config;
return;
case MBOARD_PROP_PPS_SOURCE_NAMES:
val = prop_names_t(_pps_source_dict.get_keys());
return;
- case MBOARD_PROP_PPS_POLARITY:
- val = _pps_polarity;
- return;
-
- case MBOARD_PROP_REF_SOURCE:
- val = _ref_source;
- return;
-
case MBOARD_PROP_REF_SOURCE_NAMES:
val = prop_names_t(_ref_source_dict.get_keys());
return;
@@ -237,26 +234,11 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
- case MBOARD_PROP_PPS_SOURCE:{
- std::string name = val.as<std::string>();
- assert_has(_pps_source_dict.get_keys(), name, "usrp2 pps source");
- _pps_source = name; //shadow
- update_clock_config();
- }
- return;
-
- case MBOARD_PROP_PPS_POLARITY:{
- std::string name = val.as<std::string>();
- assert_has(_pps_polarity_dict.get_keys(), name, "usrp2 pps polarity");
- _pps_polarity = name; //shadow
- update_clock_config();
- }
- return;
-
- case MBOARD_PROP_REF_SOURCE:{
- std::string name = val.as<std::string>();
- assert_has(_ref_source_dict.get_keys(), name, "usrp2 reference source");
- _ref_source = name; //shadow
+ case MBOARD_PROP_CLOCK_CONFIG:{
+ clock_config_t clock_config = val.as<clock_config_t>();
+ assert_has(_pps_source_dict.get_keys(), clock_config.pps_source, "usrp2 pps source");
+ assert_has(_ref_source_dict.get_keys(), clock_config.ref_source, "usrp2 ref source");
+ _clock_config = clock_config; //shadow
update_clock_config();
}
return;
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index e1371a094..85d73e83a 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -193,7 +193,7 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
case DEVICE_PROP_MBOARD:
ASSERT_THROW(_mboards.has_key(name));
- val = _mboards[name].get_link();
+ val = _mboards[name]->get_link();
return;
case DEVICE_PROP_MBOARD_NAMES:
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 765c523fe..70420fd49 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -15,22 +15,23 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#ifndef INCLUDED_USRP2_IMPL_HPP
+#define INCLUDED_USRP2_IMPL_HPP
+
#include <uhd/usrp/usrp2.hpp>
#include <uhd/dict.hpp>
-#include <uhd/props.hpp>
+#include <uhd/types.hpp>
#include <uhd/time_spec.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
+#include <boost/assign/list_of.hpp>
#include <uhd/transport/vrt.hpp>
#include <uhd/transport/udp_simple.hpp>
#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include "fw_common.h"
-#ifndef INCLUDED_USRP2_IMPL_HPP
-#define INCLUDED_USRP2_IMPL_HPP
-
class usrp2_impl; //dummy class declaration
/*!
@@ -50,20 +51,25 @@ class wax_obj_proxy : public wax::obj{
public:
typedef boost::function<void(const wax::obj &, wax::obj &)> get_t;
typedef boost::function<void(const wax::obj &, const wax::obj &)> set_t;
+ typedef boost::shared_ptr<wax_obj_proxy> sptr;
+
+ static sptr make(const get_t &get, const set_t &set){
+ return sptr(new wax_obj_proxy(get, set));
+ }
- wax_obj_proxy(void){
+ ~wax_obj_proxy(void){
/* NOP */
}
+private:
+ get_t _get;
+ set_t _set;
+
wax_obj_proxy(const get_t &get, const set_t &set){
_get = get;
_set = set;
};
- ~wax_obj_proxy(void){
- /* NOP */
- }
-
void get(const wax::obj &key, wax::obj &val){
return _get(key, val);
}
@@ -71,10 +77,6 @@ public:
void set(const wax::obj &key, const wax::obj &val){
return _set(key, val);
}
-
-private:
- get_t _get;
- set_t _set;
};
/*!
@@ -98,10 +100,6 @@ public:
~usrp2_impl(void);
- //properties interface
- void get(const wax::obj &, wax::obj &);
- void set(const wax::obj &, const wax::obj &);
-
//performs a control transaction
usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &);
@@ -113,6 +111,10 @@ public:
size_t recv(const boost::asio::mutable_buffer &, uhd::rx_metadata_t &, const std::string &);
private:
+ //device properties interface
+ void get(const wax::obj &, wax::obj &);
+ void set(const wax::obj &, const wax::obj &);
+
//the raw io interface (samples are in the usrp2 native format)
void recv_raw(uhd::rx_metadata_t &);
uhd::dict<boost::uint32_t, size_t> _tx_stream_id_to_packet_seq;
@@ -141,15 +143,15 @@ private:
boost::mutex _ctrl_mutex;
//methods and shadows for clock configuration
- std::string _pps_source, _pps_polarity, _ref_source;
+ uhd::clock_config_t _clock_config;
void init_clock_config(void);
void update_clock_config(void);
void set_time_spec(const uhd::time_spec_t &time_spec, bool now);
//mappings from clock config strings to over the wire enums
- uhd::dict<std::string, usrp2_pps_source_t> _pps_source_dict;
- uhd::dict<std::string, usrp2_pps_polarity_t> _pps_polarity_dict;
- uhd::dict<std::string, usrp2_ref_source_t> _ref_source_dict;
+ uhd::dict<std::string, usrp2_ref_source_t> _ref_source_dict;
+ uhd::dict<std::string, usrp2_pps_source_t> _pps_source_dict;
+ uhd::dict<uhd::clock_config_t::polarity_t, usrp2_pps_polarity_t> _pps_polarity_dict;
//rx and tx dboard methods and objects
uhd::usrp::dboard_manager::sptr _dboard_manager;
@@ -159,18 +161,18 @@ private:
void mboard_init(void);
void mboard_get(const wax::obj &, wax::obj &);
void mboard_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, wax_obj_proxy> _mboards;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _mboards;
//properties interface for rx dboard
void rx_dboard_get(const wax::obj &, wax::obj &);
void rx_dboard_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, wax_obj_proxy> _rx_dboards;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _rx_dboards;
uhd::prop_names_t _rx_subdevs_in_use;
//properties interface for tx dboard
void tx_dboard_get(const wax::obj &, wax::obj &);
void tx_dboard_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, wax_obj_proxy> _tx_dboards;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _tx_dboards;
uhd::prop_names_t _tx_subdevs_in_use;
void update_mux_config(void);
@@ -193,12 +195,12 @@ private:
//properties interface for ddc
void ddc_get(const wax::obj &, wax::obj &);
void ddc_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, wax_obj_proxy> _rx_dsps;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _rx_dsps;
//properties interface for duc
void duc_get(const wax::obj &, wax::obj &);
void duc_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, wax_obj_proxy> _tx_dsps;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _tx_dsps;
};