commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10764 - in gnuradio/branches/developers/jcorgan/gpio2


From: jcorgan
Subject: [Commit-gnuradio] r10764 - in gnuradio/branches/developers/jcorgan/gpio2: gr-usrp2/src usrp2/firmware/apps usrp2/firmware/include usrp2/firmware/lib usrp2/host/include/usrp2 usrp2/host/lib
Date: Fri, 3 Apr 2009 20:48:38 -0600 (MDT)

Author: jcorgan
Date: 2009-04-03 20:48:37 -0600 (Fri, 03 Apr 2009)
New Revision: 10764

Modified:
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.cc
   gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.h
   
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/apps/app_common_v2.c
   
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/include/usrp2_eth_packet.h
   gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/memory_map.h
   gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/u2_init.c
   gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h
   gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc
   gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc
   gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h
Log:
Host code/firmware for RX side GPIO streaming.  Still debugging FPGA code.

Modified: gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i     
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2.i     
2009-04-04 02:48:37 UTC (rev 10764)
@@ -86,6 +86,7 @@
   bool write_gpio(uint16_t value, uint16_t mask);
   %rename(_real_read_gpio) read_gpio;
   bool read_gpio(uint16_t *value);
+  bool enable_gpio_streaming(int enable);
 };
 
 // ----------------------------------------------------------------

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-04 01:32:05 UTC (rev 10763)
+++ 
gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.cc    
    2009-04-04 02:48:37 UTC (rev 10764)
@@ -171,3 +171,9 @@
 {
   return d_u2->read_gpio(usrp2::GPIO_RX_BANK, value);
 }
+
+bool
+usrp2_source_base::enable_gpio_streaming(int enable)
+{
+  return d_u2->enable_gpio_streaming(usrp2::GPIO_RX_BANK, enable);
+}

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-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/gr-usrp2/src/usrp2_source_base.h 
2009-04-04 02:48:37 UTC (rev 10764)
@@ -149,6 +149,11 @@
    * \brief Read daughterboard GPIO pin values
    */
   bool read_gpio(uint16_t *value);
+
+  /*!
+   * \brief Enable streaming GPIO in sample LSBs
+   */
+  bool enable_gpio_streaming(int enable);
 };
 
 #endif /* INCLUDED_USRP2_SOURCE_BASE_H */

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/apps/app_common_v2.c  
    2009-04-04 01:32:05 UTC (rev 10763)
+++ 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/apps/app_common_v2.c  
    2009-04-04 02:48:37 UTC (rev 10764)
@@ -553,6 +553,12 @@
                     ((op_gpio_t *)payload)->mask);
       goto generic_reply;
 
+    case OP_GPIO_STREAM:
+      ok = true;
+      printf("OP_GPIO_STREAM: value=%d\n", ((op_gpio_t *)payload)->value);
+      dsp_rx_regs->gpio_stream_enable = (uint32_t)((op_gpio_t 
*)payload)->value;
+      goto generic_reply;
+
     // Add new opcode handlers here
 
     generic_reply:

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/include/usrp2_eth_packet.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/include/usrp2_eth_packet.h
        2009-04-04 01:32:05 UTC (rev 10763)
+++ 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/include/usrp2_eth_packet.h
        2009-04-04 02:48:37 UTC (rev 10764)
@@ -206,6 +206,8 @@
 #define OP_GPIO_READ_REPLY           (OP_GPIO_READ | OP_REPLY_BIT)
 #define OP_GPIO_WRITE                20
 #define OP_GPIO_WRITE_REPLY          (OP_GPIO_WRITE | OP_REPLY_BIT)
+#define OP_GPIO_STREAM               21
+#define OP_GPIO_STREAM_REPLY         (OP_GPIO_STREAM | OP_REPLY_BIT)
 
 /*
  * All subpackets are a multiple of 4 bytes long.
@@ -436,7 +438,7 @@
  * Structures for commands in GPIO system
  */
 typedef struct {
-  uint8_t       opcode;                // OP_GPIO_SET_DDR, OP_GPIO_WRITE
+  uint8_t       opcode;                // OP_GPIO_SET_DDR, OP_GPIO_WRITE, 
OP_GPIO_STREAM
   uint8_t       len;
   uint8_t       rid;
   uint8_t       bank;

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/memory_map.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/memory_map.h  
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/memory_map.h  
2009-04-04 02:48:37 UTC (rev 10764)
@@ -471,6 +471,31 @@
    */
   volatile uint32_t     rx_mux;        // called adc_mux in dsp_core_rx.v
 
+  /*!
+   * \brief Streaming GPIO configuration
+   *
+   * This determines whether the LSBs of I and Q samples come from the DSP
+   * pipeline or from the io_rx GPIO pins.  To stream GPIO, one must first
+   * set the GPIO data direction register to have io_rx[15] and/or io_rx[14]
+   * configured as inputs.  The GPIO pins will be sampled at the time the
+   * remainder of the DSP sample is strobed into the RX sample FIFO.  There
+   * will be a decimation-dependent fixed time offset between the GPIO
+   * sample stream and the associated RF samples.
+   *
+   *    3                   2                   1                       
+   *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   * +-------+-------+-------+-------+-------+-------+-------+-------+
+   * |                           MBZ                             |Q|I|
+   * +-------+-------+-------+-------+-------+-------+-------+-------+
+   *
+   * I         0=LSB comes from DSP pipeline (default)
+   *           1=LSB comes from io_rx[15]
+   * 
+   * Q         0=LSB comes from DSP pipeline (default)
+   *           1=LSB comes from io_rx[14]
+   */
+  volatile uint32_t gpio_stream_enable;
+
 } dsp_rx_regs_t;
   
 #define dsp_rx_regs ((dsp_rx_regs_t *) DSP_RX_BASE)

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/u2_init.c
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/u2_init.c     
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/firmware/lib/u2_init.c     
2009-04-04 02:48:37 UTC (rev 10764)
@@ -51,13 +51,15 @@
 bool
 u2_init(void)
 {
-  // Set GPIOs to inputs
+  // Set GPIOs to inputs, disable GPIO streaming
   hal_gpio_set_ddr(GPIO_TX_BANK, 0x0000, 0xffff);
   hal_gpio_set_ddr(GPIO_RX_BANK, 0x0000, 0xffff);
 
   hal_gpio_write(GPIO_TX_BANK, 0x0000, 0xffff);        // init s/w output 
value to zero
   hal_gpio_write(GPIO_RX_BANK, 0x0000, 0xffff);
 
+  dsp_rx_regs->gpio_stream_enable = 0; // I, Q LSBs come from DSP
+
   hal_io_init();
 
   // init spi, so that we can switch over to the high-speed clock

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h 
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h 
2009-04-04 02:48:37 UTC (rev 10764)
@@ -477,6 +477,32 @@
      */
     bool read_gpio(int bank, uint16_t *value);
 
+    /*!
+     * Set GPIO streaming mode
+     *
+     * Individually enables streaming GPIO pins through LSBs of DSP
+     * samples.
+     *
+     * On receive, io_rx[15] replaces I[0], io_rx[14] replaces Q[0]
+     * On transmit, I[0] maps to io_tx[15], Q[0] maps to io_tx[14]
+     * (Transmit streaming is not yet implemented.)
+     *
+     * The selected GPIO pins must have been set as inputs or outputs
+     * and, for transmit, set to software control.
+     *
+     * When enabled, the replaced DSP sample LSBs become 0.
+     *
+     * \param bank     GPIO_TX_BANK or GPIO_RX_BANK
+     * \param enable   enable[0] controls I channel LSB
+     *                 enable[1] controls Q channel LSB
+     *
+     * \returns true iff successful
+     *
+     * WARNING: Improper usage of this function may result in damage to the 
USRP2
+     *
+     */
+    bool enable_gpio_streaming(int bank, int enable);
+
 #if 0  // not yet implemented
     /*!
      * \brief Write EEPROM on motherboard or any daughterboard.

Modified: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc  
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc  
2009-04-04 02:48:37 UTC (rev 10764)
@@ -437,29 +437,38 @@
     return d_impl->poke32(addr, data);
   }
 
-  bool usrp2::set_gpio_ddr(int bank, uint16_t value, uint16_t mask)
+  bool
+  usrp2::set_gpio_ddr(int bank, uint16_t value, uint16_t mask)
   {
     return d_impl->set_gpio_ddr(bank, value, mask);
   }
 
-  bool usrp2::set_gpio_sels(int bank, std::string src)
+  bool
+  usrp2::set_gpio_sels(int bank, std::string src)
   {
     return d_impl->set_gpio_sels(bank, src);
   }
 
-  bool usrp2::write_gpio(int bank, uint16_t value, uint16_t mask)
+  bool
+  usrp2::write_gpio(int bank, uint16_t value, uint16_t mask)
   {
     return d_impl->write_gpio(bank, value, mask);
   }
 
-  bool usrp2::read_gpio(int bank, uint16_t *value)
+  bool
+  usrp2::read_gpio(int bank, uint16_t *value)
   {
     return d_impl->read_gpio(bank, value);
   }
 
+  bool
+  usrp2::enable_gpio_streaming(int bank, int enable)
+  {
+    return d_impl->enable_gpio_streaming(bank, enable);
+  }
+
 } // namespace usrp2
 
-
 std::ostream& operator<<(std::ostream &os, const usrp2::props &x)
 {
   os << x.addr;

Modified: 
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc     
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc     
2009-04-04 02:48:37 UTC (rev 10764)
@@ -1358,7 +1358,7 @@
   bool usrp2::impl::write_gpio(int bank, uint16_t value, uint16_t mask)
   {
     if (bank != GPIO_TX_BANK && bank != GPIO_RX_BANK) {
-      fprintf(stderr, "set_gpio_ddr: bank must be one of GPIO_RX_BANK or 
GPIO_TX_BANK");
+      fprintf(stderr, "set_gpio_ddr: bank must be one of GPIO_RX_BANK or 
GPIO_TX_BANK\n");
       return false;
     }
 
@@ -1387,7 +1387,7 @@
   bool usrp2::impl::read_gpio(int bank, uint16_t *value)
   {
     if (bank != GPIO_TX_BANK && bank != GPIO_RX_BANK) {
-      fprintf(stderr, "set_gpio_ddr: bank must be one of GPIO_RX_BANK or 
GPIO_TX_BANK");
+      fprintf(stderr, "set_gpio_ddr: bank must be one of GPIO_RX_BANK or 
GPIO_TX_BANK\n");
       return false;
     }
 
@@ -1416,4 +1416,38 @@
     return success;
   }
 
+  bool usrp2::impl::enable_gpio_streaming(int bank, int enable)
+  {
+    if (bank != GPIO_RX_BANK) {
+      fprintf(stderr, "enable_gpio_streaming: only RX streaming is currently 
implemented\n");
+      return false;
+    }
+
+    if ((enable & ~0x03) != 0) {
+      fprintf(stderr, "enable_gpio_streaming: invalid enable format\n");
+      return false;
+    }
+
+    op_gpio_cmd cmd;
+    op_generic_t reply;
+
+    memset(&cmd, 0, sizeof(cmd));
+    init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, -1);
+    cmd.op.opcode = OP_GPIO_STREAM;
+    cmd.op.len = sizeof(cmd.op);
+    cmd.op.rid = d_next_rid++;
+    cmd.op.bank = static_cast<uint8_t>(bank);
+    cmd.op.value = htons((uint16_t)enable);
+    cmd.op.mask = 0;  // not used
+    cmd.eop.opcode = OP_EOP;
+    cmd.eop.len = sizeof(cmd.eop);
+    
+    pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+    if (!transmit_cmd(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT))
+      return false;
+
+    bool success = (ntohx(reply.ok) == 1);
+    return success;
+  }
+
 } // namespace usrp2

Modified: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h      
2009-04-04 01:32:05 UTC (rev 10763)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h      
2009-04-04 02:48:37 UTC (rev 10764)
@@ -135,6 +135,7 @@
     bool set_rx_scale_iq(int scale_i, int scale_q);
     bool set_gpio_ddr(int bank, uint16_t value, uint16_t mask);
     bool set_gpio_sels(int bank, std::string src);
+    bool enable_gpio_streaming(int bank, int enable);
     bool write_gpio(int bank, uint16_t value, uint16_t mask);
     bool read_gpio(int bank, uint16_t *value);
     bool start_rx_streaming(unsigned int channel, unsigned int 
items_per_frame);





reply via email to

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