diff options
author | Lane Kolbly <lane.kolbly@ni.com> | 2021-12-07 16:47:26 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-01-05 10:28:39 -0600 |
commit | 1880c6915d47aee1e8d6a6713da126767c9af9cf (patch) | |
tree | ed52e29f122a9d73080f79af02494e576bdab884 /host/lib/rfnoc | |
parent | 7deb56e2123785141e44969937f0ae902ea19c00 (diff) | |
download | uhd-1880c6915d47aee1e8d6a6713da126767c9af9cf.tar.gz uhd-1880c6915d47aee1e8d6a6713da126767c9af9cf.tar.bz2 uhd-1880c6915d47aee1e8d6a6713da126767c9af9cf.zip |
host: rf_control: Add internal antenna API abstraction.
Diffstat (limited to 'host/lib/rfnoc')
-rw-r--r-- | host/lib/rfnoc/rf_control/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/rfnoc/rf_control/antenna.cpp | 84 |
2 files changed, 85 insertions, 0 deletions
diff --git a/host/lib/rfnoc/rf_control/CMakeLists.txt b/host/lib/rfnoc/rf_control/CMakeLists.txt index 11c7e57ef..f55c9a8a1 100644 --- a/host/lib/rfnoc/rf_control/CMakeLists.txt +++ b/host/lib/rfnoc/rf_control/CMakeLists.txt @@ -9,5 +9,6 @@ ######################################################################## LIBUHD_APPEND_SOURCES( + ${CMAKE_CURRENT_SOURCE_DIR}/antenna.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gain_profile.cpp ) diff --git a/host/lib/rfnoc/rf_control/antenna.cpp b/host/lib/rfnoc/rf_control/antenna.cpp new file mode 100644 index 000000000..50153f3f0 --- /dev/null +++ b/host/lib/rfnoc/rf_control/antenna.cpp @@ -0,0 +1,84 @@ +// +// Copyright 2021 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/antenna_iface.hpp> +#include <stddef.h> +#include <string> +#include <vector> + +namespace uhd { namespace rfnoc { namespace rf_control { + +enumerated_antenna::enumerated_antenna(uhd::property_tree::sptr tree, + prop_path prop_path_generator, + const std::vector<std::string>& possible_antennas, + const std::unordered_map<std::string, std::string>& compat_map) + : _tree(tree) + , _prop_path_generator(prop_path_generator) + , _possible_antennas(possible_antennas) + , _compat_map(compat_map) +{ +} + +std::vector<std::string> enumerated_antenna::get_antennas(const size_t) const +{ + return _possible_antennas; +} + +void enumerated_antenna::set_antenna(const std::string& ant, const size_t chan) +{ + if (!_compat_map.count(ant)) { + assert_has(_possible_antennas, ant, "antenna"); + } + + auto path = _prop_path_generator(chan); + + _tree->access<std::string>(path).set(ant); +} + +std::string enumerated_antenna::get_antenna(const size_t chan) const +{ + auto path = _prop_path_generator(chan); + return _tree->access<std::string>(path).get(); +} + +std::string antenna_radio_control_mixin::get_tx_antenna(const size_t chan) const +{ + return _tx_antenna->get_antenna(chan); +} + +std::vector<std::string> antenna_radio_control_mixin::get_tx_antennas( + const size_t chan) const +{ + return _tx_antenna->get_antennas(chan); +} + +void antenna_radio_control_mixin::set_tx_antenna( + const std::string& ant, const size_t chan) +{ + _tx_antenna->set_antenna(ant, chan); +} + +std::string antenna_radio_control_mixin::get_rx_antenna(const size_t chan) const +{ + return _rx_antenna->get_antenna(chan); +} + +std::vector<std::string> antenna_radio_control_mixin::get_rx_antennas( + const size_t chan) const +{ + return _rx_antenna->get_antennas(chan); +} + +void antenna_radio_control_mixin::set_rx_antenna( + const std::string& ant, const size_t chan) +{ + _rx_antenna->set_antenna(ant, chan); +} + +}}} // namespace uhd::rfnoc::rf_control |