diff options
author | Lane Kolbly <lane.kolbly@ni.com> | 2021-10-29 10:45:23 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-11-03 06:04:19 -0700 |
commit | 426f078ba015f1b0a1521ad447a5a5f79f9fc2a1 (patch) | |
tree | 29656471613b63166784b48bafe301a9370b1447 /host/lib | |
parent | 905667d69ae99a81716c9723ea429fdbf76ea6c4 (diff) | |
download | uhd-426f078ba015f1b0a1521ad447a5a5f79f9fc2a1.tar.gz uhd-426f078ba015f1b0a1521ad447a5a5f79f9fc2a1.tar.bz2 uhd-426f078ba015f1b0a1521ad447a5a5f79f9fc2a1.zip |
fixup! host: x4xx: Implement GPIO API
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/x400/x400_radio_control.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/host/lib/usrp/x400/x400_radio_control.cpp b/host/lib/usrp/x400/x400_radio_control.cpp index 8b0fbf906..a58f522bf 100644 --- a/host/lib/usrp/x400/x400_radio_control.cpp +++ b/host/lib/usrp/x400/x400_radio_control.cpp @@ -180,8 +180,11 @@ x400_radio_control_impl::x400_radio_control_impl(make_args_ptr make_args) 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)); + auto mpm_rpc = _mb_control->dynamic_cast_rpc_as<uhd::usrp::mpmd_rpc_iface>(); + if (mpm_rpc->get_gpio_banks().size() > 0) { + _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() @@ -333,12 +336,18 @@ double x400_radio_control_impl::set_rate(const double rate) std::vector<std::string> x400_radio_control_impl::get_gpio_banks() const { + if (!_gpios) { + return {}; + } return {x400::GPIO_BANK_NAME}; } uint32_t x400_radio_control_impl::get_gpio_attr( const std::string& bank, const std::string& attr) { + if (!_gpios) { + throw uhd::runtime_error("X410 does not have sufficient GPIO support!"); + } std::lock_guard<std::recursive_mutex> l(_lock); if (bank != x400::GPIO_BANK_NAME) { throw uhd::key_error("Invalid GPIO bank " + bank); @@ -352,6 +361,9 @@ uint32_t x400_radio_control_impl::get_gpio_attr( void x400_radio_control_impl::set_gpio_attr( const std::string& bank, const std::string& attr, const uint32_t value) { + if (!_gpios) { + throw uhd::runtime_error("X410 does not have sufficient GPIO support!"); + } std::lock_guard<std::recursive_mutex> l(_lock); if (bank != x400::GPIO_BANK_NAME) { throw uhd::key_error("Invalid GPIO bank " + bank); |