mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +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,34 +245,42 @@ 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)
|
||||
{
|
||||
u_int32_t addr, reg, val;
|
||||
u_int32_t addr, reg, val;
|
||||
|
||||
addr=DAQ_REG;
|
||||
int value=0x7f;
|
||||
if(adcval==-1) value=0x13f;
|
||||
val=34+(42<<8)+(value<<16);
|
||||
reg=bus_r(addr);
|
||||
bus_w(addr,val);
|
||||
reg=bus_r(addr);
|
||||
addr=DAQ_REG;
|
||||
int value=0x7f;
|
||||
if(adcval==-1) value=0x13f;
|
||||
val=34+(42<<8)+(value<<16);
|
||||
reg=bus_r(addr);
|
||||
bus_w(addr,val);
|
||||
reg=bus_r(addr);
|
||||
#ifdef VERBOSE
|
||||
printf("DAQ reg:%x\n",reg);
|
||||
printf("DAQ reg:%x\n",reg);
|
||||
#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,11 +735,12 @@ int startReceiver(int start) {
|
||||
#ifdef VERBOSE
|
||||
printf("Config Reg %x\n", reg);
|
||||
#endif
|
||||
if (start && (!(reg&CPU_OR_RECEIVER_BIT)))
|
||||
int d =reg&CPU_OR_RECEIVER_BIT;
|
||||
if(d!=0) d=1;
|
||||
if(d!=start)
|
||||
return OK;
|
||||
if(!start && (reg&CPU_OR_RECEIVER_BIT))
|
||||
return OK;
|
||||
return FAIL;
|
||||
else
|
||||
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);
|
||||
tse_conf_regs=(tse_conf*)(CSP0BASE+offset2*2);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Configuring MAC\n");
|
||||
#endif
|
||||
//#ifdef VERBOSE
|
||||
printf("***Configuring MAC***\n");
|
||||
//#endif
|
||||
|
||||
if(ival)
|
||||
bus_w(addrr,(RESET_BIT|DIGITAL_TEST_BIT)); //0x080,reset mac (reset)
|
||||
@ -1474,6 +1483,7 @@ u_int32_t runState(void) {
|
||||
// State Machine
|
||||
|
||||
int startStateMachine(){
|
||||
cleanFifo();
|
||||
//#ifdef VERBOSE
|
||||
printf("Starting State Machine\n");
|
||||
//#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);
|
||||
|
||||
int setPhaseShiftOnce();
|
||||
int cleanFifo();
|
||||
int setDAQRegister(int adcval);
|
||||
|
||||
u_int32_t putout(char *s, int modnum);
|
||||
|
@ -80,8 +80,8 @@ int init_detector( int b) {
|
||||
setTrains(1);
|
||||
setExposureTime(1e9);
|
||||
setPeriod(1e9);
|
||||
setDelay(1e9);
|
||||
setGates(1);
|
||||
setDelay(0);
|
||||
setGates(0);
|
||||
#endif
|
||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
setMaster(GET_MASTER);
|
||||
@ -451,7 +451,7 @@ int set_external_signal_flag(int file_des) {
|
||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -2748,7 +2748,6 @@ int update_client(int file_des) {
|
||||
|
||||
int configure_mac(int file_des) {
|
||||
|
||||
int retval;
|
||||
int ret=OK;
|
||||
char arg[3][50];
|
||||
int n,i;
|
||||
@ -2797,21 +2796,15 @@ int configure_mac(int file_des) {
|
||||
imod=ALLMOD;
|
||||
|
||||
//#ifdef VERBOSE
|
||||
printf("Configuring MAC of module %d\n", imod);
|
||||
printf("Configuring MAC of module %d and adc %d\n", imod, adc);
|
||||
//#endif
|
||||
#ifdef MCB_FUNCS
|
||||
if (ret==OK) {
|
||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit,adc);
|
||||
if(retval==-1)
|
||||
ret=FAIL;
|
||||
}
|
||||
if (ret==OK)
|
||||
configureMAC(ipad,imacadd,iservermacadd,digitalTestBit,adc);
|
||||
#endif
|
||||
//#ifdef VERBOSE
|
||||
printf("Configured MAC with retval %d\n", retval);
|
||||
//#endif
|
||||
if (ret==FAIL) {
|
||||
if (ret==FAIL)
|
||||
printf("configuring MAC of mod %d failed\n", imod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (differentClients)
|
||||
@ -2820,10 +2813,7 @@ int configure_mac(int file_des) {
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
/* send return argument */
|
||||
n += sendDataOnly(file_des,&retval,sizeof(retval));printf("retval:%d\n",retval);
|
||||
} else {
|
||||
if (ret==FAIL) {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
}
|
||||
|
||||
@ -3106,6 +3096,7 @@ int start_receiver(int file_des) {
|
||||
}
|
||||
else
|
||||
ret = startReceiver(1);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -3141,6 +3132,7 @@ int stop_receiver(int file_des) {
|
||||
}
|
||||
else
|
||||
ret=startReceiver(0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user