commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8995 - in usrp2/trunk: firmware/apps firmware/include


From: eb
Subject: [Commit-gnuradio] r8995 - in usrp2/trunk: firmware/apps firmware/include firmware/lib host/apps host/lib
Date: Thu, 24 Jul 2008 11:34:45 -0600 (MDT)

Author: eb
Date: 2008-07-24 11:34:45 -0600 (Thu, 24 Jul 2008)
New Revision: 8995

Added:
   usrp2/trunk/firmware/include/usrp2_mimo_config.h
Modified:
   usrp2/trunk/firmware/apps/app_common_v2.c
   usrp2/trunk/firmware/include/usrp2_eth_packet.h
   usrp2/trunk/firmware/lib/clocks.c
   usrp2/trunk/firmware/lib/clocks.h
   usrp2/trunk/firmware/lib/u2_init.c
   usrp2/trunk/host/apps/rx_samples.cc
   usrp2/trunk/host/apps/rx_streaming_samples.cc
   usrp2/trunk/host/lib/usrp2_basic.cc
   usrp2/trunk/host/lib/usrp2_basic.h
Log:
added firmware and host support for configuring mimo clocking

Modified: usrp2/trunk/firmware/apps/app_common_v2.c
===================================================================
--- usrp2/trunk/firmware/apps/app_common_v2.c   2008-07-24 06:28:35 UTC (rev 
8994)
+++ usrp2/trunk/firmware/apps/app_common_v2.c   2008-07-24 17:34:45 UTC (rev 
8995)
@@ -27,6 +27,7 @@
 #include "nonstdio.h"
 #include "print_rmon_regs.h"
 #include "db.h"
+#include "clocks.h"
 #include <string.h>
 
 volatile bool link_is_up = false;      // eth handler sets this
@@ -38,6 +39,9 @@
 static unsigned char exp_seqno = 0;
 
 
+void config_mimo_cmd(op_config_mimo_t *p /* , op_generic_t *r */);
+
+
 static void
 burn_mac_addr(const op_burn_mac_addr_t *p)
 {
@@ -160,6 +164,10 @@
     send_reply(reply, reply_len);
     break;
 
+  case OP_CONFIG_MIMO:
+    config_mimo_cmd((op_config_mimo_t *) p);
+    break;
+    
   default:
     printf("app_common_v2: unhandled opcode = %d\n", opcode);
     break;
@@ -349,3 +357,10 @@
   r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq);
   r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq);
 }
+
+void
+config_mimo_cmd(op_config_mimo_t *p /* , op_generic_t *r */)
+{
+  clocks_mimo_config(p->flags);
+  // FIXME build generic reply
+}

Modified: usrp2/trunk/firmware/include/usrp2_eth_packet.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_eth_packet.h     2008-07-24 06:28:35 UTC 
(rev 8994)
+++ usrp2/trunk/firmware/include/usrp2_eth_packet.h     2008-07-24 17:34:45 UTC 
(rev 8995)
@@ -22,6 +22,7 @@
 #include "usrp2_cdefs.h"
 #include "usrp2_bytesex.h"
 #include "usrp2_mac_addr.h"
+#include "usrp2_mimo_config.h"
 
 __U2_BEGIN_DECLS
 
@@ -167,6 +168,7 @@
 #define        OP_CONFIG_TX_REPLY_V2   9
 #define        OP_START_RX_STREAMING  10
 #define        OP_STOP_RX             11
+#define        OP_CONFIG_MIMO         12       // FIXME on merge
 
 #define        OP_START_RX            20       // deprecated
 #define OP_CONFIG_TX          21       // deprecated
@@ -336,7 +338,17 @@
 
 } op_config_tx_reply_v2_t;
 
+/*!
+ * \brief Configure MIMO clocking, etc (uses generic reply)
+ */
+typedef struct {
+  uint8_t      opcode;
+  uint8_t      len;
+  uint8_t      rid;
+  uint8_t      flags;  // from usrp_mimo_config.h
+} op_config_mimo_t;
 
+
 /*
  * ================================================================
  *                 deprecated subpacket types

Added: usrp2/trunk/firmware/include/usrp2_mimo_config.h
===================================================================
--- usrp2/trunk/firmware/include/usrp2_mimo_config.h                            
(rev 0)
+++ usrp2/trunk/firmware/include/usrp2_mimo_config.h    2008-07-24 17:34:45 UTC 
(rev 8995)
@@ -0,0 +1,46 @@
+/* -*- c -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_USRP2_MIMO_CONFIG_H
+#define INCLUDED_USRP2_MIMO_CONFIG_H
+
+#define        _MC_WE_LOCK                     0x0001
+#define        _MC_MIMO_CLK_INPUT              0x0002          // else SMA 
input
+
+/*
+ * Derived masks (use these):
+ *
+ * We get our input from 1 of three places:
+ *  Our free running oscilator, our SMA connector, or from the MIMO connector
+ */
+#define        MC_WE_DONT_LOCK                 0x0000
+#define        MC_WE_LOCK_TO_SMA               (_MC_WE_LOCK | 0)
+#define        MC_WE_LOCK_TO_MIMO              (_MC_WE_LOCK | 
_MC_MIMO_CLK_INPUT)
+
+/*
+ * Independent of the source of the clock, we may or may not drive our
+ * clock onto the mimo connector.  Note that there are dedicated clock
+ * signals in each direction, so disaster doesn't occurs if we're
+ * unnecessarily providing clock.
+ */
+#define        MC_PROVIDE_CLK_TO_MIMO          0x0004
+
+
+#endif /* INCLUDED_USRP2_MIMO_CONFIG_H */


Property changes on: usrp2/trunk/firmware/include/usrp2_mimo_config.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: usrp2/trunk/firmware/lib/clocks.c
===================================================================
--- usrp2/trunk/firmware/lib/clocks.c   2008-07-24 06:28:35 UTC (rev 8994)
+++ usrp2/trunk/firmware/lib/clocks.c   2008-07-24 17:34:45 UTC (rev 8995)
@@ -48,7 +48,7 @@
   timesync_regs->tick_control = 4;
 
   // Primary clock configuration
-  clocks_mimo_config(CMC_WE_DONT_LOCK);
+  clocks_mimo_config(MC_WE_DONT_LOCK);
 
   // Set up other clocks
 
@@ -61,9 +61,6 @@
   ad9510_write_reg(0x53, 0x80); // Bypass divider
   ad9510_write_reg(0x5A, 0x01); // Update Regs
 
-  // Enable ADCs
-  output_regs->adc_ctrl = ADC_CTRL_ON;
-  
   // Enable clock to ADCs and DACs
   ad9510_write_reg(0x3F, 0x00); // Turn on output 3 (DAC CLK), normal levels
   ad9510_write_reg(0x4F, 0x80); // Bypass Div #3
@@ -78,7 +75,7 @@
 void
 clocks_mimo_config(int flags)
 {
-  if (flags & _CMC_WE_LOCK){
+  if (flags & _MC_WE_LOCK){
     // Reg 8, Charge pump on, dig lock det, positive PFD, 47
     ad9510_write_reg(0x08, 0x47);
   }
@@ -103,8 +100,8 @@
 
   // Allow for clock switchover
 
-  if (flags & _CMC_WE_LOCK){           // WE LOCK
-    if (flags & _CMC_MIMO_CLK_INPUT) {
+  if (flags & _MC_WE_LOCK){            // WE LOCK
+    if (flags & _MC_MIMO_CLK_INPUT) {
       // Turn on ref output and choose the MIMO connector
       output_regs->clk_ctrl = 0x15;  
     }
@@ -120,7 +117,7 @@
 
   // Do we drive a clock onto the MIMO connector?
 
-  if (flags & CMC_PROVIDE_CLK_TO_MIMO) {
+  if (flags & MC_PROVIDE_CLK_TO_MIMO) {
     ad9510_write_reg(0x3E, 0x00); // Turn on output 2 (clk_exp_out), normal 
levels
     ad9510_write_reg(0x4D, 0x00); // Turn on Div2
     ad9510_write_reg(0x4C, 0x44); // Set Div2 = 10, output a 10 MHz clock

Modified: usrp2/trunk/firmware/lib/clocks.h
===================================================================
--- usrp2/trunk/firmware/lib/clocks.h   2008-07-24 06:28:35 UTC (rev 8994)
+++ usrp2/trunk/firmware/lib/clocks.h   2008-07-24 17:34:45 UTC (rev 8995)
@@ -24,6 +24,7 @@
  */
 
 #include <bool.h>
+#include <usrp2_mimo_config.h>
 
 
 /*!
@@ -38,32 +39,10 @@
  * \brief MIMO clock configuration.
  *
  * Configure our master clock source, and whether or not we drive a
- * clock onto the mimo connector.  See CMC_flags below.
+ * clock onto the mimo connector.  See MC_flags in usrp2_mimo_config.h.
  */
 void clocks_mimo_config(int flags);
 
-#define        _CMC_WE_LOCK                    0x0001
-#define        _CMC_MIMO_CLK_INPUT             0x0002          // else SMA 
input
-
-/*
- * Derived masks (use these):
- *
- * We get our input from 1 of three places:
- *  Our free running oscilator, our SMA connector, or from the MIMO connector
- */
-#define        CMC_WE_DONT_LOCK                0x0000
-#define        CMC_WE_LOCK_TO_SMA              (_CMC_WE_LOCK | 0)
-#define        CMC_WE_LOCK_TO_MIMO             (_CMC_WE_LOCK | 
_CMC_MIMO_CLK_INPUT)
-
-/*
- * Independent of the source of the clock, we may or may not drive our
- * clock onto the mimo connector.  Note that there are dedicated clock
- * signals in each direction, so disaster doesn't occurs if we're
- * unnecessarily providing clock.
- */
-#define        CMC_PROVIDE_CLK_TO_MIMO         0x0004
-
-
 /*!
  * \brief Enable or disable test clock (extra clock signal)
  */

Modified: usrp2/trunk/firmware/lib/u2_init.c
===================================================================
--- usrp2/trunk/firmware/lib/u2_init.c  2008-07-24 06:28:35 UTC (rev 8994)
+++ usrp2/trunk/firmware/lib/u2_init.c  2008-07-24 17:34:45 UTC (rev 8995)
@@ -55,6 +55,9 @@
   // set up the default clocks
   clocks_init();
 
+  // Enable ADCs
+  output_regs->adc_ctrl = ADC_CTRL_ON;
+
   // Set up AD9777 DAC
   ad9777_write_reg(0, R0_1R);
   ad9777_write_reg(1, R1_INTERP_4X | R1_REAL_MIX);

Modified: usrp2/trunk/host/apps/rx_samples.cc
===================================================================
--- usrp2/trunk/host/apps/rx_samples.cc 2008-07-24 06:28:35 UTC (rev 8994)
+++ usrp2/trunk/host/apps/rx_samples.cc 2008-07-24 17:34:45 UTC (rev 8995)
@@ -97,6 +97,8 @@
   fprintf(stderr, "  -N NSAMPLES          total number of samples to receive 
[default=2.5e6]\n");
   fprintf(stderr, "  -F SAMPLES_PER_FRAME number of samples in each frame 
[default=371]\n");
   fprintf(stderr, "  -S SCALE             fpga scaling factor for I & Q 
[default=1024]\n");
+  fprintf(stderr, "  -M DONT_LOCK|LOCK_TO_SMA|LOCK_TO_MIMO   specify MIMO 
clock source\n");
+  fprintf(stderr, "  -P                   provide clock to MIMO connector\n");
 }
 
 struct pkt_info {
@@ -123,6 +125,8 @@
   int32_t nsamples = static_cast<int32_t>(2.5e6);
   int32_t samples_per_frame = 371;
   int32_t scale = 1024;
+  int    mimo_config = MC_WE_DONT_LOCK;
+  bool   provide_clock = false;
 
   int    ch;
   double tmp;
@@ -130,7 +134,7 @@
 
   setvbuf(stdout, 0, _IOFBF, 64 * 1024); // make stdout fully buffered
 
-  while ((ch = getopt(argc, argv, "he:m:o:f:d:N:F:S:")) != EOF){
+  while ((ch = getopt(argc, argv, "he:m:o:f:d:N:F:S:M:P")) != EOF){
     switch (ch){
 
     case 'e':
@@ -184,6 +188,23 @@
       scale = static_cast<int32_t>(tmp);
       break;
       
+    case 'M':
+      if (strcmp(optarg, "DONT_LOCK") == 0)
+       mimo_config = MC_WE_DONT_LOCK;
+      else if (strcmp(optarg, "LOCK_TO_SMA") == 0)
+       mimo_config = MC_WE_LOCK_TO_SMA;
+      else if (strcmp(optarg, "LOCK_TO_MIMO") == 0)
+       mimo_config = MC_WE_LOCK_TO_MIMO;
+      else {
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+
+    case 'P':
+      provide_clock = true;
+      break;
+
     case 'h':
     default:
       usage(argv[0]);
@@ -233,7 +254,12 @@
   if (rt != RT_OK)
     std::cerr << "failed to enable realtime scheduling\n";
 
+  if (provide_clock)
+    mimo_config |= MC_PROVIDE_CLK_TO_MIMO;
 
+  u2->config_mimo(which, mimo_confg);
+  
+
   gri_if_stats start, stop;
   gri_get_if_stats(interface, &start);
 

Modified: usrp2/trunk/host/apps/rx_streaming_samples.cc
===================================================================
--- usrp2/trunk/host/apps/rx_streaming_samples.cc       2008-07-24 06:28:35 UTC 
(rev 8994)
+++ usrp2/trunk/host/apps/rx_streaming_samples.cc       2008-07-24 17:34:45 UTC 
(rev 8995)
@@ -187,6 +187,8 @@
   fprintf(stderr, "  -N NSAMPLES          total number of samples to receive 
[default=infinite]\n");
   fprintf(stderr, "  -F SAMPLES_PER_FRAME number of samples in each frame 
[default=371]\n");
   fprintf(stderr, "  -S SCALE             fpga scaling factor for I & Q 
[default=256]\n");
+  fprintf(stderr, "  -M DONT_LOCK|LOCK_TO_SMA|LOCK_TO_MIMO   specify MIMO 
clock source\n");
+  fprintf(stderr, "  -P                   provide clock to MIMO connector\n");
 }
 
 struct pkt_info {
@@ -216,6 +218,8 @@
   int32_t samples_per_frame = 250;
   int32_t scale = 1024;
   double gain = GAIN_NOT_SET;
+  int    mimo_config = MC_WE_DONT_LOCK;
+  bool   provide_clock = false;
 
   int    ch;
   double tmp;
@@ -223,7 +227,7 @@
 
   // setvbuf(stdout, 0, _IOFBF, 64 * 1024); // make stdout fully buffered
 
-  while ((ch = getopt(argc, argv, "he:m:o:f:d:N:F:S:g:")) != EOF){
+  while ((ch = getopt(argc, argv, "he:m:o:f:d:N:F:S:g:M:P")) != EOF){
     switch (ch){
 
     case 'e':
@@ -285,6 +289,23 @@
       }
       break;
 
+    case 'M':
+      if (strcmp(optarg, "DONT_LOCK") == 0)
+       mimo_config = MC_WE_DONT_LOCK;
+      else if (strcmp(optarg, "LOCK_TO_SMA") == 0)
+       mimo_config = MC_WE_LOCK_TO_SMA;
+      else if (strcmp(optarg, "LOCK_TO_MIMO") == 0)
+       mimo_config = MC_WE_LOCK_TO_MIMO;
+      else {
+       usage(argv[0]);
+       exit(1);
+      }
+      break;
+
+    case 'P':
+      provide_clock = true;
+      break;
+
     case 'h':
     default:
       usage(argv[0]);
@@ -344,7 +365,12 @@
   class file_writer *writer = new file_writer(ofd, rb);
   writer->start_undetached();
   
+  if (provide_clock)
+    mimo_config |= MC_PROVIDE_CLK_TO_MIMO;
 
+  u2->config_mimo(which, mimo_config);
+  
+
   usrp2_tune_result tune_result;
   
   if (gain != GAIN_NOT_SET){

Modified: usrp2/trunk/host/lib/usrp2_basic.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2_basic.cc 2008-07-24 06:28:35 UTC (rev 8994)
+++ usrp2/trunk/host/lib/usrp2_basic.cc 2008-07-24 17:34:45 UTC (rev 8995)
@@ -644,6 +644,30 @@
   return true;
 }
 
+bool
+usrp2_basic::config_mimo(const u2_mac_addr_t &which, int flags)
+{
+  uint8_t      pktbuf[MAX_PKTLEN];
+  memset(pktbuf, 0, sizeof(pktbuf));
+
+  struct command {
+    u2_eth_packet_t    h;
+    op_config_mimo_t   op;
+  };
+    
+  command      *c = (command *) pktbuf;
+  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+
+  c->op.opcode = OP_CONFIG_MIMO;
+  c->op.len = sizeof(op_config_mimo_t);
+  c->op.flags = flags;
+  int len = std::max((size_t) MIN_PKTLEN, sizeof(command));
+  if (d_ethernet->write_packet(c, len) != len)
+    return false;
+
+  return true;
+}
+
 void
 usrp2_basic::init_etf_hdrs(u2_eth_packet_t *p,
                           const u2_mac_addr_t &dst,

Modified: usrp2/trunk/host/lib/usrp2_basic.h
===================================================================
--- usrp2/trunk/host/lib/usrp2_basic.h  2008-07-24 06:28:35 UTC (rev 8994)
+++ usrp2/trunk/host/lib/usrp2_basic.h  2008-07-24 17:34:45 UTC (rev 8995)
@@ -129,6 +129,25 @@
   bool set_tx_scale_iq(const u2_mac_addr_t &which, int scale_i, int scale_q);
   
 
+  /*!
+   * \brief MIMO configuration
+   *
+   * \param flags from usrp2_mimo_config.h
+   *
+   * <pre>
+   *   one of these:
+   *
+   *     MC_WE_DONT_LOCK
+   *     MC_WE_LOCK_TO_SMA
+   *     MC_WE_LOCK_TO_MIMO
+   *
+   *   and optionally this:
+   *
+   *     MC_PROVIDE_CLK_TO_MIMO
+   * </pre>
+   */
+  bool config_mimo(const u2_mac_addr_t &which, int flags);
+
 #if 0
   bool start_rx(const u2_mac_addr_t &which,
                double freq,





reply via email to

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