17,27 → 17,36 |
uint32_t ptaddr=0; |
|
int Pts_write(uint32_t addr, uint32_t data ){ |
VME_A32D32_W(ptaddr+addr,&data); |
return 0; |
fprintf(stderr, "Pts_write ADDR 0x%04x 0x%04x ",addr,ptaddr+addr ); |
int nb=VME_A32D32_W(ptaddr+addr,&data); |
fprintf(stderr, " nb=%d\n",nb); |
return nb; |
} |
|
int Pts_Mwrite(uint32_t addr, uint32_t data ){ |
VME_A32D32_MW(ptaddr+addr,&data); |
return 1; |
} |
|
int Pts_read(uint32_t addr, uint32_t *data ){ |
VME_A32D32_R(ptaddr+addr,data); |
return 0; |
fprintf(stderr, "Pts_read ADDR 0x%04x 0x%04x ",addr,ptaddr+addr ); |
int nb=VME_A32D32_R(ptaddr+addr,data); |
fprintf(stderr, " nb=%d\n",nb); |
return nb; |
} |
|
|
int Pts_erase( int verbose ) { |
uint32_t dum; |
uint32_t dum = 0; |
Pts_write( ADR_CSR1, 0 ); |
Delay(0.1); |
Pts_read( ADR_CSR1, &dum); |
if( verbose ) printf( "CSR1(0x%02x) = 0x%04x\n", ADR_CSR1, |
if( verbose ) fprintf( stderr, "CSR1(0x%02x) = 0x%04x <<<<\n", ADR_CSR1, |
dum & 0xffff ); |
Pts_write( ADR_CSR1, CSR1_PROGRAM_ ); |
Delay(0.1); |
Pts_read( ADR_CSR1, &dum); |
if( verbose ) printf( "CSR1(0x%02x) = 0x%04x\n", ADR_CSR1, |
if( verbose ) fprintf(stderr, "CSR1(0x%02x) = 0x%04x >>>>>\n", ADR_CSR1, |
dum & 0xffff ); |
return 1; |
} |
112,8 → 121,8 |
if( ( fp = fopen( filename, "rb" ) ) == NULL ) { |
if( verbose ) fprintf( stderr, "cannot open \"%s\"\n", filename ); |
return -1; |
} |
if(verbose) printf( "file \"%s\" opened.\n", filename ); |
} |
if(verbose) printf( "Verbose= %d File \"%s\" opened.\n", verbose ,filename ); |
|
/* ------------------------------------------------------------ *\ |
The data for the configuration start from 0xffff_ffff_aa99_aa66 |
127,37 → 136,67 |
} |
(c == 0xff) ? dummyword++ : (dummyword=0); |
} while( dummyword < 4 ); |
|
|
// const long byte_per_dot = BYTE_PER_DOT; |
// unsigned long nchar = 0; |
|
if( mode == SLAVESERIAL_MODE ) { |
if(verbose) puts("slave serial mode"); |
if(verbose) fprintf(stderr, "slave serial mode"); |
Pts_write( ADR_MODE, mode ); |
Pts_erase( verbose ); |
for( j=0; j<32; j++ ) Pts_write( ADR_CFG, 0x1 ); |
while( (c=getc(fp))!=EOF ){ |
while(!feof(fp)) |
{ |
int nb = fread(&c,1,1,fp); |
if (nb<=0) continue; |
//while( (c=getc(fp))!=EOF ){ |
for( j=0; j<8; j++ ) Pts_write( ADR_CFG, (c>>(7-j))&0x1 ); |
nchar++; |
if( verbose && nchar%byte_per_dot==0 ) putchar('.'); |
} |
} else if( mode == SELECTMAP_MODE ) { |
if( verbose ) puts("select map mode"); |
if( verbose ) fprintf(stderr, "select map mode ...."); |
|
Pts_write( ADR_MODE, SELECTMAP_MODE ); |
Pts_erase( verbose ); |
for( j=0; j<4; j++ ) Pts_write( ADR_CFG, 0xff ); |
while( (c=getc(fp))!=EOF ){ |
|
fprintf(stderr, "-------------\n"); |
|
//if( verbose ) fprintf(stderr, "program ....\n"); |
|
for( j=0; j<4; j++ ) { |
fprintf(stderr, "%d ------------\n", j); |
Pts_write( ADR_CFG, 0xff ); |
} |
fprintf(stderr, "at line %d -------------\n", __LINE__); |
VME_MWRST(); |
while(!feof(fp)) |
{ |
int nb = fread(&c,1,1,fp); |
if (nb<=0) continue; |
// while ( (c=getc(fp))!=EOF ){ |
if (feof(fp)) { |
if(verbose) fprintf(stderr, "feof detected. Exit.\n"); |
return -1; |
} |
int cc = 0; |
for(j=0; j<8; j++) cc |= ((c&(1<<j))>>j)<<(7-j); |
Pts_write( ADR_CFG, cc ); |
//fprintf(stderr, "s"); |
Pts_Mwrite( ADR_CFG, cc ); |
nchar++; |
if( verbose && nchar%byte_per_dot==0 ) putchar('.'); |
if( verbose && nchar%byte_per_dot==0 ) { |
fprintf(stderr, "#"); |
VME_MWEXEC(); |
VME_MWRST(); |
fprintf(stderr, "."); |
} |
} |
} else { |
if(verbose) fprintf(stderr, "\nIllegal mode\n"); |
return -1; |
} |
if(verbose) printf("\ntotal %ld bits\n", nchar); |
fclose(fp); |
if(verbose) fprintf(stderr, "\ntotal %ld bits\n", nchar); |
if (fp) fclose(fp); |
return Pts_check_configure( verbose ); |
} |
|
166,10 → 205,10 |
Pts_read(ADR_CSR1,&csr1_value); |
if(verbose) printf("CSR1(0x%02x)=0x%04x\n",ADR_CSR1,csr1_value&0xffff); |
if(csr1_value&CSR1_DONE) { |
if(verbose) puts("configure complete."); |
if(verbose) fprintf(stderr, "configure complete.\n"); |
return 1; |
} else { |
if(verbose) puts("configure not complete."); |
if(verbose) fprintf(stderr, "configure not complete.\n"); |
return -1; |
} |
} |