commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10873 - in gnuradio/branches/developers/eb/tims_timer


From: eb
Subject: [Commit-gnuradio] r10873 - in gnuradio/branches/developers/eb/tims_timer2/usrp2: firmware/apps firmware/include host/lib
Date: Fri, 17 Apr 2009 15:03:46 -0600 (MDT)

Author: eb
Date: 2009-04-17 15:03:46 -0600 (Fri, 17 Apr 2009)
New Revision: 10873

Modified:
   
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.c
   
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.h
   
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/include/usrp2_eth_packet.h
   gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.cc
   gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.h
Log:
Support Tim's Timer within the normal framework.  Ready to test.



Modified: 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.c 
    2009-04-17 20:35:43 UTC (rev 10872)
+++ 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.c 
    2009-04-17 21:03:46 UTC (rev 10873)
@@ -589,8 +589,81 @@
   send_reply(reply, reply_payload - reply);
 }
 
+/*
+ * ================================================================
+ *                 Support for Tim's Timer
+ * ================================================================
+ */
 
+// reply must point into the buffer pool.
+
+static void
+send_reply_no_copy(unsigned char *reply, size_t reply_len)
+{
+  if (reply_len < 64)
+    reply_len = 64;
+
+  unsigned int bufno =
+    (reply - (unsigned char *)buffer_ram(0)) / (BP_NLINES * sizeof(uint32_t));
+
+  // wait for buffer to become idle
+  //hal_set_leds(0x4, 0x4);
+  while((buffer_pool_status->status & BPS_IDLE(bufno)) == 0)
+    ;
+  //hal_set_leds(0x0, 0x4);
+
+  // wait until nobody else is sending to the ethernet
+  if (ac_could_be_sending_to_eth){
+    //hal_set_leds(0x8, 0x8);
+    dbsm_wait_for_opening(ac_could_be_sending_to_eth);
+    //hal_set_leds(0x0, 0x8);
+  }
+
+  if (0){
+    printf("sending_reply to port %d, len = %d\n", cpu_tx_buf_dest_port, 
(int)reply_len);
+    print_buffer(buffer_ram(bufno), reply_len/4);
+  }
+
+  // fire it off
+  bp_send_from_buf(bufno, cpu_tx_buf_dest_port, 1, 0, reply_len/4);
+
+  // wait for it to complete
+  while((buffer_pool_status->status & (BPS_DONE(bufno) | BPS_ERROR(bufno))) == 
0)
+    ;
+
+  bp_clear_buf(bufno);
+}
+
 /*
+ * We generate our reply using the same buffer...
+ */
+void
+handle_tims_timer_frame(u2_eth_packet_t *pkt, size_t len)
+{
+  // point to beginning of payload
+  uint32_t *payload = (uint32_t *)(((unsigned char *) pkt) + 
sizeof(u2_eth_packet_t));
+  int subopcode = payload[0] >> 16;
+  int payload_reply_len_bytes = ((payload[0] & 0xffff) + 3) & ~0x3;
+
+  // setup MAC src and dst addresses
+  struct {
+    u2_mac_addr_t dst;
+    u2_mac_addr_t src;
+  } __attribute__((aligned (4))) mac_addrs;    // 12-bytes (word aligned)
+
+  mac_addrs.dst = pkt->ehdr.src;
+  mac_addrs.src = *ethernet_mac_addr();
+  memcpy_wa(&pkt->ehdr, &mac_addrs, sizeof(mac_addrs));        // buffer is 
only word-writable
+
+  payload[1] = timer_regs->time;       // fill in FPGA time
+
+  send_reply_no_copy((unsigned char*) pkt,
+                    payload_reply_len_bytes + sizeof(u2_eth_packet_t));
+}
+
+// ================================================================
+
+/*
  * Called when an ethernet packet is received.
  * Return true if we handled it here, otherwise
  * it'll be passed on to the DSP Tx pipe
@@ -618,6 +691,11 @@
     return true;       // we handled the packet
     break;
 
+  case TIMS_TIMER_CHAN:
+    handle_tims_timer_frame(pkt, byte_len);
+    return true;
+    break;
+
   case 0:
   default:
 #if 0

Modified: 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.h
===================================================================
--- 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.h 
    2009-04-17 20:35:43 UTC (rev 10872)
+++ 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/apps/app_common_v2.h 
    2009-04-17 21:03:46 UTC (rev 10873)
@@ -60,5 +60,6 @@
 bool is_streaming(void);
 
 void handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len);
+void handle_tims_timer_frame(u2_eth_packet_t *pkt, size_t len);
 
 #endif /* INCLUDED_APP_COMMON_H */

Modified: 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/include/usrp2_eth_packet.h
===================================================================
--- 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/include/usrp2_eth_packet.h
       2009-04-17 20:35:43 UTC (rev 10872)
+++ 
gnuradio/branches/developers/eb/tims_timer2/usrp2/firmware/include/usrp2_eth_packet.h
       2009-04-17 21:03:46 UTC (rev 10873)
@@ -101,7 +101,9 @@
 #define        U2P_ALL_FLAGS           0x00000007
 
 #define        CONTROL_CHAN            0x1f
+#define        TIMS_TIMER_CHAN         0x1e
 
+
 static inline int
 u2p_chan(u2_fixed_hdr_t *p)
 {

Modified: 
gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.cc    
2009-04-17 20:35:43 UTC (rev 10872)
+++ gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.cc    
2009-04-17 21:03:46 UTC (rev 10873)
@@ -318,6 +318,21 @@
     return res == 1;
   }
 
+  void
+  usrp2::impl::init_tims_timer_hdrs(void *frame, int sub_opcode, int reply_len)
+  {
+    init_etf_hdrs((u2_eth_packet_t *) frame, d_addr, 0, TIMS_TIMER_CHAN, -1);
+    uint32_t *payload = (uint32_t *)((char *)frame + sizeof(u2_eth_packet_t));
+    payload[0] = htonl(((sub_opcode & 0xffff) << 16) | (reply_len & 0xffff));
+  }
+
+  bool
+  usrp2::impl::transmit_tims_timer(void *frame, size_t len)
+  {
+    return d_eth_buf->tx_frame(frame, len) == eth_buffer::EB_OK;
+  }
+
+
   // ----------------------------------------------------------------
   //        Background loop: received packet demuxing
   // ----------------------------------------------------------------
@@ -372,6 +387,9 @@
       DEBUG_LOG("c");
       return handle_control_packet(base, len);
     }
+    else if (chan == TIMS_TIMER_CHAN){ 
+      return handle_tims_timer_packet(base, len);
+    }
     else {                             // data packets
       return handle_data_packet(base, len);
     }
@@ -415,6 +433,19 @@
   }
   
   data_handler::result
+  usrp2::impl::handle_tims_timer_packet(const void *base, size_t len)
+  {
+    // point to beginning of payload
+    uint32_t *p = (uint32_t *)((unsigned char *)base + 
sizeof(u2_eth_packet_t));
+    
+    // FIXME (p % 4) == 2.  Not good.  Unaligned loads ahead...
+    
+    // FIXME tims_timer
+
+    return data_handler::RELEASE;
+  }
+  
+  data_handler::result
   usrp2::impl::handle_data_packet(const void *base, size_t len)
   {
     u2_eth_samples_t *pkt = (u2_eth_samples_t *)base;

Modified: 
gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.h     
2009-04-17 20:35:43 UTC (rev 10872)
+++ gnuradio/branches/developers/eb/tims_timer2/usrp2/host/lib/usrp2_impl.h     
2009-04-17 21:03:46 UTC (rev 10873)
@@ -106,12 +106,18 @@
     void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
     void init_config_tx_v2_cmd(op_config_tx_v2_cmd *cmd);
     bool transmit_cmd(void *cmd, size_t len, pending_reply *p, double 
secs=0.0);
+
     virtual data_handler::result operator()(const void *base, size_t len);
     data_handler::result handle_control_packet(const void *base, size_t len);
     data_handler::result handle_data_packet(const void *base, size_t len);
     bool dboard_info();
     bool reset_db();
 
+    void init_tims_timer_hdrs(void *frame, int sub_opcode, int reply_len);
+    bool transmit_tims_timer(void *frame, size_t len);
+    data_handler::result handle_tims_timer_packet(const void *base, size_t 
len);
+
+
   public:
     impl(const std::string &ifc, props *p);
     ~impl();





reply via email to

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