aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/dboard/basic.cpp1
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp74
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp11
3 files changed, 35 insertions, 51 deletions
diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp
index 02b391244..82485ae6a 100644
--- a/host/lib/usrp/dboard/basic.cpp
+++ b/host/lib/usrp/dboard/basic.cpp
@@ -17,6 +17,7 @@
#include <uhd/utils.hpp>
#include <uhd/props.hpp>
+#include <uhd/types.hpp>
#include <uhd/usrp/dboard_base.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <boost/assign/list_of.hpp>
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 4f63e6cc9..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;
@@ -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);
@@ -175,22 +180,14 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
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.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 59e23aba5..70420fd49 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -20,11 +20,12 @@
#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>
@@ -142,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;