commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10424 - in gnuradio/trunk/usrp2: firmware/apps firmwa


From: jcorgan
Subject: [Commit-gnuradio] r10424 - in gnuradio/trunk/usrp2: firmware/apps firmware/include firmware/lib fpga/timing host/include/usrp2 host/lib
Date: Tue, 10 Feb 2009 09:35:18 -0700 (MST)

Author: jcorgan
Date: 2009-02-10 09:35:17 -0700 (Tue, 10 Feb 2009)
New Revision: 10424

Modified:
   gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c
   gnuradio/trunk/usrp2/firmware/include/usrp2_eth_packet.h
   gnuradio/trunk/usrp2/firmware/lib/memory_map.h
   gnuradio/trunk/usrp2/fpga/timing/time_sync.v
   gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h
   gnuradio/trunk/usrp2/host/lib/usrp2.cc
   gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc
   gnuradio/trunk/usrp2/host/lib/usrp2_impl.h
Log:
Merged r10418:10423 from jcorgan/pps into trunk.  Adds usrp2::sync_every_pps

Modified: gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c  2009-02-10 16:23:10 UTC 
(rev 10423)
+++ gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c  2009-02-10 16:35:17 UTC 
(rev 10424)
@@ -55,6 +55,18 @@
 }
 
 static bool
+sync_every_pps(const op_generic_t *p)
+{
+  // FIXME use bit fields or defined masks
+  if (p->ok)
+    timesync_regs->tick_control |= 16;
+  else
+    timesync_regs->tick_control &= ~16;
+
+  return true;
+}
+
+static bool
 config_mimo_cmd(const op_config_mimo_t *p)
 {
   clocks_mimo_config(p->flags);
@@ -505,6 +517,11 @@
       subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true);
       break;
 
+    case OP_SYNC_EVERY_PPS:
+      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
+                               sync_every_pps((op_generic_t *) payload));
+      break;
+
     default:
       printf("app_common_v2: unhandled opcode = %d\n", gp->opcode);
       break;

Modified: gnuradio/trunk/usrp2/firmware/include/usrp2_eth_packet.h
===================================================================
--- gnuradio/trunk/usrp2/firmware/include/usrp2_eth_packet.h    2009-02-10 
16:23:10 UTC (rev 10423)
+++ gnuradio/trunk/usrp2/firmware/include/usrp2_eth_packet.h    2009-02-10 
16:35:17 UTC (rev 10424)
@@ -195,6 +195,8 @@
 #define OP_SET_RX_LO_OFFSET_REPLY    (OP_SET_RX_LO_OFFSET | OP_REPLY_BIT)
 #define OP_RESET_DB                  15
 #define OP_RESET_DB_REPLY            (OP_RESET_DB | OP_REPLY_BIT)
+#define OP_SYNC_EVERY_PPS            16
+#define OP_SYNC_EVERY_PPS_REPLY      (OP_SYNC_EVERY_PPS | OP_REPLY_BIT)
 
 /*
  * All subpackets are a multiple of 4 bytes long.

Modified: gnuradio/trunk/usrp2/firmware/lib/memory_map.h
===================================================================
--- gnuradio/trunk/usrp2/firmware/lib/memory_map.h      2009-02-10 16:23:10 UTC 
(rev 10423)
+++ gnuradio/trunk/usrp2/firmware/lib/memory_map.h      2009-02-10 16:35:17 UTC 
(rev 10424)
@@ -629,6 +629,25 @@
 #define TIMESYNC_BASE  0xE800
 
 typedef struct {
+  /*!
+   * \brief Time sync configuration.
+   *
+   * <pre>
+   *
+   *    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
+   * +-----------------------------------------------------+-+-+-+-+-+
+   * |                                                     |T|G|X|I|S|
+   * +-----------------------------------------------------+-+-+-+-+-+
+   *
+   * S - Tick source (0 = free run, 1 = pps, default=0)
+   * I - Tick interrupt enable (not implemented)
+   * X - Use external sync source (default=1)
+   * G - PPS edge selection (0=negedge, 1=posedge, default=0)
+   * T - Trigger sync every pps edge (default=0)
+   *
+   * </pre>
+   */
   volatile uint32_t tick_control;
   volatile uint32_t tick_interval;
   volatile uint32_t delta_time;

Modified: gnuradio/trunk/usrp2/fpga/timing/time_sync.v
===================================================================
--- gnuradio/trunk/usrp2/fpga/timing/time_sync.v        2009-02-10 16:23:10 UTC 
(rev 10423)
+++ gnuradio/trunk/usrp2/fpga/timing/time_sync.v        2009-02-10 16:35:17 UTC 
(rev 10424)
@@ -22,6 +22,7 @@
    reg                tick_int_enable, tick_source, external_sync;
    reg [31:0]  tick_interval;
    reg                sync_on_next_pps;
+   reg         sync_every_pps;
    reg                pps_edge;
    
    // Generate master time
@@ -30,7 +31,7 @@
        master_time <= 0;
      else if(external_sync & sync_rcvd)
        master_time <= master_time_rcvd + delta_time;
-     else if(pps_ext & sync_on_next_pps)
+     else if(pps_ext & (sync_on_next_pps|sync_every_pps))
        master_time <= 0;
      else
        master_time <= master_time + 1;
@@ -62,6 +63,7 @@
          tick_interval <= 100000-1;  // default to 1K times per second
          delta_time <= 0;
          pps_edge <= 0;
+         sync_every_pps <= 0;
        end
      else if(wb_write)
        case(adr_i[2:0])
@@ -71,6 +73,7 @@
              tick_int_enable <= dat_i[1];
              external_sync <= dat_i[2];
              pps_edge <= dat_i[3];
+             sync_every_pps <= dat_i[4];
           end
         3'd1 :
           tick_interval <= dat_i;

Modified: gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h
===================================================================
--- gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h     2009-02-10 16:23:10 UTC 
(rev 10423)
+++ gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h     2009-02-10 16:35:17 UTC 
(rev 10424)
@@ -372,11 +372,16 @@
     bool burn_mac_addr(const std::string &new_addr);
 
     /*!
-     * Reset master time to 0 at next PPS rising edge
+     * Reset master time to 0 at next PPS edge
      */
     bool sync_to_pps();
 
     /*!
+     * Reset master time to 0 at every PPS edge
+     */
+    bool sync_every_pps(bool enable);
+
+    /*!
      * Read memory from Wishbone bus as 32-bit words.  Handles endian swapping 
if needed.
      *
      * \param addr      32-bit aligned address.  Only the lower 16-bits are 
significant.

Modified: gnuradio/trunk/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/trunk/usrp2/host/lib/usrp2.cc      2009-02-10 16:23:10 UTC (rev 
10423)
+++ gnuradio/trunk/usrp2/host/lib/usrp2.cc      2009-02-10 16:35:17 UTC (rev 
10424)
@@ -413,6 +413,12 @@
     return d_impl->sync_to_pps();
   }
 
+  bool
+  usrp2::sync_every_pps(bool enable)
+  {
+    return d_impl->sync_every_pps(enable);
+  }
+
   std::vector<uint32_t>
   usrp2::peek32(uint32_t addr, uint32_t words)
   {

Modified: gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc 2009-02-10 16:23:10 UTC (rev 
10423)
+++ gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc 2009-02-10 16:35:17 UTC (rev 
10424)
@@ -77,6 +77,8 @@
     case OP_SET_TX_LO_OFFSET_REPLY: return "OP_SET_TX_LO_OFFSET_REPLY";
     case OP_SET_RX_LO_OFFSET: return "OP_SET_RX_LO_OFFSET";
     case OP_SET_RX_LO_OFFSET_REPLY: return "OP_SET_RX_LO_OFFSET_REPLY";
+    case OP_SYNC_EVERY_PPS: return "OP_SYNC_EVERY_PPS";
+    case OP_SYNC_EVERY_PPS_REPLY: return "OP_SYNC_EVERY_PPS_REPLY";
 
     default:
       char buf[64];
@@ -1128,6 +1130,28 @@
     return ntohx(reply.ok) == 1;
   }
 
+  bool
+  usrp2::impl::sync_every_pps(bool enable)
+  {
+    op_generic_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_SYNC_EVERY_PPS;
+    cmd.op.len = sizeof(cmd.op);
+    cmd.op.rid = d_next_rid++;
+    cmd.op.ok = enable ? 1 : 0;
+    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;
+  }
+
   std::vector<uint32_t>
   usrp2::impl::peek32(uint32_t addr, uint32_t words)
   {

Modified: gnuradio/trunk/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/trunk/usrp2/host/lib/usrp2_impl.h  2009-02-10 16:23:10 UTC (rev 
10423)
+++ gnuradio/trunk/usrp2/host/lib/usrp2_impl.h  2009-02-10 16:35:17 UTC (rev 
10424)
@@ -180,6 +180,7 @@
 
     bool burn_mac_addr(const std::string &new_addr);
     bool sync_to_pps();
+    bool sync_every_pps(bool enable);
     std::vector<uint32_t> peek32(uint32_t addr, uint32_t words);
     bool poke32(uint32_t addr, const std::vector<uint32_t> &data);
   };





reply via email to

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