From: Dobrica Pavlinusic Date: Sat, 11 Jun 2016 09:49:03 +0000 (+0200) Subject: fix pin manipulation X-Git-Url: http://git.rot13.org/?p=x300-pci;a=commitdiff_plain;h=9bc5611183afd89723d9cc4ec761e555332eeec7;hp=0e3e3c9f4e9f91da0493308875a5c1f71bf8cea2 fix pin manipulation --- diff --git a/openocd-jtag-boundary-scan.pl b/openocd-jtag-boundary-scan.pl index dafd874..acb4a5d 100755 --- a/openocd-jtag-boundary-scan.pl +++ b/openocd-jtag-boundary-scan.pl @@ -9,6 +9,7 @@ use Storable; my $openocd_remote = shift @ARGV || 'picam:4444'; + my $bit2pin; my $io2bit; @@ -70,6 +71,8 @@ sub print_io { my $bits = shift; $bits = reverse $bits; # make substr work as expected + return if $last_bits eq $bits; + print "pin off io___ ICO prv | " x 4, $openocd_remote,"\n"; foreach my $i ( 0 .. ($#$pin2io/4)-1 ) { foreach my $j ( 0 .. 3 ) { @@ -154,9 +157,17 @@ sub diff_bits { print "# diff_bits $diff\n"; } -print "[press enter]\n"; -my $cmd = ; +my $cmd = ''; +if ( $ENV{SLEEP} ) { + sleep $ENV{SLEEP}; + $cmd = ; + exit if ! $cmd; +} else { + print "[press enter]\n"; + $cmd = ; +} chomp $cmd; + if ( $cmd =~ /(\d+)=(\d)/ ) { my ( $pin, $v ) = ( $1, $2 ); warn "# pin $pin = $v\n"; @@ -164,11 +175,14 @@ if ( $cmd =~ /(\d+)=(\d)/ ) { my $io = $pin2io->[$pin]; my $bit = $io2bit->{$io}->[0]; - my $b = substr($BSR,0,$bit+1) - . ( substr($BSR,$bit+1,1) ^ 1 ) + my $old_bsr = reverse $BSR; + + my $b = substr($old_bsr,0,$bit+1) + . ( substr($old_bsr,$bit+1,1) ^ 1 ) . ( $v & 1 ) - . substr($BSR,$bit+3) + . substr($old_bsr,$bit+3) ; + $b = reverse $b; diff_bits( $BSR, $b ), $/; @@ -183,3 +197,73 @@ if ( $cmd =~ /(\d+)=(\d)/ ) { }#while(1) + +__DATA__ +5=1 +a +b +c +d +e +f +a +a +a +a +a +a +a +a +a +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +b +c +d +e +f +5=0 +a +b +c +d +e +f