mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 00:00:02 +02:00
a few changes for the fifo_read and the bus_r16
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@113 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
af2c6b9bb2
commit
266d13759c
@ -26,12 +26,12 @@ int fr;
|
||||
int wait_time;
|
||||
int *fifocntrl;
|
||||
int *values;
|
||||
int *statusreg;
|
||||
//int *statusreg; commented out by dhanya
|
||||
const int nModY=1;
|
||||
int nModBoard;
|
||||
int nModX=NMAXMOD;
|
||||
int dynamicRange=32;
|
||||
int dataBytes=NMAXMOD*NCHIP*NCHAN*4;
|
||||
int dynamicRange=16;//32;
|
||||
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||
int storeInRAM=0;
|
||||
int *ram_values=NULL;
|
||||
char *now_ptr=NULL;
|
||||
@ -169,18 +169,28 @@ int mapCSP0(void) {
|
||||
printf("CSPObase is 0x%x \n",CSP0BASE);
|
||||
printf("CSPOBASE=from %08x to %x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
|
||||
|
||||
u_int32_t address;
|
||||
address = FIFO_DATA_REG_OFF;
|
||||
values=(u_int16_t*)(CSP0BASE+address*2);
|
||||
printf("values=%04x\n",values);
|
||||
//printf("values=%08x\n",((u_int32_t*)(CSP0BASE+FIFO_DATA_REG_OFF*2)));
|
||||
|
||||
/* must b uncommentedlater////////////////////////////////////////////////////////
|
||||
values=(u_int32_t*)(CSP0BASE+FIFO_DATA_REG_OFF);
|
||||
printf("values=%08x\n",values);
|
||||
fifocntrl=(u_int32_t*)(CSP0BASE+FIFO_CNTRL_REG_OFF);
|
||||
printf("fifcntrl=%08x\n",fifocntrl);
|
||||
*/
|
||||
statusreg=(u_int32_t*)(CSP0BASE+STATUS_REG);
|
||||
printf("statusreg=%08x\n",statusreg);
|
||||
// statusreg=(u_int32_t*)(CSP0BASE+STATUS_REG*2);
|
||||
printf("statusreg=%08x\n",bus_r(STATUS_REG));
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
u_int16_t bus_r16(u_int32_t offset){
|
||||
u_int16_t *ptr1;
|
||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||
return *ptr1;
|
||||
}
|
||||
//aldos function volatile (not needed)
|
||||
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
||||
u_int16_t *ptr1;
|
||||
@ -1391,20 +1401,21 @@ u_int32_t* fifo_read_event()
|
||||
#ifdef VIRTUAL
|
||||
return NULL;
|
||||
#endif
|
||||
printf("before looping\n");
|
||||
#ifdef VERYVERBOSE
|
||||
printf("before looping\n");
|
||||
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||
if ((fifoReadCounter(ichip)&FIFO_COUNTER_MASK)%128)
|
||||
printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK));
|
||||
}
|
||||
#endif
|
||||
while(bus_r(LOOK_AT_ME_REG)==0) {
|
||||
#ifdef VERYVERBOSE
|
||||
printf("Waiting for data status %x\n",runState());
|
||||
#endif
|
||||
while(bus_r(LOOK_AT_ME_REG)==0) {
|
||||
//#ifdef VERYVERBOSE
|
||||
printf("Waiting for data status %x\n",runState());
|
||||
//#endif
|
||||
if (runBusy()==0) {
|
||||
if (bus_r(LOOK_AT_ME_REG)==0) {
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("no frame found - exiting ");
|
||||
|
||||
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
@ -1413,16 +1424,17 @@ u_int32_t* fifo_read_event()
|
||||
printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK));
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
//#endif
|
||||
return NULL;
|
||||
} else {
|
||||
#ifdef VERYVERBOSE
|
||||
//#ifdef VERYVERBOSE
|
||||
printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
|
||||
#endif
|
||||
//#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||
@ -1432,7 +1444,7 @@ u_int32_t* fifo_read_event()
|
||||
#endif
|
||||
memcpy(now_ptr, values, dataBytes);
|
||||
/*
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
for (ichip=0;ichip<dataBytes/4; ichip++) {
|
||||
now_ptr[ichip*4]=values[ichip];
|
||||
#ifdef VERBOSE
|
||||
@ -1440,16 +1452,17 @@ u_int32_t* fifo_read_event()
|
||||
printf("chip %d ch %d %d\n",ichip/128, ichip%128, (fifoReadCounter(ichip/128)&FIFO_COUNTER_MASK));
|
||||
#endif
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
//#ifdef VERYVERBOSE
|
||||
printf("Copying to ptr %x %d\n",now_ptr, dataBytes);
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
//#endif
|
||||
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
for (ichip=0; ichip<nModBoard*NCHIP; ichip++) {
|
||||
if ((fifoReadCounter(ichip)&FIFO_COUNTER_MASK)%128)
|
||||
printf("FIFO %d contains %d words\n",ichip,(fifoReadCounter(ichip)&FIFO_COUNTER_MASK));
|
||||
@ -1527,6 +1540,7 @@ u_int32_t* decode_data(int *datain)
|
||||
|
||||
|
||||
int setDynamicRange(int dr) {
|
||||
/*
|
||||
int ow;
|
||||
int nm;
|
||||
|
||||
@ -1557,7 +1571,7 @@ int setDynamicRange(int dr) {
|
||||
putout("0000000000000000",ALLMOD);
|
||||
setNMod(nm);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
return getDynamicRange();
|
||||
}
|
||||
@ -1568,6 +1582,7 @@ int setDynamicRange(int dr) {
|
||||
|
||||
|
||||
int getDynamicRange() {
|
||||
/*
|
||||
int dr;
|
||||
u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG);
|
||||
u_int32_t outmux=(shiftin >> OUTMUX_OFF) & OUTMUX_MASK;
|
||||
@ -1606,7 +1621,8 @@ int getDynamicRange() {
|
||||
;
|
||||
} else
|
||||
printf("ram not allocated\n");
|
||||
|
||||
*/
|
||||
dynamicRange=16;
|
||||
return dynamicRange;
|
||||
|
||||
}
|
||||
@ -1670,7 +1686,7 @@ int allocateRAM() {
|
||||
size=dataBytes;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("nmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,size );
|
||||
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,size );
|
||||
#endif
|
||||
|
||||
if (size==ram_size) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
int mapCSP0(void);
|
||||
|
||||
u_int16_t bus_r16(u_int32_t offset);
|
||||
u_int16_t bus_w16(u_int32_t offset, u_int16_t data);//aldos function
|
||||
u_int32_t bus_w(u_int32_t offset, u_int32_t data);
|
||||
u_int32_t bus_r(u_int32_t offset);
|
||||
|
@ -98,7 +98,7 @@ int initDetector() {
|
||||
*/
|
||||
|
||||
/* initialize dynamic range etc. */
|
||||
/* dynamicRange=getDynamicRange(); //commented out by dhanya
|
||||
/* dynamicRange=getDynamicRange(); //always 16 not required commented out
|
||||
nModX=setNMod(-1);*/
|
||||
|
||||
//dataBytes=nModX*NCHIP*NCHAN*4;
|
||||
@ -106,7 +106,7 @@ int initDetector() {
|
||||
// initChip(0, 0,ALLMOD);
|
||||
//nModX=n;
|
||||
//
|
||||
// allocateRAM();
|
||||
allocateRAM();
|
||||
|
||||
|
||||
return OK;
|
||||
|
@ -37,7 +37,6 @@
|
||||
//not used so far
|
||||
#define SPEED_REG 0x006000
|
||||
#define SET_NBITS_REG 0x008000
|
||||
#define LOOK_AT_ME_REG 0x009000
|
||||
|
||||
//user entered
|
||||
#define SET_DELAY_LSB_REG 0x44<<11
|
||||
@ -91,7 +90,13 @@
|
||||
#define MCB_DOUT_REG_OFF 0x200000
|
||||
#define FIFO_CNTRL_REG_OFF 0x300000
|
||||
#define FIFO_COUNTR_REG_OFF 0x400000
|
||||
#define FIFO_DATA_REG_OFF 0x800000
|
||||
|
||||
//FIFO
|
||||
#define LOOK_AT_ME_REG 0x97<<11
|
||||
|
||||
|
||||
#define FIFO_DATA_REG_OFF 0x98<<11
|
||||
#define COUNTER_REG_OFF 0x99<<11
|
||||
|
||||
#define SHIFTMOD 2
|
||||
#define SHIFTFIFO 9
|
||||
|
@ -70,7 +70,7 @@ int init_detector( int b) {
|
||||
initDetector();
|
||||
printf("\ninitdetector done! \n");
|
||||
testFpga();
|
||||
//testRAM();
|
||||
testRAM();
|
||||
|
||||
//gotthard specific
|
||||
setPhaseShiftOnce();
|
||||
@ -821,13 +821,16 @@ int read_register(int file_des) {
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("reading register 0x%x\n", addr);
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
if(ret!=FAIL){
|
||||
address=(addr<<11);
|
||||
retval=bus_r(address);
|
||||
if((addr==0x98)||(addr==0x99))
|
||||
retval=bus_r16(address);
|
||||
else
|
||||
retval=bus_r(address);
|
||||
}
|
||||
|
||||
|
||||
@ -1368,7 +1371,7 @@ int set_module(int file_des) {
|
||||
int ret=OK;
|
||||
int dr, ow;
|
||||
|
||||
// dr=setDynamicRange(-1); commented out by dhanya
|
||||
dr=setDynamicRange(-1);
|
||||
|
||||
if (myDac)
|
||||
myModule.dacs=myDac;
|
||||
@ -1418,8 +1421,7 @@ int set_module(int file_des) {
|
||||
#endif
|
||||
|
||||
if (ret==OK) {
|
||||
// if (myModule.module>=getNModBoard()) {//commented out by dhanya
|
||||
if (myModule.module>=1) {
|
||||
if (myModule.module>=getNModBoard()) {
|
||||
ret=FAIL;
|
||||
printf("Module number is too large %d\n",myModule.module);
|
||||
}
|
||||
@ -1458,7 +1460,7 @@ int set_module(int file_des) {
|
||||
free(myDac);
|
||||
free(myAdc);
|
||||
|
||||
// setDynamicRange(dr);commentedout by dhanya
|
||||
// setDynamicRange(dr); always 16 commented out
|
||||
|
||||
|
||||
return ret;
|
||||
@ -1905,19 +1907,18 @@ int read_frame(int file_des) {
|
||||
return dataret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (storeInRAM==0) {
|
||||
if ((dataretval=(char*)fifo_read_event())) {
|
||||
dataret=OK;
|
||||
#ifdef VERYVERBOSE
|
||||
//#ifdef VERYVERBOSE
|
||||
printf("Sending ptr %x %d\n",dataretval, dataBytes);
|
||||
#endif
|
||||
//#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("sent %d bytes\n",dataBytes);
|
||||
#endif
|
||||
//#endif
|
||||
printf("dataret OK\n");
|
||||
return OK;
|
||||
} else {
|
||||
@ -1938,7 +1939,7 @@ int read_frame(int file_des) {
|
||||
sendDataOnly(file_des,mess,sizeof(mess));//sizeof(mess));//sizeof(mess));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("message sent\n",mess);
|
||||
#endif
|
||||
#endif
|
||||
printf("dataret %d\n",dataret);
|
||||
return dataret;
|
||||
}
|
||||
@ -1949,14 +1950,14 @@ int read_frame(int file_des) {
|
||||
}
|
||||
dataretval=(char*)ram_values;
|
||||
dataret=OK;
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("sending data of %d frames\n",nframes);
|
||||
#endif
|
||||
//#endif
|
||||
for (iframes=0; iframes<nframes; iframes++) {
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
#ifdef VERYVERBOSE
|
||||
//#ifdef VERYVERBOSE
|
||||
printf("sending pointer %x of size %d\n",dataretval,dataBytes);
|
||||
#endif
|
||||
//#endif
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
dataretval+=dataBytes;
|
||||
}
|
||||
@ -1971,9 +1972,9 @@ int read_frame(int file_des) {
|
||||
if (differentClients)
|
||||
dataret=FORCE_UPDATE;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("Frames left %d\n",getFrames());
|
||||
#endif
|
||||
//#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
printf("dataret %d\n",dataret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user