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