diff options
author | Josh Blum <josh@joshknows.com> | 2011-05-14 19:57:03 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-05-14 19:57:03 -0700 |
commit | f991d3dc751e110425d4a0eed722f6de0fef4261 (patch) | |
tree | d147596eba8d16294d4131dec2f66ca5c653f37a /host/lib/usrp | |
parent | 29a0c916dfdc2f960761c1bebcccc53478abd30c (diff) | |
download | uhd-f991d3dc751e110425d4a0eed722f6de0fef4261.tar.gz uhd-f991d3dc751e110425d4a0eed722f6de0fef4261.tar.bz2 uhd-f991d3dc751e110425d4a0eed722f6de0fef4261.zip |
usrp1: apply conditional disables/enables to rx and tx
Scapped the old gnuradio code for information about VRQ_FPGA_SET_XX_ENABLE.
It turns out that we should disabled + restore state when changing muxes or rates.
The USRP seems to stream properly when receiving single and dual channel.
Prior to this commit, tx was accicentally always disabled from a few commits ago.
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/usrp1/dsp_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/io_impl.cpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/mboard_impl.cpp | 12 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_ctrl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_ctrl.hpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.hpp | 39 |
7 files changed, 60 insertions, 9 deletions
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp index 9f1e4975a..1679c0470 100644 --- a/host/lib/usrp/usrp1/dsp_impl.cpp +++ b/host/lib/usrp/usrp1/dsp_impl.cpp @@ -113,7 +113,9 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh //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; @@ -212,7 +214,9 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh //TODO Poll every 100ms. Make it selectable? _tx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() * 2 / rate); + bool s = this->disable_tx(); _iface->poke32(FR_INTERP_RATE, _tx_dsp_interp / 4 - 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..7252ac587 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -240,12 +240,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..d6f6832a4 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -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 */ |