]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
updates, added com_reset comand to trbcmd
authorhadaq <hadaq>
Sun, 1 Nov 2009 18:31:57 +0000 (18:31 +0000)
committerhadaq <hadaq>
Sun, 1 Nov 2009 18:31:57 +0000 (18:31 +0000)
libtrbnet/trbcmd.c
libtrbnet/trbnet.c
libtrbnet/trbnet.h

index 555c7603ebfd85203ccd54c98739fbef54015b03..ee6ac49bad56a192ef30829b1624dae5036e0203 100644 (file)
@@ -16,7 +16,7 @@
 
 static int hexMode = HEXMODE;
 
-static const char trbcmd_version[] = "$Revision: 2.37 $";
+static const char trbcmd_version[] = "$Revision: 2.38 $";
 
 /* ---- User Buffer Size ----------------------------------------------- */
 
@@ -66,6 +66,8 @@ void usage(const char *progName)
          "reload FPGA\n");
   printf("   reset                                            -> "
          "reset TRBNetwork\n");
+  printf("   comreset                                         -> "
+         "reset Etrax-FIFO Logic\n");
   printf("   f <channel>                                      -> "
          "flush FIFO of channel\n");
   printf("   R <register>                                     -> "
@@ -701,30 +703,42 @@ int main(int argc, char ** argv)
           fprintf(stderr, "Command: RESET:\n");
         }
         
-        if (fpga_register_write(0x10, 0x0000) == -1) {
+        if (network_reset() == -1) {
           if (scriptFile != NULL) {
             fprintf(stderr, "Line #%d: ", lineCtr);
           }
-          trb_error("fpga_register_write failed");
+          trb_error("TRBNet RESET failed");
           exit(EXIT_FAILURE);
         }
+      
+      } else if (strncmp(cmd[0], "reset", CMD_SIZE) == 0) {
         
-        if (fpga_register_write(0x10, 0x8000) == -1) {
+        /*******************************************/
+        /* Etrax-FIFO Reset                        */
+        /*******************************************/
+    
+        if (cmdLen !=  1) {
           if (scriptFile != NULL) {
-            fprintf(stderr, "Line #%d: ", lineCtr);
+            fprintf(stderr, "Line #%d: Invalid command\n", lineCtr);
+          } else {
+            usage(basename(argv[0]));
           }
-          trb_error("fpga_register_write failed");
           exit(EXIT_FAILURE);
-        } else {
-          if (fpga_register_write(0x10, 0x0000) == -1) {
-            if (scriptFile != NULL) {
-              fprintf(stderr, "Line #%d: ", lineCtr);
-            }
-            trb_error("fpga_register_write failed");
-            exit(EXIT_FAILURE);
-          }
         }
         
+        /* DEBUG Info */
+        if (trb_debug > 0) {
+          fprintf(stderr, "Command: COMRESET:\n");
+        }
+        
+        if (com_reset() == -1) {
+          if (scriptFile != NULL) {
+            fprintf(stderr, "Line #%d: ", lineCtr);
+          }
+          trb_error("Etrax RESET failed");
+          exit(EXIT_FAILURE);
+        }
+      
       } else if (strncmp(cmd[0], "reload", CMD_SIZE) == 0) {
     
         /*********************************************/
index a1f10d177d5094f33d884970857bde170ec2fc1b..098815a1686947a4b862a040a453801f5cf544d6 100644 (file)
@@ -1,4 +1,4 @@
-const char trbnet_version[] = "$Revision: 2.49 $";
+const char trbnet_version[] = "$Revision: 2.50 $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -245,12 +245,6 @@ static inline int read32_from_FPGA_dma(uint16_t fifo_address,
   return -1;
 }
 
-static void com_reset()
-{
-  setbitsPC(0x30000);
-  clrbitsPC(0x30000);
-}
-
 /* ------ Internal Functions -------------------------------------------- */
 
 static void TRB_Package_dump(const TRB_Package* pkg)
@@ -1538,3 +1532,42 @@ int fpga_register_write(uint16_t reg_address, uint32_t value)
 
   return 0;
 }
+
+int network_reset()
+{
+  trb_errno = TRB_NONE;
+  
+  if (lockPorts() == -1) return -1;
+
+  /* DEBUG INFO */
+  if (trb_debug > 0) {
+    fprintf(stderr, "network_reset started.\n");
+  }
+  
+  if (fpga_register_write(0x10, 0x0000) == -1) return -1;
+  if (fpga_register_write(0x10, 0x8000) == -1) return -1;
+  if (fpga_register_write(0x10, 0x0000) == -1) return -1;
+  
+  if (unlockPorts() == -1) return -1;
+  
+  return 0;
+}
+
+int com_reset()
+{
+  trb_errno = TRB_NONE;
+
+  if (lockPorts() == -1) return -1;
+
+  /* DEBUG INFO */
+  if (trb_debug > 0) {
+    fprintf(stderr, "com_reset started.\n");
+  }
+  
+  setbitsPC(0x30000);
+  clrbitsPC(0x30000);
+  
+  if (unlockPorts() == -1) return -1;
+
+  return 0;
+}
index 5d9c83d965ad3befd850f7a2234db208cb843889..b9281d244dbdc949b14255b6931d807f3a112b62 100644 (file)
@@ -69,7 +69,9 @@ int fpga_register_write(uint16_t reg_address, uint32_t value);
 
 int trb_fifo_flush(uint8_t channel);
 
+int network_reset();
 
+int com_reset();
 
 /* ---------------------------------------------------------------------- */