Go to the source code of this file.
int vf48_AcqStart | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 467 of file vf48.c.
Referenced by vf48_Reset().
00468 { 00469 int csr; 00470 00471 mvme_set_am(mvme, MVME_AM_A24); 00472 mvme_set_dmode(mvme, MVME_DMODE_D32); 00473 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00474 csr |= VF48_CSR_START_ACQ; // start ACQ 00475 mvme_write_value(mvme, base+VF48_CSR_REG_RW, csr); 00476 mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00477 return VF48_SUCCESS; 00478 00479 #if 0 00480 status = mvme_read_value(mvme, base+VF48_NFRAME_R); 00481 if (status <= 0xFF) { 00482 mvme_write_value(mvme, base+VF48_SELECTIVE_SET_W, VF48_CSR_ACTIVE_ACQ); 00483 } 00484 return (status > 0xFF ? VF48_ERR_HW : VF48_SUCCESS); 00485 #endif 00486 }
int vf48_AcqStop | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 489 of file vf48.c.
Referenced by vf48_Reset().
00490 { 00491 int csr; 00492 00493 mvme_set_am(mvme, MVME_AM_A24); 00494 mvme_set_dmode(mvme, MVME_DMODE_D32); 00495 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00496 csr &= ~(VF48_CSR_START_ACQ); // stop ACQ 00497 mvme_write_value(mvme, base+VF48_CSR_REG_RW, csr); 00498 mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00499 return VF48_SUCCESS; 00500 00501 #if 0 00502 status = mvme_read_value(mvme, base+VF48_NFRAME_R); 00503 if (status <= 0xFF) { 00504 mvme_write_value(mvme, base+VF48_SELECTIVE_CLR_W, VF48_CSR_ACTIVE_ACQ); 00505 } 00506 return (status > 0xFF ? VF48_ERR_HW : VF48_SUCCESS); 00507 #endif 00508 }
int vf48_ActiveChMaskRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the channel enable mask for a given group.
Definition at line 726 of file vf48.c.
00727 { 00728 int val; 00729 00730 mvme_set_am(mvme, MVME_AM_A24); 00731 mvme_set_dmode(mvme, MVME_DMODE_D16); 00732 val = vf48_ParameterRead(mvme, base, grp, VF48_ACTIVE_CH_MASK); 00733 return val; 00734 }
int vf48_ActiveChMaskSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
DWORD | size | |||
) |
Enable the channel within the given group. By default all 8 channels are enabled.
Definition at line 713 of file vf48.c.
00714 { 00715 00716 mvme_set_am(mvme, MVME_AM_A24); 00717 mvme_set_dmode(mvme, MVME_DMODE_D16); 00718 vf48_ParameterWrite(mvme, base, grp, VF48_ACTIVE_CH_MASK, size); 00719 return grp; 00720 }
int vf48_ChSuppRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the channel suppression flag for a given group.
Definition at line 789 of file vf48.c.
00790 { 00791 int val; 00792 00793 mvme_set_am(mvme, MVME_AM_A24); 00794 mvme_set_dmode(mvme, MVME_DMODE_D16); 00795 val = 0x1 & vf48_ParameterRead(mvme, base, grp, VF48_MBIT2); 00796 return val; 00797 }
int vf48_ChSuppSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
DWORD | value | |||
) |
Enable the suppression of channel based on the hit threshold for a given group. Currently the MBIT2 contains the divisor parameter too. This function will overwrite this parameter. Apply this function prior the divisor.
Definition at line 772 of file vf48.c.
00773 { 00774 int mbit2; 00775 00776 mvme_set_am(mvme, MVME_AM_A24); 00777 mvme_set_dmode(mvme, MVME_DMODE_D16); 00778 mbit2 = vf48_ParameterRead(mvme, base, grp, VF48_MBIT2); 00779 mbit2 &= ~1; 00780 mbit2 |= value&0x1; 00781 vf48_ParameterWrite(mvme, base, grp, VF48_MBIT2, mbit2); 00782 return grp; 00783 }
int vf48_CsrRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 559 of file vf48.c.
00560 { 00561 int csr; 00562 00563 mvme_set_am(mvme, MVME_AM_A24); 00564 mvme_set_dmode(mvme, MVME_DMODE_D16); 00565 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00566 return csr; 00567 }
int vf48_DataRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
DWORD * | pdest, | |||
int * | nentry | |||
) |
vf48_DataRead Read N entries (32bit) from the VF48 data FIFO using the MBLT64 mode
mvme | vme structure | |
base | VF48 base address | |
pdest | Destination pointer |
Definition at line 184 of file vf48.c.
Referenced by vf48_EventRead64().
00185 { 00186 int status; 00187 00188 mvme_set_am( mvme, MVME_AM_A24); 00189 mvme_set_dmode( mvme, MVME_DMODE_D32); 00190 mvme_set_blt( mvme, MVME_BLT_MBLT64); 00191 //mvme_set_blt( mvme, MVME_BLT_BLT32); 00192 //mvme_set_blt( mvme, 0); 00193 00194 // Transfer in MBLT64 (8bytes), nentry is in 32bits(VF48) 00195 // *nentry * 8 / 2 00196 status = mvme_read(mvme, pdest, base+VF48_DATA_FIFO_R, *nentry<<2); 00197 if (status != MVME_SUCCESS) 00198 return 0; 00199 00200 return (*nentry); 00201 }
int vf48_DivisorRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the divisor parameter of the given group. All the groups should read the same value.
Definition at line 838 of file vf48.c.
Referenced by vf48_DivisorWrite().
00839 { 00840 int val; 00841 00842 mvme_set_am(mvme, MVME_AM_A24); 00843 mvme_set_dmode(mvme, MVME_DMODE_D16); 00844 val = vf48_ParameterRead(mvme, base, grp, VF48_MBIT2); 00845 val = (val >> 8) & 0xff; 00846 return val; 00847 }
int vf48_DivisorWrite | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
DWORD | value | |||
) |
write the sub-sampling divisor factor to all 6 groups. Value of 0 : base sampling Value of x>0 : base sampling / x
Definition at line 805 of file vf48.c.
00806 { 00807 int i, mbit2, grp; 00808 00809 assert(value > 0); 00810 assert(value < 256); 00811 00812 mvme_set_am(mvme, MVME_AM_A24); 00813 mvme_set_dmode(mvme, MVME_DMODE_D16); 00814 grp = vf48_GrpRead(mvme, base); 00815 for (i=0;i<6;i++) 00816 if (grp&(1<<i)) { 00817 mbit2 = vf48_ParameterRead(mvme, base, i, VF48_MBIT2); 00818 mbit2 &= ~0xFF00; 00819 mbit2 |= (value << 8); 00820 vf48_ParameterWrite(mvme, base, i, VF48_MBIT2, mbit2); 00821 } 00822 for (i=0;i<6;i++) 00823 if (grp&(1<<i)) { 00824 int rd = vf48_DivisorRead(mvme, base, i); 00825 if (rd != value) { 00826 printf("vf48_DivisorWrite: Divisor read back mismatch: module at 0x%x, group %d, wrote %d, read back %d\n", base, i, value, rd); 00827 abort(); 00828 } 00829 } 00830 return value; 00831 }
int vf48_EventRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
DWORD * | pdest, | |||
int * | nentry | |||
) |
vf48_EventRead Read one Event (in 32bit mode)
mvme | vme structure | |
base | VF48 base address | |
pdest | Pointer to destination | |
nentry | Number of DWORD to transfer |
Definition at line 128 of file vf48.c.
00129 { 00130 int timeout, nframe; 00131 DWORD hdata; 00132 00133 mvme_set_am( mvme, MVME_AM_A24); 00134 mvme_set_dmode(mvme, MVME_DMODE_D32); 00135 00136 *nentry = 0; 00137 nframe = mvme_read_value(mvme, base+VF48_NFRAME_R); 00138 // printf("Event Nframe : %d - 0x%x\n", nframe, nframe); 00139 00140 timeout=25000; // max number of 32bits per event 00141 if (nframe) { 00142 do { 00143 timeout--; 00144 hdata = mvme_read_value(mvme, base+VF48_DATA_FIFO_R); 00145 } while (!((hdata & 0xF0000000) == VF48_HEADER) && (timeout)); // skip up to the header 00146 00147 if (timeout == 0) { 00148 *nentry = 0; 00149 // printf("timeout on header data:0x%lx\n", hdata); 00150 return VF48_ERR_NODATA; 00151 } 00152 // channel = (hdata >> 24) & 0xF; 00153 // printf(">>>>>>>>>>>>>>> Channel : %d \n", channel); 00154 pdest[*nentry] = hdata; 00155 *nentry += 1; 00156 timeout=25000; // max number of 32bits per event 00157 // Copy until Trailer (max event size == timeout!) 00158 do { 00159 pdest[*nentry] = mvme_read_value(mvme, base+VF48_DATA_FIFO_R); 00160 // printf("pdest[%d]=0x%x\n", *nentry, pdest[*nentry]); 00161 timeout--; 00162 *nentry += 1; 00163 } while (!((pdest[*nentry-1] & 0xF0000000) == VF48_TRAILER) && timeout); // copy until trailer (included) 00164 if (timeout == 0) { 00165 printf("timeout on Trailer data:0x%x\n", pdest[*nentry-1]); 00166 printf("nentry:%d data:0x%x base:0x%x \n", *nentry, pdest[*nentry], base+VF48_DATA_FIFO_R); 00167 *nentry = 0; 00168 return VF48_ERROR; 00169 } 00170 nentry--; 00171 } 00172 00173 return (VF48_SUCCESS); 00174 }
int vf48_EventRead64 | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
DWORD * | pdest, | |||
int * | nentry | |||
) |
Definition at line 29 of file vf48.c.
00030 { 00031 int markerfound, j; 00032 DWORD lData[VF48_IDXMAX]; 00033 DWORD *phead; 00034 00035 int timeout; 00036 00037 mvme_set_am( mvme, MVME_AM_A24); 00038 mvme_set_dmode(mvme, MVME_DMODE_D32); 00039 00040 if (inbuf > VF48_IDXMAX) idx = 0; 00041 00042 if (idx == 0) { 00043 inbuf = vf48_NFrameRead(mvme, base); 00044 // max readout buffer (HW dependent) 00045 vf48_DataRead(mvme, base, lData, &inbuf); 00046 // printf("Data Read Idx=0 %d\n", inbuf); 00047 } 00048 00049 // Check if available event found in local buffer 00050 timeout = 16; 00051 markerfound = 0; 00052 while (timeout) { 00053 // Scan local buffer from current index to top for Header 00054 while ((idx < inbuf) && ((lData[idx] & 0xF0000000) != VF48_HEADER)) { 00055 idx++; 00056 } 00057 if (idx < inbuf) { 00058 // Header found, save head, flag header, cp header 00059 timeout = 0; // Reset to force exit on next test 00060 phead = pdest; // Save top of event for evt length 00061 markerfound = 1; // 00062 // printf("Head found idx %d\n", idx); 00063 *pdest++ = lData[idx]; 00064 lData[idx] = 0xffffffff; 00065 idx++; 00066 } else { 00067 // No header found, request VME data (start at idx = 0) 00068 timeout--; // Safe exit 00069 inbuf = vf48_NFrameRead(mvme, base); 00070 // max readout buffer (HW dependent) 00071 idx = 0; 00072 vf48_DataRead(mvme, base, lData, &inbuf); 00073 // printf("Data Read Header search %d (timeout %d)\n", inbuf, timeout); 00074 } 00075 } 00076 if ((timeout == 0) && !markerfound) { 00077 // printf("vf48_EventRead: Header Loop: Timeout Header not found\n"); 00078 idx = 0; // make sure we read VME on next call 00079 *nentry = 0; // Set returned event length 00080 return VF48_ERROR; 00081 } 00082 00083 // printf("Starting data copy\n"); 00084 timeout = 64; 00085 while(timeout) { 00086 timeout--; 00087 // copy rest of event until Trailer (nentry: valid# from last vme data) 00088 while ((idx < inbuf) && ((lData[idx] & 0xF0000000) != VF48_TRAILER)) { 00089 *pdest++ = lData[idx++]; 00090 } 00091 if ((lData[idx] & 0xF0000000) == VF48_TRAILER) { 00092 // Event complete return 00093 *pdest++ = lData[idx++]; // copy Trailer 00094 *nentry = pdest - phead; // Compute event length 00095 // printf("Event complete idx:%d last inbuf:%d evt len:%d\n", idx, inbuf, *nentry); 00096 return SUCCESS; 00097 } else { 00098 // No Trailer found, request VME data (start at idx = 0) 00099 // timeout--; // Safe exit 00100 j = 40000; 00101 while (j) { j--; } 00102 // usleep(1); 00103 inbuf = vf48_NFrameRead(mvme, base); 00104 vf48_DataRead(mvme, base, lData, &inbuf); 00105 idx = 0; 00106 // printf("Data Read Trailer search %d (timeout:%d)\n", inbuf, timeout); 00107 } 00108 if (timeout == 0) { 00109 printf("vf48_EventRead: Trailer Loop: Timeout Trailer not found\n"); 00110 idx = 0; // make sure we read VME on next call 00111 *nentry = 0; // Set returned event length 00112 return VF48_ERROR; 00113 } 00114 } 00115 printf(" coming out from here\n"); 00116 return VF48_ERROR; 00117 }
int vf48_ExtTrgClr | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Clear External Trigger enable
mvme | vme structure | |
base | VMEIO base address |
Definition at line 535 of file vf48.c.
00536 { 00537 int csr; 00538 00539 mvme_set_am(mvme, MVME_AM_A24); 00540 mvme_set_dmode(mvme, MVME_DMODE_D32); 00541 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00542 csr &= ~(VF48_CSR_EXT_TRIGGER); // clr 00543 mvme_write_value(mvme, base+VF48_CSR_REG_RW, csr); 00544 return VF48_SUCCESS; 00545 }
int vf48_ExtTrgSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Set External Trigger enable
mvme | vme structure | |
base | VF48 base address |
Definition at line 517 of file vf48.c.
Referenced by vf48_Setup().
00518 { 00519 int csr; 00520 mvme_set_am(mvme, MVME_AM_A24); 00521 mvme_set_dmode(mvme, MVME_DMODE_D32); 00522 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00523 csr |= VF48_CSR_EXT_TRIGGER; // Set 00524 mvme_write_value(mvme, base+VF48_CSR_REG_RW, csr); 00525 return VF48_SUCCESS; 00526 }
int vf48_FeFull | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 570 of file vf48.c.
00571 { 00572 int fefull; 00573 00574 mvme_set_am(mvme, MVME_AM_A24); 00575 mvme_set_dmode(mvme, MVME_DMODE_D32); 00576 fefull = mvme_read_value(mvme, base+VF48_CSR_REG_RW) & VF48_CSR_FE_FULL; 00577 return fefull; 00578 }
int vf48_FeNotEmpty | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 581 of file vf48.c.
00582 { 00583 int fenotempty; 00584 00585 mvme_set_am(mvme, MVME_AM_A24); 00586 mvme_set_dmode(mvme, MVME_DMODE_D32); 00587 fenotempty = mvme_read_value(mvme, base+VF48_CSR_REG_RW) & VF48_CSR_FE_NOTEMPTY; 00588 return fenotempty; 00589 }
int vf48_GrpEnable | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grpbit | |||
) |
Definition at line 592 of file vf48.c.
00593 { 00594 00595 mvme_set_am(mvme, MVME_AM_A24); 00596 mvme_set_dmode(mvme, MVME_DMODE_D16); 00597 grpbit &= 0x3F; 00598 mvme_write_value(mvme, base+VF48_GRP_REG_RW, grpbit); 00599 return VF48_SUCCESS; 00600 }
int vf48_GrpRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 603 of file vf48.c.
Referenced by vf48_DivisorWrite().
00604 { 00605 int grp; 00606 00607 mvme_set_am(mvme, MVME_AM_A24); 00608 mvme_set_dmode(mvme, MVME_DMODE_D16); 00609 grp = mvme_read_value(mvme, base+VF48_GRP_REG_RW); 00610 return grp; 00611 }
int vf48_HitThresholdRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the hit threshold for a given group.
Definition at line 698 of file vf48.c.
00699 { 00700 int val; 00701 00702 mvme_set_am(mvme, MVME_AM_A24); 00703 mvme_set_dmode(mvme, MVME_DMODE_D16); 00704 val = vf48_ParameterRead(mvme, base, grp, VF48_HIT_THRESHOLD); 00705 return val; 00706 }
int vf48_HitThresholdSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
DWORD | size | |||
) |
Set the hit threshold for the given group. the threshold value correspond to the difference of 2 sampling values separated by 2 points (s6-s3). It is compared to a positive value. If the slope of the signal is negative, the signal should be inverted. The hit threshold is used for channel suppression in case none of the described condition is satisfied.
Definition at line 685 of file vf48.c.
00686 { 00687 00688 mvme_set_am(mvme, MVME_AM_A24); 00689 mvme_set_dmode(mvme, MVME_DMODE_D16); 00690 vf48_ParameterWrite(mvme, base, grp, VF48_HIT_THRESHOLD, size); 00691 return grp; 00692 }
int vf48_isPresent | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
vf48_isPresent
mvme | vme structure | |
base | VF48 base address |
Definition at line 957 of file vf48.c.
Referenced by vf48_ParameterRead(), and vf48_Reset().
00958 { 00959 int missing = 0; 00960 00961 mvme_set_am(mvme, MVME_AM_A24); 00962 mvme_set_dmode(mvme, MVME_DMODE_D32); 00963 00964 missing |= (0xFFFFFFFF==mvme_read_value(mvme, base + 0x0)); 00965 missing |= (0xFFFFFFFF==mvme_read_value(mvme, base + 0x30)); 00966 00967 if (missing) return VF48_ERROR; 00968 00969 return VF48_SUCCESS; 00970 }
int vf48_NFrameRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 548 of file vf48.c.
Referenced by vf48_EventRead64().
00549 { 00550 int nframe; 00551 00552 mvme_set_am(mvme, MVME_AM_A24); 00553 mvme_set_dmode(mvme, MVME_DMODE_D32); 00554 nframe = mvme_read_value(mvme, base+VF48_NFRAME_R); 00555 return nframe; 00556 }
int vf48_ParameterRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
int | param | |||
) |
Read any Parameter for a given group. Each group (0..5) handles 8 consecutive input channels.
mvme | vme structure | |
base | VMEIO base address | |
grp | group number (0..5) |
Definition at line 286 of file vf48.c.
Referenced by vf48_ActiveChMaskRead(), vf48_ChSuppRead(), vf48_ChSuppSet(), vf48_DivisorRead(), vf48_DivisorWrite(), vf48_HitThresholdRead(), vf48_ParameterWrite(), vf48_RawDataSuppRead(), vf48_Reset(), vf48_SegmentSizeRead(), vf48_Setup(), vf48_Status(), and vf48_TrgThresholdRead().
00287 { 00288 int to, retry; 00289 int debug = 0; 00290 00291 if (vf48_isPresent(mvme, base) != VF48_SUCCESS) { 00292 printf("vf48_ParameterRead: There is no VF48 at VME A24 0x%x\n", base); 00293 return VF48_ERR_PARM; 00294 } 00295 00296 if (grp < 0 || grp >= 6) { 00297 printf("vf48_ParameterRead: Invalid grp %d\n", grp); 00298 return VF48_ERR_PARM; 00299 } 00300 00301 mvme_set_am(mvme, MVME_AM_A24); 00302 mvme_set_dmode(mvme, MVME_DMODE_D32); 00303 00304 for (retry=20; retry>0; retry--) { 00305 00306 int csr = 0; 00307 int data = 0; 00308 int wr; 00309 00310 if (debug) { 00311 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00312 printf("vf48_ParameterRead: CSR 0x%x, Reading grp %d, param %d, ID_RDY %d, DATA_RDY %d\n", csr, grp, param, csr & VF48_CSR_PARM_ID_RDY, csr & VF48_CSR_PARM_DATA_RDY); 00313 } 00314 00315 wr = VF48_PARMA_BIT_RD | param | grp<<VF48_GRP_OFFSET; 00316 00317 if (debug) 00318 printf("write id 0x%04x\n", wr); 00319 00320 mvme_write_value(mvme, base+VF48_PARAM_ID_W, wr); 00321 00322 // flush posted PCI writes 00323 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00324 00325 if (debug) { 00326 printf("vf48_ParameterRead: CSR 0x%x, Reading grp %d, param %d, ID_RDY %d, DATA_RDY %d\n", csr, grp, param, csr & VF48_CSR_PARM_ID_RDY, csr & VF48_CSR_PARM_DATA_RDY); 00327 00328 //if (!(csr & VF48_CSR_PARM_ID_RDY)) 00329 //exit(123); 00330 } 00331 00332 //mvme_write_value(mvme, base+VF48_PARAM_DATA_RW, 0xFFFFFFFF); 00333 mvme_write_value(mvme, base+VF48_PARAM_DATA_RW, 0xFFFFFFFF); 00334 00335 // flush posted PCI writes 00336 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00337 00338 if (debug) { 00339 printf("vf48_ParameterRead: CSR 0x%x, Reading grp %d, param %d, ID_RDY %d, DATA_RDY %d\n", csr, grp, param, csr & VF48_CSR_PARM_ID_RDY, csr & VF48_CSR_PARM_DATA_RDY); 00340 } 00341 00342 // wait for VF48_CSR_PARM_DATA_RDY 00343 for (to=10; to>0; to--) { 00344 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00345 if (debug) { 00346 printf("vf48_ParameterRead: CSR 0x%x, Waiting for 0x%x, TO %d\n", csr, VF48_CSR_PARM_DATA_RDY, to); 00347 data = mvme_read_value(mvme, base+VF48_PARAM_DATA_RW); 00348 printf("data register 0x%x\n", data); 00349 } 00350 if (csr & VF48_CSR_PARM_DATA_RDY) 00351 break; 00352 } 00353 00354 if (csr & VF48_CSR_CRC_ERROR) { 00355 if (1) 00356 printf("vf48_ParameterRead: CSR 0x%x, CRC error!\n", csr); 00357 //continue; 00358 } 00359 00360 if (! (csr & VF48_CSR_PARM_DATA_RDY)) { 00361 if (debug) 00362 printf("vf48_ParameterRead: Group %d, parameter %d, timeout waiting for VF48_CSR_PARAM_DATA_RDY, retry %d\n", grp, param, retry); 00363 continue; 00364 } 00365 00366 data = 0xFFFF & mvme_read_value(mvme, base+VF48_PARAM_DATA_RW); 00367 00368 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00369 00370 if (debug) 00371 printf("vf48_ParameterRead: CSR 0x%x, data 0x%x\n", csr, data); 00372 00373 return data; 00374 } 00375 00376 //fprintf(stderr, "vf48_ParameterRead: Group %d, parameter %d, too many retries reading vf48 parameter!\n", grp, param); 00377 return VF48_ERR_PARM; 00378 }
int vf48_ParameterWrite | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
int | param, | |||
int | value | |||
) |
Definition at line 204 of file vf48.c.
Referenced by vf48_ActiveChMaskSet(), vf48_ChSuppSet(), vf48_DivisorWrite(), vf48_HitThresholdSet(), vf48_RawDataSuppSet(), vf48_SegmentSizeSet(), vf48_Setup(), and vf48_TrgThresholdSet().
00205 { 00206 int retry; 00207 00208 if (grp < 0 || grp >= 6) { 00209 printf("vf48_ParameterWrite: Invalid grp %d\n", grp); 00210 return VF48_ERR_PARM; 00211 } 00212 00213 switch (param) { 00214 case VF48_SEGMENT_SIZE: 00215 if (value > 1023) { 00216 value = 1023; 00217 printf("vf48_ParameterWrite: Segment size troncated to 1023\n"); 00218 } 00219 break; 00220 case VF48_PRE_TRIGGER: 00221 if (value > 127) { 00222 value = 100; 00223 printf("vf48_ParameterWrite: Pre trigger troncated to 100\n"); 00224 } 00225 break; 00226 case VF48_LATENCY: 00227 if (value > 127) { 00228 value = 127; 00229 printf("vf48_ParameterWrite: Latency troncated to 127\n"); 00230 } 00231 break; 00232 }; 00233 00234 mvme_set_am( mvme, MVME_AM_A24); 00235 mvme_set_dmode(mvme, MVME_DMODE_D32); 00236 00237 if (0) { 00238 int csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00239 printf("Writing grp %d, param %d, ID_RDY %d, DATA_RDY %d\n", grp, param, csr & VF48_CSR_PARM_ID_RDY, csr & VF48_CSR_PARM_DATA_RDY); 00240 } 00241 00242 for (retry=20; retry>0; retry--) { 00243 int wr; 00244 int rd; 00245 00246 wr = param | grp<<VF48_GRP_OFFSET; 00247 mvme_write_value(mvme, base+VF48_PARAM_ID_W, wr); 00248 00249 // flush posted PCI writes 00250 mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00251 00252 mvme_write_value(mvme, base+VF48_PARAM_DATA_RW, value); 00253 00254 // flush posted PCI writes 00255 mvme_read_value(mvme, base+VF48_CSR_REG_RW); 00256 00257 rd = vf48_ParameterRead(mvme, base, grp, param); 00258 00259 if (rd == VF48_ERR_PARM) { 00260 printf("vf48_ParameterWrite: Module at 0x%x, Group %d, parameter %d: Error %d during parameter read-back\n", base, grp, param, rd); 00261 return VF48_ERR_PARM; 00262 } 00263 00264 //printf("Group %d, param %d, write %d, read %d\n", grp, param, value, rd); 00265 00266 if (rd == value) { 00267 return VF48_SUCCESS; 00268 } 00269 00270 printf("vf48_ParameterWrite: Module at 0x%x, Group %d, parameter %d: data mismatch error: wrote 0x%08x, read 0x%08x\n", base, grp, param, value, rd); 00271 } 00272 00273 fprintf(stderr, "vf48_ParameterWrite: Group %d, parameter %d, too many retries writing VF48 parameter!\n", grp, param); 00274 return VF48_ERR_PARM; 00275 }
int vf48_RawDataSuppRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the flag of the raw data suppression of a given channel.
Definition at line 754 of file vf48.c.
00755 { 00756 int val; 00757 00758 mvme_set_am(mvme, MVME_AM_A24); 00759 mvme_set_dmode(mvme, MVME_DMODE_D16); 00760 val = vf48_ParameterRead(mvme, base, grp, VF48_MBIT1); 00761 return val; 00762 }
int vf48_RawDataSuppSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
DWORD | size | |||
) |
Suppress the transmission of the raw data (wave form) of all the channels of a given group. Feature Q,T are always present expect if channel masked.
Definition at line 741 of file vf48.c.
00742 { 00743 00744 mvme_set_am(mvme, MVME_AM_A24); 00745 mvme_set_dmode(mvme, MVME_DMODE_D16); 00746 vf48_ParameterWrite(mvme, base, grp, VF48_MBIT1, size); 00747 return grp; 00748 }
int vf48_Reset | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 381 of file vf48.c.
00382 { 00383 int i, v, csr, good; 00384 00385 mvme_set_am(mvme, MVME_AM_A24); 00386 mvme_set_dmode(mvme, MVME_DMODE_D16); 00387 00388 if (1) 00389 printf("vf48_Reset: CSR 0x%x\n", mvme_read_value(mvme, base+VF48_CSR_REG_RW)); 00390 mvme_write_value(mvme, base+VF48_GLOBAL_RESET_W, 0); 00391 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00392 00393 if (1) 00394 printf("vf48_Reset: CSR 0x%x\n", csr); 00395 00396 #if 0 00397 if (!(csr & VF48_CSR_PARM_ID_RDY) || !(csr & VF48_CSR_PARM_DATA_RDY)) { 00398 /* frontend realtime signals did not reset correctly, 00399 * reset them by toggling the "col_run" realtime signal */ 00400 00401 vf48_AcqStart(mvme, base); 00402 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00403 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00404 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00405 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00406 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00407 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00408 vf48_AcqStop(mvme, base); 00409 00410 csr = mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00411 00412 if (1) 00413 printf("vf48_Reset: CSR 0x%x\n", csr); 00414 } 00415 #endif 00416 00417 mvme_write_value(mvme, base+VF48_TEST_REG_RW, 0x00000000); 00418 v = mvme_read_value(mvme, base+VF48_TEST_REG_RW); 00419 if (v != 0) 00420 printf("vf48_Reset: Test register data mismatch: read 0x%08x, expected 0\n", v); 00421 00422 mvme_write_value(mvme, base+VF48_TEST_REG_RW, 0x0000FFFF); 00423 v = mvme_read_value(mvme, base+VF48_TEST_REG_RW); 00424 if (v != 0x0000FFFF) 00425 printf("vf48_Reset: Test register data mismatch: read 0x%08x, expected 0x0000FFFF\n", v); 00426 00427 if (vf48_isPresent(mvme, base) != VF48_SUCCESS) { 00428 printf("There is no VF48 at VME A24 0x%x\n", base); 00429 return VF48_ERR_HW; 00430 } 00431 00432 printf("vf48_Reset: Module 0x%06x: Firmware revision: collector: 0x%x, frontend:", base, mvme_read_value(mvme, base+VF48_FIRMWARE_R)); 00433 00434 good = 1; 00435 for (i=0; i<6; i++) { 00436 v = vf48_ParameterRead(mvme, base, i, VF48_FIRMWARE_ID); 00437 printf(" 0x%x", v); 00438 if (v < 0) 00439 good = 0; 00440 } 00441 printf("\n"); 00442 00443 return VF48_SUCCESS; 00444 }
int vf48_ResetCollector | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 447 of file vf48.c.
00448 { 00449 mvme_set_am(mvme, MVME_AM_A24); 00450 mvme_set_dmode(mvme, MVME_DMODE_D16); 00451 mvme_write_value(mvme, base+VF48_SOFTWARE_RESET_W, 0); 00452 mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00453 return VF48_SUCCESS; 00454 }
int vf48_ResetFrontends | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | groupMask | |||
) |
Definition at line 457 of file vf48.c.
00458 { 00459 mvme_set_am(mvme, MVME_AM_A24); 00460 mvme_set_dmode(mvme, MVME_DMODE_D16); 00461 mvme_write_value(mvme, base+VF48_LVDSSR_W, groupMask); 00462 mvme_read_value(mvme, base+VF48_CSR_REG_RW); // flush posted PCI writes 00463 return VF48_SUCCESS; 00464 }
int vf48_SegmentSizeRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the segment size from a given group. This value should be the same for all the groups.
Definition at line 636 of file vf48.c.
00637 { 00638 int val; 00639 00640 mvme_set_am(mvme, MVME_AM_A24); 00641 mvme_set_dmode(mvme, MVME_DMODE_D16); 00642 val = vf48_ParameterRead(mvme, base, grp, VF48_SEGMENT_SIZE); 00643 return val; 00644 }
int vf48_SegmentSizeSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
DWORD | size | |||
) |
Set the segment size for all 6 groups
Definition at line 617 of file vf48.c.
00618 { 00619 int i; 00620 00621 assert(size>0); 00622 assert(size<=1000); 00623 00624 mvme_set_am(mvme, MVME_AM_A24); 00625 mvme_set_dmode(mvme, MVME_DMODE_D16); 00626 for (i=0;i<6;i++) 00627 vf48_ParameterWrite(mvme, base, i, VF48_SEGMENT_SIZE, size); 00628 return 1; 00629 }
int vf48_Setup | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | mode | |||
) |
Definition at line 863 of file vf48.c.
00864 { 00865 int i; 00866 00867 mvme_set_am(mvme, MVME_AM_A24); 00868 mvme_set_dmode(mvme, MVME_DMODE_D16); 00869 00870 switch (mode) { 00871 case 0x1: 00872 printf("Default setting after power up (mode:%d)\n", mode); 00873 printf("\n"); 00874 break; 00875 case 0x2: 00876 printf("External Trigger (mode:%d)\n", mode); 00877 vf48_ExtTrgSet(mvme, base); 00878 break; 00879 case 0x3: 00880 printf("External Trigger, Seg Size=16 (mode:%d)\n", mode); 00881 vf48_ExtTrgSet(mvme, base); 00882 for (i=0;i<6;i++) 00883 vf48_ParameterWrite(mvme, base, i, VF48_SEGMENT_SIZE, 16); 00884 for (i=0;i<6;i++) 00885 printf("SegSize grp %i:%d\n", i, vf48_ParameterRead(mvme, base, i, VF48_SEGMENT_SIZE)); 00886 break; 00887 default: 00888 printf("Unknown setup mode\n"); 00889 return -1; 00890 } 00891 return 0; 00892 00893 }
int vf48_Status | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
vf48_Status
mvme | vme structure | |
base | VF48 base address |
Definition at line 901 of file vf48.c.
00902 { 00903 char *parname[] = { 00904 "", 00905 "PED", 00906 "Hit Det Threshold", 00907 "Clip Delay", 00908 "PreTrigger", 00909 "Segment Size", 00910 "K", 00911 "L", 00912 "M", 00913 "Channel enable", 00914 "Mbits1", 00915 "Mbits2", 00916 "Latency", 00917 "Firmware ID", 00918 "Attenuator", 00919 "Trigger Threshold" 00920 }; 00921 00922 int i, j; 00923 00924 mvme_set_am(mvme, MVME_AM_A24); 00925 mvme_set_dmode(mvme, MVME_DMODE_D32); 00926 00927 printf("VF48 at VME A24 0x%06x, status:\n", base); 00928 printf(" CSR: 0x%08x\n", mvme_read_value(mvme, base + 0x0)); 00929 printf(" Test reg: 0x%08x\n", mvme_read_value(mvme, base + 0x20)); 00930 printf(" Firmware: 0x%08x\n", mvme_read_value(mvme, base + 0x30)); 00931 printf(" Group enable: 0x%08x\n", mvme_read_value(mvme, base + 0x90)); 00932 printf(" NbrFrames: 0x%08x\n", mvme_read_value(mvme, base + 0xA0)); 00933 00934 if (mvme_read_value(mvme, base + 0x0) & 1) { 00935 printf("Module is in running mode: cannot read parameters\n"); 00936 } else { 00937 printf("Parameters:\n"); 00938 for (i=1; i<16; i++) { 00939 printf(" par%02d (%-20s): ", i, parname[i]); 00940 for (j=0; j<6; j++) { 00941 int v = vf48_ParameterRead(mvme, base, j, i); 00942 printf(" %6d (0x%04x) ", v, v); 00943 } 00944 printf("\n"); 00945 } 00946 } 00947 00948 return VF48_SUCCESS; 00949 }
int vf48_TrgThresholdRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp | |||
) |
Read the trigger threshold for a given group.
Definition at line 666 of file vf48.c.
00667 { 00668 int val; 00669 00670 mvme_set_am(mvme, MVME_AM_A24); 00671 mvme_set_dmode(mvme, MVME_DMODE_D16); 00672 val = vf48_ParameterRead(mvme, base, grp, VF48_TRIG_THRESHOLD); 00673 return val; 00674 }
int vf48_TrgThresholdSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | grp, | |||
DWORD | size | |||
) |
Set the trigger threshold for the given group. the threshold value correspond to the difference of 2 sampling values separated by 2 points (s6-s3). It is compared to a positive value. If the slope of the signal is negative, the signal should be inverted.
Definition at line 653 of file vf48.c.
00654 { 00655 00656 mvme_set_am(mvme, MVME_AM_A24); 00657 mvme_set_dmode(mvme, MVME_DMODE_D16); 00658 vf48_ParameterWrite(mvme, base, grp, VF48_TRIG_THRESHOLD, size); 00659 return grp; 00660 }
int vf48_Trigger | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Definition at line 850 of file vf48.c.
00851 { 00852 int r; 00853 //printf("Write 0x%x\n", base + VF48_SOFT_TRIG_W); 00854 mvme_set_am(mvme, MVME_AM_A24); 00855 mvme_set_dmode(mvme, MVME_DMODE_D16); 00856 mvme_write_value(mvme, base + VF48_SOFT_TRIG_W, 0); 00857 r = mvme_read_value(mvme, base + VF48_CSR_REG_RW); // flush posted PCI writes 00858 //printf("Readback: CSR 0x%x\n", r); 00859 return VF48_SUCCESS; 00860 }
int idx = 0 [static] |
vf48_EventRead64 Read one Event through the local buffer. MBLT64 is used for aquiring a buffer, the event is then extracted from this buffer until event incomplete which in this case a DMA is requested again.
mvme | vme structure | |
base | VF48 base address | |
pdest | Pointer to destination | |
nentry | Number of DWORD to transfer |
Definition at line 28 of file vf48.c.
Referenced by bm_check_buffers(), bm_close_buffer(), bm_empty_buffers(), bm_request_event(), cm_set_client_info(), cm_set_watchdog_params(), cm_transition1(), db_close_database(), el_submit(), initialize_equipment(), register_equipment(), and vf48_EventRead64().
int inbuf [static] |