aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_200.cpp21
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_200.hpp1
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp4
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp7
4 files changed, 30 insertions, 3 deletions
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp
index d562c64db..023216a09 100644
--- a/host/lib/usrp/cores/rx_dsp_core_200.cpp
+++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp
@@ -42,6 +42,7 @@
#define REG_RX_CTRL_VRT_TLR _ctrl_base + 24
#define REG_RX_CTRL_NSAMPS_PP _ctrl_base + 28
#define REG_RX_CTRL_NCHANNELS _ctrl_base + 32
+#define REG_RX_CTRL_FORMAT _ctrl_base + 36
template <class T> T ceil_log2(T num){
return std::ceil(std::log(num)/std::log(T(2)));
@@ -162,7 +163,7 @@ public:
}
double get_scaling_adjustment(void){
- return _scaling_adjustment;
+ return _scaling_adjustment/_fxpt_scale_adj;
}
double set_freq(const double freq_){
@@ -192,12 +193,28 @@ public:
if (_continuous_streaming) issue_stream_command(stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
}
+ void set_format(const std::string &format, const unsigned scale){
+ unsigned format_word = 0;
+ if (format == "sc16"){
+ format_word = 0;
+ _fxpt_scale_adj = 32767.;
+ }
+ else if (format == "sc8"){
+ format_word = (1 << 18);
+ _fxpt_scale_adj = 32767./scale;
+ }
+ else throw uhd::value_error("USRP RX cannot handle requested wire format: " + format);
+
+ const unsigned scale_word = scale & 0x3ffff; //18 bits;
+ _iface->poke32(REG_RX_CTRL_FORMAT, format_word | scale_word);
+ }
+
private:
wb_iface::sptr _iface;
const size_t _dsp_base, _ctrl_base;
double _tick_rate, _link_rate;
bool _continuous_streaming;
- double _scaling_adjustment;
+ double _scaling_adjustment, _fxpt_scale_adj;
};
rx_dsp_core_200::sptr rx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid, const bool lingering_packet){
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp
index 391cc8441..ddd6f2abf 100644
--- a/host/lib/usrp/cores/rx_dsp_core_200.hpp
+++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp
@@ -56,6 +56,7 @@ public:
virtual void handle_overflow(void) = 0;
+ virtual void set_format(const std::string &format, const unsigned scale) = 0;
};
#endif /* INCLUDED_LIBUHD_USRP_RX_DSP_CORE_200_HPP */
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index 835c78ecc..eaa6d02b4 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -564,6 +564,10 @@ rx_streamer::sptr usrp1_impl::get_rx_stream(const uhd::stream_args_t &args){
boost::shared_ptr<usrp1_recv_packet_streamer> my_streamer =
boost::make_shared<usrp1_recv_packet_streamer>(spp, _soft_time_ctrl);
+ //special scale factor change for sc8
+ if (args.otw_format == "sc8")
+ my_streamer->set_scale_factor(1.0/127);
+
//init some streamer stuff
my_streamer->set_tick_rate(_master_clock_rate);
my_streamer->set_vrt_unpacker(&usrp1_bs_vrt_unpacker);
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index d37be403b..f917a35db 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -290,7 +290,7 @@ void usrp2_impl::update_rx_samp_rate(const std::string &mb, const size_t dsp, co
my_streamer->set_samp_rate(rate);
const double adj = _mbc[mb].rx_dsps[dsp]->get_scaling_adjustment();
- my_streamer->set_scale_factor(adj/32767.);
+ my_streamer->set_scale_factor(adj);
}
void usrp2_impl::update_tx_samp_rate(const std::string &mb, const size_t dsp, const double rate){
@@ -404,6 +404,7 @@ rx_streamer::sptr usrp2_impl::get_rx_stream(const uhd::stream_args_t &args){
if (chan < num_chan_so_far){
const size_t dsp = num_chan_so_far - chan - 1;
_mbc[mb].rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this
+ _mbc[mb].rx_dsps[dsp]->set_format(args.otw_format, 0x400);
my_streamer->set_xport_chan_get_buff(chan_i, boost::bind(
&zero_copy_if::get_recv_buff, _mbc[mb].rx_dsp_xports[dsp], _1
));
@@ -427,6 +428,10 @@ rx_streamer::sptr usrp2_impl::get_rx_stream(const uhd::stream_args_t &args){
* Transmit streamer
**********************************************************************/
tx_streamer::sptr usrp2_impl::get_tx_stream(const uhd::stream_args_t &args){
+ if (args.otw_format != "sc16"){
+ throw uhd::value_error("USRP TX cannot handle requested wire format: " + args.otw_format);
+ }
+
//map an empty channel set to chan0
const std::vector<size_t> channels = args.channels.empty()? std::vector<size_t>(1, 0) : args.channels;