commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8493 - usrp2/trunk/firmware/apps


From: eb
Subject: [Commit-gnuradio] r8493 - usrp2/trunk/firmware/apps
Date: Sun, 25 May 2008 18:23:26 -0600 (MDT)

Author: eb
Date: 2008-05-25 18:23:25 -0600 (Sun, 25 May 2008)
New Revision: 8493

Modified:
   usrp2/trunk/firmware/apps/txrx.c
Log:
refactored: moving towards recovery from overrun

Modified: usrp2/trunk/firmware/apps/txrx.c
===================================================================
--- usrp2/trunk/firmware/apps/txrx.c    2008-05-26 00:22:10 UTC (rev 8492)
+++ usrp2/trunk/firmware/apps/txrx.c    2008-05-26 00:23:25 UTC (rev 8493)
@@ -120,8 +120,9 @@
 
 // variables for streaming mode
 
-static bool     streaming_p = false;
-static int      streaming_frame_count = 0;
+static bool         streaming_p = false;
+static unsigned int streaming_items_per_frame = 0;
+static int          streaming_frame_count = 0;
 #define FRAMES_PER_CMD 1000
 
 
@@ -190,6 +191,34 @@
 }
 
 
+static void
+restart_streaming(void)
+{
+  // setup RX DSP regs
+  dsp_rx_regs->clear_state = 1;                        // reset
+
+  streaming_p = true;
+  streaming_frame_count = FRAMES_PER_CMD;
+
+  dsp_rx_regs->rx_command =
+    MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
+             streaming_items_per_frame,
+             1, 1);                    // set "chain" bit
+
+  // kick off the state machine
+  dbsm_start(&dsp_rx_sm);
+
+  dsp_rx_regs->rx_time = 0;            // enqueue first of two commands
+
+  // make sure this one and the rest have the "now" and "chain" bits set.
+  dsp_rx_regs->rx_command =
+    MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
+             streaming_items_per_frame,
+             1, 1);                            
+
+  dsp_rx_regs->rx_time = 0;            // enqueue second command
+}
+
 void
 start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
 {
@@ -212,37 +241,8 @@
   if (FW_SETS_SEQNO)
     fw_seqno = 0;
 
-  // setup RX DSP regs
-  dsp_rx_regs->clear_state = 1;                        // reset
-
-  if (1){                      // we're streaming
-    streaming_p = true;
-    streaming_frame_count = FRAMES_PER_CMD;
-    dsp_rx_regs->rx_command =
-      MK_RX_CMD(FRAMES_PER_CMD * p->items_per_frame, p->items_per_frame,
-               1, 1);                  // set "chain" bit
-
-    // kick off the state machine
-    dbsm_start(&dsp_rx_sm);
-    dsp_rx_regs->rx_time = 0;          // enqueue first of two commands
-
-    // make sure this one and the rest have the "now" and "chain" bits set.
-    dsp_rx_regs->rx_command =
-      MK_RX_CMD(FRAMES_PER_CMD * p->items_per_frame, p->items_per_frame,
-               1, 1);                          
-    dsp_rx_regs->rx_time = 0;          // enqueue second command
-  }
-#if 0
-  else {
-    streaming_p = false;
-    dsp_rx_regs->rx_command =
-      MK_RX_CMD(p->total_samples, p->items_per_frame, p->rx_now, 0);
-
-    // kick off the state machine
-    dbsm_start(&dsp_rx_sm);
-    dsp_rx_regs->rx_time = p->rx_time;
-  }
-#endif
+  streaming_items_per_frame = p->items_per_frame;
+  restart_streaming();
 }
 
 
@@ -308,19 +308,10 @@
 inline static void
 buffer_irq_handler(unsigned irq)
 {
-  //hal_toggle_leds(0x2);
-
   uint32_t  status = buffer_pool_status->status;
 
   dbsm_process_status(&dsp_tx_sm, status);
   dbsm_process_status(&dsp_rx_sm, status);
-
-#if 0 // not needed, we busy wait in app_common_v2  
-  if (status & BPS_DONE(CPU_TX_BUF)){
-    bp_clear_buf(CPU_TX_BUF);
-  }
-#endif
-
 }
 
 int
@@ -377,6 +368,17 @@
     if (pending & PIC_OVERRUN_INT){
       dbsm_handle_rx_overrun(&dsp_rx_sm);
       pic_regs->pending = PIC_OVERRUN_INT;     // clear pending interrupt
+
+      // FIXME Figure out how to handle this robustly.
+      // Any buffers that are emptying should be allowed to drain...
+
+      if (streaming_p){
+       // restart_streaming();
+       // FIXME report error
+      }
+      else {
+       // FIXME report error
+      }
       putchar('O');
     }
   }





reply via email to

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