#include extern unsigned int fa125AddrList[FA125_MAX_BOARDS]; int fa125_download(){ int slot, ichan; int stat; int nfadc125 = 0; int debug_init = 0; for(slot = 3; slot < 21; slot++){ if(fa125[slot].group == 1){ fa125AddrList[nfadc125] = (slot<<19); nfadc125++; } } // fa125AddrList[0] = (3<<19); // fa125AddrList[1] = (4<<19); // nfadc125 = 2; printf(" NUMBER OF FADC125 boards found in config file = %d \n",nfadc125); int iFlag = 0; iFlag = (1<<17); /* use fa125AddrList */ /* bits 2-1: defines Trigger source (0) 0 0 VXS (P0) (1) 0 1 Internal Timer (2) 1 0 Internal Multiplicity Sum (3) 1 1 P2 Connector (Backplane) bit 3: NOT USED WITH THIS FIRMWARE VERSION bits 5-4: defines Clock Source (0) 0 0 P2 Connector (Backplane) (1) 0 1 VXS (P0) (2) 1 0 Internal 125MHz Clock */ iFlag |= (0<<1); /* Trigger Source */ iFlag |= (1<<4); /* Clock Source */ stat = fa125Init(0,0,nfadc125,iFlag); if (stat != OK) { printf(BOLDRED "ERROR: fa125Init failed \n" RESET); return -1; } NFADC = nfadc125; /* Redefine our NFADC with what was found from the driver */ printf(" NUMBER OF FADC125 initialized %d \n",NFADC); for(slot = 0; slot < NFADC; slot++){ FA_SLOT = fa125Slot(slot); fa125PowerOn(FA_SLOT); printf(" DAC = "); for(ichan = 0; ichan < 72; ichan++) { fa125SetOffset(FA_SLOT,ichan,0x8000); printf(" %d ",fa125[FA_SLOT].dac[ichan]); // fa125SetOffset(FA_SLOT, ichan, fa125[FA_SLOT].dac[ichan]); } printf(" \n "); printf(" SLOT = %d \n",FA_SLOT); fa125SetProcMode(FA_SLOT, fa125[FA_SLOT].mode, fa125[FA_SLOT].winOffset, fa125[FA_SLOT].winWidth, fa125[FA_SLOT].nsb, fa125[FA_SLOT].nsa, fa125[FA_SLOT].npeak); if(debug_init){ printf(" SLOT = %d \n",FA_SLOT); printf(" mode = %d \n",fa125[FA_SLOT].mode); printf(" winOffset = %d \n",fa125[FA_SLOT].winOffset); printf(" winWidth = %d \n",fa125[FA_SLOT].winWidth); printf(" nsb = %d \n",fa125[FA_SLOT].nsb); printf(" nsa = %d \n",fa125[FA_SLOT].nsa); printf(" npeak = %d \n",fa125[FA_SLOT].npeak); } fa125Status(FA_SLOT, 1); } /*************************************** * SD SETUP ***************************************/ stat = sdInit(); /* Initialize the SD library */ printf("SD fa125ScanMask() = 0x%x",fa125ScanMask()); if(stat == 0){ sdSetActiveVmeSlots( fa125ScanMask()); // sdSetActiveVmeSlots(fadcSlotMask); /* Use the fadcSlotMask to configure the SD */ } sdStatus(); } int fa125_prestart(){ int stat; int islot; fa125ResetToken(0); /* FADC Perform some resets, status */ for(islot = 0; islot < NFADC; islot++) { FA_SLOT = fa125Slot(islot); // faSetClkSource(FA_SLOT,2); // faClear(FA_SLOT); faResetToken(FA_SLOT); faResetTriggerCount(FA_SLOT); fa125Reset(FA_SLOT, 0); fa125Enable(FA_SLOT); fa125Status(FA_SLOT,1); } }