aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp9
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp21
-rw-r--r--host/lib/usrp/usrp2/fw_common.h8
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp35
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp1
5 files changed, 55 insertions, 19 deletions
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 32c64f541..da05c3241 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -16,6 +16,7 @@
//
#include <uhd/utils.hpp>
+#include <boost/format.hpp>
#include "usrp2_impl.hpp"
#include "dboard_interface.hpp"
@@ -83,8 +84,8 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_rx_subdev_names();
return;
- case DBOARD_PROP_CODEC:
- throw std::runtime_error("unhandled prop in usrp2 dboard");
+ //case DBOARD_PROP_CODEC:
+ // throw std::runtime_error("unhandled prop in usrp2 dboard");
}
}
@@ -113,8 +114,8 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_tx_subdev_names();
return;
- case DBOARD_PROP_CODEC:
- throw std::runtime_error("unhandled prop in usrp2 dboard");
+ //case DBOARD_PROP_CODEC:
+ // throw std::runtime_error("unhandled prop in usrp2 dboard");
}
}
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index 7831b7667..cb7f58ec8 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -16,6 +16,7 @@
//
#include <uhd/utils.hpp>
+#include <boost/format.hpp>
#include <boost/assign/list_of.hpp>
#include "usrp2_impl.hpp"
@@ -110,7 +111,7 @@ void usrp2_impl::ddc_get(const wax::obj &key, wax::obj &val){
prop_names_t others = boost::assign::list_of
("rate")
("decim")
- ("decim_rates")
+ ("decims")
("freq")
("enabled")
("stream_at")
@@ -131,7 +132,7 @@ void usrp2_impl::ddc_get(const wax::obj &key, wax::obj &val){
val = _ddc_decim;
return;
}
- else if (key_name == "decim_rates"){
+ else if (key_name == "decims"){
val = _allowed_decim_and_interp_rates;
return;
}
@@ -154,10 +155,10 @@ void usrp2_impl::ddc_set(const wax::obj &key, const wax::obj &val){
std::string key_name = wax::cast<std::string>(key);
if (key_name == "decim"){
size_t new_decim = wax::cast<size_t>(val);
- ASSERT_THROW(std::has(
+ assert_has(
_allowed_decim_and_interp_rates,
- new_decim
- ));
+ new_decim, "usrp2 decimation"
+ );
_ddc_decim = new_decim; //shadow
update_ddc_config();
return;
@@ -244,7 +245,7 @@ void usrp2_impl::duc_get(const wax::obj &key, wax::obj &val){
prop_names_t others = boost::assign::list_of
("rate")
("interp")
- ("interp_rates")
+ ("interps")
("freq")
;
val = others;
@@ -263,7 +264,7 @@ void usrp2_impl::duc_get(const wax::obj &key, wax::obj &val){
val = _duc_interp;
return;
}
- else if (key_name == "interp_rates"){
+ else if (key_name == "interps"){
val = _allowed_decim_and_interp_rates;
return;
}
@@ -282,10 +283,10 @@ void usrp2_impl::duc_set(const wax::obj &key, const wax::obj &val){
std::string key_name = wax::cast<std::string>(key);
if (key_name == "interp"){
size_t new_interp = wax::cast<size_t>(val);
- ASSERT_THROW(std::has(
+ assert_has(
_allowed_decim_and_interp_rates,
- new_interp
- ));
+ new_interp, "usrp2 interpolation"
+ );
_duc_interp = new_interp; //shadow
update_duc_config();
return;
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 8e4b2ba35..10c1ef8cf 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -91,6 +91,9 @@ typedef enum{
USRP2_CTRL_ID_SETUP_THIS_DUC_FOR_ME_BRO,
USRP2_CTRL_ID_TOTALLY_SETUP_THE_DUC_DUDE,
+ USRP2_CTRL_ID_GOT_A_NEW_TIME_FOR_YOU_BRO,
+ USRP2_CTRL_ID_SWEET_I_GOT_THAT_TIME_DUDE,
+
USRP2_CTRL_ID_PEACE_OUT
} usrp2_ctrl_id_t;
@@ -186,6 +189,11 @@ typedef struct{
uint32_t interp;
uint32_t scale_iq;
} duc_args;
+ struct {
+ uint32_t secs;
+ uint32_t ticks;
+ uint8_t now;
+ } time_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 8e682a675..47e22c473 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -28,6 +28,10 @@ void usrp2_impl::mboard_init(void){
boost::bind(&usrp2_impl::mboard_get, this, _1, _2),
boost::bind(&usrp2_impl::mboard_set, this, _1, _2)
);
+
+ //set the time on the usrp2 as close as possible to the system utc time
+ boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
+ set_time_spec(time_spec_t(now, get_master_clock_freq()), true);
}
void usrp2_impl::init_clock_config(void){
@@ -64,6 +68,19 @@ void usrp2_impl::update_clock_config(void){
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THE_NEW_CLOCK_CONFIG_DUDE);
}
+void usrp2_impl::set_time_spec(const time_spec_t &time_spec, bool now){
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_GOT_A_NEW_TIME_FOR_YOU_BRO);
+ out_data.data.time_args.secs = htonl(time_spec.secs);
+ out_data.data.time_args.ticks = htonl(time_spec.ticks);
+ out_data.data.time_args.now = (now)? 1 : 0;
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_SWEET_I_GOT_THAT_TIME_DUDE);
+}
+
/***********************************************************************
* MBoard Get Properties
**********************************************************************/
@@ -157,7 +174,7 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
case MBOARD_PROP_PPS_SOURCE:{
std::string name = wax::cast<std::string>(val);
- ASSERT_THROW(_pps_source_dict.has_key(name));
+ assert_has(_pps_source_dict.get_keys(), name, "usrp2 pps source");
_pps_source = name; //shadow
update_clock_config();
}
@@ -165,7 +182,7 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
case MBOARD_PROP_PPS_POLARITY:{
std::string name = wax::cast<std::string>(val);
- ASSERT_THROW(_pps_polarity_dict.has_key(name));
+ assert_has(_pps_polarity_dict.get_keys(), name, "usrp2 pps polarity");
_pps_polarity = name; //shadow
update_clock_config();
}
@@ -173,12 +190,22 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
case MBOARD_PROP_REF_SOURCE:{
std::string name = wax::cast<std::string>(val);
- ASSERT_THROW(_ref_source_dict.has_key(name));
+ assert_has(_ref_source_dict.get_keys(), name, "usrp2 reference source");
_ref_source = name; //shadow
update_clock_config();
}
return;
+ case MBOARD_PROP_TIME_NOW:{
+ set_time_spec(wax::cast<time_spec_t>(val), true);
+ return;
+ }
+
+ case MBOARD_PROP_TIME_NEXT_PPS:{
+ set_time_spec(wax::cast<time_spec_t>(val), false);
+ return;
+ }
+
case MBOARD_PROP_NAME:
case MBOARD_PROP_OTHERS:
case MBOARD_PROP_CLOCK_RATE:
@@ -192,8 +219,6 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
case MBOARD_PROP_TX_DBOARD_NAMES:
case MBOARD_PROP_PPS_SOURCE_NAMES:
case MBOARD_PROP_REF_SOURCE_NAMES:
- case MBOARD_PROP_TIME_NOW:
- case MBOARD_PROP_TIME_NEXT_PPS:
throw std::runtime_error("Error: trying to set read-only property on usrp2 mboard");
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index f4e6054bd..fc713c2bf 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -135,6 +135,7 @@ private:
std::string _pps_source, _pps_polarity, _ref_source;
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;