commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10753 - gnuradio/branches/developers/jcorgan/gpio2/gr


From: jcorgan
Subject: [Commit-gnuradio] r10753 - gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src
Date: Thu, 2 Apr 2009 19:54:43 -0600 (MDT)

Author: jcorgan
Date: 2009-04-02 19:54:43 -0600 (Thu, 02 Apr 2009)
New Revision: 10753

Modified:
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.cc
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.h
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.cc
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.h
Log:
Python API functions for GPIO access

Modified: gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i     
2009-04-03 01:20:48 UTC (rev 10752)
+++ gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i     
2009-04-03 01:54:43 UTC (rev 10753)
@@ -81,6 +81,11 @@
   bool daughterboard_id(int *dbid);
   unsigned int overruns();
   unsigned int missing();
+  bool set_gpio_ddr(uint16_t value, uint16_t mask);
+  bool set_gpio_sels(std::string sels);
+  bool write_gpio(uint16_t value, uint16_t mask);
+  %rename(_real_read_gpio) read_gpio;
+  bool read_gpio(uint16_t *value);
 };
 
 // ----------------------------------------------------------------
@@ -147,6 +152,11 @@
   double freq_max();
   %rename(_real_daughterboard_id) daughterboard_id;
   bool daughterboard_id(int *dbid);
+  bool set_gpio_ddr(uint16_t value, uint16_t mask);
+  bool set_gpio_sels(std::string sels);
+  bool write_gpio(uint16_t value, uint16_t mask);
+  %rename(_real_read_gpio) read_gpio;
+  bool read_gpio(uint16_t *value);
 };
 
 // ----------------------------------------------------------------
@@ -195,6 +205,9 @@
   int *make_int_ptr() { return (int *)malloc(sizeof(int)); }
   int deref_int_ptr(int *l) { return *l; }
   void free_int_ptr(int *l) { free(l); }
+  uint16_t *make_uint16_ptr() { return (uint16_t *)malloc(sizeof(uint16_t)); }
+  int deref_uint16_ptr(uint16_t *l) { return *l; }
+  void free_uint16_ptr(uint16_t *l) { free(l); }
 %}
 
 long *make_long_ptr();
@@ -203,6 +216,9 @@
 int *make_int_ptr();
 int deref_int_ptr(int *l);
 void free_int_ptr(int *l);
+uint16_t *make_uint16_ptr();
+int deref_uint16_ptr(uint16_t *l);
+void free_uint16_ptr(uint16_t *l);
 
 // create a more pythonic interface
 %pythoncode %{
@@ -273,6 +289,17 @@
   self._real_default_tx_scale_iq(interp, scale_i, scale_q)
   return (deref_int_ptr(scale_i), deref_int_ptr(scale_q))
 
+def __read_gpio(self):
+  value = make_uint16_ptr()
+  r = self._real_read_gpio(value)
+  if r:
+    result = deref_uint16_ptr(value)
+  else:
+    result = None
+  free_uint16_ptr(value)
+  return result
+
+
 usrp2_source_32fc_sptr.set_center_freq = __set_center_freq
 usrp2_source_16sc_sptr.set_center_freq = __set_center_freq
 usrp2_sink_32fc_sptr.set_center_freq = __set_center_freq
@@ -306,4 +333,9 @@
 usrp2_sink_32fc_sptr.default_scale_iq = __default_tx_scale_iq
 usrp2_sink_16sc_sptr.default_scale_iq = __default_tx_scale_iq
 
+usrp2_source_32fc_sptr.read_gpio = __read_gpio
+usrp2_source_16sc_sptr.read_gpio = __read_gpio
+usrp2_sink_32fc_sptr.read_gpio = __read_gpio
+usrp2_sink_16sc_sptr.read_gpio = __read_gpio
+
 %}

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.cc  
2009-04-03 01:20:48 UTC (rev 10752)
+++ gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.cc  
2009-04-03 01:54:43 UTC (rev 10753)
@@ -129,3 +129,23 @@
 {
   return d_u2->tx_daughterboard_id(dbid);
 }
+
+bool usrp2_sink_base::set_gpio_ddr(uint16_t value, uint16_t mask)
+{
+  return d_u2->set_gpio_ddr(usrp2::GPIO_TX_BANK, value, mask);
+}
+
+bool usrp2_sink_base::set_gpio_sels(std::string sels)
+{
+  return d_u2->set_gpio_sels(usrp2::GPIO_TX_BANK, sels);
+}
+
+bool usrp2_sink_base::write_gpio(uint16_t value, uint16_t mask)
+{
+  return d_u2->write_gpio(usrp2::GPIO_TX_BANK, value, mask);
+}
+
+bool usrp2_sink_base::read_gpio(uint16_t *value)
+{
+  return d_u2->read_gpio(usrp2::GPIO_TX_BANK, value);
+}

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.h   
2009-04-03 01:20:48 UTC (rev 10752)
+++ gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_sink_base.h   
2009-04-03 01:54:43 UTC (rev 10753)
@@ -114,6 +114,26 @@
    * -2 if invalid EEPROM on daughterboard.
    */
   bool daughterboard_id(int *dbid);
+
+  /*!
+   * \brief Set daughterboard GPIO data direction register.
+   */
+  bool set_gpio_ddr(uint16_t value, uint16_t mask);
+
+  /*!
+   * \brief Set daughterboard GPIO output selection register.
+   */
+  bool set_gpio_sels(std::string sels);
+
+  /*!
+   * \brief Set daughterboard GPIO pin values.
+   */
+  bool write_gpio(uint16_t value, uint16_t mask);
+
+  /*!
+   * \brief Read daughterboard GPIO pin values
+   */
+  bool read_gpio(uint16_t *value);
 };
 
 #endif /* INCLUDED_USRP2_SINK_BASE_H */

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.cc    
    2009-04-03 01:20:48 UTC (rev 10752)
+++ 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.cc    
    2009-04-03 01:54:43 UTC (rev 10753)
@@ -147,3 +147,27 @@
 {
   return d_u2->stop_rx_streaming(0); // FIXME: someday sources will have 
channel #s
 }
+
+bool
+usrp2_source_base::set_gpio_ddr(uint16_t value, uint16_t mask)
+{
+  return d_u2->set_gpio_ddr(usrp2::GPIO_RX_BANK, value, mask);
+}
+
+bool
+usrp2_source_base::set_gpio_sels(std::string sels)
+{
+  return d_u2->set_gpio_sels(usrp2::GPIO_RX_BANK, sels);
+}
+
+bool
+usrp2_source_base::write_gpio(uint16_t value, uint16_t mask)
+{
+  return d_u2->write_gpio(usrp2::GPIO_RX_BANK, value, mask);
+}
+
+bool
+usrp2_source_base::read_gpio(uint16_t *value)
+{
+  return d_u2->read_gpio(usrp2::GPIO_RX_BANK, value);
+}

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.h 
2009-04-03 01:20:48 UTC (rev 10752)
+++ gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.h 
2009-04-03 01:54:43 UTC (rev 10753)
@@ -129,6 +129,26 @@
    * \brief Called by scheduler when stopping flowgraph
    */
   virtual bool stop();
+
+  /*!
+   * \brief Set daughterboard GPIO data direction register.
+   */
+  bool set_gpio_ddr(uint16_t value, uint16_t mask);
+
+  /*!
+   * \brief Set daughterboard GPIO output selection register.
+   */
+  bool set_gpio_sels(std::string sels);
+
+  /*!
+   * \brief Set daughterboard GPIO pin values.
+   */
+  bool write_gpio(uint16_t value, uint16_t mask);
+
+  /*!
+   * \brief Read daughterboard GPIO pin values
+   */
+  bool read_gpio(uint16_t *value);
 };
 
 #endif /* INCLUDED_USRP2_SOURCE_BASE_H */





reply via email to

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