Rev 207 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 207 | Rev 265 | ||
---|---|---|---|
Line 106... | Line 106... | ||
106 | DRSTimeout=1; |
106 | DRSTimeout=1; |
107 | printf("->>> Timer Out !!!\n"); |
107 | printf("->>> Timer Out !!!\n"); |
108 | } |
108 | } |
109 | 109 | ||
110 | static DRS *drs=NULL; |
110 | static DRS *drs=NULL; |
- | 111 | ||
- | 112 | ||
- | 113 | DLLEXPORT int DRSCalibrateTiming( ) |
|
- | 114 | { |
|
- | 115 | DRSBoard *b; |
|
- | 116 | if (drs == NULL) drs = new DRS(); |
|
- | 117 | if (!drs) return -1; |
|
- | 118 | DRSParameters = drssettings::instance(); |
|
- | 119 | ||
- | 120 | //fCalMode = 2; |
|
- | 121 | if (drs->GetNumberOfBoards() ) { |
|
- | 122 | /* continue working with first board only */ |
|
- | 123 | b = drs->GetBoard(0); |
|
- | 124 | ||
- | 125 | if (b->GetFirmwareVersion() < 13279) |
|
- | 126 | printf("Firmware revision 13279 or later\nrequired for timing calibration\n"); |
|
- | 127 | else if (b->GetInputRange() != 0) |
|
- | 128 | printf("Timing calibration can only be done\nat the -0.5V to +0.5V input range\n"); |
|
- | 129 | ||
- | 130 | else { |
|
- | 131 | ||
- | 132 | ||
- | 133 | /* remember current settings */ |
|
- | 134 | double acalVolt = b->GetAcalVolt(); |
|
- | 135 | int acalMode = b->GetAcalMode(); |
|
- | 136 | int tcalFreq = b->GetTcalFreq(); |
|
- | 137 | int tcalLevel = b->GetTcalLevel(); |
|
- | 138 | int tcalSource = b->GetTcalSource(); |
|
- | 139 | int flag1 = b->GetTriggerEnable(0); |
|
- | 140 | int flag2 = b->GetTriggerEnable(1); |
|
- | 141 | int trgSource = b->GetTriggerSource(); |
|
- | 142 | int trgDelay = b->GetTriggerDelay(); |
|
- | 143 | double range = b->GetInputRange(); |
|
- | 144 | int config = b->GetReadoutChannelConfig(); |
|
- | 145 | ||
- | 146 | ||
- | 147 | int status = b->CalibrateTiming(NULL); |
|
- | 148 | ||
- | 149 | if (!status) |
|
- | 150 | printf("Error performing timing calibration, please check waveforms and redo voltage calibration.\n"); |
|
- | 151 | else |
|
- | 152 | printf("Timing calibration successfully finished.\n"); |
|
- | 153 | ||
- | 154 | ||
- | 155 | /* restore old values */ |
|
- | 156 | b->EnableAcal(acalMode, acalVolt); |
|
- | 157 | b->EnableTcal(tcalFreq, tcalLevel); |
|
- | 158 | b->SelectClockSource(tcalSource); |
|
- | 159 | b->EnableTrigger(flag1, flag2); |
|
- | 160 | b->SetTriggerSource(trgSource); |
|
- | 161 | b->SetTriggerDelayPercent(trgDelay); |
|
- | 162 | b->SetInputRange(range); |
|
- | 163 | b->SetChannelConfig(config, 8, 8); |
|
- | 164 | ||
- | 165 | if (b->GetBoardType() == 5) |
|
- | 166 | b->SetTranspMode(1); // Evaluation board with build-in trigger |
|
- | 167 | else |
|
- | 168 | b->SetTranspMode(1); // VPC Mezzanine board |
|
- | 169 | ||
- | 170 | return status; |
|
- | 171 | } |
|
- | 172 | ||
- | 173 | } |
|
- | 174 | return -1; |
|
- | 175 | } |
|
- | 176 | ||
111 | 177 | ||
112 | DLLEXPORT int DRSInit() |
178 | DLLEXPORT int DRSInit() |
113 | { |
179 | { |
114 | 180 | ||
115 | DRSBoard *b; |
181 | DRSBoard *b; |
116 | /* do drsinitial scan */ |
182 | /* do drsinitial scan */ |
117 | drs = new DRS(); |
183 | if (drs == NULL) drs = new DRS(); |
118 | if (!drs) return -1; |
184 | if (!drs) return -1; |
119 | DRSParameters = drssettings::instance(); |
185 | DRSParameters = drssettings::instance(); |
120 | 186 | ||
121 | /* show any found board(s) */ |
187 | /* show any found board(s) */ |
122 | for (int i=0 ; i<drs->GetNumberOfBoards() ; i++) { |
188 | for (int i=0 ; i<drs->GetNumberOfBoards() ; i++) { |