mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
configuremac doesnt return a retval, separated setdaqregister and clean fifo, included clean fifo before startstatemachine, set delay and gates to 0 at start of server
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@335 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
3cc914a8fb
commit
33fa69d546
@ -245,6 +245,24 @@ int setPhaseShiftOnce(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cleanFifo(){
|
||||||
|
u_int32_t addr, reg, val;
|
||||||
|
printf("\nCleaning FIFO\n");
|
||||||
|
addr=ADC_SYNC_REG;
|
||||||
|
val=ADCSYNC_VAL | ADCSYNC_CLEAN_FIFO_BITS;
|
||||||
|
bus_w(addr,val);
|
||||||
|
|
||||||
|
val=ADCSYNC_VAL;
|
||||||
|
bus_w(addr,val);
|
||||||
|
reg=bus_r(addr);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("\nADC SYNC reg:%d\n",reg);
|
||||||
|
#endif
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int setDAQRegister(int adcval)
|
int setDAQRegister(int adcval)
|
||||||
{
|
{
|
||||||
u_int32_t addr, reg, val;
|
u_int32_t addr, reg, val;
|
||||||
@ -260,18 +278,8 @@ int setDAQRegister(int adcval)
|
|||||||
printf("DAQ reg:%x\n",reg);
|
printf("DAQ reg:%x\n",reg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cleanFifo();
|
||||||
|
|
||||||
//clean fifo
|
|
||||||
addr=ADC_SYNC_REG;
|
|
||||||
val=ADCSYNC_VAL | ADCSYNC_CLEAN_FIFO_BITS;
|
|
||||||
bus_w(addr,val);
|
|
||||||
|
|
||||||
val=ADCSYNC_VAL;
|
|
||||||
bus_w(addr,val);
|
|
||||||
reg=bus_r(addr);
|
|
||||||
#ifdef VERBOSE
|
|
||||||
printf("\nADC SYNC reg:%d\n",reg);
|
|
||||||
#endif
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,10 +735,11 @@ int startReceiver(int start) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Config Reg %x\n", reg);
|
printf("Config Reg %x\n", reg);
|
||||||
#endif
|
#endif
|
||||||
if (start && (!(reg&CPU_OR_RECEIVER_BIT)))
|
int d =reg&CPU_OR_RECEIVER_BIT;
|
||||||
return OK;
|
if(d!=0) d=1;
|
||||||
if(!start && (reg&CPU_OR_RECEIVER_BIT))
|
if(d!=start)
|
||||||
return OK;
|
return OK;
|
||||||
|
else
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,9 +1285,9 @@ int configureMAC(int ipad,long long int macad,long long int servermacad,int ival
|
|||||||
mac_conf_regs=(mac_conf*)(CSP0BASE+offset*2);
|
mac_conf_regs=(mac_conf*)(CSP0BASE+offset*2);
|
||||||
tse_conf_regs=(tse_conf*)(CSP0BASE+offset2*2);
|
tse_conf_regs=(tse_conf*)(CSP0BASE+offset2*2);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Configuring MAC\n");
|
printf("***Configuring MAC***\n");
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
if(ival)
|
if(ival)
|
||||||
bus_w(addrr,(RESET_BIT|DIGITAL_TEST_BIT)); //0x080,reset mac (reset)
|
bus_w(addrr,(RESET_BIT|DIGITAL_TEST_BIT)); //0x080,reset mac (reset)
|
||||||
@ -1474,6 +1483,7 @@ u_int32_t runState(void) {
|
|||||||
// State Machine
|
// State Machine
|
||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
|
cleanFifo();
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Starting State Machine\n");
|
printf("Starting State Machine\n");
|
||||||
//#endif
|
//#endif
|
||||||
|
@ -26,6 +26,7 @@ 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);
|
||||||
|
|
||||||
int setPhaseShiftOnce();
|
int setPhaseShiftOnce();
|
||||||
|
int cleanFifo();
|
||||||
int setDAQRegister(int adcval);
|
int setDAQRegister(int adcval);
|
||||||
|
|
||||||
u_int32_t putout(char *s, int modnum);
|
u_int32_t putout(char *s, int modnum);
|
||||||
|
@ -80,8 +80,8 @@ int init_detector( int b) {
|
|||||||
setTrains(1);
|
setTrains(1);
|
||||||
setExposureTime(1e9);
|
setExposureTime(1e9);
|
||||||
setPeriod(1e9);
|
setPeriod(1e9);
|
||||||
setDelay(1e9);
|
setDelay(0);
|
||||||
setGates(1);
|
setGates(0);
|
||||||
#endif
|
#endif
|
||||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||||
setMaster(GET_MASTER);
|
setMaster(GET_MASTER);
|
||||||
@ -451,7 +451,7 @@ int set_external_signal_flag(int file_des) {
|
|||||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -2748,7 +2748,6 @@ int update_client(int file_des) {
|
|||||||
|
|
||||||
int configure_mac(int file_des) {
|
int configure_mac(int file_des) {
|
||||||
|
|
||||||
int retval;
|
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
char arg[3][50];
|
char arg[3][50];
|
||||||
int n,i;
|
int n,i;
|
||||||
@ -2797,21 +2796,15 @@ int configure_mac(int file_des) {
|
|||||||
imod=ALLMOD;
|
imod=ALLMOD;
|
||||||
|
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("Configuring MAC of module %d\n", imod);
|
printf("Configuring MAC of module %d and adc %d\n", imod, adc);
|
||||||
//#endif
|
//#endif
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
if (ret==OK) {
|
if (ret==OK)
|
||||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit,adc);
|
configureMAC(ipad,imacadd,iservermacadd,digitalTestBit,adc);
|
||||||
if(retval==-1)
|
|
||||||
ret=FAIL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
//#ifdef VERBOSE
|
if (ret==FAIL)
|
||||||
printf("Configured MAC with retval %d\n", retval);
|
|
||||||
//#endif
|
|
||||||
if (ret==FAIL) {
|
|
||||||
printf("configuring MAC of mod %d failed\n", imod);
|
printf("configuring MAC of mod %d failed\n", imod);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (differentClients)
|
if (differentClients)
|
||||||
@ -2820,10 +2813,7 @@ int configure_mac(int file_des) {
|
|||||||
/* send answer */
|
/* send answer */
|
||||||
/* send OK/failed */
|
/* send OK/failed */
|
||||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
if (ret!=FAIL) {
|
if (ret==FAIL) {
|
||||||
/* send return argument */
|
|
||||||
n += sendDataOnly(file_des,&retval,sizeof(retval));printf("retval:%d\n",retval);
|
|
||||||
} else {
|
|
||||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3106,6 +3096,7 @@ int start_receiver(int file_des) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = startReceiver(1);
|
ret = startReceiver(1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -3141,6 +3132,7 @@ int stop_receiver(int file_des) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret=startReceiver(0);
|
ret=startReceiver(0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user