diff options
author | Lane Kolbly <lane.kolbly@ni.com> | 2020-06-18 17:46:06 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-01-11 12:26:00 -0600 |
commit | 12673d9290319d2453fedd806ddf248d3d5586e3 (patch) | |
tree | 811016297552c5358129aecb5953a0c143229e86 /host/lib/rfnoc | |
parent | c9b35e3b7107ab82c0e3978b7cbfd76ba98e2407 (diff) | |
download | uhd-12673d9290319d2453fedd806ddf248d3d5586e3.tar.gz uhd-12673d9290319d2453fedd806ddf248d3d5586e3.tar.bz2 uhd-12673d9290319d2453fedd806ddf248d3d5586e3.zip |
uhd: Split radio_control into rf_control interfaces
These rf_control interfaces allow easier implementation of
radio controls as well as allowing easier sharing of code
for implementing e.g. gain_profile.
Diffstat (limited to 'host/lib/rfnoc')
-rw-r--r-- | host/lib/rfnoc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/rfnoc/radio_control_impl.cpp | 36 | ||||
-rw-r--r-- | host/lib/rfnoc/rf_control/CMakeLists.txt | 13 | ||||
-rw-r--r-- | host/lib/rfnoc/rf_control/gain_profile.cpp | 68 |
4 files changed, 98 insertions, 20 deletions
diff --git a/host/lib/rfnoc/CMakeLists.txt b/host/lib/rfnoc/CMakeLists.txt index 33da287fe..53bca9b45 100644 --- a/host/lib/rfnoc/CMakeLists.txt +++ b/host/lib/rfnoc/CMakeLists.txt @@ -61,3 +61,4 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/window_block_control.cpp ) +INCLUDE_SUBDIRECTORY(rf_control) diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index f9347b9e7..e20f5d4f6 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -253,6 +253,10 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) boost::optional<uint64_t> timestamp) { this->async_message_handler(addr, data, timestamp); }); + + // Set the default gain profiles + _rx_gain_profile_api = std::make_shared<rf_control::default_gain_profile>(); + _tx_gain_profile_api = std::make_shared<rf_control::default_gain_profile>(); } /* ctor */ /****************************************************************************** @@ -436,42 +440,34 @@ void radio_control_impl::set_rx_agc(const bool, const size_t) throw uhd::not_implemented_error("set_rx_agc() is not supported on this radio!"); } -void radio_control_impl::set_tx_gain_profile(const std::string& profile, const size_t) +void radio_control_impl::set_tx_gain_profile(const std::string& profile, const size_t chan) { - if (profile != DEFAULT_GAIN_PROFILE) { - throw uhd::value_error( - std::string("set_tx_gain_profile(): Unknown gain profile: `") + profile - + "'"); - } + _tx_gain_profile_api->set_gain_profile(profile, chan); } -void radio_control_impl::set_rx_gain_profile(const std::string& profile, const size_t) +void radio_control_impl::set_rx_gain_profile(const std::string& profile, const size_t chan) { - if (profile != DEFAULT_GAIN_PROFILE) { - throw uhd::value_error( - std::string("set_rx_gain_profile(): Unknown gain profile: `") + profile - + "'"); - } + _rx_gain_profile_api->set_gain_profile(profile, chan); } -std::vector<std::string> radio_control_impl::get_tx_gain_profile_names(const size_t) const +std::vector<std::string> radio_control_impl::get_tx_gain_profile_names(const size_t chan) const { - return {DEFAULT_GAIN_PROFILE}; + return _tx_gain_profile_api->get_gain_profile_names(chan); } -std::vector<std::string> radio_control_impl::get_rx_gain_profile_names(const size_t) const +std::vector<std::string> radio_control_impl::get_rx_gain_profile_names(const size_t chan) const { - return {DEFAULT_GAIN_PROFILE}; + return _rx_gain_profile_api->get_gain_profile_names(chan); } -std::string radio_control_impl::get_tx_gain_profile(const size_t) const +std::string radio_control_impl::get_tx_gain_profile(const size_t chan) const { - return DEFAULT_GAIN_PROFILE; + return _tx_gain_profile_api->get_gain_profile(chan); } -std::string radio_control_impl::get_rx_gain_profile(const size_t) const +std::string radio_control_impl::get_rx_gain_profile(const size_t chan) const { - return DEFAULT_GAIN_PROFILE; + return _rx_gain_profile_api->get_gain_profile(chan); } double radio_control_impl::set_tx_bandwidth(const double bandwidth, const size_t chan) diff --git a/host/lib/rfnoc/rf_control/CMakeLists.txt b/host/lib/rfnoc/rf_control/CMakeLists.txt new file mode 100644 index 000000000..11c7e57ef --- /dev/null +++ b/host/lib/rfnoc/rf_control/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2020 Ettus Research, a National Instruments Brand +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +######################################################################## +# This file included, use CMake directory variables +######################################################################## + +LIBUHD_APPEND_SOURCES( + ${CMAKE_CURRENT_SOURCE_DIR}/gain_profile.cpp +) diff --git a/host/lib/rfnoc/rf_control/gain_profile.cpp b/host/lib/rfnoc/rf_control/gain_profile.cpp new file mode 100644 index 000000000..54ccb9006 --- /dev/null +++ b/host/lib/rfnoc/rf_control/gain_profile.cpp @@ -0,0 +1,68 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhd/exception.hpp> +#include <uhd/utils/assert_has.hpp> +#include <uhd/utils/log.hpp> +#include <uhdlib/rfnoc/rf_control/gain_profile_iface.hpp> +#include <stddef.h> +#include <string> +#include <vector> + +namespace uhd { namespace rfnoc { namespace rf_control { + +const std::string default_gain_profile::DEFAULT_GAIN_PROFILE = "default"; + +std::vector<std::string> default_gain_profile::get_gain_profile_names(const size_t) const +{ + return {DEFAULT_GAIN_PROFILE}; +} + +void default_gain_profile::set_gain_profile(const std::string& profile, const size_t) +{ + if (profile != DEFAULT_GAIN_PROFILE) { + throw uhd::value_error( + std::string("set_tx_gain_profile(): Unknown gain profile: `") + profile + + "'"); + } +} + +std::string default_gain_profile::get_gain_profile(const size_t) const +{ + return DEFAULT_GAIN_PROFILE; +} + +enumerated_gain_profile::enumerated_gain_profile( + const std::vector<std::string>& possible_profiles, + const std::string& default_profile, + size_t num_channels) + : _possible_profiles(possible_profiles), _gain_profile(num_channels, default_profile) +{ +} + +void enumerated_gain_profile::set_gain_profile( + const std::string& profile, const size_t chan) +{ + if (!uhd::has(_possible_profiles, profile)) { + const std::string err_msg = ("Invalid gain profile provided: " + profile); + UHD_LOG_ERROR("gain_profile", err_msg); + throw uhd::key_error(err_msg); + } + _gain_profile.at(chan) = profile; +} + +std::string enumerated_gain_profile::get_gain_profile(const size_t chan) const +{ + return _gain_profile.at(chan); +} + +std::vector<std::string> enumerated_gain_profile::get_gain_profile_names( + const size_t) const +{ + return _possible_profiles; +} + +}}} // namespace uhd::rfnoc::rf_control |