aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp28
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp22
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp16
-rw-r--r--host/lib/usrp/usrp1/usrp1_ctrl.cpp4
-rw-r--r--host/lib/usrp/usrp1/usrp1_ctrl.hpp5
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp2
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp39
7 files changed, 75 insertions, 41 deletions
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index 9f1e4975a..66b11b989 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -103,17 +103,16 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh
{
size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as<double>());
- if ((rate & 0x01) || (rate < 4) || (rate > 256)) {
- UHD_MSG(error) << "Decimation must be even and between 4 and 256"
- << std::endl;
- return;
- }
+ //clip the rate to something in range:
+ rate = std::min<size_t>(std::max<size_t>(rate, 4), 256);
_rx_dsp_decim = rate;
//TODO Poll every 100ms. Make it selectable?
_rx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() / rate);
+ bool s = this->disable_rx();
_iface->poke32(FR_DECIM_RATE, _rx_dsp_decim/2 - 1);
+ this->restore_rx(s);
}
return;
@@ -164,11 +163,11 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val, size_t which_ds
return;
case DSP_PROP_CODEC_RATE:
- val = _clock_ctrl->get_master_clock_freq() * 2;
+ val = _clock_ctrl->get_master_clock_freq();
return;
case DSP_PROP_HOST_RATE:
- val = _clock_ctrl->get_master_clock_freq() * 2 / _tx_dsp_interp;
+ val = _clock_ctrl->get_master_clock_freq() / _tx_dsp_interp;
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -199,20 +198,19 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh
case DSP_PROP_HOST_RATE:
if (which_dsp != 0) return; //only for dsp[0] as this is vectorized
{
- size_t rate = size_t(_clock_ctrl->get_master_clock_freq() * 2 / val.as<double>());
+ size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as<double>());
- if ((rate & 0x01) || (rate < 8) || (rate > 512)) {
- UHD_MSG(error) << "Interpolation rate must be even and between 8 and 512"
- << std::endl;
- return;
- }
+ //clip the rate to something in range:
+ rate = std::min<size_t>(std::max<size_t>(rate, 4), 256);
_tx_dsp_interp = rate;
//TODO Poll every 100ms. Make it selectable?
- _tx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() * 2 / rate);
+ _tx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() / rate);
- _iface->poke32(FR_INTERP_RATE, _tx_dsp_interp / 4 - 1);
+ bool s = this->disable_tx();
+ _iface->poke32(FR_INTERP_RATE, _tx_dsp_interp/2 - 1);
+ this->restore_tx(s);
return;
}
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index 22d078e70..8ac2696eb 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -61,39 +61,28 @@ class offset_managed_send_buffer : public managed_send_buffer{
public:
typedef boost::function<void(offset_send_buffer&, offset_send_buffer&, size_t)> commit_cb_type;
offset_managed_send_buffer(const commit_cb_type &commit_cb):
- _expired(true), _commit_cb(commit_cb)
+ _commit_cb(commit_cb)
{
/* NOP */
}
- bool expired(void){return _expired;}
-
void commit(size_t size){
- if (_expired) return;
- this->_commit_cb(_curr_buff, _next_buff, size);
- _expired = true;
+ if (size != 0) this->_commit_cb(_curr_buff, _next_buff, size);
}
sptr get_new(
offset_send_buffer &curr_buff,
offset_send_buffer &next_buff
){
- _expired = false;
_curr_buff = curr_buff;
_next_buff = next_buff;
- return sptr(this, &offset_managed_send_buffer::fake_deleter);
+ return make_managed_buffer(this);
}
private:
- static void fake_deleter(void *){
- //dont do anything and assume the bastard committed it
- //static_cast<offset_managed_send_buffer *>(obj)->commit(0);
- }
-
void *get_buff(void) const{return _curr_buff.buff->cast<char *>() + _curr_buff.offset;}
size_t get_size(void) const{return _curr_buff.buff->size() - _curr_buff.offset;}
- bool _expired;
offset_send_buffer _curr_buff, _next_buff;
commit_cb_type _commit_cb;
};
@@ -210,7 +199,7 @@ void usrp1_impl::io_impl::flush_send_buff(void){
bool usrp1_impl::io_impl::get_send_buffs(
vrt_packet_handler::managed_send_buffs_t &buffs
){
- UHD_ASSERT_THROW(omsb.expired() and buffs.size() == 1);
+ UHD_ASSERT_THROW(buffs.size() == 1);
//try to get a new managed buffer with timeout
offset_send_buffer next_buff(data_transport->get_send_buff(send_timeout));
@@ -240,12 +229,13 @@ void usrp1_impl::io_init(void){
boost::bind(&usrp1_impl::rx_stream_on_off, this, _1)
);
+ this->enable_tx(true); //always enabled
rx_stream_on_off(false);
_io_impl->flush_send_buff();
}
void usrp1_impl::rx_stream_on_off(bool enb){
- return _iface->write_firmware_cmd(VRQ_FPGA_SET_RX_ENABLE, enb, 0, 0, 0);
+ this->enable_rx(enb);
//drain any junk in the receive transport after stop streaming command
while(not enb and _data_transport->get_recv_buff().get() != NULL){
/* NOP */
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index cd04e7351..e9108e4f1 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -214,8 +214,8 @@ void usrp1_impl::mboard_init(void)
// Normal mode with no loopback or Rx counting
_iface->poke32(FR_MODE, 0x00000000);
_iface->poke32(FR_DEBUG_EN, 0x00000000);
- _iface->poke32(FR_RX_SAMPLE_RATE_DIV, 0x00000001);
- _iface->poke32(FR_TX_SAMPLE_RATE_DIV, 0x00000003);
+ _iface->poke32(FR_RX_SAMPLE_RATE_DIV, 0x00000001); //divide by 2
+ _iface->poke32(FR_TX_SAMPLE_RATE_DIV, 0x00000001); //divide by 2
_iface->poke32(FR_DC_OFFSET_CL_EN, 0x0000000f);
// Reset offset correction registers
@@ -339,7 +339,7 @@ void usrp1_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_RX_SUBDEV_SPEC:
+ case MBOARD_PROP_RX_SUBDEV_SPEC:{
_rx_subdev_spec = val.as<subdev_spec_t>();
if (_rx_subdev_spec.size() > this->get_num_ddcs()){
throw uhd::value_error(str(boost::format(
@@ -349,10 +349,12 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
}
verify_rx_subdev_spec(_rx_subdev_spec, _mboard_proxy->get_link());
//set the mux and set the number of rx channels
+ bool s = this->disable_rx();
_iface->poke32(FR_RX_MUX, calc_rx_mux(_rx_subdev_spec, _mboard_proxy->get_link()));
- return;
+ this->restore_rx(s);
+ }return;
- case MBOARD_PROP_TX_SUBDEV_SPEC:
+ case MBOARD_PROP_TX_SUBDEV_SPEC:{
_tx_subdev_spec = val.as<subdev_spec_t>();
if (_tx_subdev_spec.size() > this->get_num_ducs()){
throw uhd::value_error(str(boost::format(
@@ -362,8 +364,10 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
}
verify_tx_subdev_spec(_tx_subdev_spec, _mboard_proxy->get_link());
//set the mux and set the number of tx channels
+ bool s = this->disable_tx();
_iface->poke32(FR_TX_MUX, calc_tx_mux(_tx_subdev_spec, _mboard_proxy->get_link()));
- return;
+ this->restore_tx(s);
+ }return;
case MBOARD_PROP_EEPROM_MAP:
// Step1: commit the map, writing only those values set.
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
index 96dc5d80c..2e6f6e014 100644
--- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
@@ -210,10 +210,6 @@ public:
usrp_tx_reset(true);
usrp_rx_reset(false);
usrp_tx_reset(false);
-
- //enable
- //usrp_rx_enable(true); //dont enable, enable means dont work
- //usrp_tx_enable(true);
}
void usrp_load_fpga(std::string filestring)
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.hpp b/host/lib/usrp/usrp1/usrp1_ctrl.hpp
index 970ca2951..a6e4ffba7 100644
--- a/host/lib/usrp/usrp1/usrp1_ctrl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_ctrl.hpp
@@ -108,6 +108,11 @@ public:
unsigned char *buf,
boost::uint16_t len) = 0;
+ //! enable/disable the rx path
+ virtual void usrp_rx_enable(bool on) = 0;
+
+ //! enable/disable the tx path
+ virtual void usrp_tx_enable(bool on) = 0;
};
#endif /* INCLUDED_USRP_CTRL_HPP */
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 57aae1b58..b1fa986d1 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -209,6 +209,8 @@ usrp1_impl::usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport,
}
usrp1_impl::~usrp1_impl(void){
+ UHD_SAFE_CALL(this->enable_rx(false);)
+ UHD_SAFE_CALL(this->enable_tx(false);)
//Safely destruct all RAII objects in a device.
//This prevents the mboard deconstructor from throwing,
//which allows the device to be safely deconstructed.
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index f53894b29..69ad9b0a0 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -205,6 +205,45 @@ private:
size_t get_num_ddcs(void);
bool has_rx_halfband(void);
bool has_tx_halfband(void);
+
+ //handle the enables
+ bool _rx_enabled, _tx_enabled;
+ void enable_rx(bool enb){
+ _rx_enabled = enb;
+ _ctrl_transport->usrp_rx_enable(enb);
+ }
+ void enable_tx(bool enb){
+ _tx_enabled = enb;
+ _ctrl_transport->usrp_tx_enable(enb);
+ }
+
+ //conditionally disable and enable rx
+ bool disable_rx(void){
+ if (_rx_enabled){
+ enable_rx(false);
+ return true;
+ }
+ return false;
+ }
+ void restore_rx(bool last){
+ if (last != _rx_enabled){
+ enable_rx(last);
+ }
+ }
+
+ //conditionally disable and enable tx
+ bool disable_tx(void){
+ if (_tx_enabled){
+ enable_tx(false);
+ return true;
+ }
+ return false;
+ }
+ void restore_tx(bool last){
+ if (last != _tx_enabled){
+ enable_tx(last);
+ }
+ }
};
#endif /* INCLUDED_USRP1_IMPL_HPP */