aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/include/uhdlib/usrp/common/mpmd_mb_controller.hpp8
-rw-r--r--host/lib/usrp/mpmd/mpmd_mb_controller.cpp40
2 files changed, 48 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/usrp/common/mpmd_mb_controller.hpp b/host/lib/include/uhdlib/usrp/common/mpmd_mb_controller.hpp
index 0c64ecbad..8111d05b8 100644
--- a/host/lib/include/uhdlib/usrp/common/mpmd_mb_controller.hpp
+++ b/host/lib/include/uhdlib/usrp/common/mpmd_mb_controller.hpp
@@ -82,6 +82,10 @@ public:
uhd::sensor_value_t get_sensor(const std::string& name);
std::vector<std::string> get_sensor_names();
uhd::usrp::mboard_eeprom_t get_eeprom();
+ std::vector<std::string> get_gpio_banks() const;
+ std::vector<std::string> get_gpio_srcs(const std::string& bank) const;
+ std::vector<std::string> get_gpio_src(const std::string& bank);
+ void set_gpio_src(const std::string& bank, const std::vector<std::string>& src);
private:
/**************************************************************************
@@ -94,6 +98,10 @@ private:
//! List of MB sensor names
std::unordered_set<std::string> _sensor_names;
+
+ //! Cache of available GPIO sources
+ std::vector<std::string> _gpio_banks;
+ std::unordered_map<std::string, std::vector<std::string>> _gpio_srcs;
};
}} // namespace uhd::rfnoc
diff --git a/host/lib/usrp/mpmd/mpmd_mb_controller.cpp b/host/lib/usrp/mpmd/mpmd_mb_controller.cpp
index 13e57b273..9aa61a5a8 100644
--- a/host/lib/usrp/mpmd/mpmd_mb_controller.cpp
+++ b/host/lib/usrp/mpmd/mpmd_mb_controller.cpp
@@ -23,10 +23,18 @@ mpmd_mb_controller::mpmd_mb_controller(
register_timekeeper(tk_idx, std::make_shared<mpmd_timekeeper>(tk_idx, _rpc));
}
+ // Enumerate sensors
auto sensor_list =
_rpc->request_with_token<std::vector<std::string>>("get_mb_sensors");
UHD_LOG_DEBUG("MPMD", "Found " << sensor_list.size() << " motherboard sensors.");
_sensor_names.insert(sensor_list.cbegin(), sensor_list.cend());
+
+ // Enumerate GPIO banks that are under mb_controller control
+ _gpio_banks = _rpc->request_with_token<std::vector<std::string>>("get_gpio_banks");
+ for (const auto& bank : _gpio_banks) {
+ _gpio_srcs.insert({bank,
+ _rpc->request_with_token<std::vector<std::string>>("get_gpio_srcs", bank)});
+ }
}
/******************************************************************************
@@ -174,3 +182,35 @@ uhd::usrp::mboard_eeprom_t mpmd_mb_controller::get_eeprom()
return mb_eeprom_dict;
}
+std::vector<std::string> mpmd_mb_controller::get_gpio_banks() const
+{
+ return _gpio_banks;
+}
+
+std::vector<std::string> mpmd_mb_controller::get_gpio_srcs(const std::string& bank) const
+{
+ if (!_gpio_srcs.count(bank)) {
+ UHD_LOG_ERROR("MPMD", "Invalid GPIO bank: `" << bank << "'");
+ throw uhd::key_error(std::string("Invalid GPIO bank: ") + bank);
+ }
+ return _gpio_srcs.at(bank);
+}
+
+std::vector<std::string> mpmd_mb_controller::get_gpio_src(const std::string& bank)
+{
+ if (!_gpio_srcs.count(bank)) {
+ UHD_LOG_ERROR("MPMD", "Invalid GPIO bank: `" << bank << "'");
+ throw uhd::key_error(std::string("Invalid GPIO bank: ") + bank);
+ }
+ return _rpc->request_with_token<std::vector<std::string>>("get_gpio_srcs", bank);
+}
+
+void mpmd_mb_controller::set_gpio_src(
+ const std::string& bank, const std::vector<std::string>& src)
+{
+ if (!_gpio_srcs.count(bank)) {
+ UHD_LOG_ERROR("MPMD", "Invalid GPIO bank: `" << bank << "'");
+ throw uhd::key_error(std::string("Invalid GPIO bank: ") + bank);
+ }
+ _rpc->notify_with_token("set_gpio_src", bank, src);
+}