]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
added functions for flash and ram control to padiwa.pl
authorJan Michel <j.michel@gsi.de>
Wed, 8 May 2013 18:22:51 +0000 (20:22 +0200)
committerJan Michel <j.michel@gsi.de>
Wed, 8 May 2013 18:22:51 +0000 (20:22 +0200)
.kateproject [new file with mode: 0644]
padiwa.pl

diff --git a/.kateproject b/.kateproject
new file mode 100644 (file)
index 0000000..90377ce
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "name": "DAQtools"
+, "files": [ { "git": 1 } ]
+}
index af7a9e0da6437c1348b6218b543291908f0b9969..484cd60f158a5c14a27ab4c3717a849827d4f35a 100755 (executable)
--- a/padiwa.pl
+++ b/padiwa.pl
@@ -18,23 +18,29 @@ if (!defined &trb_init_ports()) {
 if(!(defined $ARGV[0]) || !(defined $ARGV[1]) || !(defined $ARGV[2])) {
   print "usage: padiwa.pl \$FPGA \$chain \$command \$options\n\n";
   print "\t uid \t\t read unique ID, no options\n";
+  print "\t time \t\t read compile time. no options\n";
   print "\t temp \t\t read temperature, no options\n";
-  print "\t resettemp \t\t resets the 1-wire logic\n";
+  print "\t resettemp \t resets the 1-wire logic\n";
   print "\t dac \t\t set LTC-DAC value. options: \$channel, \$value\n";
   print "\t pwm \t\t set PWM value. options: \$channel, \$value\n";
-  print "\t pwm \t\t read PWM value. options: \$channel\n";
+  print "\t  \t\t read PWM value. options: \$channel\n";
   print "\t disable \t set input diable. options: \$mask\n";
-  print "\t disable \t read input disable. no options\n";
+  print "\t \t\t read input disable. no options\n";
   print "\t input \t\t read input status. no options\n";
   print "\t invert \t set invert status. options: \$mask\n";
-  print "\t invert \t read invert status. no options\n";
+  print "\t  \t\t read invert status. no options\n";
   print "\t led \t\t set led status. options: mask (5 bit, highest bit is override enable)\n";
-  print "\t led \t\t read LED status. no options\n";
-  print "\t monitor \t set input for monitor output. options: mask (4 bit). \n\t\t\t0x10: OR of all channels, 0x18: or of all channels, extended to  16ns\n";
-  print "\t monitor \t read monitor selection. no options\n";
-  print "\t stretch \t\t set stretcher status.\n";
-  print "\t stretch \t\t read stretcher status. no options\n";
-  print "\t time \t\t read compile time. no options\n";
+  print "\t  \t\t read LED status. no options\n";
+  print "\t monitor \t set input for monitor output. options: mask (4 bit). \n\t\t\t 0x10: OR of all channels, 0x18: or of all channels, extended to  16ns\n";
+  print "\t  \t\t read monitor selection. no options\n";
+  print "\t stretch \t set stretcher status.\n";
+  print "\t  \t\t read stretcher status. no options\n";
+  print "\t ram \t\t writes the RAM content, options: 16 byte in hex notation, separated by space, no 0x.\n";
+  print "\t  \t\t read the RAM content (16 Byte)\n";
+  print "\t flash \t\t execute flash command, options: \$command, \$page. See manual for commands.\n";
+  print "\t enablecfg\t enable or disable access to configuration flash, options: 1/0\n";
+  print "\t dumpcfg \t Dump content of configuration flash\n";
+  
   exit;
   }
 my $board, my $value, my $mask;
@@ -55,7 +61,12 @@ if (defined $ARGV[4]) {
   }
     
   
-  
+sub sendcmd16 {
+  my @cmd = @_;
+  my $c = [@cmd,1<<$chain,16+0x80];
+  trb_register_write_mem($board,0xd400,0,$c,scalar @{$c});
+  usleep(1000);
+  }  
   
 sub sendcmd {
   my ($cmd) = @_;
@@ -63,7 +74,7 @@ sub sendcmd {
   trb_register_write_mem($board,0xd400,0,$c,scalar @{$c});
 #   trb_register_write($board,0xd410,1<<$chain) or die "trb_register_write: ", trb_strerror();   
 #   trb_register_write($board,0xd411,1);
-  usleep(10000);
+  usleep(1000);
   return trb_register_read($board,0xd412);
   }
   
@@ -199,3 +210,48 @@ if($ARGV[2] eq "time") {
     }
   } 
   
+if($ARGV[2] eq "ram" && defined $ARGV[18]) {
+  my @a;
+  for(my $i=0;$i<16;$i++) {
+    push(@a,0x40800000+hex($ARGV[3+$i])+($i << 16));
+    }
+  sendcmd16(@a);
+  printf("Wrote RAM\n");
+  }
+
+if($ARGV[2] eq "ram") {
+  for(my $i=0;$i<16;$i++) {
+    my $b = sendcmd(0x40000000 + ($i << 16));
+    foreach my $e (sort keys %$b) {    
+      printf(" %02x ",$b->{$e}&0xff);
+      }
+    }
+  printf("\n");
+  }
+  
+if($ARGV[2] eq "flash" && defined $ARGV[4]) {
+  my $c = 0x50800000+(($mask&0xe)<< 12)+($value&0x1fff);
+  my $b = sendcmd($c);
+  printf("Sent command\n");
+  }
+  
+if($ARGV[2] eq "dumpcfg") {   
+  for(my $p = 0; $p<5758; $p++) {  #5758
+    sendcmd(0x50800000 + $p);
+    printf("0x%04x:\t",$p);
+    for(my $i=0;$i<16;$i++) {
+      my $b = sendcmd(0x40000000 + ($i << 16));
+      foreach my $e (sort keys %$b) {    
+        printf(" %02x ",$b->{$e}&0xff);
+        }
+      }
+    printf("\n");
+    printf(STDERR "\r%d / 5758",$p) if(!($p%10)); 
+    }
+  }
+
+if($ARGV[2] eq "enablecfg" && defined $ARGV[3]) {
+  my $c = 0x5C800000 + $ARGV[3];
+  my $b = sendcmd($c);
+  printf("Sent command.\n");
+  }  
\ No newline at end of file