commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9805 - in gnuradio/branches/developers/eb/u2-wip2: gr


From: eb
Subject: [Commit-gnuradio] r9805 - in gnuradio/branches/developers/eb/u2-wip2: gr-usrp2/src usrp2/host/include/usrp2 usrp2/host/lib
Date: Sat, 18 Oct 2008 13:56:30 -0600 (MDT)

Author: eb
Date: 2008-10-18 13:56:29 -0600 (Sat, 18 Oct 2008)
New Revision: 9805

Modified:
   gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_16sc.cc
   gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_32fc.cc
   gnuradio/branches/developers/eb/u2-wip2/usrp2/host/include/usrp2/usrp2.h
   gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h
   gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc
   gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc
   gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h
Log:
rolled eb/u2-wip changes into eb/u2-wip2.  Merged eb/u2-wip -r9643:9803 \
in to eb/u2-wip2

Modified: 
gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_16sc.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_16sc.cc     
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_16sc.cc     
2008-10-18 19:56:29 UTC (rev 9805)
@@ -62,7 +62,7 @@
   metadata.send_now = 1;
   metadata.start_of_burst = 1;
 
-  bool ok = d_u2->tx_16sc(0,  // FIXME: use channel number instead of 0
+  bool ok = d_u2->tx_16sc(0,  // FIXME: someday, streams will have channel 
numbers
                          in, noutput_items, &metadata);
   if (!ok){
     std::cerr << "usrp2_sink_16sc: tx_16sc failed" << std::endl;

Modified: 
gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_32fc.cc     
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/gr-usrp2/src/usrp2_sink_32fc.cc     
2008-10-18 19:56:29 UTC (rev 9805)
@@ -62,7 +62,7 @@
   metadata.send_now = 1;
   metadata.start_of_burst = 1;
 
-  bool ok = d_u2->tx_32fc(0, // FIXME: use channel number instead of 0
+  bool ok = d_u2->tx_32fc(0, // FIXME: someday, streams will have channel 
numbers
                          in, noutput_items, &metadata);
   if (!ok){
     std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl;

Modified: 
gnuradio/branches/developers/eb/u2-wip2/usrp2/host/include/usrp2/usrp2.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/include/usrp2/usrp2.h    
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/include/usrp2/usrp2.h    
2008-10-18 19:56:29 UTC (rev 9805)
@@ -26,9 +26,15 @@
 //#include <iosfwd>
 #include <usrp2/rx_sample_handler.h>
 #include <usrp2/tune_result.h>
-#include <usrp2/rx_sample_handler.h>
 
 
+/*
+ * N.B., The interfaces described here are still in flux.
+ *
+ * We will keep all the code in the tree up-to-date with regard to changes
+ * here, but reserve the right to change this on a whim.
+ */
+
 namespace usrp2 {
 
   /*!
@@ -89,14 +95,6 @@
      */
     std::string mac_addr();
 
-    /*!
-     * Burn new mac address into EEPROM on USRP2
-     *
-     * \param new_addr  Network mac address, e.g., "01:23:45:67:89:ab" or 
"89:ab".
-     *                  If \p addr is HH:HH, it's treated as if it were 
00:50:c2:85:HH:HH
-     */
-    bool burn_mac_addr(const std::string &new_addr);
-
     /*
      * ----------------------------------------------------------------
      * Rx configuration and control
@@ -253,7 +251,11 @@
                size_t nitems,
                const tx_metadata *metadata);
 
-    // ----------------------------------------------------------------
+    /*
+     * ----------------------------------------------------------------
+     *  miscellaneous methods
+     * ----------------------------------------------------------------
+     */
 
     /*!
      * \brief MIMO configuration
@@ -274,6 +276,122 @@
      */
     bool config_mimo(int flags);
 
+
+    //! Get frequency of master oscillator in Hz
+    bool fpga_master_clock_freq(long *freq);
+
+    // Get Sampling rate of A/D converter in Hz
+    bool adc_rate(long *rate);
+
+    // Get Sampling rate of D/A converter in Hz
+    bool dac_rate(long *rate);
+
+    /*!
+     * \brief Get Tx daughterboard ID
+     *
+     * \param[out] dbid returns the daughterboard id.
+     *
+     * daughterboard id >= 0 if successful, -1 if no daugherboard installed,
+     * -2 if invalid EEPROM on daughterboard.
+     */
+    bool tx_daughterboard_id(int *dbid);
+
+    /*!
+     * \brief Get Rx daughterboard ID
+     *
+     * \param[out] dbid returns the daughterboard id.
+     *
+     * daughterboard id >= 0 if successful, -1 if no daugherboard installed,
+     * -2 if invalid EEPROM on daughterboard.
+     */
+    bool rx_daughterboard_id(int *dbid);
+
+    /*
+     * ----------------------------------------------------------------
+     *  Low level methods
+     * ----------------------------------------------------------------
+     */
+
+    /*!
+     * Burn new mac address into EEPROM on USRP2
+     *
+     * \param new_addr  Network mac address, e.g., "01:23:45:67:89:ab" or 
"89:ab".
+     *                  If \p addr is HH:HH, it's treated as if it were 
00:50:c2:85:HH:HH
+     */
+    bool burn_mac_addr(const std::string &new_addr);
+
+
+#if 0  // not yet implemented
+    /*!
+     * \brief Write EEPROM on motherboard or any daughterboard.
+     * \param i2c_addr         I2C bus address of EEPROM
+     * \param eeprom_offset    byte offset in EEPROM to begin writing
+     * \param buf              the data to write
+     * \returns true iff sucessful
+     */
+    bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string 
&buf);
+
+    /*!
+     * \brief Read EEPROM on motherboard or any daughterboard.
+     * \param i2c_addr         I2C bus address of EEPROM
+     * \param eeprom_offset    byte offset in EEPROM to begin reading
+     * \param len              number of bytes to read
+     * \returns the data read if successful, else a zero length string.
+     */
+    std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+
+    /*!
+     * \brief Write to I2C peripheral
+     * \param i2c_addr         I2C bus address (7-bits)
+     * \param buf              the data to write
+     * \returns true iff successful
+     * Writes are limited to a maximum of of 64 bytes.
+     */
+    bool write_i2c (int i2c_addr, const std::string &buf);
+
+    /*!
+     * \brief Read from I2C peripheral
+     * \param i2c_addr         I2C bus address (7-bits)
+     * \param len              number of bytes to read
+     * \returns the data read if successful, else a zero length string.
+     * Reads are limited to a maximum of 64 bytes.
+     */
+    std::string read_i2c (int i2c_addr, int len);
+
+    /*!
+     * \brief Write data to SPI bus peripheral.
+     *
+     * \param optional_header  0,1 or 2 bytes to write before buf.
+     * \param enables          bitmask of peripherals to write. See 
usrp_spi_defs.h
+     * \param format           transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+     * \param buf              the data to write
+     * \returns true iff successful
+     * Writes are limited to a maximum of 64 bytes.
+     *
+     * If \p format specifies that optional_header bytes are present, they are
+     * written to the peripheral immediately prior to writing \p buf.
+     */
+    bool write_spi (int optional_header, int enables, int format, const 
std::string &buf);
+
+    /*
+     * \brief Read data from SPI bus peripheral.
+     *
+     * \param optional_header  0,1 or 2 bytes to write before buf.
+     * \param enables          bitmask of peripheral to read. See 
usrp_spi_defs.h
+     * \param format           transaction format.  See usrp_spi_defs.h 
SPI_FMT_*
+     * \param len              number of bytes to read.  Must be in [0,64].
+     * \returns the data read if sucessful, else a zero length string.
+     *
+     * Reads are limited to a maximum of 64 bytes.
+     *
+     * If \p format specifies that optional_header bytes are present, they
+     * are written to the peripheral first.  Then \p len bytes are read from
+     * the peripheral and returned.
+     */
+    std::string read_spi (int optional_header, int enables, int format, int 
len);
+#endif
+
+
     class impl;                // implementation details
 
   private:

Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h    
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/control.h    
2008-10-18 19:56:29 UTC (rev 9805)
@@ -53,6 +53,13 @@
     op_generic_t      eop;
   };
 
+  struct op_config_mimo_cmd
+  {
+    u2_eth_packet_t   h;
+    op_config_mimo_t  op;
+    op_generic_t      eop;
+  };
+
   struct op_burn_mac_addr_cmd 
   {
     u2_eth_packet_t    h;

Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc     
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2.cc     
2008-10-18 19:56:29 UTC (rev 9805)
@@ -160,13 +160,6 @@
     return d_impl->mac_addr();
   }
 
-  bool
-  usrp2::burn_mac_addr(const std::string &new_addr)
-  {
-    return d_impl->burn_mac_addr(new_addr);
-  }
-
-
   // Receive
 
   bool 
@@ -276,6 +269,54 @@
     return d_impl->tx_raw(channel, items, nitems, metadata);
   }
 
+  // miscellaneous methods
+
+  bool
+  usrp2::config_mimo(int flags)
+  {
+    return d_impl->config_mimo(flags);
+  }
+
+  bool
+  usrp2::fpga_master_clock_freq(long *freq)
+  {
+    return d_impl->fpga_master_clock_freq(freq);
+  }
+
+  bool
+  usrp2::adc_rate(long *rate)
+  {
+    return d_impl->adc_rate(rate);
+  }
+
+  bool
+  usrp2::dac_rate(long *rate)
+  {
+    return d_impl->dac_rate(rate);
+  }
+
+  bool
+  usrp2::tx_daughterboard_id(int *dbid)
+  {
+    return d_impl->tx_daughterboard_id(dbid);
+  }
+
+  bool
+  usrp2::rx_daughterboard_id(int *dbid)
+  {
+    return d_impl->rx_daughterboard_id(dbid);
+  }
+  
+
+  // low level methods
+
+  bool
+  usrp2::burn_mac_addr(const std::string &new_addr)
+  {
+    return d_impl->burn_mac_addr(new_addr);
+  }
+
+
 } // namespace usrp2
 
 

Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc        
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.cc        
2008-10-18 19:56:29 UTC (rev 9805)
@@ -68,6 +68,7 @@
     case OP_CONFIG_TX_REPLY_V2: return "OP_CONFIG_TX_REPLY_V2";
     case OP_START_RX_STREAMING: return "OP_START_RX_STREAMING";
     case OP_STOP_RX: return "OP_STOP_RX";
+    case OP_CONFIG_MIMO: return "OP_CONFIG_MIMO";
 #if 0
     case OP_WRITE_REG: return "OP_WRITE_REG";
     case OP_WRITE_REG_MASKED: return "OP_WRITE_REG_MASKED";
@@ -105,9 +106,13 @@
     md->word0 = u2p_word0(fh);
     md->timestamp = u2p_timestamp(fh);
 
+    // FIXME when we've got more info
     // md->start_of_burst = (md->word0 & XXX) != 0;
     // md->end_of_burst =   (md->word0 & XXX) != 0;
     // md->rx_overrun =     (md->word0 & XXX) != 0;
+    md->start_of_burst = 0;
+    md->end_of_burst =   0;
+    md->rx_overrun =     0;
 
     *items = (uint32_t *)(&fh[1]);
     size_t nbytes = payload_len_in_bytes - sizeof(u2_fixed_hdr_t);
@@ -412,33 +417,6 @@
 
 
   // ----------------------------------------------------------------
-  //                      misc commands
-  // ----------------------------------------------------------------
-
-  bool
-  usrp2::impl::burn_mac_addr(const std::string &new_addr)
-  {
-    op_burn_mac_addr_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_BURN_MAC_ADDR;
-    cmd.op.len = sizeof(cmd.op);
-    cmd.op.rid = d_next_rid++;
-    if (!parse_mac_addr(new_addr, &cmd.op.addr))
-      return false;
-
-    pending_reply p(cmd.op.rid, &reply, sizeof(reply));
-    if (!transmit_cmd(&cmd, sizeof(cmd), &p, 4*DEF_CMD_TIMEOUT))
-      return false;
-
-    bool success = (ntohx(reply.ok) == 1);
-    return success;
-  }
-
-
-  // ----------------------------------------------------------------
   //                          Receive
   // ----------------------------------------------------------------
 
@@ -870,5 +848,90 @@
     return true;
   }
 
+  // ----------------------------------------------------------------
+  //                      misc commands
+  // ----------------------------------------------------------------
 
+  bool
+  usrp2::impl::config_mimo(int flags)
+  {
+    op_config_mimo_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_CONFIG_MIMO;
+    cmd.op.len = sizeof(cmd.op);
+    cmd.op.rid = d_next_rid++;
+    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;
+
+    return ntohx(reply.ok) == 1;
+  }
+
+  bool
+  usrp2::impl::fpga_master_clock_freq(long *freq)
+  {
+    *freq = 100000000L;                // 100 MHz
+    return true;
+  }
+
+  bool
+  usrp2::impl::adc_rate(long *rate)
+  {
+    return fpga_master_clock_freq(rate);
+  }
+
+  bool
+  usrp2::impl::dac_rate(long *rate)
+  {
+    return fpga_master_clock_freq(rate);
+  }
+
+  bool
+  usrp2::impl::tx_daughterboard_id(int *dbid)
+  {
+    *dbid = -1;                // FIXME implement
+    return true;
+  }
+
+  bool
+  usrp2::impl::rx_daughterboard_id(int *dbid)
+  {
+    *dbid = -1;                // FIXME implement
+    return true;
+  }
+
+
+  // ----------------------------------------------------------------
+  //                   low-level commands
+  // ----------------------------------------------------------------
+
+  bool
+  usrp2::impl::burn_mac_addr(const std::string &new_addr)
+  {
+    op_burn_mac_addr_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_BURN_MAC_ADDR;
+    cmd.op.len = sizeof(cmd.op);
+    cmd.op.rid = d_next_rid++;
+    if (!parse_mac_addr(new_addr, &cmd.op.addr))
+      return false;
+
+    pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+    if (!transmit_cmd(&cmd, sizeof(cmd), &p, 4*DEF_CMD_TIMEOUT))
+      return false;
+
+    bool success = (ntohx(reply.ok) == 1);
+    return success;
+  }
+
+
 } // namespace usrp2

Modified: gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h 
2008-10-18 19:26:25 UTC (rev 9804)
+++ gnuradio/branches/developers/eb/u2-wip2/usrp2/host/lib/usrp2_impl.h 
2008-10-18 19:56:29 UTC (rev 9805)
@@ -95,8 +95,9 @@
     void bg_loop();
 
     std::string mac_addr() const { return d_addr; } // FIXME: convert from 
u2_mac_addr_t
-    bool burn_mac_addr(const std::string &new_addr);
 
+    // Rx
+
     bool set_rx_gain(double gain);
     bool set_rx_center_freq(double frequency, tune_result *result);
     bool set_rx_decim(int decimation_factor);
@@ -107,6 +108,8 @@
     unsigned int rx_overruns() const { return d_num_rx_overruns; }
     unsigned int rx_missing() const { return d_num_rx_missing; }
 
+    // Tx
+
     bool set_tx_gain(double gain);
     bool set_tx_center_freq(double frequency, tune_result *result);
     bool set_tx_interp(int interpolation_factor);
@@ -126,6 +129,19 @@
                const uint32_t *items,
                size_t nitems,
                const tx_metadata *metadata);
+
+    // misc
+
+    bool config_mimo(int flags);
+    bool fpga_master_clock_freq(long *freq);
+    bool adc_rate(long *rate);
+    bool dac_rate(long *rate);
+    bool tx_daughterboard_id(int *dbid);
+    bool rx_daughterboard_id(int *dbid);
+
+    // low level
+
+    bool burn_mac_addr(const std::string &new_addr);
   };
   
 } // namespace usrp2





reply via email to

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