extern int nfadc; /* Number of FADC250s verified with the library */ extern int fadcID[FA_MAX_BOARDS]; /* Array of slot numbers, discovered by the library */ extern unsigned int fadcAddrList[FA_MAX_BOARDS]; /* Array of a24 addresses for FADCs */ extern volatile struct fadc_struct *FAp[(FA_MAX_BOARDS+1)]; /* pointers to FADC memory map */ int iFlag; int Naddr; int AllSl; FADC250_CONF fa250[Nfa250+1]; board_ti ti_bd; #define SCAN_TI_SOFT(BKEYWORD,TI_SOFT) \ if(strcmp(keyword,(BKEYWORD)) == 0){ \ sscanf (str_tmp, "%*s %d %d %d %d", &ti_soft[0], &ti_soft[1], &ti_soft[2], &ti_soft[3]); \ printf(" SASCHA I AM HERE ======= %d \n",ti_soft[0]); \ for(jj=0; jj < 4; jj++)(TI_SOFT)[jj] = ti_soft[jj]; \ } #define SCAN_MSK \ args = sscanf (str_tmp, "%*s %d %d %d %d %d %d %d %d \ %d %d %d %d %d %d %d %d", \ &msk[ 0], &msk[ 1], &msk[ 2], &msk[ 3], \ &msk[ 4], &msk[ 5], &msk[ 6], &msk[ 7], \ &msk[ 8], &msk[ 9], &msk[10], &msk[11], \ &msk[12], &msk[13], &msk[14], &msk[15]) #define GET_READ_MSK \ SCAN_MSK; \ ui1 = 0; \ for(jj=0; jj 1)) \ { \ printf("\nReadConfigFile: Wrong mask bit value, %d\n\n",msk[jj]); return(-6); \ } \ if(strcmp(keyword,"FADC250_ADC_MASK") == 0) msk[jj] = ~(msk[jj])&0x1; \ ui1 |= (msk[jj]<=NCHAN)) \ { \ printf("\nReadConfigFile: Wrong channel number %d, %s\n",slot,str_tmp); \ return(-7); \ } \ for(jj=3; jj%s<\n" RESET,fname); return(-2); } printf("\nReadConfigFile: Using configuration file >%s<\n",fname); /* Parsing of config file */ while ((ch = getc(fd)) != EOF) { if ( ch == '#' || ch == ' ' || ch == '\t' ) { while (getc(fd) != '\n') {} } else if( ch == '\n' ) {} else { ungetc(ch,fd); fgets(str_tmp, STRLEN, fd); sscanf (str_tmp, "%s %s", keyword, ROC_name); /* Start parsing real config inputs */ if(strcmp(keyword,"CRATE") == 0) { if(strcmp(ROC_name,host) != 0) { printf(BOLDRED "\nReadConfigFile: Wrong crate name in config file, %s\n" RESET, str_tmp); return(-3); } printf(BOLDBLUE "\nReadConfigFile: conf_CRATE_name = %s host = %s\n" RESET, ROC_name, host); } else if(strcmp(keyword,"FADC250_ALLSLOTS") == 0) { AllSl = 1; gr++; for(jj=3; jj20) { printf("\nReadConfigFile: Wrong slot number %d, %s\n",slot,str_tmp); return(-4); } fa250[slot].group = gr; } } SCAN_B_XSETS("FADC250_F_REV", fa250[jj].f_rev) SCAN_B_XSETS("FADC250_B_REV", fa250[jj].b_rev) SCAN_B_XSETS("FADC250_ID", fa250[jj].b_ID) SCAN_B_SETS("FADC250_MODE", fa250[jj].mode) SCAN_B_SETS("FADC250_W_OFFSET", fa250[jj].winOffset) SCAN_B_SETS("FADC250_W_WIDTH", fa250[jj].winWidth) SCAN_B_SETS("FADC250_NSB", fa250[jj].nsb) SCAN_B_SETS("FADC250_NSA", fa250[jj].nsa) SCAN_B_SETS("FADC250_NPEAK", fa250[jj].npeak) SCAN_B_MSKS("FADC250_ADC_MASK", fa250[jj].chDisMask) SCAN_B_MSKS("FADC250_TRG_MASK", fa250[jj].trigMask) SCAN_TDP("FADC250_TET",fa250[jj].thr) SCAN_TDP_CH("FADC250_CH_TET",fa250[jj].thr) SCAN_TDP_ALLCH("FADC250_ALLCH_TET",fa250[jj].thr) SCAN_TDP("FADC250_DAC",fa250[jj].dac) SCAN_TDP_CH("FADC250_CH_DAC",fa250[jj].dac) SCAN_TDP_ALLCH("FADC250_ALLCH_DAC",fa250[jj].dac) SCAN_TDP("FADC250_PED",fa250[jj].ped) SCAN_TDP_CH("FADC250_CH_PED",fa250[jj].ped) SCAN_TDP_ALLCH("FADC250_ALLCH_PED",fa250[jj].ped) SCAN_TI_SOFT("TI_SOFT_TRIG",ti_bd.ti_soft_trig) } } fclose(fd); /* fill up fadcAddrList, to init only fadc250 from config file */ Naddr = 0; if(AllSl == 0) /* fill up only if FADC250_ALLSLOTS was not called */ for(jj=3; jj 0) { fadcAddrList[Naddr] = jj<<19; Naddr++; printf("\nReadConfigFile: ...fadcAddrList[%d] = 0x%08x group=%d\n", (Naddr-1),fadcAddrList[Naddr-1], fa250[jj].group); } gr--; return(gr); } void fadc250InitGlobals() { int ii, jj; nfadc = 0; for(jj=0; jj gg) { FA_SLOT = jj; printf("\nfadc250DownloadAll: FA_SLOT=%d fa250[%d].group=%d mode=%d nsb=%d \n", FA_SLOT,jj,fa250[jj].group, fa250[jj].mode, fa250[jj].nsb); faSetProcMode(FA_SLOT, fa250[jj].mode, fa250[jj].winOffset, fa250[jj].winWidth, fa250[jj].nsb, fa250[jj].nsa, fa250[jj].npeak, 0); faChanDisable( FA_SLOT, fa250[jj].chDisMask); for(ii=0; ii