From 4b1b276fdd0e98f25a3f357dab8453e17b1aa4cf Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 10 Jan 2012 10:21:43 -0800 Subject: uhd: add API call to set user registers --- gr-uhd/include/gr_uhd_usrp_sink.h | 9 +++++++++ gr-uhd/include/gr_uhd_usrp_source.h | 9 +++++++++ gr-uhd/lib/gr_uhd_usrp_sink.cc | 5 +++++ gr-uhd/lib/gr_uhd_usrp_source.cc | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h index ce76ec03b..d6cbe2fdc 100644 --- a/gr-uhd/include/gr_uhd_usrp_sink.h +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -448,6 +448,15 @@ public: * \return the multi usrp device object */ virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; + + /*! + * Perform write on the user configuration register bus. These only exist if + * the user has implemented custom setting registers in the device FPGA. + * \param addr 8-bit register address + * \param data 32-bit register value + * \param mboard which motherboard to set the user register + */ + virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = 0) = 0; }; #endif /* INCLUDED_GR_UHD_USRP_SINK_H */ diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index 8a799b397..cf2186bc0 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -456,6 +456,15 @@ public: */ virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; + /*! + * Perform write on the user configuration register bus. These only exist if + * the user has implemented custom setting registers in the device FPGA. + * \param addr 8-bit register address + * \param data 32-bit register value + * \param mboard which motherboard to set the user register + */ + virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = 0) = 0; + /*! * Convenience function for finite data acquisition. * This is not to be used with the scheduler; rather, diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 05237100c..8ff7c1f6e 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -278,6 +278,11 @@ public: return _dev; } + void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ + _dev->set_user_register(addr, data, mboard); + } + + /*********************************************************************** * Work **********************************************************************/ diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 2244238bd..26cd0bf27 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -290,6 +290,10 @@ public: return _dev; } + void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ + _dev->set_user_register(addr, data, mboard); + } + /*********************************************************************** * Work **********************************************************************/ -- cgit From 30adb8816974f1e4580ea5bb1ee27a9a12dbb78e Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Fri, 16 Mar 2012 14:32:34 -0700 Subject: uhd: conditionalize set_user_register call on availability in UHD API --- gr-uhd/lib/gr_uhd_usrp_sink.cc | 6 +++++- gr-uhd/lib/gr_uhd_usrp_source.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 8ff7c1f6e..7d173d972 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -279,7 +279,11 @@ public: } void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ - _dev->set_user_register(addr, data, mboard); + #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API + _dev->set_user_register(addr, data, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif } diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 26cd0bf27..5d3a3321e 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -291,7 +291,11 @@ public: } void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ - _dev->set_user_register(addr, data, mboard); + #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API + _dev->set_user_register(addr, data, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif } /*********************************************************************** -- cgit