aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/dsp_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp2/dsp_impl.cpp')
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp68
1 files changed, 31 insertions, 37 deletions
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index 34cce0afb..0d43fac0e 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include <uhd/utils.hpp>
+#include <uhd/utils/assert.hpp>
#include <boost/format.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/math/special_functions/round.hpp>
@@ -35,7 +35,7 @@ template <class T> T log2(T num){
/***********************************************************************
* DDC Helper Methods
**********************************************************************/
-static boost::uint32_t calculate_freq_word_and_update_actual_freq(freq_t &freq, freq_t clock_freq){
+static boost::uint32_t calculate_freq_word_and_update_actual_freq(double &freq, double clock_freq){
double scale_factor = std::pow(2.0, 32);
//calculate the freq register word
@@ -63,9 +63,8 @@ void usrp2_impl::init_ddc_config(void){
_ddc_freq = 0;
update_ddc_config();
- _ddc_stream_at = time_spec_t();
- _ddc_enabled = false;
- update_ddc_enabled();
+ //initial command that kills streaming (in case if was left on)
+ //issue_ddc_stream_cmd(TODO)
}
void usrp2_impl::update_ddc_config(void){
@@ -86,21 +85,19 @@ void usrp2_impl::update_ddc_config(void){
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_TOTALLY_SETUP_THE_DDC_DUDE);
}
-void usrp2_impl::update_ddc_enabled(void){
+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_CONFIGURE_STREAMING_FOR_ME_BRO);
- out_data.data.streaming.enabled = (_ddc_enabled)? 1 : 0;
- out_data.data.streaming.secs = htonl(_ddc_stream_at.secs);
- out_data.data.streaming.ticks = htonl(_ddc_stream_at.ticks);
- out_data.data.streaming.samples = htonl(_max_rx_samples_per_packet);
+ 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.continuous = (stream_cmd.continuous)? 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);
+ out_data.data.stream_cmd.num_samps = htonl(stream_cmd.num_samps);
//send and recv
usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
- ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_CONFIGURED_THAT_STREAMING_DUDE);
-
- //clear the stream at time spec (it must be set for the next round of enable/disable)
- _ddc_stream_at = time_spec_t();
+ ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THAT_STREAM_COMMAND_DUDE);
}
/***********************************************************************
@@ -116,12 +113,12 @@ void usrp2_impl::ddc_get(const wax::obj &key, wax::obj &val){
case DSP_PROP_OTHERS:{
prop_names_t others = boost::assign::list_of
- ("rate")
+ ("if_rate")
+ ("bb_rate")
("decim")
("decims")
("freq")
- ("enabled")
- ("stream_at")
+ ("stream_cmd")
;
val = others;
}
@@ -131,10 +128,14 @@ void usrp2_impl::ddc_get(const wax::obj &key, wax::obj &val){
//handle string-based properties specific to this dsp
std::string key_name = key.as<std::string>();
- if (key_name == "rate"){
+ if (key_name == "if_rate"){
val = get_master_clock_freq();
return;
}
+ else if (key_name == "bb_rate"){
+ val = get_master_clock_freq()/_ddc_decim;
+ return;
+ }
else if (key_name == "decim"){
val = _ddc_decim;
return;
@@ -147,10 +148,6 @@ void usrp2_impl::ddc_get(const wax::obj &key, wax::obj &val){
val = _ddc_freq;
return;
}
- else if (key_name == "enabled"){
- val = _ddc_enabled;
- return;
- }
throw std::invalid_argument(str(
boost::format("error getting: unknown key with name %s") % key_name
@@ -171,23 +168,15 @@ void usrp2_impl::ddc_set(const wax::obj &key, const wax::obj &val){
return;
}
else if (key_name == "freq"){
- freq_t new_freq = val.as<freq_t>();
+ double new_freq = val.as<double>();
ASSERT_THROW(new_freq <= get_master_clock_freq()/2.0);
ASSERT_THROW(new_freq >= -get_master_clock_freq()/2.0);
_ddc_freq = new_freq; //shadow
update_ddc_config();
return;
}
- else if (key_name == "enabled"){
- bool new_enabled = val.as<bool>();
- _ddc_enabled = new_enabled; //shadow
- update_ddc_enabled();
- return;
- }
- else if (key_name == "stream_at"){
- time_spec_t new_stream_at = val.as<time_spec_t>();
- _ddc_stream_at = new_stream_at; //shadow
- //update_ddc_enabled(); //dont update from here
+ else if (key_name == "stream_cmd"){
+ issue_ddc_stream_cmd(val.as<stream_cmd_t>());
return;
}
@@ -250,7 +239,8 @@ void usrp2_impl::duc_get(const wax::obj &key, wax::obj &val){
case DSP_PROP_OTHERS:{
prop_names_t others = boost::assign::list_of
- ("rate")
+ ("if_rate")
+ ("bb_rate")
("interp")
("interps")
("freq")
@@ -263,10 +253,14 @@ void usrp2_impl::duc_get(const wax::obj &key, wax::obj &val){
//handle string-based properties specific to this dsp
std::string key_name = key.as<std::string>();
- if (key_name == "rate"){
+ if (key_name == "if_rate"){
val = get_master_clock_freq();
return;
}
+ else if (key_name == "bb_rate"){
+ val = get_master_clock_freq()/_duc_interp;
+ return;
+ }
else if (key_name == "interp"){
val = _duc_interp;
return;
@@ -299,7 +293,7 @@ void usrp2_impl::duc_set(const wax::obj &key, const wax::obj &val){
return;
}
else if (key_name == "freq"){
- freq_t new_freq = val.as<freq_t>();
+ double new_freq = val.as<double>();
ASSERT_THROW(new_freq <= get_master_clock_freq()/2.0);
ASSERT_THROW(new_freq >= -get_master_clock_freq()/2.0);
_duc_freq = new_freq; //shadow