From 1880c6915d47aee1e8d6a6713da126767c9af9cf Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Tue, 7 Dec 2021 16:47:26 -0600 Subject: host: rf_control: Add internal antenna API abstraction. --- host/lib/rfnoc/rf_control/antenna.cpp | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 host/lib/rfnoc/rf_control/antenna.cpp (limited to 'host/lib/rfnoc/rf_control/antenna.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 +#include +#include +#include +#include +#include +#include + +namespace uhd { namespace rfnoc { namespace rf_control { + +enumerated_antenna::enumerated_antenna(uhd::property_tree::sptr tree, + prop_path prop_path_generator, + const std::vector& possible_antennas, + const std::unordered_map& compat_map) + : _tree(tree) + , _prop_path_generator(prop_path_generator) + , _possible_antennas(possible_antennas) + , _compat_map(compat_map) +{ +} + +std::vector 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(path).set(ant); +} + +std::string enumerated_antenna::get_antenna(const size_t chan) const +{ + auto path = _prop_path_generator(chan); + return _tree->access(path).get(); +} + +std::string antenna_radio_control_mixin::get_tx_antenna(const size_t chan) const +{ + return _tx_antenna->get_antenna(chan); +} + +std::vector 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 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 -- cgit v1.2.3