diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-08-09 17:16:01 -0500 |
---|---|---|
committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-08-16 11:40:48 -0700 |
commit | d0e8f4effa356d2c8018241e78a520c50ab23f9a (patch) | |
tree | 273908b3f73174035cdc7fa7d0ae7e3a90e7bd6f | |
parent | 029e29e24b071e0f316ca74c6d1ff614acc23e19 (diff) | |
download | uhd-d0e8f4effa356d2c8018241e78a520c50ab23f9a.tar.gz uhd-d0e8f4effa356d2c8018241e78a520c50ab23f9a.tar.bz2 uhd-d0e8f4effa356d2c8018241e78a520c50ab23f9a.zip |
multi_usrp: Add get_user_settings_iface() API call
For USRPs that support user settings (e.g., B2xx, N230), this will
return an object that will allow peeking and poking user-defined
settings registers.
Mock code example:
auto usrp = multi_usrp::make(...);
auto user_settings_iface = usrp->get_user_settings_iface();
user_settings_iface->poke32(0, 23);
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 27 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 12 |
2 files changed, 39 insertions, 0 deletions
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index c2b905426..9e098d3e1 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -33,6 +33,7 @@ #include <uhd/types/tune_result.hpp> #include <uhd/types/sensors.hpp> #include <uhd/types/filters.hpp> +#include <uhd/types/wb_iface.hpp> #include <uhd/usrp/subdev_spec.hpp> #include <uhd/usrp/dboard_iface.hpp> #include <boost/shared_ptr.hpp> @@ -437,6 +438,32 @@ public: */ virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = ALL_MBOARDS) = 0; + /*! Return a user settings interface object + * + * This is only supported by some USRPs (B2xx series, N230). It will return + * an object that will allow to peek and poke user settings, which typically + * are implemented by custom FPGA images. + * If the device does not support such an interface, it will return a null + * pointer. This allows to probe this functionality, but can lead to + * dereferencing errors if no checks are performed. + * + * A typical way to use this is as follows: + * ~~~~{.cpp} + * auto usrp = multi_usrp::make(device_args); + * const size_t chan = 0; + * auto user_settings = usrp->get_user_settings_iface(chan); + * if (!user_settings) { + * std::cout << "No user settings!" << std::endl; + * } else { + * user_settings->poke32(0, 23); // Write value 23 to register 0 + * } + * ~~~~ + * + * \returns Either a uhd::wb_iface object to poke the user settings, or a + * nullptr if the device doesn't support this interface. + */ + virtual uhd::wb_iface::sptr get_user_settings_iface(const size_t chan = 0) = 0; + /******************************************************************* * RX methods ******************************************************************/ diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 1985da254..687f1c06d 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -820,6 +820,18 @@ public: } } + wb_iface::sptr get_user_settings_iface(const size_t chan) + { + const auto user_settings_path = + rx_rf_fe_root(chan) / "user_settings" / "iface"; + if (_tree->exists(user_settings_path)) { + return _tree->access<wb_iface::sptr>(user_settings_path).get(); + } + UHD_LOG_WARNING("MULTI_USRP", + "Attempting to read back non-existant user settings iface!"); + return nullptr; + } + /******************************************************************* * RX methods ******************************************************************/ |