Go to the source code of this file.
void vpc6_ASDDefaultLoad | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Definition at line 344 of file vpc6.c.
00345 { 00346 vpc6_Reg def; 00347 00348 def.asdx1.chipmode = 1; // ToT 00349 def.asdx1.channelmode = 0; // All on 00350 def.asdx1.deadtime = 0; // 300ns 00351 def.asdx1.wilkinsonRCurrent = 0; // N/A 00352 def.asdx1.wilkinsonIGate = 0; // N/A 00353 def.asdx1.hysteresisDAC = 7; // ~10mV hysteresis 00354 def.asdx1.wilkinsonADC = 0; // bit0 here N/A 00355 vpc6_ASDRegSet(mvme, base, port, 0, &def); 00356 00357 def.asdx2.wilkinsonADC = 0; // bits2..1 here N/A 00358 def.asdx2.mainThresholdDAC = 108; // N/A 00359 def.asdx2.capInjCapSel = 0; // N/A 00360 def.asdx2.calMaskReg = 0; // N/A 00361 def.asdx2.notused = 0; 00362 vpc6_ASDRegSet(mvme, base, port, 1, &def); 00363 00364 def.asdx1.chipmode = 1; // ToT 00365 def.asdx1.channelmode = 0; 00366 def.asdx1.deadtime = 0; 00367 def.asdx1.wilkinsonRCurrent = 0; 00368 def.asdx1.wilkinsonIGate = 0; 00369 def.asdx1.hysteresisDAC = 7; 00370 def.asdx1.wilkinsonADC = 0; // bit0 here N/A 00371 vpc6_ASDRegSet(mvme, base, port, 2, &def); 00372 00373 def.asdx2.wilkinsonADC = 0; // bits2..1 here N/A 00374 def.asdx2.mainThresholdDAC = 108; 00375 def.asdx2.capInjCapSel = 0; 00376 def.asdx2.calMaskReg = 0; 00377 def.asdx2.notused = 0; 00378 vpc6_ASDRegSet(mvme, base, port, 3, &def); 00379 }
int vpc6_ASDHysteresisSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port, | |||
float | value | |||
) |
Definition at line 488 of file vpc6.c.
00489 { 00490 int cmode; 00491 int ivalue; 00492 vpc6_Reg reg[2]; 00493 00494 mvme_get_dmode(mvme, &cmode); 00495 mvme_set_dmode(mvme, MVME_DMODE_D32); 00496 00497 reg[0] = (vpc6_Reg) mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x00); 00498 reg[1] = (vpc6_Reg) mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x08); 00499 00500 // Hysteresis Value 00501 ivalue = (int) (value / 1.25); 00502 if ((ivalue >= 0x0) && (ivalue <= 0xF)) { 00503 reg[0].asdx1.hysteresisDAC = ivalue; 00504 reg[1].asdx1.hysteresisDAC = ivalue; 00505 } 00506 else { 00507 printf("Invalid Hysteresis Setting %f...\n", value); 00508 printf("Hysteresis = 0x0 .. 0xF (ie. 0 - 18.75mV)\n"); 00509 mvme_set_dmode(mvme, cmode); 00510 return -1; 00511 } 00512 00513 vpc6_ASDRegSet(mvme, base, port, 0, ®[0]); 00514 vpc6_ASDRegSet(mvme, base, port, 2, ®[1]); 00515 vpc6_PortCfgLoad(mvme, base, port); 00516 vpc6_CfgRetrieve(mvme, base, port); 00517 mvme_set_dmode(mvme, cmode); 00518 00519 return 0; 00520 }
int vpc6_ASDModeSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port, | |||
int | channel, | |||
int | mode | |||
) |
Definition at line 397 of file vpc6.c.
00398 { 00399 int cmode; 00400 int ch; 00401 vpc6_Reg reg[2]; 00402 00403 mvme_get_dmode(mvme, &cmode); 00404 mvme_set_dmode(mvme, MVME_DMODE_D32); 00405 00406 reg[0] = (vpc6_Reg) mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x00); 00407 reg[1] = (vpc6_Reg) mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x08); 00408 00409 if((mode >= 0) && (mode < 4)) { 00410 if (channel == ALL_CHANNELS) { 00411 reg[0].asdx1.channelmode = 0x0000; 00412 reg[1].asdx1.channelmode = 0x0000; 00413 for (ch=0; ch<8; ch++) { 00414 reg[0].asdx1.channelmode |= mode << ch*2; 00415 } 00416 for (ch=0; ch<8; ch++) { 00417 reg[1].asdx1.channelmode |= mode << ch*2; 00418 } 00419 } 00420 else if ((channel >= 0) && (channel < 8)) { 00421 reg[0].asdx1.channelmode &= (~0x0003) << channel*2; 00422 reg[0].asdx1.channelmode |= mode << channel*2; 00423 } 00424 else if ((channel >= 8) && (channel < 16)) { 00425 reg[1].asdx1.channelmode &= (~0x0003) << (channel-8)*2; 00426 reg[1].asdx1.channelmode |= mode << channel*2; 00427 } 00428 else { 00429 printf("Invalid Channel # %d...\n", channel); 00430 printf("Channels 0..15 (%d for ALL)\n", ALL_CHANNELS); 00431 mvme_set_dmode(mvme, cmode); 00432 return -1; 00433 } 00434 } 00435 else { 00436 printf("Invalid ASD Channel Mode Setting... %d\n", mode); 00437 printf("Modes: 0 (ON), 1 (ON), 2 (Forced LOW), 3 (Forced HIGH)\n"); 00438 mvme_set_dmode(mvme, cmode); 00439 return -1; 00440 } 00441 00442 vpc6_ASDRegSet(mvme, base, port, 0, ®[0]); 00443 vpc6_ASDRegSet(mvme, base, port, 2, ®[1]); 00444 vpc6_PortCfgLoad(mvme, base, port); 00445 vpc6_CfgRetrieve(mvme, base, port); 00446 mvme_set_dmode(mvme, cmode); 00447 return 0; 00448 }
void vpc6_ASDRegSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port, | |||
WORD | reg, | |||
vpc6_Reg * | Reg | |||
) |
Definition at line 382 of file vpc6.c.
Referenced by vpc6_ASDDefaultLoad(), vpc6_ASDHysteresisSet(), vpc6_ASDModeSet(), and vpc6_ASDThresholdSet().
00384 { 00385 int cmode; 00386 00387 mvme_get_dmode(mvme, &cmode); 00388 mvme_set_dmode(mvme, MVME_DMODE_D32); 00389 00390 mvme_write_value(mvme, base+VPC6_CFG_RW+((port-1)*0x10)+(reg*0x04), Reg->asdcfg); 00391 //DEBUG 00392 //printf("port:%d reg:%d addr: 0x%x\n",port, reg, VPC6_CFG_RW+((port-1)*0x10)+(reg*0x04)); 00393 mvme_set_dmode(mvme, cmode); 00394 }
int vpc6_ASDThresholdSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port, | |||
int | value | |||
) |
Definition at line 452 of file vpc6.c.
00453 { 00454 int cmode; 00455 vpc6_Reg reg[2]; 00456 00457 mvme_get_dmode(mvme, &cmode); 00458 mvme_set_dmode(mvme, MVME_DMODE_D32); 00459 00460 reg[0] = (vpc6_Reg) mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x04); 00461 reg[1] = (vpc6_Reg) mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x0C); 00462 00463 // Threshold Value in mV (~9mV / fC) 00464 if ((value >= -256) && (value <= 254)) { 00465 reg[0].asdx2.mainThresholdDAC = (value / 2) + 128; 00466 reg[1].asdx2.mainThresholdDAC = (value / 2) + 128; 00467 } 00468 else { 00469 printf("Invalid Threshold Setting %d...\n", value); 00470 printf("Threshold = -256 .. 254 (in mV's)\n"); 00471 mvme_set_dmode(mvme, cmode); 00472 return -1; 00473 } 00474 00475 vpc6_ASDRegSet(mvme, base, port, 1, ®[0]); 00476 vpc6_ASDRegSet(mvme, base, port, 3, ®[1]); 00477 00478 vpc6_PortCfgLoad(mvme, base, port); 00479 vpc6_CfgRetrieve(mvme, base, port); 00480 00481 mvme_set_dmode(mvme, cmode); 00482 00483 return 0; 00484 }
int vpc6_BuckeyeModeSet | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port, | |||
int | channel, | |||
int | mode | |||
) |
int vpc6_CfgRetrieve | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Retrieve bit string full configuration from a given port. Loads bit string into Readback registers that can then be read. the port is either ASD01 or Buckeye for now.
Definition at line 121 of file vpc6.c.
Referenced by vpc6_ASDHysteresisSet(), vpc6_ASDModeSet(), and vpc6_ASDThresholdSet().
00122 { 00123 int cmode, action, timeout=100; 00124 00125 mvme_get_dmode(mvme, &cmode); 00126 mvme_set_dmode(mvme, MVME_DMODE_D32); 00127 if ((port > 0) && (port < 7)) { 00128 action = (0x10) | port; 00129 } 00130 00131 do { 00132 if (~(vpc6_isPortBusy(mvme, base, port))) { 00133 // Not busy, read bit string from PA 00134 // printf(" cfg request 0x%x %d\n", base+VPC6_CMD_WO, action); 00135 mvme_write_value(mvme, base+VPC6_CMD_WO, action); 00136 usleep(10000); 00137 mvme_write_value(mvme, base+VPC6_CMD_WO, action); 00138 break; 00139 } 00140 usleep(10000); 00141 } while (timeout--); 00142 00143 if (timeout == 0) 00144 printf(" Port %d still busy\n", port); 00145 00146 mvme_set_dmode(mvme, cmode); 00147 return VPC6_SUCCESS; 00148 }
decoded printout of readout entry for ASD type preamp Not to be trusted for data decoding but acceptable for display purpose as its implementation is strongly compiler dependent and not flawless.
v |
Definition at line 238 of file vpc6.c.
Referenced by vpc6_PortDisplay().
00239 { 00240 vpc6_Reg * v2 = v+1; 00241 00242 00243 if (type == VPC6_ASD01) { 00244 switch (chip) { 00245 case vpc6_asd_ch1_8: 00246 printf("Channel 1 to 8...\n"); 00247 printf("Chip mode :%s ", v->asdx1.chipmode == 0 ? "ADC" : "TOT"); 00248 printf(" Channel mode :0x%04x \n", v->asdx1.channelmode); 00249 printf("Threshold :0x%02x Hysteresis :0x%02x CalInjCap :0x%02x CalMaskReg :0x%02x\n" 00250 , v2->asdx2.mainThresholdDAC, v->asdx1.hysteresisDAC 00251 , v2->asdx2.capInjCapSel, v2->asdx2.calMaskReg); 00252 if (v->asdx1.chipmode == 0) { 00253 printf("ADC Threshold:0x%02x Dead Time :0x%02x WADC Run Current :0x%02x WADC Int Gate:0x%02x\n" 00254 , ((v2->asdx2.wilkinsonADC << 1) | v ->asdx1.wilkinsonADC), v->asdx1.deadtime 00255 , v->asdx1.wilkinsonRCurrent, v->asdx1.wilkinsonIGate); 00256 } 00257 break; 00258 case vpc6_asd_ch9_16: 00259 printf("Channel 9 to 16...\n"); 00260 printf("Chip mode :%s ", v->asdx1.chipmode == 0 ? "ADC" : "TOT"); 00261 printf(" Channel mode :0x%04x \n", v->asdx1.channelmode); 00262 printf("Threshold :0x%02x Hysteresis :0x%02x CalInjCap :0x%02x CalMaskReg :0x%02x\n" 00263 , v2->asdx2.mainThresholdDAC, v->asdx1.hysteresisDAC 00264 , v2->asdx2.capInjCapSel, v2->asdx2.calMaskReg); 00265 if (v->asdx1.chipmode == 0) { 00266 printf("ADC Threshold:0x%02x Dead Time :0x%02x WADC Run Current :0x%02x WADC Int Gate:0x%02x\n" 00267 , ((v2->asdx2.wilkinsonADC << 1) | v ->asdx1.wilkinsonADC), v->asdx1.deadtime 00268 , v->asdx1.wilkinsonRCurrent, v->asdx1.wilkinsonIGate); 00269 } 00270 break; 00271 } 00272 } 00273 else if (type == VPC6_BUCKEYE) { 00274 printf("Channel: 1 to 16...\n"); 00275 } 00276 }
int vpc6_isPortBusy | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Definition at line 19 of file vpc6.c.
Referenced by vpc6_CfgRetrieve(), vpc6_PortCfgLoad(), vpc6_PortRegRBRead(), and vpc6_Status().
00020 { 00021 int cmode, busy; 00022 00023 mvme_get_dmode(mvme, &cmode); 00024 mvme_set_dmode(mvme, MVME_DMODE_D32); 00025 busy = mvme_read_value(mvme, base+VPC6_SR_RO); 00026 mvme_set_dmode(mvme, cmode); 00027 return (busy & (1 << (port-1))); 00028 }
int vpc6_PATypeRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base | |||
) |
Read the 6 AP type of the board (either ASD01 or Buckeye for now.
Definition at line 51 of file vpc6.c.
00052 { 00053 int cmode, type; 00054 00055 mvme_get_dmode(mvme, &cmode); 00056 mvme_set_dmode(mvme, MVME_DMODE_D32); 00057 type = mvme_read_value(mvme, base+VPC6_CR_RW); 00058 mvme_set_dmode(mvme, cmode); 00059 return (type & 0xFFF); 00060 }
void vpc6_PATypeWrite | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | data | |||
) |
Setup Preamp type of the board (2 bit per PA) 00 : ASD, 01 : Buckeye
Definition at line 35 of file vpc6.c.
Referenced by vpc6_Setup().
00036 { 00037 int cmode; 00038 00039 mvme_get_dmode(mvme, &cmode); 00040 mvme_set_dmode(mvme, MVME_DMODE_D32); 00041 data &= 0xFFF; 00042 mvme_write_value(mvme, base+VPC6_CR_RW, data); 00043 mvme_set_dmode(mvme, cmode); 00044 return; 00045 }
int vpc6_PortCfgLoad | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Load full configuration for a given port. the port is either ASD01 or Buckeye for now.
Definition at line 84 of file vpc6.c.
Referenced by vpc6_ASDHysteresisSet(), vpc6_ASDModeSet(), and vpc6_ASDThresholdSet().
00085 { 00086 int cmode, action, timeout=100; 00087 00088 mvme_get_dmode(mvme, &cmode); 00089 mvme_set_dmode(mvme, MVME_DMODE_D32); 00090 if ((port > 0) && (port < 7)) { 00091 action = (0x18) | port; 00092 } 00093 else 00094 return VPC6_PARAM_ERROR; 00095 00096 do { 00097 if (~(vpc6_isPortBusy(mvme, base, port))) { 00098 // Not busy, load bit string to PA 00099 mvme_write_value(mvme, base+VPC6_CMD_WO, action); 00100 usleep(10000); 00101 mvme_write_value(mvme, base+VPC6_CMD_WO, action); 00102 break; 00103 } 00104 else 00105 usleep(10000); 00106 } while (timeout--); 00107 00108 if (timeout == 0) 00109 printf("Port %d still busy\n", port); 00110 00111 mvme_set_dmode(mvme, cmode); 00112 return VPC6_SUCCESS; 00113 }
decoded printout of readout entry
Definition at line 220 of file vpc6.c.
Referenced by vpc6_PortRegRBRead(), and vpc6_PortRegRead().
00221 { 00222 printf("\n---- Port:%d Type:%s ----------------------------\n" 00223 , port, type == VPC6_ASD01 ? "ASD01" : "Buckeye"); 00224 vpc6_EntryPrint(type, 0, (vpc6_Reg *)®[0]); 00225 if (type == VPC6_ASD01) { 00226 vpc6_EntryPrint(type, 1, (vpc6_Reg *)®[2]); 00227 } 00228 }
int vpc6_PortRegRBRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Read the Readback and Display in a readable form the Port setting No action to the PA board
Definition at line 155 of file vpc6.c.
00156 { 00157 int cmode, timeout=100; 00158 WORD type; 00159 DWORD reg[4]; 00160 00161 mvme_get_dmode(mvme, &cmode); 00162 mvme_set_dmode(mvme, MVME_DMODE_D32); 00163 00164 do { 00165 if (~(vpc6_isPortBusy(mvme, base, port))) { 00166 type = mvme_read_value(mvme, base+VPC6_CR_RW); 00167 type = ((type >> (2*(port-1))) & 0x03); // ASD or Buck 00168 reg[0] = mvme_read_value(mvme, base+VPC6_RBCK_RO+(0x10*(port-1))+0x00); 00169 reg[1] = mvme_read_value(mvme, base+VPC6_RBCK_RO+(0x10*(port-1))+0x04); 00170 reg[2] = mvme_read_value(mvme, base+VPC6_RBCK_RO+(0x10*(port-1))+0x08); 00171 reg[3] = mvme_read_value(mvme, base+VPC6_RBCK_RO+(0x10*(port-1))+0x0C); 00172 vpc6_PortDisplay(type, port, reg); 00173 break; 00174 } 00175 } while (timeout--); 00176 00177 // printf("DEBUG Readback Register:\n reg[0]=0x%8lx \n reg[1]=0x%8lx \n reg[2]=0x%8lx \n reg[3]=0x%8lx \n" 00178 // , reg[0], reg[1], reg[2], reg[3]); 00179 00180 if (timeout == 0) 00181 printf(" Port %d busy\n", port); 00182 00183 mvme_set_dmode(mvme, cmode); 00184 return VPC6_SUCCESS; 00185 }
int vpc6_PortRegRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Read the Register and Display in a readable form the Port setting No action to the PA board
Definition at line 192 of file vpc6.c.
00193 { 00194 int cmode; 00195 WORD type; 00196 DWORD reg[4]; 00197 00198 mvme_get_dmode(mvme, &cmode); 00199 mvme_set_dmode(mvme, MVME_DMODE_D32); 00200 00201 type = mvme_read_value(mvme, base+VPC6_CR_RW); 00202 type = ((type >> (2*(port-1))) & 0x03); // ASD or Buck 00203 reg[0] = mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x00); 00204 reg[1] = mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x04); 00205 reg[2] = mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x08); 00206 reg[3] = mvme_read_value(mvme, base+VPC6_CFG_RW+(0x10*(port-1))+0x0C); 00207 vpc6_PortDisplay(type, port, reg); 00208 00209 //printf("DEBUG Configuration Register:\n reg[0]=0x%8lx \n reg[1]=0x%8lx \n reg[2]=0x%8lx \n reg[3]=0x%8lx \n" 00210 // , reg[0], reg[1], reg[2], reg[3]); 00211 00212 mvme_set_dmode(mvme, cmode); 00213 return VPC6_SUCCESS; 00214 }
int vpc6_PortTypeRead | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Read Port type of the board (either ASD01 or Buckeye for now) return the type of the requested port
Definition at line 67 of file vpc6.c.
Referenced by vpc6_Status().
00068 { 00069 int cmode, type; 00070 00071 mvme_get_dmode(mvme, &cmode); 00072 mvme_set_dmode(mvme, MVME_DMODE_D32); 00073 type = mvme_read_value(mvme, base+VPC6_CR_RW); 00074 mvme_set_dmode(mvme, cmode); 00075 type = ((type >> (2*(port-1))) & 0x03); // ASD or Buck 00076 return (type & 0xFFF); 00077 }
int vpc6_Setup | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
int | mode | |||
) |
Sets all the necessary paramters for a given configuration. The configuration is provided by the mode argument. Add your own configuration in the case statement. Let me know your setting if you want to include it in the distribution.
*mvme | VME structure | |
base | Module base address | |
mode | Configuration mode number | |
*nentry | number of entries requested and returned. |
Definition at line 291 of file vpc6.c.
00292 { 00293 int cmode; 00294 00295 mvme_get_dmode(mvme, &cmode); 00296 mvme_set_dmode(mvme, MVME_DMODE_D32); 00297 00298 switch (mode) { 00299 case 0x1: 00300 printf("Default setting after power up (mode:%d)\n", mode); 00301 printf("All Buckeye\n"); 00302 vpc6_PATypeWrite(mvme, base, VPC6_ALL_BUCKEYE); 00303 break; 00304 case 0x2: 00305 printf("Modified setting (mode:%d)\n", mode); 00306 printf("All ASD01\n"); 00307 vpc6_PATypeWrite(mvme, base, VPC6_ALL_ASD); 00308 break; 00309 case 0x3: 00310 printf("Modified setting (mode:%d)\n", mode); 00311 printf("3 ASD and 3 Buckeye\n"); 00312 vpc6_PATypeWrite(mvme, base, VPC6_3ASD_3BUCK); 00313 break; 00314 case 0x4: 00315 printf("Modified setting (mode:%d)\n", mode); 00316 printf("All Buckeye\n"); 00317 vpc6_PATypeWrite(mvme, base, VPC6_3BUCK_3ASD); 00318 break; 00319 default: 00320 printf("Unknown setup mode\n"); 00321 mvme_set_dmode(mvme, cmode); 00322 return -1; 00323 } 00324 mvme_set_dmode(mvme, cmode); 00325 return 0; 00326 }
void vpc6_Status | ( | MVME_INTERFACE * | mvme, | |
DWORD | base, | |||
WORD | port | |||
) |
Definition at line 329 of file vpc6.c.
00330 { 00331 int status, cmode; 00332 00333 mvme_get_dmode(mvme, &cmode); 00334 mvme_set_dmode(mvme, MVME_DMODE_D32); 00335 printf("vpc6 Status for Base:0x%lx\n", base); 00336 status = vpc6_isPortBusy(mvme, base, port); 00337 printf("Port Busy Status: 0x%x\n", status); 00338 status = vpc6_PortTypeRead(mvme, base, port); 00339 printf("PA type: 0x%x\n", status); 00340 mvme_set_dmode(mvme, cmode); 00341 }