From 255f50988113d7cf5f50617fb4ef595d4ed86f60 Mon Sep 17 00:00:00 2001 From: michael-west Date: Mon, 17 Dec 2018 13:35:15 -0800 Subject: E310: Fix initialization of antenna and frequency values --- host/lib/usrp/e300/e3xx_radio_ctrl_impl.cpp | 43 +++++++++++++++++++++++------ host/lib/usrp/e300/e3xx_radio_ctrl_impl.hpp | 1 + 2 files changed, 36 insertions(+), 8 deletions(-) (limited to 'host/lib') diff --git a/host/lib/usrp/e300/e3xx_radio_ctrl_impl.cpp b/host/lib/usrp/e300/e3xx_radio_ctrl_impl.cpp index ff532f9f3..787faf6df 100644 --- a/host/lib/usrp/e300/e3xx_radio_ctrl_impl.cpp +++ b/host/lib/usrp/e300/e3xx_radio_ctrl_impl.cpp @@ -144,8 +144,12 @@ e3xx_radio_ctrl_impl::~e3xx_radio_ctrl_impl() _tree->remove(fs_path("rx_codecs" / _radio_slot)); _tree->remove(fs_path("tx_codecs" / _radio_slot)); for (size_t i = 0; i < _get_num_radios(); i++) { - _tree->remove(fs_path("tx_dsps") / i); - _tree->remove(fs_path("rx_dsps") / i); + if (_tree->exists(fs_path("tx_dsps") / i)) { + _tree->remove(fs_path("tx_dsps") / i); + } + if (_tree->exists(fs_path("rx_dsps") / i)) { + _tree->remove(fs_path("rx_dsps") / i); + } } for (const auto attr : usrp::gpio_atr::gpio_attr_map) { const auto gpio_fs_path = fs_path("gpio") / "INT0" / attr.second; @@ -178,7 +182,18 @@ double e3xx_radio_ctrl_impl::set_rate(double rate) return actual_tick_rate; } -/*! Select antenna \p for channel \p chan. +/*! Select TX antenna \p for channel \p chan. + */ +void e3xx_radio_ctrl_impl::set_tx_antenna(const std::string &ant, const size_t chan) +{ + std::lock_guard lock(_mutex); + if (ant != "TX/RX") + throw uhd::value_error("Unknown TX antenna option: " + ant); + + radio_ctrl_impl::set_tx_antenna(ant, chan); +} + +/*! Select RX antenna \p for channel \p chan. */ void e3xx_radio_ctrl_impl::set_rx_antenna(const std::string &ant, const size_t chan) { @@ -361,9 +376,15 @@ void e3xx_radio_ctrl_impl::_setup_radio_channel(const size_t chan) _tree->create(rf_fe_path / "sensors" / "lo_locked") .set_publisher(boost::bind(&e3xx_radio_ctrl_impl::_get_fe_pll_lock, this, dir == TX_DIRECTION)) ; - _tree->access(rf_fe_path / "freq" / "value") - .add_coerced_subscriber(boost::bind(&e3xx_radio_ctrl_impl::_update_fe_lo_freq, this, key, _1)) + const double freq = _tree->access(rf_fe_path / "freq" / "value") + .add_coerced_subscriber(boost::bind(&e3xx_radio_ctrl_impl::_update_fe_lo_freq, this, key, _1)).get() ; + // Set frequency in parent (to be used to update ATR values later) + if (dir == RX_DIRECTION) { + radio_ctrl_impl::set_rx_frequency(freq, chan); + } else { + radio_ctrl_impl::set_tx_frequency(freq, chan); + } // Antenna Setup if (dir == RX_DIRECTION) { @@ -371,13 +392,19 @@ void e3xx_radio_ctrl_impl::_setup_radio_channel(const size_t chan) _tree->create >(rf_fe_path / "antenna" / "options").set(ants); _tree->create(rf_fe_path / "antenna" / "value") .add_coerced_subscriber(boost::bind(&e3xx_radio_ctrl_impl::set_rx_antenna, this, _1, chan)) - .set_publisher(boost::bind(&e3xx_radio_ctrl_impl::get_rx_antenna, this, chan)) - .set("RX2"); + .set_publisher(boost::bind(&e3xx_radio_ctrl_impl::get_rx_antenna, this, chan)); + // Set default in parent (to be used to update ATR values later) + radio_ctrl_impl::set_rx_antenna("RX2", chan); + // Set up LEDs for default antenna + _update_atr_leds(_e3xx_perifs[chan].leds, "RX2"); } else if (dir == TX_DIRECTION) { static const std::vector ants(1, "TX/RX"); _tree->create >(rf_fe_path / "antenna" / "options").set(ants); - _tree->create(rf_fe_path / "antenna" / "value").set("TX/RX"); + _tree->create(rf_fe_path / "antenna" / "value") + .add_coerced_subscriber(boost::bind(&e3xx_radio_ctrl_impl::set_tx_antenna, this, _1, chan)) + .set_publisher(boost::bind(&e3xx_radio_ctrl_impl::get_tx_antenna, this, chan)) + .set("TX/RX"); } } } diff --git a/host/lib/usrp/e300/e3xx_radio_ctrl_impl.hpp b/host/lib/usrp/e300/e3xx_radio_ctrl_impl.hpp index b0804ba50..3d23efff0 100644 --- a/host/lib/usrp/e300/e3xx_radio_ctrl_impl.hpp +++ b/host/lib/usrp/e300/e3xx_radio_ctrl_impl.hpp @@ -43,6 +43,7 @@ public: * API calls ***********************************************************************/ double set_rate(double rate); + void set_tx_antenna(const std::string &ant, const size_t chan); void set_rx_antenna(const std::string &ant, const size_t chan); double set_tx_frequency(const double freq, const size_t chan); -- cgit v1.2.3