aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/mboard_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp')
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp96
1 files changed, 62 insertions, 34 deletions
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 7594c85fa..94ab88a6b 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -29,7 +29,7 @@ using namespace uhd::usrp;
* Helper Methods
**********************************************************************/
void usrp2_impl::mboard_init(void){
- _mboards[""] = wax_obj_proxy::make(
+ _mboard_proxy = wax_obj_proxy::make(
boost::bind(&usrp2_impl::mboard_get, this, _1, _2),
boost::bind(&usrp2_impl::mboard_set, this, _1, _2)
);
@@ -67,19 +67,56 @@ void usrp2_impl::update_clock_config(void){
}
//set the pps flags
- this->poke(FR_TIME64_FLAGS, pps_flags);
+ this->poke32(FR_TIME64_FLAGS, pps_flags);
//TODO clock source ref 10mhz (spi ad9510)
}
void usrp2_impl::set_time_spec(const time_spec_t &time_spec, bool now){
//set ticks and seconds
- this->poke(FR_TIME64_SECS, time_spec.secs);
- this->poke(FR_TIME64_TICKS, time_spec.ticks);
+ this->poke32(FR_TIME64_SECS, time_spec.secs);
+ this->poke32(FR_TIME64_TICKS, time_spec.ticks);
//set the register to latch it all in
boost::uint32_t imm_flags = (now)? FRF_TIME64_LATCH_NOW : FRF_TIME64_LATCH_NEXT_PPS;
- this->poke(FR_TIME64_IMM, imm_flags);
+ this->poke32(FR_TIME64_IMM, imm_flags);
+}
+
+void usrp2_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
+ //setup the out data
+ usrp2_ctrl_data_t out_data;
+ out_data.id = htonl(USRP2_CTRL_ID_SEND_STREAM_COMMAND_FOR_ME_BRO);
+ out_data.data.stream_cmd.now = (stream_cmd.stream_now)? 1 : 0;
+ out_data.data.stream_cmd.secs = htonl(stream_cmd.time_spec.secs);
+ out_data.data.stream_cmd.ticks = htonl(stream_cmd.time_spec.ticks);
+
+ //set these to defaults, then change in the switch statement
+ out_data.data.stream_cmd.continuous = 0;
+ out_data.data.stream_cmd.chain = 0;
+ out_data.data.stream_cmd.num_samps = htonl(stream_cmd.num_samps);
+
+ //setup chain, num samps, and continuous below
+ switch(stream_cmd.stream_mode){
+ case stream_cmd_t::STREAM_MODE_START_CONTINUOUS:
+ out_data.data.stream_cmd.continuous = 1;
+ break;
+
+ case stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS:
+ out_data.data.stream_cmd.num_samps = htonl(0);
+ break;
+
+ case stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE:
+ //all set by defaults above
+ break;
+
+ case stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE:
+ out_data.data.stream_cmd.chain = 1;
+ break;
+ }
+
+ //send and recv
+ usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THAT_STREAM_COMMAND_DUDE);
}
/***********************************************************************
@@ -136,21 +173,21 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
return;
case MBOARD_PROP_RX_DBOARD:
- ASSERT_THROW(_rx_dboards.has_key(name));
- val = _rx_dboards[name]->get_link();
+ ASSERT_THROW(name == "");
+ val = _rx_dboard_proxy->get_link();
return;
case MBOARD_PROP_RX_DBOARD_NAMES:
- val = prop_names_t(_rx_dboards.get_keys());
+ val = prop_names_t(1, "");
return;
case MBOARD_PROP_TX_DBOARD:
- ASSERT_THROW(_tx_dboards.has_key(name));
- val = _tx_dboards[name]->get_link();
+ ASSERT_THROW(name == "");
+ val = _tx_dboard_proxy->get_link();
return;
case MBOARD_PROP_TX_DBOARD_NAMES:
- val = prop_names_t(_tx_dboards.get_keys());
+ val = prop_names_t(1, "");
return;
case MBOARD_PROP_CLOCK_RATE:
@@ -158,29 +195,28 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
return;
case MBOARD_PROP_RX_DSP:
- ASSERT_THROW(_rx_dsps.has_key(name));
- val = _rx_dsps[name]->get_link();
+ ASSERT_THROW(name == "");
+ val = _rx_dsp_proxy->get_link();
return;
case MBOARD_PROP_RX_DSP_NAMES:
- val = prop_names_t(_rx_dsps.get_keys());
+ val = prop_names_t(1, "");
return;
case MBOARD_PROP_TX_DSP:
- ASSERT_THROW(_tx_dsps.has_key(name));
- val = _tx_dsps[name]->get_link();
+ ASSERT_THROW(name == "");
+ val = _tx_dsp_proxy->get_link();
return;
case MBOARD_PROP_TX_DSP_NAMES:
- val = prop_names_t(_tx_dsps.get_keys());
+ val = prop_names_t(1, "");
return;
case MBOARD_PROP_CLOCK_CONFIG:
val = _clock_config;
return;
- case MBOARD_PROP_TIME_NOW:
- case MBOARD_PROP_TIME_NEXT_PPS:
+ default:
throw std::runtime_error("Error: trying to get write-only property on usrp2 mboard");
}
@@ -226,27 +262,19 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
update_clock_config();
return;
- case MBOARD_PROP_TIME_NOW:{
+ case MBOARD_PROP_TIME_NOW:
set_time_spec(val.as<time_spec_t>(), true);
return;
- }
- case MBOARD_PROP_TIME_NEXT_PPS:{
+ case MBOARD_PROP_TIME_NEXT_PPS:
set_time_spec(val.as<time_spec_t>(), false);
return;
- }
- case MBOARD_PROP_NAME:
- case MBOARD_PROP_OTHERS:
- case MBOARD_PROP_CLOCK_RATE:
- case MBOARD_PROP_RX_DSP:
- case MBOARD_PROP_RX_DSP_NAMES:
- case MBOARD_PROP_TX_DSP:
- case MBOARD_PROP_TX_DSP_NAMES:
- case MBOARD_PROP_RX_DBOARD:
- case MBOARD_PROP_RX_DBOARD_NAMES:
- case MBOARD_PROP_TX_DBOARD:
- case MBOARD_PROP_TX_DBOARD_NAMES:
+ case MBOARD_PROP_STREAM_CMD:
+ issue_ddc_stream_cmd(val.as<stream_cmd_t>());
+ return;
+
+ default:
throw std::runtime_error("Error: trying to set read-only property on usrp2 mboard");
}