From: Benedikt Gutsche Date: Mon, 27 Feb 2023 13:18:48 +0000 (+0100) Subject: clean up X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=671a12f4b0a8670947f5309c1cf83835fd34ae93;p=mimosis_chain.git clean up --- diff --git a/scripts/Mimosis.pm b/scripts/Mimosis.pm index c6145b3..1ab8731 100644 --- a/scripts/Mimosis.pm +++ b/scripts/Mimosis.pm @@ -6,7 +6,7 @@ use HADES::TrbNet; use Time::HiRes qw(usleep); #use FileHandle; -#use Data::Dumper; +use Data::Dumper; sub adc_i2c_command { @@ -47,6 +47,8 @@ sub mimosis_i2c_command { [ $reg_flag, $reg_data, 0x1 ], 3 ); usleep(1000); my $reg_return = trb_register_read( $fpga, 0xde04 ); + + # print Dumper $reg_return; return $reg_return->{$fpga} & 0xffff; } } @@ -66,20 +68,15 @@ sub mimosis_register_write { sub mimosis_register_read { my ( $fpga, $mimosis_reg ) = @_; - my ( $addr, $cmd, $data ); - $addr = 0x12; - $cmd = ( $mimosis_reg >> 8 ); - $data = ( $mimosis_reg & 0xff ); - mimosis_i2c_command( $fpga, $addr, $cmd, $data, 0, 0, 0 ); + my $cmd = ( $mimosis_reg >> 8 ); + my $data = ( $mimosis_reg & 0xff ); - # printf( "%x %x %x %x\n", $fpga, $addr, $cmd, $data ); - usleep(1000); - $addr = 0x15; - $val = mimosis_i2c_command( $fpga, $addr, 0, 0, 1, 1, 0 ); + mimosis_i2c_command( $fpga, 0x12, 0x0, $mimosis_reg, 0, 1, 1 ); - # printf( "%x\n", $val ); - return $val; + # printf( "%x %x %x\n", $fpga, $cmd, $data ); + usleep(1000); + return mimosis_i2c_command( $fpga, 0x15, 0x0, 0x0, 1, 1, 0 ); } 1; diff --git a/scripts/basicsettings.pl b/scripts/basicsettings.pl index 6263644..f48f910 100755 --- a/scripts/basicsettings.pl +++ b/scripts/basicsettings.pl @@ -39,8 +39,22 @@ foreach my $a (@config) { Mimosis::mimosis_register_write( $fpga, @$a[0], @$a[1] ); - # usleep(1000); + usleep(1000); # printf( "%x %x %x\n", $fpga, @$a[0], @$a[1] ); } } + +foreach my $a (@config) { + if ( defined( @$a[1] ) ) + { + my $val = Mimosis::mimosis_register_read $fpga, @$a[0]; + usleep(1000); + unless(($val & 0xff) == @$a[1]) + { + my $reg_return = trb_register_read $fpga, 0xde04; + my $status = ($reg_return->{$fpga} >> 16 ) & 0xff; + printf "%x %x Status: %x\n", @$a[0], $val, $status; + } + } +} diff --git a/scripts/basicsettings_read.pl b/scripts/basicsettings_read.pl new file mode 100755 index 0000000..bd2ba8a --- /dev/null +++ b/scripts/basicsettings_read.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +use warnings; +use Getopt::Long; +use HADES::TrbNet; +use lib "."; +use Mimosis; +use Time::HiRes qw(usleep); + +my $fpga = 0xa000; +my @config = do $ARGV[0]; + +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + "fpga|f=s" => \$fpga, + "file|d=s" => \$file, + "help|h" => \$help, +); + +if ($help) { + my $message = <<'END_MESSAGE'; +-f, --fpga -> Hex address of the FPGA. Must be provided, should not be a broadcast address. +-d, --file -> File with configurations. Must be provided. +-h, --help -> Print this help. +END_MESSAGE + print $message; + exit(); +} + +defined($fpga) ? $fpga = hex($fpga) : die print("Must provide FPGA address.\n"); +defined($file) + ? @config = do $file + : die print("Must provide path to config file.\n"); + +trb_init_ports() or die trb_strerror(); + +foreach my $a (@config) { + if ( defined( @$a[1] ) ) + { + my $val = Mimosis::mimosis_register_read $fpga, @$a[0]; + usleep(1000); + my $reg_return = trb_register_read $fpga, 0xde04; + my $status = ($reg_return->{$fpga} >> 16 ) & 0xff; + usleep(1000); + if ( ($val & 0xff) != @$a[1] ) + { + printf "%x %x %x\n", @$a[0], $val, $status; + } + else + { + printf "%x %x\n", @$a[0], $val; + } + } +} diff --git a/scripts/basicsettings_write.pl b/scripts/basicsettings_write.pl new file mode 100755 index 0000000..ea08dec --- /dev/null +++ b/scripts/basicsettings_write.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use warnings; +use Getopt::Long; +use HADES::TrbNet; +use lib "."; +use Mimosis; +use Time::HiRes qw(usleep); + +my $fpga = 0xa000; +my @config = do $ARGV[0]; + +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + "fpga|f=s" => \$fpga, + "file|d=s" => \$file, + "help|h" => \$help, +); + +if ($help) { + my $message = <<'END_MESSAGE'; +-f, --fpga -> Hex address of the FPGA. Must be provided, should not be a broadcast address. +-d, --file -> File with configurations. Must be provided. +-h, --help -> Print this help. +END_MESSAGE + print $message; + exit(); +} + +defined($fpga) ? $fpga = hex($fpga) : die print("Must provide FPGA address.\n"); +defined($file) + ? @config = do $file + : die print("Must provide path to config file.\n"); + +trb_init_ports() or die trb_strerror(); + +foreach my $a (@config) { + if ( defined( @$a[1] ) ) { + Mimosis::mimosis_register_write( $fpga, @$a[0], @$a[1] ); + usleep(1000); + } +} diff --git a/scripts/CONF_1out.pl b/scripts/conf/CONF_1out.pl similarity index 100% rename from scripts/CONF_1out.pl rename to scripts/conf/CONF_1out.pl diff --git a/scripts/CONF_TEMPLATE.pl b/scripts/conf/CONF_TEMPLATE.pl similarity index 100% rename from scripts/CONF_TEMPLATE.pl rename to scripts/conf/CONF_TEMPLATE.pl diff --git a/scripts/CONF_VCAS_2.pl b/scripts/conf/CONF_VCAS_2.pl similarity index 100% rename from scripts/CONF_VCAS_2.pl rename to scripts/conf/CONF_VCAS_2.pl diff --git a/scripts/CONF_allregisters.pl b/scripts/conf/CONF_allregisters.pl similarity index 100% rename from scripts/CONF_allregisters.pl rename to scripts/conf/CONF_allregisters.pl diff --git a/scripts/CONF_noise_M4.pl b/scripts/conf/CONF_noise_M4.pl similarity index 100% rename from scripts/CONF_noise_M4.pl rename to scripts/conf/CONF_noise_M4.pl diff --git a/scripts/CONF_seq.pl b/scripts/conf/CONF_seq.pl similarity index 100% rename from scripts/CONF_seq.pl rename to scripts/conf/CONF_seq.pl diff --git a/scripts/CONF_testmode_enable.pl b/scripts/conf/CONF_testmode_enable.pl similarity index 100% rename from scripts/CONF_testmode_enable.pl rename to scripts/conf/CONF_testmode_enable.pl diff --git a/scripts/dac_scan/dac_scan.pl b/scripts/dac_scan/dac_scan.pl index 1c9e087..29e7c4f 100755 --- a/scripts/dac_scan/dac_scan.pl +++ b/scripts/dac_scan/dac_scan.pl @@ -67,6 +67,8 @@ open( v_FH, '>', $vmon_file ) or die $!; #MONVOLT for my $dac ( sort keys %vdac ) { #loop over voltage DACs + printf "Scan: %x\n", $vdac{$dac}; + Mimosis::mimosis_register_write( $fpga, 0x0026, $dac ); usleep(1000); @@ -97,6 +99,8 @@ open( i_FH, '>', $imon_file ) or die $!; #MONCURR for my $dac ( sort keys %idac ) { #loop over current DACs + printf "Scan: %x\n", $idac{$dac}; + Mimosis::mimosis_register_write( $fpga, 0x0025, $dac ); usleep(1000); @@ -126,6 +130,8 @@ open( o_FH, '>', $other_file ) or die $!; #MONVOLT_others for my $dac ( sort keys %odac ) { + printf "Scan: %x\n", $odac{$dac}; + Mimosis::mimosis_register_write( $fpga, 0x0026, $dac ); usleep(1000); diff --git a/scripts/dac_scan/img/2023-02-21_13-32-29.png b/scripts/dac_scan/img/2023-02-21_13-32-29.png new file mode 100644 index 0000000..8ce133d Binary files /dev/null and b/scripts/dac_scan/img/2023-02-21_13-32-29.png differ diff --git a/scripts/dac_scan/img/2023-02-21_14-50-13.png b/scripts/dac_scan/img/2023-02-21_14-50-13.png new file mode 100644 index 0000000..57974cc Binary files /dev/null and b/scripts/dac_scan/img/2023-02-21_14-50-13.png differ diff --git a/scripts/dac_scan/img/2023-02-21_14-51-13.png b/scripts/dac_scan/img/2023-02-21_14-51-13.png new file mode 100644 index 0000000..236e022 Binary files /dev/null and b/scripts/dac_scan/img/2023-02-21_14-51-13.png differ diff --git a/scripts/dac_scan/img/2023-02-24_14-44-15.png b/scripts/dac_scan/img/2023-02-24_14-44-15.png new file mode 100644 index 0000000..5d22a7b Binary files /dev/null and b/scripts/dac_scan/img/2023-02-24_14-44-15.png differ diff --git a/scripts/dac_scan/img/2023-02-25_17-22-55.png b/scripts/dac_scan/img/2023-02-25_17-22-55.png new file mode 100644 index 0000000..57ac4bb Binary files /dev/null and b/scripts/dac_scan/img/2023-02-25_17-22-55.png differ diff --git a/scripts/dac_scan/img/2023-02-25_17-27-35.png b/scripts/dac_scan/img/2023-02-25_17-27-35.png new file mode 100644 index 0000000..96258ed Binary files /dev/null and b/scripts/dac_scan/img/2023-02-25_17-27-35.png differ diff --git a/scripts/legacy/i2c_cmd.pl b/scripts/legacy/i2c_cmd.pl new file mode 100755 index 0000000..11720fc --- /dev/null +++ b/scripts/legacy/i2c_cmd.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl -I. + +use warnings; +use Getopt::Long; +use HADES::TrbNet; +use Time::HiRes qw(usleep); +use lib "."; +use Mimosis; + +my ( $fpga, $addr, $cmd, $cmd_t, $data, $data_t, $word ); + +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + "fpga|f=s" => \$fpga, + "addr|a=s" => \$addr, + "cmd|c=s" => \$cmd_t, + "data|d=s" => \$data_t, + "word|w" => \$word, + "help|h" => \$help_t, +); + +if ($help_t) { + print("Usage:\n"); + print("-f, --fpga:\n"); + print("-a, --addr:\n"); + print("-c, --cmd:\n"); + print("-d, --data:\n"); + print("-w, --word:\n"); + print("-h, --help:\n"); +} + +trb_init_ports() or die trb_strerror(); + +defined($fpga) ? $fpga = hex($fpga) : die print("Must provide FPGA address.\n"); +defined($addr) ? $addr = hex($addr) : die print("Must provide I2C address.\n"); +$cmd = defined($cmd_t) ? hex($cmd_t) : 0x0; +$data = defined($data_t) ? hex($data_t) : 0x0; + +$val = Mimosis::send_i2c_command( $fpga, $addr, $cmd, $data, !defined($data_t), + !defined($cmd_t), defined($word) ); +if ( not defined($data_t) ) { + printf( "%x\n", $val ); +} diff --git a/scripts/mimosis_i2c_cmd.pl b/scripts/mimosis_i2c_cmd.pl index 8d9127a..3165d21 100755 --- a/scripts/mimosis_i2c_cmd.pl +++ b/scripts/mimosis_i2c_cmd.pl @@ -29,8 +29,8 @@ END_MESSAGE } if ( defined $fpga_t && defined $reg_t) { - $fpga_t = hex $fpga_t if ( $fpga_t =~ /^0x/ ); - $reg_t = hex $reg_t if ( $reg_t =~ /^0x/ ); + $fpga_t = hex $fpga_t if ( $fpga_t =~ /^0x/ ); + $reg_t = hex $reg_t if ( $reg_t =~ /^0x/ ); } else {die print "Must provide FPGA address and register.\n";}