commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: jcorgan
Subject: [Commit-gnuradio] r10116 - in gnuradio/trunk/usrp2: firmware/apps firmware/include host/include/usrp2 host/lib
Date: Sat, 13 Dec 2008 18:01:13 -0700 (MST)

Author: jcorgan
Date: 2008-12-13 18:01:11 -0700 (Sat, 13 Dec 2008)
New Revision: 10116

Modified:
   gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c
   gnuradio/trunk/usrp2/firmware/include/usrp2_eth_packet.h
   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:
Implement sync_to_pps command for USRP2

Modified: gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c  2008-12-13 23:28:58 UTC 
(rev 10115)
+++ gnuradio/trunk/usrp2/firmware/apps/app_common_v2.c  2008-12-14 01:01:11 UTC 
(rev 10116)
@@ -47,6 +47,14 @@
 }
 
 static bool
+sync_to_pps(const op_generic_t *p)
+{
+  timesync_regs->sync_on_next_pps = 1;
+  putstr("SYNC to PPS\n");
+  return true;
+}
+
+static bool
 config_mimo_cmd(const op_config_mimo_t *p)
 {
   clocks_mimo_config(p->flags);
@@ -422,6 +430,10 @@
       subpktlen = dboard_info_cmd(gp, reply_payload, reply_payload_space);
       break;
 
+    case OP_SYNC_TO_PPS:
+      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
+                               sync_to_pps((op_generic_t *) payload));
+
     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    2008-12-13 
23:28:58 UTC (rev 10115)
+++ gnuradio/trunk/usrp2/firmware/include/usrp2_eth_packet.h    2008-12-14 
01:01:11 UTC (rev 10116)
@@ -183,6 +183,8 @@
 #define OP_CONFIG_MIMO_REPLY        (OP_CONFIG_MIMO | OP_REPLY_BIT)
 #define        OP_DBOARD_INFO               9
 #define        OP_DBOARD_INFO_REPLY         (OP_DBOARD_INFO | OP_REPLY_BIT)
+#define        OP_SYNC_TO_PPS               10
+#define        OP_SYNC_TO_PPS_REPLY         (OP_SYNC_TO_PPS | OP_REPLY_BIT)
 
 
 //#define OP_WRITE_REG          xx     // not implemented

Modified: gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h
===================================================================
--- gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h     2008-12-13 23:28:58 UTC 
(rev 10115)
+++ gnuradio/trunk/usrp2/host/include/usrp2/usrp2.h     2008-12-14 01:01:11 UTC 
(rev 10116)
@@ -356,6 +356,10 @@
      */
     bool burn_mac_addr(const std::string &new_addr);
 
+    /*!
+     * Reset master time to 0 at next PPS rising edge
+     */
+    bool sync_to_pps();
 
 #if 0  // not yet implemented
     /*!

Modified: gnuradio/trunk/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/trunk/usrp2/host/lib/usrp2.cc      2008-12-13 23:28:58 UTC (rev 
10115)
+++ gnuradio/trunk/usrp2/host/lib/usrp2.cc      2008-12-14 01:01:11 UTC (rev 
10116)
@@ -389,6 +389,11 @@
     return d_impl->burn_mac_addr(new_addr);
   }
 
+  bool
+  usrp2::sync_to_pps()
+  {
+    return d_impl->sync_to_pps();
+  }
 
 } // namespace usrp2
 

Modified: gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc 2008-12-13 23:28:58 UTC (rev 
10115)
+++ gnuradio/trunk/usrp2/host/lib/usrp2_impl.cc 2008-12-14 01:01:11 UTC (rev 
10116)
@@ -71,6 +71,7 @@
     case OP_CONFIG_MIMO: return "OP_CONFIG_MIMO";
     case OP_DBOARD_INFO: return "OP_DBOARD_INFO";
     case OP_DBOARD_INFO_REPLY: return "OP_DBOARD_INFO_REPLY";
+    case OP_SYNC_TO_PPS: return "OP_SYNC_TO_PPS";
 #if 0
     case OP_WRITE_REG: return "OP_WRITE_REG";
     case OP_WRITE_REG_MASKED: return "OP_WRITE_REG_MASKED";
@@ -1020,4 +1021,25 @@
   }
 
 
+  bool
+  usrp2::impl::sync_to_pps()
+  {
+    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_SYNC_TO_PPS;
+    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;
+  }
+
 } // namespace usrp2

Modified: gnuradio/trunk/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/trunk/usrp2/host/lib/usrp2_impl.h  2008-12-13 23:28:58 UTC (rev 
10115)
+++ gnuradio/trunk/usrp2/host/lib/usrp2_impl.h  2008-12-14 01:01:11 UTC (rev 
10116)
@@ -173,6 +173,7 @@
     // low level
 
     bool burn_mac_addr(const std::string &new_addr);
+    bool sync_to_pps();
   };
   
 } // namespace usrp2





reply via email to

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