From c515552588fb804d34eb7d37aa98a514809108f1 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 8 May 2013 20:22:51 +0200 Subject: [PATCH] added functions for flash and ram control to padiwa.pl --- .kateproject | 4 +++ padiwa.pl | 80 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 .kateproject diff --git a/.kateproject b/.kateproject new file mode 100644 index 0000000..90377ce --- /dev/null +++ b/.kateproject @@ -0,0 +1,4 @@ +{ + "name": "DAQtools" +, "files": [ { "git": 1 } ] +} diff --git a/padiwa.pl b/padiwa.pl index af7a9e0..484cd60 100755 --- 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 -- 2.43.0