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