Go to the source code of this file.
Functions | |
int | v1190_EventRead (DWORD *pbase, DWORD *pdest, int *nentry) |
int | v1190_DataRead (DWORD *pbase, uint32_t *dest, int maxwords) |
int | v1190_GeoWrite (WORD *pbase, int geo) |
void | v1190_SoftReset (uint16_t *pbase) |
void | v1190_SoftClear (uint16_t *pbase) |
void | v1190_SoftTrigger (uint16_t *pbase) |
int | v1190_DataReady (uint16_t *pbase) |
int | v1190_EvtStored (uint16_t *pbase) |
int | v1190_EvtCounter (uint16_t *pbase) |
int | v1190B_TdcIdList (uint16_t *pbase) |
int | v1190B_ResolutionRead (uint16_t *pbase) |
int | v1190B_AcqModeRead (uint16_t *pbase) |
int | v1190B_TriggerMatchingSet (uint16_t *pbase) |
int | v1190B_ContinuousSet (uint16_t *pbase) |
void | v1190_SetEdgeDetection (uint16_t *pbase, int enableLeading, int enableTrailing) |
int | v1190_MicroWrite (uint16_t *pbase, uint16_t data) |
int | v1190_MicroRead (const uint16_t *pbase) |
int | v1190_MicroFlush (const uint16_t *pbase) |
int | v1190_Setup (uint16_t *pbase, int mode) |
int | v1190_Status (uint16_t *pbase) |
int | udelay (int usec) |
int udelay | ( | int | usec | ) |
Definition at line 402 of file caenv1190B.c.
Referenced by v1190_MicroRead(), and v1190_MicroWrite().
00403 { 00404 int i, j, k = 0; 00405 for (i=0; i<133; i++) 00406 for (j=0; j<usec; j++) 00407 k += (k+1)*j*k*(j+1); 00408 return k; 00409 }
int v1190_DataRead | ( | DWORD * | pbase, | |
uint32_t * | dest, | |||
int | maxwords | |||
) |
Definition at line 64 of file caenv1190B.c.
00065 { 00066 int i; 00067 for (i=0; i<maxwords; i++) 00068 { 00069 if (!v1190_DataReady((uint16_t *)pbase)) 00070 break; 00071 *dest++ = *pbase; 00072 } 00073 return i; 00074 }
int v1190_DataReady | ( | uint16_t * | pbase | ) |
Definition at line 102 of file caenv1190B.c.
Referenced by v1190_DataRead(), and v1190_EventRead().
00103 { 00104 return (pbase[V1190_SR_RO] & V1190_DATA_READY); 00105 }
Definition at line 21 of file caenv1190B.c.
00022 { 00023 uint32_t hdata; 00024 00025 *nentry = 0; 00026 if (v1190_DataReady((WORD *)pbase)) { 00027 do { 00028 hdata = *pbase; 00029 } while (!(hdata & 0x40000000)); 00030 pdest[*nentry] = hdata; 00031 *nentry += 1; 00032 do { 00033 pdest[*nentry] = *pbase; 00034 *nentry += 1; 00035 } while (!(pdest[*nentry-1] & 0xc0000000)); 00036 00037 nentry--; 00038 } 00039 return *nentry; 00040 00041 /* 00042 header = *pbase & 0xFF000000; 00043 00044 switch (header) { 00045 case 0x40000000: // Global Header 00046 break; 00047 case 0x00000000: // TDC Header 00048 break; 00049 case 0x10000000: // Data 00050 break; 00051 case 0x20000000: // Error 00052 break; 00053 case 0x80000000: // Trailer 00054 break; 00055 case 0xc0000000: // Filler 00056 break; 00057 } 00058 00059 return *nentry; 00060 */ 00061 }
int v1190_EvtCounter | ( | uint16_t * | pbase | ) |
int v1190_EvtStored | ( | uint16_t * | pbase | ) |
Definition at line 108 of file caenv1190B.c.
00109 { 00110 return (pbase[V1190_EVT_STORED_RO]); 00111 }
int v1190_GeoWrite | ( | WORD * | pbase, | |
int | geo | |||
) |
Definition at line 77 of file caenv1190B.c.
00078 { 00079 pbase[V1190_GEO_REG_RW] = (geo & 0x1F); 00080 return (int) (pbase[V1190_GEO_REG_RW] & 0x1F); 00081 }
int v1190_MicroFlush | ( | const uint16_t * | pbase | ) |
Definition at line 247 of file caenv1190B.c.
Referenced by v1190_SetEdgeDetection().
00248 { 00249 int count = 0; 00250 while (1) 00251 { 00252 int data = v1190_MicroRead(pbase); 00253 printf("microData[%d]: 0x%04x\n",count,data); 00254 if (data < 0) 00255 break; 00256 count++; 00257 } 00258 return count; 00259 }
int v1190_MicroRead | ( | const uint16_t * | pbase | ) |
Definition at line 229 of file caenv1190B.c.
Referenced by v1190_AcqModeRead(), v1190_MicroFlush(), v1190_ResolutionRead(), v1190_Status(), v1190_TdcIdList(), v1190B_AcqModeRead(), v1190B_ResolutionRead(), and v1190B_TdcIdList().
00230 { 00231 int i; 00232 int reg=-1; 00233 00234 for (i=100; i>0; i--) { 00235 uint16_t microHS = pbase[V1190_MICRO_HAND_RO]; 00236 if (microHS & V1190_MICRO_RD_OK) { 00237 reg = pbase[V1190_MICRO_RW]; 00238 // printf("i:%d microHS:%d %x\n", i, microHS, reg); 00239 return (reg); 00240 } 00241 udelay(500); 00242 }; 00243 return -1; 00244 }
int v1190_MicroWrite | ( | uint16_t * | pbase, | |
uint16_t | data | |||
) |
Definition at line 211 of file caenv1190B.c.
Referenced by v1190_AcqModeRead(), v1190_ContinuousSet(), v1190_LEResolutionSet(), v1190_OffsetSet(), v1190_ResolutionRead(), v1190_SetEdgeDetection(), v1190_Setup(), v1190_Status(), v1190_TdcIdList(), v1190_TriggerMatchingSet(), v1190_WidthSet(), v1190B_AcqModeRead(), v1190B_ContinuousSet(), v1190B_ResolutionRead(), v1190B_TdcIdList(), and v1190B_TriggerMatchingSet().
00212 { 00213 int i; 00214 for (i=0; i<1000; i++) 00215 { 00216 uint16_t microHS = pbase[V1190_MICRO_HAND_RO]; 00217 if (microHS & V1190_MICRO_WR_OK) { 00218 pbase[V1190_MICRO_RW] = data; 00219 return 0; 00220 } 00221 udelay(500); 00222 } 00223 00224 printf("v1190_MicroWrite: Micro not ready for writing!\n"); 00225 return -1; 00226 }
void v1190_SetEdgeDetection | ( | uint16_t * | pbase, | |
int | enableLeading, | |||
int | enableTrailing | |||
) |
Definition at line 195 of file caenv1190B.c.
00196 { 00197 int value = 0; 00198 00199 if (enableLeading) 00200 value |= 2; 00201 00202 if (enableTrailing) 00203 value |= 1; 00204 00205 v1190_MicroFlush(pbase); 00206 v1190_MicroWrite(pbase, 0x2200); 00207 v1190_MicroWrite(pbase, value); 00208 }
int v1190_Setup | ( | uint16_t * | pbase, | |
int | mode | |||
) |
Definition at line 262 of file caenv1190B.c.
00263 { 00264 uint16_t value; 00265 int status = -1; 00266 00267 // v1190_MicroFlush(pbase); 00268 switch (mode) { 00269 case 0x1: 00270 printf("Trigger Matching Setup (mode:%d)\n", mode); 00271 printf("Default setting + Width : 800ns, Offset : -400ns\n"); 00272 printf("Time subtract, Leading Edge only\n"); 00273 status = v1190_MicroWrite(pbase, 0x0000); 00274 if (status < 0) 00275 return status; 00276 #if 0 00277 value = v1190_MicroWrite(pbase, 0x1000); // width 00278 value = v1190_MicroWrite(pbase, 0x60); // Width : 800ns 00279 value = v1190_MicroWrite(pbase, 0x1100); // offset 00280 value = v1190_MicroWrite(pbase, 0xfe8); // offset: -400ns 00281 value = v1190_MicroWrite(pbase, 0x1500); // subtraction flag 00282 value = v1190_MicroWrite(pbase, 0x2100); // leading edge detection 00283 #endif 00284 break; 00285 case 0x2: 00286 value = v1190_MicroWrite(pbase, 0x0500); // default configuration 00287 break; 00288 default: 00289 printf("Unknown setup mode\n"); 00290 return -1; 00291 } 00292 v1190_Status(pbase); 00293 return 0; 00294 }
void v1190_SoftClear | ( | uint16_t * | pbase | ) |
void v1190_SoftReset | ( | uint16_t * | pbase | ) |
void v1190_SoftTrigger | ( | uint16_t * | pbase | ) |
int v1190_Status | ( | uint16_t * | pbase | ) |
Definition at line 297 of file caenv1190B.c.
Referenced by v1190_Setup().
00298 { 00299 uint16_t i, code, pair=0; 00300 uint32_t value; 00301 00302 printf("\nAcquisition mode:\n"); 00303 value = v1190_MicroWrite(pbase, 0x0200); 00304 value = v1190_MicroRead(pbase); 00305 printf(" mode: 0x%02x\n", value); 00306 00307 code = 0x1600; 00308 printf("\nTrigger Section [code:0x%04x]:\n", code); 00309 if ((value = v1190_MicroWrite(pbase, code)) < 0) 00310 return -value; 00311 value = v1190_MicroRead(pbase); 00312 printf(" Match Window width : 0x%04x\n", value); 00313 value = v1190_MicroRead(pbase); 00314 printf(" Window offset : 0x%04x\n", value); 00315 value = v1190_MicroRead(pbase); 00316 printf(" Extra Search Window Width: 0x%04x\n", value); 00317 value = v1190_MicroRead(pbase); 00318 printf(" Reject Margin : 0x%04x\n", value); 00319 value = v1190_MicroRead(pbase); 00320 printf(" Trigger Time subtration : %s\n",(value & 0x1) ? "y" : "n"); 00321 00322 printf("\nEdge Detection & Resolution Section:\n"); 00323 code = 0x2300; 00324 value = v1190_MicroWrite(pbase, code); 00325 pair = value = v1190_MicroRead(pbase); 00326 printf(" Edge Detection (1:T/2:L/3:TL) : 0x%02x\n", (value&0x3)); 00327 code = 0x2600; 00328 value = v1190_MicroWrite(pbase, code); 00329 value = v1190_MicroRead(pbase); 00330 if (pair==0x3) { 00331 value = v1190_MicroRead(pbase); 00332 printf(" Leading Edge Resolution (see table) : 0x%02x\n", (value&0x3)); 00333 printf(" Pulse Width Resolution (see table) : 0x%02x\n", ((value>>8)&0xF)); 00334 } else { 00335 printf(" Resolution [ps] (0:800/1:200/2:100) : 0x%02x\n", (value&0x3)); 00336 } 00337 code = 0x2900; 00338 value = v1190_MicroWrite(pbase, code); 00339 value = v1190_MicroRead(pbase); 00340 printf(" Dead Time between hit [~ns](5/10/30/100): 0x%02x\n", (value&0x3)); 00341 00342 printf("\nReadout Section:\n"); 00343 code = 0x3200; 00344 value = v1190_MicroWrite(pbase, code); 00345 value = v1190_MicroRead(pbase); 00346 printf(" Header/Trailer : %s\n",(value & 0x1) ? "y" : "n"); 00347 code = 0x3400; 00348 value = v1190_MicroWrite(pbase, code); 00349 value = v1190_MicroRead(pbase); 00350 printf(" Max #hits per event 2^n-1 (>128:no limit) : %d\n", value&0xF); 00351 code = 0x3a00; 00352 value = v1190_MicroWrite(pbase, code); 00353 value = v1190_MicroRead(pbase); 00354 printf(" Internal TDC error type (see doc) : 0x%04x\n", (value&0x7FF)); 00355 code = 0x3c00; 00356 value = v1190_MicroWrite(pbase, code); 00357 value = v1190_MicroRead(pbase); 00358 printf(" Effective size of readout Fifo 2^n-1 : 0x%04x\n", (value&0xF)); 00359 00360 printf("\nChannel Enable Section:\n"); 00361 code = 0x4500; 00362 value = v1190_MicroWrite(pbase, code); 00363 value = v1190_MicroRead(pbase); 00364 printf(" Read Enable Pattern [ 0..15 ] : 0x%04x\n", value); 00365 value = v1190_MicroRead(pbase); 00366 printf(" Read Enable Pattern [ 16..31 ] : 0x%04x\n", value); 00367 value = v1190_MicroRead(pbase); 00368 printf(" Read Enable Pattern [ 32..47 ] : 0x%04x\n", value); 00369 value = v1190_MicroRead(pbase); 00370 printf(" Read Enable Pattern [ 48..63 ] : 0x%04x\n", value); 00371 code = 0x4700; 00372 value = v1190_MicroWrite(pbase, code); 00373 value = v1190_MicroRead(pbase); 00374 value = (v1190_MicroRead(pbase)<<16) | value; 00375 printf(" Read Enable Pattern 32 (0) : 0x%08x\n", value); 00376 code = 0x4701; 00377 value = v1190_MicroWrite(pbase, code); 00378 value = v1190_MicroRead(pbase); 00379 value = (v1190_MicroRead(pbase)<<16) | value; 00380 printf(" Read Enable Pattern 32 (1) : 0x%08x\n", value); 00381 printf("\nAdjust Section:\n"); 00382 code = 0x5100; 00383 value = v1190_MicroWrite(pbase, code); 00384 value = v1190_MicroRead(pbase); 00385 printf(" Coarse Counter Offset: 0x%04x\n", (value&0x7FF)); 00386 value = v1190_MicroRead(pbase); 00387 printf(" Fine Counter Offset: 0x%04x\n", (value&0x1F)); 00388 printf("\nMiscellaneous Section:\n"); 00389 for (i=0; i<2 ; i++) { 00390 code = 0x6000 | (i & 0x0F); 00391 value = v1190_MicroWrite(pbase, code); 00392 value = v1190_MicroRead(pbase); 00393 value = (v1190_MicroRead(pbase) << 16) | value; 00394 printf(" TDC ID(%i) 0x%08x [code:0x%04x]\n", i, value, code); 00395 } 00396 return 0; 00397 }
int v1190B_AcqModeRead | ( | uint16_t * | pbase | ) |
Definition at line 153 of file caenv1190B.c.
00154 { 00155 uint16_t code; 00156 uint32_t value; 00157 00158 // v1190_MicroFlush(pbase); 00159 code = V1190_ACQ_MODE_RO; 00160 value = v1190_MicroWrite(pbase, code); 00161 value = v1190_MicroRead(pbase); 00162 // printf("Received :code: 0x%04x 0x%08x\n", code, value); 00163 return 1; 00164 }
int v1190B_ContinuousSet | ( | uint16_t * | pbase | ) |
Definition at line 181 of file caenv1190B.c.
00182 { 00183 uint16_t code; 00184 uint32_t value; 00185 00186 // v1190_MicroFlush(pbase); 00187 code = V1190_CONTINUOUS_WO; 00188 value = v1190_MicroWrite(pbase, code); 00189 // printf("Received :code: 0x%04x 0x%08x\n", code, value); 00190 00191 return 1; 00192 }
int v1190B_ResolutionRead | ( | uint16_t * | pbase | ) |
Definition at line 137 of file caenv1190B.c.
00138 { 00139 uint16_t i, code; 00140 uint32_t value; 00141 00142 // v1190_MicroFlush(pbase); 00143 for (i=0; i<2 ; i++) { 00144 code = V1190_RESOLUTION_RO | (i & 0x0F); 00145 value = v1190_MicroWrite(pbase, code); 00146 value = v1190_MicroRead(pbase); 00147 // printf("Received :code: 0x%04x 0x%08x\n", code, value); 00148 } 00149 return 1; 00150 }
int v1190B_TdcIdList | ( | uint16_t * | pbase | ) |
Definition at line 120 of file caenv1190B.c.
00121 { 00122 uint16_t i, code; 00123 uint32_t value; 00124 00125 // v1190_MicroFlush(pbase); 00126 for (i=0; i<2 ; i++) { 00127 code = 0x6000 | (i & 0x0F); 00128 value = v1190_MicroWrite(pbase, code); 00129 value = v1190_MicroRead(pbase); 00130 value = (v1190_MicroRead(pbase) << 16) | value; 00131 printf("Received :code: 0x%04x 0x%08x\n", code, value); 00132 } 00133 return 1; 00134 }
int v1190B_TriggerMatchingSet | ( | uint16_t * | pbase | ) |
Definition at line 167 of file caenv1190B.c.
00168 { 00169 uint16_t code; 00170 uint32_t value; 00171 00172 // v1190_MicroFlush(pbase); 00173 code = V1190_TRIGGER_MATCH_WO; 00174 value = v1190_MicroWrite(pbase, code); 00175 // printf("Received :code: 0x%04x 0x%08x\n", code, value); 00176 00177 return 1; 00178 }