diff options
author | Trung N Tran <trung.tran@ettus.com> | 2018-01-04 11:32:24 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-01-12 16:26:03 -0800 |
commit | 00402669d08b206f3b0367f5f4e3383d25e7944b (patch) | |
tree | 1ab5948382dde42f164499ce8e1cd68c3c4d959c /host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp | |
parent | 7ffea3746be77cf926db946987ee83d48a33c798 (diff) | |
download | uhd-00402669d08b206f3b0367f5f4e3383d25e7944b.tar.gz uhd-00402669d08b206f3b0367f5f4e3383d25e7944b.tar.bz2 uhd-00402669d08b206f3b0367f5f4e3383d25e7944b.zip |
mg: add facility that handle individual gain
-Create name for each gain/att element
-Create property tree entry for each gain and their handlers.
-Create gain profile that control how gain distributed.
Right now, it is either "default" or "manual".
Diffstat (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp')
-rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp | 213 |
1 files changed, 206 insertions, 7 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp index 5858995b0..5eb3cacd0 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp @@ -315,33 +315,232 @@ void magnesium_radio_ctrl_impl::_init_frontend_subtree( return this->set_tx_gain(gain, chan_idx); }) .set_publisher([this, chan_idx](){ - return this->get_tx_gain(chan_idx); + return radio_ctrl_impl::get_tx_gain(chan_idx); }) ; subtree->create<meta_range_t>(tx_fe_path / "gains" / "all" / "range") - .set(meta_range_t(ALL_TX_MIN_GAIN, ALL_TX_MAX_GAIN, ALL_TX_GAIN_STEP)) .add_coerced_subscriber([](const meta_range_t &){ throw uhd::runtime_error( - "Attempting to update bandwidth range!"); + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[TX_DIRECTION] == "manual") { + return meta_range_t(0.0, 0.0, 0.0); + }else{ + return meta_range_t(ALL_TX_MIN_GAIN, ALL_TX_MAX_GAIN, ALL_TX_GAIN_STEP); + } }) ; + + subtree->create<std::vector<std::string> >(tx_fe_path / "gains/all/profile/options") + .set(boost::assign::list_of("manual")("default")); + + subtree->create<std::string>(tx_fe_path / "gains/all/profile/value") + .set_coercer([this, chan_idx](const std::string& profile){ + std::string return_profile = profile; + if (std::find(MAGNESIUM_GP_OPTIONS.begin(), + MAGNESIUM_GP_OPTIONS.end(), + profile + ) == MAGNESIUM_GP_OPTIONS.end()) + { + return_profile = "default"; + } + _gain_profile[TX_DIRECTION] = return_profile; + return return_profile; + }) + .set_publisher([this, chan_idx](){ + return _gain_profile[TX_DIRECTION]; + }) + ; + // RX gains subtree->create<double>(rx_fe_path / "gains" / "all" / "value") .set_coercer([this, chan_idx](const double gain){ return this->set_rx_gain(gain, chan_idx); }) .set_publisher([this, chan_idx](){ - return this->get_rx_gain(chan_idx); + return radio_ctrl_impl::get_rx_gain(chan_idx); }) ; + subtree->create<meta_range_t>(rx_fe_path / "gains" / "all" / "range") - .set(meta_range_t(ALL_RX_MIN_GAIN, ALL_RX_MAX_GAIN, ALL_RX_GAIN_STEP)) .add_coerced_subscriber([](const meta_range_t &){ throw uhd::runtime_error( - "Attempting to update bandwidth range!"); + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[RX_DIRECTION] == "manual") { + return meta_range_t(0.0, 0.0, 0.0); + }else{ + return meta_range_t(ALL_RX_MIN_GAIN, ALL_RX_MAX_GAIN, ALL_RX_GAIN_STEP); + } + }) + ; + + subtree->create<std::vector<std::string> >(rx_fe_path / "gains/all/profile/options") + .set(MAGNESIUM_GP_OPTIONS); + + subtree->create<std::string>(rx_fe_path / "gains/all/profile/value") + .set_coercer([this, chan_idx](const std::string& profile){ + std::string return_profile = profile; + if (std::find(MAGNESIUM_GP_OPTIONS.begin(), + MAGNESIUM_GP_OPTIONS.end(), + profile + ) == MAGNESIUM_GP_OPTIONS.end()) + { + return_profile = "default"; + } + _gain_profile[RX_DIRECTION] = return_profile; + return return_profile; + }) + .set_publisher([this, chan_idx](){ + return _gain_profile[RX_DIRECTION]; }) ; - // FIXME separate DSA and Myk gains + + // TX mykonos attenuation + subtree->create<double>(tx_fe_path / "gains" / MAGNESIUM_GAIN1 / "value") + .set_coercer([this, chan_idx](const double gain){ + return _set_tx_gain(MAGNESIUM_GAIN1, gain, chan_idx); + }) + .set_publisher([this, chan_idx](){ + return this->_get_tx_gain(MAGNESIUM_GAIN1, chan_idx); + }) + ; + + subtree->create<meta_range_t>(tx_fe_path / "gains" / MAGNESIUM_GAIN1 / "range") + .add_coerced_subscriber([](const meta_range_t &){ + throw uhd::runtime_error( + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[TX_DIRECTION] == "manual") { + return meta_range_t(AD9371_MIN_TX_GAIN, AD9371_MAX_TX_GAIN, AD9371_TX_GAIN_STEP); + }else{ + return meta_range_t(0.0, 0.0, 0.0); + } + }) + ; + // TX DSA + subtree->create<double>(tx_fe_path / "gains" / MAGNESIUM_GAIN2 / "value") + .set_coercer([this, chan_idx](const double gain){ + return this->_set_tx_gain(MAGNESIUM_GAIN2, gain, chan_idx); + }) + .set_publisher([this, chan_idx](){ + return this->_get_tx_gain(MAGNESIUM_GAIN2, chan_idx); + }) + ; + + subtree->create<meta_range_t>(tx_fe_path / "gains" / MAGNESIUM_GAIN2 / "range") + .add_coerced_subscriber([](const meta_range_t &){ + throw uhd::runtime_error( + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[TX_DIRECTION] == "manual") { + return meta_range_t(DSA_MIN_GAIN, DSA_MAX_GAIN, DSA_GAIN_STEP); + }else{ + return meta_range_t(0.0, 0.0, 0.0); + } + }) + ; + //TX amp + subtree->create<double>(tx_fe_path / "gains" / MAGNESIUM_AMP / "value") + .set_coercer([this, chan_idx](const double gain) { + return this->_set_tx_gain(MAGNESIUM_AMP, gain, chan_idx); + }) + .set_publisher([this, chan_idx]() { + return this->_get_tx_gain(MAGNESIUM_AMP, chan_idx); + }) + ; + + subtree->create<meta_range_t>(tx_fe_path / "gains" / MAGNESIUM_AMP / "range") + .add_coerced_subscriber([](const meta_range_t &) { + throw uhd::runtime_error( + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[TX_DIRECTION] == "manual") { + return meta_range_t(AMP_MIN_GAIN, AMP_MAX_GAIN, AMP_GAIN_STEP); + }else{ + return meta_range_t(0.0, 0.0, 0.0); + } + }) + ; + + // RX mykonos attenuation + subtree->create<double>(rx_fe_path / "gains" / MAGNESIUM_GAIN1 / "value") + .set_coercer([this, chan_idx](const double gain){ + UHD_VAR(gain); + return this->_set_rx_gain(MAGNESIUM_GAIN1, gain, chan_idx); + }) + .set_publisher([this, chan_idx](){ + return this->_get_rx_gain(MAGNESIUM_GAIN1, chan_idx); + }) + ; + + subtree->create<meta_range_t>(rx_fe_path / "gains" / MAGNESIUM_GAIN1 / "range") + .add_coerced_subscriber([](const meta_range_t &) { + throw uhd::runtime_error( + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[RX_DIRECTION] == "manual") { + return meta_range_t(AD9371_MIN_RX_GAIN, AD9371_MAX_RX_GAIN, AD9371_RX_GAIN_STEP); + }else{ + return meta_range_t(0.0, 0.0, 0.0); + } + }) + ; + //RX DSA + subtree->create<double>(rx_fe_path / "gains" / MAGNESIUM_GAIN2 / "value") + .set_coercer([this, chan_idx](const double gain) { + UHD_VAR(gain); + return this->_set_rx_gain(MAGNESIUM_GAIN2, gain, chan_idx); + }) + .set_publisher([this, chan_idx]() { + return this->_get_rx_gain(MAGNESIUM_GAIN2, chan_idx); + }) + ; + + subtree->create<meta_range_t>(rx_fe_path / "gains" / MAGNESIUM_GAIN2 / "range") + .add_coerced_subscriber([](const meta_range_t &){ + throw uhd::runtime_error( + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[RX_DIRECTION] == "manual") { + return meta_range_t(DSA_MIN_GAIN, DSA_MAX_GAIN, DSA_MAX_GAIN); + }else{ + return meta_range_t(0.0, 0.0, 0.0); + } + }) + ; + + //RX amp + subtree->create<double>(rx_fe_path / "gains" / MAGNESIUM_AMP / "value") + .set_coercer([this, chan_idx](const double gain) { + return this->_set_rx_gain(MAGNESIUM_AMP, gain, chan_idx); + }) + .set_publisher([this, chan_idx]() { + return this->_get_rx_gain(MAGNESIUM_AMP, chan_idx); + }) + ; + + subtree->create<meta_range_t>(rx_fe_path / "gains" / MAGNESIUM_AMP / "range") + .add_coerced_subscriber([](const meta_range_t &) { + throw uhd::runtime_error( + "Attempting to update gain range!"); + }) + .set_publisher([this, chan_idx](){ + if (_gain_profile[RX_DIRECTION] == "manual") { + return meta_range_t(AMP_MIN_GAIN, AMP_MAX_GAIN, AMP_GAIN_STEP); + }else{ + return meta_range_t(0.0, 0.0, 0.0); + } + }) + ; + // TX LO lock sensor ////////////////////////////////////////////////////// // Note: The lowband and AD9371 LO lock sensors are generated // programmatically in set_rpc_client(). The actual lo_locked publisher is |