commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 05/10: uhd: Expose GPIO functions through S


From: git
Subject: [Commit-gnuradio] [gnuradio] 05/10: uhd: Expose GPIO functions through SWIG
Date: Sun, 14 Jun 2015 16:34:15 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 1c9d7d93c0d87158e7cce85f39d2c1420c51c9ec
Author: Martin Braun <address@hidden>
Date:   Thu Jun 11 13:17:05 2015 -0700

    uhd: Expose GPIO functions through SWIG
---
 gr-uhd/include/gnuradio/uhd/usrp_block.h | 56 ++++++++++++++++++++++++++++++++
 gr-uhd/lib/usrp_block_impl.cc            | 38 ++++++++++++++++++++++
 gr-uhd/lib/usrp_block_impl.h             | 13 ++++++++
 3 files changed, 107 insertions(+)

diff --git a/gr-uhd/include/gnuradio/uhd/usrp_block.h 
b/gr-uhd/include/gnuradio/uhd/usrp_block.h
index 5605ab8..d57e1d2 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 c36898a..1977b89 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 5b38b51..2158d54 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();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]