summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2015-06-14 09:13:10 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2015-06-14 09:13:10 -0700
commit6c7e4bf41a94032492839f131710a7777da2df7e (patch)
treef6056b09947b805efba06ade0023260fbea84045
parentf86e0db3a8912ee8a47c6b223ecf1ebee6cfe4d1 (diff)
parent1c9d7d93c0d87158e7cce85f39d2c1420c51c9ec (diff)
Merge remote-tracking branch 'mbr0wn/uhd/gpios'
-rw-r--r--gr-uhd/include/gnuradio/uhd/usrp_block.h56
-rw-r--r--gr-uhd/lib/usrp_block_impl.cc38
-rw-r--r--gr-uhd/lib/usrp_block_impl.h13
3 files changed, 107 insertions, 0 deletions
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_block.h b/gr-uhd/include/gnuradio/uhd/usrp_block.h
index 5605ab82fb..d57e1d24cb 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_block.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_block.h
@@ -500,6 +500,62 @@ namespace gr {
*/
virtual void set_stream_args(const ::uhd::stream_args_t &stream_args) = 0;
+ /*******************************************************************
+ * GPIO methods
+ ******************************************************************/
+ /*!
+ * Enumerate GPIO banks on the current device.
+ * \param mboard the motherboard index 0 to M-1
+ * \return a list of string for each bank name
+ */
+ virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
+
+ /*!
+ * Set a GPIO attribute on a particular GPIO bank.
+ * Possible attribute names:
+ * - CTRL - 1 for ATR mode 0 for GPIO mode
+ * - DDR - 1 for output 0 for input
+ * - OUT - GPIO output level (not ATR mode)
+ * - ATR_0X - ATR idle state
+ * - ATR_RX - ATR receive only state
+ * - ATR_TX - ATR transmit only state
+ * - ATR_XX - ATR full duplex state
+ * \param bank the name of a GPIO bank
+ * \param attr the name of a GPIO attribute
+ * \param value the new value for this GPIO bank
+ * \param mask the bit mask to effect which pins are changed
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_gpio_attr(
+ const std::string &bank,
+ const std::string &attr,
+ const boost::uint32_t value,
+ const boost::uint32_t mask = 0xffffffff,
+ const size_t mboard = 0
+ ) = 0;
+
+ /*!
+ * Get a GPIO attribute on a particular GPIO bank.
+ * Possible attribute names:
+ * - CTRL - 1 for ATR mode 0 for GPIO mode
+ * - DDR - 1 for output 0 for input
+ * - OUT - GPIO output level (not ATR mode)
+ * - ATR_0X - ATR idle state
+ * - ATR_RX - ATR receive only state
+ * - ATR_TX - ATR transmit only state
+ * - ATR_XX - ATR full duplex state
+ * - READBACK - readback input GPIOs
+ * \param bank the name of a GPIO bank
+ * \param attr the name of a GPIO attribute
+ * \param mboard the motherboard index 0 to M-1
+ * \return the value set for this attribute
+ */
+ virtual boost::uint32_t get_gpio_attr(
+ const std::string &bank,
+ const std::string &attr,
+ const size_t mboard = 0
+ ) = 0;
+
};
} /* namespace uhd */
diff --git a/gr-uhd/lib/usrp_block_impl.cc b/gr-uhd/lib/usrp_block_impl.cc
index c36898aab8..1977b89a3a 100644
--- a/gr-uhd/lib/usrp_block_impl.cc
+++ b/gr-uhd/lib/usrp_block_impl.cc
@@ -327,6 +327,29 @@ usrp_block_impl::get_time_last_pps(size_t mboard)
return _dev->get_time_last_pps(mboard);
}
+std::vector<std::string>
+usrp_block_impl::get_gpio_banks(const size_t mboard)
+{
+#ifdef UHD_USRP_MULTI_USRP_GPIO_API
+ return _dev->get_gpio_banks(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+}
+
+boost::uint32_t
+usrp_block_impl::get_gpio_attr(
+ const std::string &bank,
+ const std::string &attr,
+ const size_t mboard
+) {
+#ifdef UHD_USRP_MULTI_USRP_GPIO_API
+ return _dev->get_gpio_attr(bank, attr, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+}
+
void
usrp_block_impl::set_time_now(const ::uhd::time_spec_t &time_spec,
size_t mboard)
@@ -379,6 +402,21 @@ usrp_block_impl::set_user_register(const uint8_t addr,
#endif
}
+void
+usrp_block_impl::set_gpio_attr(
+ const std::string &bank,
+ const std::string &attr,
+ const boost::uint32_t value,
+ const boost::uint32_t mask,
+ const size_t mboard
+) {
+#ifdef UHD_USRP_MULTI_USRP_GPIO_API
+ return _dev->set_gpio_attr(bank, attr, value, mask, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+}
+
::uhd::usrp::multi_usrp::sptr
usrp_block_impl::get_device(void)
{
diff --git a/gr-uhd/lib/usrp_block_impl.h b/gr-uhd/lib/usrp_block_impl.h
index 5b38b51fa5..2158d542bc 100644
--- a/gr-uhd/lib/usrp_block_impl.h
+++ b/gr-uhd/lib/usrp_block_impl.h
@@ -62,6 +62,12 @@ namespace gr {
::uhd::time_spec_t get_time_now(size_t mboard = 0);
::uhd::time_spec_t get_time_last_pps(size_t mboard);
::uhd::usrp::multi_usrp::sptr get_device(void);
+ std::vector<std::string> get_gpio_banks(const size_t mboard);
+ boost::uint32_t get_gpio_attr(
+ const std::string &bank,
+ const std::string &attr,
+ const size_t mboard = 0
+ );
// Setters
void set_clock_config(const ::uhd::clock_config_t &clock_config, size_t mboard);
@@ -74,6 +80,13 @@ namespace gr {
void set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard);
void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard);
void clear_command_time(size_t mboard);
+ void set_gpio_attr(
+ const std::string &bank,
+ const std::string &attr,
+ const boost::uint32_t value,
+ const boost::uint32_t mask,
+ const size_t mboard
+ );
// RPC
void setup_rpc();