diff options
author | Lane Kolbly <lane.kolbly@ni.com> | 2021-10-18 16:45:46 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-11-03 06:04:19 -0700 |
commit | c23dc3b0122a46353810d1ccbe98c08b080850e8 (patch) | |
tree | d89ab38b0565190737bd5e16b65c601f4df58fd6 /host/lib/usrp/x400/x400_radio_control.cpp | |
parent | 3162b92bedda20f5b376137f5e918ebe07406fbb (diff) | |
download | uhd-c23dc3b0122a46353810d1ccbe98c08b080850e8.tar.gz uhd-c23dc3b0122a46353810d1ccbe98c08b080850e8.tar.bz2 uhd-c23dc3b0122a46353810d1ccbe98c08b080850e8.zip |
host: x4xx: Implement GPIO API
This implements the GPIO API for X410 through get_gpio_attr and
set_gpio_attr. In ATR mode, which channel's ATR state is chosen by the
set_gpio_src call, setting e.g. DB0_RF0 for channel 0 or DB0_RF1 for
channel 1. In manual mode, all 24 bits (for both ports) are set in
a single register write.
Although the front panel of the device has two ports, labelled GPIO0 and
GPIO1, this API exposes them as though they were a single 24-bit GPIO
port.
Diffstat (limited to 'host/lib/usrp/x400/x400_radio_control.cpp')
-rw-r--r-- | host/lib/usrp/x400/x400_radio_control.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/host/lib/usrp/x400/x400_radio_control.cpp b/host/lib/usrp/x400/x400_radio_control.cpp index 281ae7916..8b0fbf906 100644 --- a/host/lib/usrp/x400/x400_radio_control.cpp +++ b/host/lib/usrp/x400/x400_radio_control.cpp @@ -12,6 +12,7 @@ #include <uhdlib/usrp/dboard/debug_dboard.hpp> #include <uhdlib/usrp/dboard/null_dboard.hpp> #include <uhdlib/usrp/dboard/zbx/zbx_dboard.hpp> +#include <uhdlib/rfnoc/reg_iface_adapter.hpp> namespace uhd { namespace rfnoc { @@ -178,6 +179,9 @@ x400_radio_control_impl::x400_radio_control_impl(make_args_ptr make_args) get_num_output_ports(), _adc_self_calibration, get_unique_id()); register_feature(_fpga_onload); _mb_control->_fpga_onload->request_cb(_fpga_onload); + + _gpios = std::make_shared<x400::gpio_control>(_rpcc, + RFNOC_MAKE_WB_IFACE(regmap::PERIPH_BASE + 0xC000, 0)); } void x400_radio_control_impl::_init_prop_tree() @@ -327,6 +331,37 @@ double x400_radio_control_impl::set_rate(const double rate) return get_rate(); } +std::vector<std::string> x400_radio_control_impl::get_gpio_banks() const +{ + return {x400::GPIO_BANK_NAME}; +} + +uint32_t x400_radio_control_impl::get_gpio_attr( + const std::string& bank, const std::string& attr) +{ + std::lock_guard<std::recursive_mutex> l(_lock); + if (bank != x400::GPIO_BANK_NAME) { + throw uhd::key_error("Invalid GPIO bank " + bank); + } + if (usrp::gpio_atr::gpio_attr_rev_map.count(attr) == 0) { + throw uhd::key_error("Invalid GPIO attribute " + attr); + } + return _gpios->get_gpio_attr(usrp::gpio_atr::gpio_attr_rev_map.at(attr)); +} + +void x400_radio_control_impl::set_gpio_attr( + const std::string& bank, const std::string& attr, const uint32_t value) +{ + std::lock_guard<std::recursive_mutex> l(_lock); + if (bank != x400::GPIO_BANK_NAME) { + throw uhd::key_error("Invalid GPIO bank " + bank); + } + if (usrp::gpio_atr::gpio_attr_rev_map.count(attr) == 0) { + throw uhd::key_error("Invalid GPIO attribute " + attr); + } + _gpios->set_gpio_attr(usrp::gpio_atr::gpio_attr_rev_map.at(attr), value); +} + eeprom_map_t x400_radio_control_impl::get_db_eeprom() { std::lock_guard<std::recursive_mutex> l(_lock); |