262{
263
265
266 std::stringstream ss;
267 fDeviceId = inet_network(conf->get_board_ip().c_str());
268 TLOG() <<
"DeviceInterface: trying to connect to " << boost::asio::ip::address_v4(
fDeviceId).to_string();
269
272
273
275
276 if (!device) {
277 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"Unable to get handle to device; giving up!" << std::endl;
278 throw(ENoSuchDevice());
279 }
280
282
283
285
286 unsigned int pdts_status = 0;
287 unsigned int pdts_control = 0;
288 unsigned int dsp_clock_control = 0;
289
291 TLOG() <<
"The pdts_status read back as 0x" << std::hex << pdts_status << std::dec << std::endl;
293 TLOG() <<
"The pdts_control read back as 0x" << std::hex << pdts_control << std::dec << std::endl;
295 TLOG() <<
"The dsp_clock_control read back as 0x" << std::hex << dsp_clock_control << std::dec << std::endl;
296
297 unsigned int presentTimingAddress = (pdts_control >> 16) & 0xFF;
298 unsigned int presentTimingPartition = pdts_control & 0x3;
299
300 TLOG() <<
"SSP HW presently on partition " << presentTimingPartition <<
", address 0x" << std::hex
301 << presentTimingAddress << " with endpoint status 0x" << (pdts_status & 0xF)
302 << " and dsp_clock_control at 0x" << dsp_clock_control << std::dec << std::endl;
303
304
305
306 if ((pdts_status & 0xF) >= 0x6 && (pdts_status & 0xF) <= 0x8 && presentTimingAddress ==
fTimingAddress &&
307 presentTimingPartition ==
fPartitionNumber && (dsp_clock_control & 0xF) == 0x1) {
308
309
310 TLOG() <<
"Clock already looks ok... skipping endpoint reset." << std::endl;
311 } else {
312
313 TLOG() <<
"Syncing SSP LED Calib to PDTS (partition " <<
fPartitionNumber <<
", endpoint address 0x"
315
316 unsigned int nTries = 0;
317
318 while (nTries < 5) {
320 TLOG() <<
"The dsp_clock_control was set to 0x" << std::hex << 0x30 << std::dec
321 << std::endl;
324 << std::dec << std::endl;
325
327 TLOG() <<
"The pdts_status read back as 0x" << std::hex << pdts_status << std::dec
328 << std::endl;
330 TLOG() <<
"The pdts_control read back as 0x" << std::hex << pdts_control << std::dec
331 << std::endl;
333 TLOG() <<
"The dsp_clock_control read back as 0x" << std::hex << dsp_clock_control << std::dec
334 << std::endl;
335
337 TLOG() <<
"The pdts_status value was set to 0x" << std::hex
339 usleep(2000000);
341 0x31);
342 TLOG() <<
"The dsp_clock_control was set to 0x" << std::hex << 0x31 << std::dec << std::endl;
343 usleep(2000000);
345 TLOG() <<
"The pdts_status read back as 0x" << std::hex << pdts_status << std::dec
346 << std::endl;
347 if ((pdts_status & 0xF) >= 0x6 && (pdts_status & 0xF) <= 0x8)
348 break;
349 TLOG() <<
"Timing endpoint sync failed (try " << nTries <<
")" << std::endl;
350 ++nTries;
351 }
352
353 if ((pdts_status & 0xF) >= 0x6 && (pdts_status & 0xF) <= 0x8) {
354 TLOG() <<
"The pdts_status value is 0x" << std::hex << pdts_status
355 << " and the 0xF bit masked value is 0x" << (pdts_status & 0xF) << std::dec
356 << std::endl;
357 TLOG() <<
"Timing endpoint synced!" << std::endl;
358 } else {
359 TLOG() <<
"The pdts_status value is 0x" << std::hex << pdts_status
360 << " and the 0xF bit masked value is 0x" << (pdts_status & 0xF) << std::dec
361 << std::endl;
362 TLOG() <<
"Giving up on endpoint sync after 5 tries. Value of pdts_status register was 0x"
363 << std::hex << pdts_status << std::dec << std::endl;
364 }
365 }
366
367 TLOG() <<
"Woke up from 2 seconds of sleep and Waiting for endpoint to reach status 0x8..."
368 << std::endl;
369
370 if ((pdts_status & 0xF) != 0x8) {
371 TLOG() <<
"Waiting for endpoint to reach status 0x8..." << std::endl;
372 TLOG() <<
"The pdts_status value is 0x" << std::hex << pdts_status
373 << " and the 0xF bit masked value is 0x" << (pdts_status & 0xF) << std::dec << std::endl;
374 }
375 int nTries = 0;
376 while ((pdts_status & 0xF) != 0x8) {
377 if (nTries == 2) {
378 TLOG() <<
"Wrong PDTS status!" << std::endl;
380 }
381 usleep(2000000);
382 TLOG() <<
"Woke up from 2 seconds of sleep and Waiting for endpoint to reach status 0x8..."
383 << std::endl;
385 TLOG() <<
"The pdts_status value is 0x" << std::hex << pdts_status
386 << " and the 0xF bit masked value is 0x" << (pdts_status & 0xF) << std::dec << std::endl;
387 nTries++;
388 }
389
390 TLOG() <<
"Endpoint is in running state, continuing with configuration!" << std::endl;
391 TLOG() <<
"SSP LED Calib Device Interface Configured complete.";
392}
Device * OpenDevice(unsigned int deviceId, bool slowControlOnly=false)
static DeviceManager & Get()
virtual void DeviceRead(unsigned int address, unsigned int *value)=0
virtual void DeviceWrite(unsigned int address, unsigned int value)=0
unsigned int dsp_clock_control
unsigned int pdts_control
#define TLOG_DEBUG(lvl,...)
LED calibration failed to ERS_EMPTY DeviceInterfacePDTSStatus
#define TLVL_ENTER_EXIT_METHODS