#!/bin/sh # first separate one large line, transform hexadecimal numbers # next insert wake_up and sleep_up procedure # # read COPYRIGHT in this directory !! # rm -f table.? zcat $1|./CR |tr ':;<=>?' 'ABCDEF'|\ sed s/F9_/'\ sleep_up(0xA0);\ \ wake_up(0xF9);'/ |\ sed s/A9_/'\ wake_up(0xA9);'/ | # # parse file, one read from register is transformed to epp_read one # and remark is made with latest value from register # # read block is transformed to epp_read_block # # one write is transformed to epp_write_one with appropriate values # # block write ... if block is zeros, remark is made (// zeros) # other .. a file "table.X" is made , X is number of table for write # awk -F@ '{ if(substr($0,1,1) == "o") { reg=substr($1,2) num=length($2) if(num==2) printf("epp_write_one (0x%s, 0x%s);\n",$2,reg); else { printf("epp_write_block (&buffer, 0x%s, %d);",reg,num/2); if($2 ~ /[^0]/) { ntable++; printf(" // table %d\n",ntable); file="table."ntable; print $2 > file ; #for(i=0;i> file # } } else printf(" // zeros \n"); } } else if(substr($0,1,1) == "i") { reg=substr($1,2) num=substr($2,0,4) if(num=="0001") printf("epp_read_one (0x%s); //%s\n",reg,substr($2,5,2)); else printf("epp_read_block (&buffer, 0x%s, 0x%s);\n",reg,num); } else print $0; }'| # #search for adc write sequences, and transformate sequence to simple call # awk '{ if(($1=="epp_write_one") && ($3 == "0x0D);")) { if(($2=="(0x20,") ||($2=="(0x35,")) print $0,"//-------------" else { if(i==-2) printf("adc_write ("); if(i==-1) if($2=="(0x80,") printf(" 0x%04x);\n",word) else print "err" if((i==3) && ($2=="(0x80,")) { if(b==0) { j+=1; word=word*2; } else print "Error"; } if((i==3) && ($2=="(0x82,")) { if(b==1) { j+=1; word*=2; word+=1; } else print "Error"; } if((i==2) && ($2=="(0x84,")) { if(b!=0) print "error 0 "; } if((i==2) && ($2=="(0x86,")) { if(b!=1) print "error 1 "; } if( (j!=14) && (i==1) && ($2=="(0x80,")) b=0; if( (j!=14) && (i==1) && ($2=="(0x82,")) b=1; if((i==0) && ($2=="(0x80,")) { j=0; word=0; } i+=1; if(i==4) if(j==14) i=-2 else i=1; } } else print $0; }'| # #search scan image procedure and transformate sequence of scanning to call # awk '{ if(s==0) if($2=="(0x12);") { s=1; count=0 print "//Start of scanning <<<<<<<<<<<<<<<<<<<"; next; } else print $0; if(s==1) { if($1=="epp_read_block") { len=substr($4,3,4); count++; next; } if(($1 != "epp_read_one")) { s=0; printf("scan_lines(%d,0x%s);\n",count,len); print $0; next; } if(($2 == "(0x00);")) next; if(($2 == "(0x12);")) next; if(($2 == "(0x13);")) next; if(($2 == "(0x0C);")) next; s=0; printf("scan_lines(%d,0x%s);\n",count,len); print $0; } }'| # # add comments .. # awk '{ if(($1=="epp_write_one") && ($3=="0x0E);")) { print "\n//--------------- FIFO adres write " } print $0 }'