]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
FIFO_TOGGLE_BIT-BUG Workaround com_reset()
authorhadaq <hadaq>
Wed, 10 Nov 2010 18:47:06 +0000 (18:47 +0000)
committerhadaq <hadaq>
Wed, 10 Nov 2010 18:47:06 +0000 (18:47 +0000)
libtrbnet/trbnet.c

index 3122e4b1c7af4ae3625dd597600510c83c8c2952..6f475aa898c07c58b8358b5e0dcbee0143c5123e 100644 (file)
@@ -1,4 +1,4 @@
-const char trbnet_version[] = "$Revision: 2.91 $";
+const char trbnet_version[] = "$Revision: 2.92 $";
 
 #include <stdlib.h>
 #include <signal.h>
@@ -422,7 +422,7 @@ static int trb_wait_tx_not_busy(uint8_t channel)
 static int trb_init_transfer(uint8_t channel)
 {
   uint32_t tmp = 0;
-  
+
   if (channel >= 4) {
     trb_errno = TRB_INVALID_CHANNEL;
     return -1;
@@ -430,12 +430,23 @@ static int trb_init_transfer(uint8_t channel)
   
   /* Check for TX not Busy */
   read32_from_FPGA(CHANNEL_N_SENDER_STATUS | ((channel * 2 + 1) << 4), &tmp);
+  if (tmp != 0) {
+    /* FIFO_TOGGLE_BIT-BUG Workaround */
+    com_reset();
+  }
+  read32_from_FPGA(CHANNEL_N_SENDER_STATUS | ((channel * 2 + 1) << 4), &tmp);
   if (tmp != 0) {
     trb_errno = TRB_TX_BUSY;
     return -1;
   }
   
   /* Check receiver FIFO empty*/
+  read32_from_FPGA(CHANNEL_N_RECEIVER_FIFO_STATUS | ((channel * 2 + 1) << 4), 
+                   &tmp);
+  if ((tmp & MASK_FIFO_EMPTY) == 0) {
+    /* FIFO_TOGGLE_BIT-BUG Workaround */
+    com_reset();
+  }
   read32_from_FPGA(CHANNEL_N_RECEIVER_FIFO_STATUS | ((channel * 2 + 1) << 4), 
                    &tmp);
   if ((tmp & MASK_FIFO_EMPTY) == 0) {