]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
all currently in FPGA implemented features are supportet, mt
authorHades User <daq@hades.de>
Sat, 13 Jan 2018 01:34:14 +0000 (02:34 +0100)
committerHades User <daq@hades.de>
Sat, 13 Jan 2018 01:34:14 +0000 (02:34 +0100)
tools/padiwa_amps2.pl

index 643aa4f110b1f36043b8509762db637b9e1d02d6..b697ad25b1143ca0f5a0542019bc92895ca473c4 100755 (executable)
@@ -169,6 +169,37 @@ sub flash_is_busy {
     return (($b->{$endpoint} >> 2) & 0x1);
 }
 
+
+sub check_std_io {
+  (my $command, my $register) = @_;
+
+  if ($execute eq $command) {
+    if(!defined $data) {
+      my $b = sendcmd($register<<$REGNR | $READ);
+      foreach my $e (sort keys %$b) {
+        printf("endpoint: 0x%04x  chain: %d  $command: 0x%04x\n",$e,$chain,$b->{$e}&0xffff);
+      }
+    }
+    else {
+      my $b = sendcmd($register<<$REGNR | $WRITE | ($data & 0xffff));
+    }
+  }
+}
+
+check_std_io("inputenable",          0x20);
+check_std_io("inputstatus",          0x21);
+check_std_io("led",                  0x22);
+check_std_io("monitor",              0x23);
+check_std_io("invert",               0x24);
+check_std_io("stretch",              0x25);
+check_std_io("compensation",         0x26);
+check_std_io("dischargedisable",     0x27);
+check_std_io("dischargeoverride",    0x28);
+check_std_io("dischargehighz",       0x29);
+check_std_io("dischargedelayinvert", 0x2a);
+check_std_io("dischargedelayselect", 0x2b);
+
+
 if ($execute eq "temp") {
   die("not implemented");
   my $b = sendcmd(0x10040000);
@@ -184,19 +215,17 @@ if ($execute eq "resettemp") {
   sendcmd(0x10800000);
 }
 
-
 if ($execute eq "uid" || defined $time) {
+  die("not implemented");
   my $ids;
   for (my $i = 0; $i <= 3; $i++) {
-    my $b = sendcmd( (0x10+$i)<<$REGNR );
-    #print "uid: send done\n";
-    #exit;
+    my $b = sendcmd( (0x60+$i)<<$REGNR );
     foreach my $e (sort keys %$b) {
       $ids->{$e}->{$i} = $b->{$e}&0xffff;
     }
   }
   foreach my $e (sort keys %$ids) {
-    printf("0x%04x\t%d\t0x%04x%04x%04x%04x\n",
+    printf("endpoint: 0x%04x  chain: %d  raw: 0x%04x%04x%04x%04x\n",
            $e, $chain, $ids->{$e}->{3}, $ids->{$e}->{2}, $ids->{$e}->{1}, $ids->{$e}->{0} );
   }
 }
@@ -223,35 +252,6 @@ if ($execute eq "pwm") {
 }
 
 
-sub check_std_io {
-  (my $command, my $register) = @_;
-
-  if ($execute eq $command) {
-    if(!defined $data) {
-      my $b = sendcmd($register<<$REGNR | $READ);
-      foreach my $e (sort keys %$b) {
-        printf("endpoint: 0x%04x  chain: %d  $command: 0x%04x\n",$e,$chain,$b->{$e}&0xffff);
-      }
-    }
-    else {
-      my $b = sendcmd($register<<$REGNR | $WRITE | ($data & 0xffff));
-    }
-  }
-}
-
-check_std_io("inputenable",          0x20);
-check_std_io("inputstatus",          0x21);
-check_std_io("led",                  0x22);
-check_std_io("monitor",              0x23);
-check_std_io("invert",               0x24);
-check_std_io("stretch",              0x25);
-check_std_io("compensation",         0x26);
-check_std_io("dischargedisable",     0x27);
-check_std_io("dischargeoverride",    0x28);
-check_std_io("dischargehighz",       0x29);
-check_std_io("dischargedelayinvert", 0x2a);
-check_std_io("dischargedelayselect", 0x2b);
-
 if ($execute eq "ledoff") {
   my $b = sendcmd(0x22<<$REGNR | $WRITE | 0);
 }
@@ -261,7 +261,7 @@ if ($execute eq "counter" && defined $ARGV[3]) {
   my $b = sendcmd(0x22000000+(($mask&0x1f)<< 16));
   my $c = sendcmd(0x23000000+(($mask&0x1f)<< 16));
   foreach my $e (sort keys %$b) {
-    printf("0x%04x\t%d\t%8x\n",$e,$chain,($b->{$e}&0xffff)+($c->{$e}&0xff)*2**16);
+    printf("endpoint: 0x%04x  chain: %d  counter: %8x\n",$e,$chain,($b->{$e}&0xffff)+($c->{$e}&0xff)*2**16);
   }
 }
 
@@ -269,9 +269,8 @@ if ($execute eq "counter" && defined $ARGV[3]) {
 if ($execute eq "readreg" || $execute eq "rr" ) {
   if (!defined $register) {
     print "for the command readreg an option --register|r is missing.\n";
-    usage;
+    exit;
   }
-
   my $b = sendcmd($register<<$REGNR | $READ);
   foreach my $e (sort keys %$b) {
     printf("0x%x\n", ($b->{$e}) & 0xffff);
@@ -279,10 +278,15 @@ if ($execute eq "readreg" || $execute eq "rr" ) {
 }
 
 if ($execute eq "writereg" | $execute eq "wr") {
+  if (!defined $register) {
+    print "for the command writereg an option --register|r is missing.\n";
+    exit;
+  }
   if (!defined $data) {
     print "for the command writereg an option --data|d is missing.\n";
-    usage;
+    exit;
   }
+  #print "write: "; printf "reg: %x, data: %x\n",$register, $data;
   my $b = sendcmd($register<<$REGNR | $WRITE | ($data & 0xffff) );
 }
 
@@ -296,7 +300,7 @@ if ($execute eq "time") {
   }
   foreach my $e (sort keys %$ids) {
     printf("endpoint: 0x%04x  chain: %d  version: 0x%02x  raw: 0x%04x%04x  %s\n", 
-           $e, $chain, $ids->{$e}->{2}, $ids->{$e}->{1}, $ids->{$e}->{0}, 
+           $e, $chain, $ids->{$e}->{2}, $ids->{$e}->{1}, $ids->{$e}->{0},
            time2str('%Y-%m-%d %H:%M', ( ($ids->{$e}->{1})<<16  | ($ids->{$e}->{0}) )) );
   }
 }
@@ -322,7 +326,6 @@ if ($execute eq "ram") {
   printf("\n");
 }
 
-###################################################################################################
 if (defined $flashcmd) {
   #my $c = 0x50800000 + (($mask&0xe)<< 12) + ($value&0x1fff);
   if (!defined $flashaddress) {
@@ -333,7 +336,6 @@ if (defined $flashcmd) {
   printf("Sent flash command $flashcmd\n");
 }
 
-###################################################################################################
 if (defined $enablecfgflash) {
   die "--enableccfgflash can only be 0 or 1\n" unless ($enablecfgflash == 0 || $enablecfgflash == 1);
   my $c = 0x5C<<$REGNR | $WRITE | $enablecfgflash;
@@ -342,7 +344,7 @@ if (defined $enablecfgflash) {
   printf("$str cfgflash.\n");
 }
 
-###################################################################################################
+
 if (defined $dumpcfgflash) {
   for (my $p = 0; $p<5760; $p++) { #5758
     sendcmd(0x50<<$REGNR | $WRITE | $p);      # read page $p
@@ -357,7 +359,6 @@ if (defined $dumpcfgflash) {
     printf(STDERR "\r%d / 5760",$p) if(!($p%10));
   }
 }
-###################################################################################################
 
 if ($execute eq "erasecfgflash") {
   while (flash_is_busy()) {
@@ -401,7 +402,7 @@ if ($execute eq "writecfgflash") {
 if ($execute eq "fifo" || $execute eq "ffarr") {
   my $b = sendcmd(0x200f0000);
   foreach my $e (sort keys %$b) {
-    printf("0x%04x\t%d\t0x%04x\n",$e,$chain,$b->{$e}&0xffff);
+    printf("endpoint: 0x%04x  chain: %d  fifo: 0x%04x\n",$e,$chain,$b->{$e}&0xffff);
   }
 }