266 std::stringstream ss;
268 TLOG() <<
"DeviceInterface: trying to connect to " << boost::asio::ip::address_v4(fDeviceId).to_string();
277 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"Unable to get handle to device; giving up!" << std::endl;
286 unsigned int pdts_status = 0;
287 unsigned int pdts_control = 0;
288 unsigned int dsp_clock_control = 0;
290 fDevice->DeviceRead(duneReg.
pdts_status, &pdts_status);
291 TLOG() <<
"The pdts_status read back as 0x" << std::hex << pdts_status << std::dec << std::endl;
292 fDevice->DeviceRead(duneReg.
pdts_control, &pdts_control);
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;
297 unsigned int presentTimingAddress = (pdts_control >> 16) & 0xFF;
298 unsigned int presentTimingPartition = pdts_control & 0x3;
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;
306 if ((pdts_status & 0xF) >= 0x6 && (pdts_status & 0xF) <= 0x8 && presentTimingAddress == fTimingAddress &&
307 presentTimingPartition == fPartitionNumber && (dsp_clock_control & 0xF) == 0x1) {
310 TLOG() <<
"Clock already looks ok... skipping endpoint reset." << std::endl;
313 TLOG() <<
"Syncing SSP LED Calib to PDTS (partition " << fPartitionNumber <<
", endpoint address 0x"
314 << std::hex << fTimingAddress << std::dec <<
")" << std::endl;
316 unsigned int nTries = 0;
320 TLOG() <<
"The dsp_clock_control was set to 0x" << std::hex << 0x30 << std::dec
322 fDevice->DeviceWrite(duneReg.
pdts_control, 0x80000000 + fPartitionNumber + fTimingAddress * 0x10000);
323 TLOG() <<
"The pdts_control value was set to 0x" << std::hex << 0x80000000 + fPartitionNumber + fTimingAddress * 0x10000
324 << std::dec << std::endl;
326 fDevice->DeviceRead(duneReg.
pdts_status, &pdts_status);
327 TLOG() <<
"The pdts_status read back as 0x" << std::hex << pdts_status << std::dec
329 fDevice->DeviceRead(duneReg.
pdts_control, &pdts_control);
330 TLOG() <<
"The pdts_control read back as 0x" << std::hex << pdts_control << std::dec
333 TLOG() <<
"The dsp_clock_control read back as 0x" << std::hex << dsp_clock_control << std::dec
336 fDevice->DeviceWrite(duneReg.
pdts_control, 0x00000000 + fPartitionNumber + fTimingAddress * 0x10000);
337 TLOG() <<
"The pdts_status value was set to 0x" << std::hex
338 << 0x00000000 + fPartitionNumber + fTimingAddress * 0x10000 << std::dec << std::endl;
342 TLOG() <<
"The dsp_clock_control was set to 0x" << std::hex << 0x31 << std::dec << std::endl;
344 fDevice->DeviceRead(duneReg.
pdts_status, &pdts_status);
345 TLOG() <<
"The pdts_status read back as 0x" << std::hex << pdts_status << std::dec
347 if ((pdts_status & 0xF) >= 0x6 && (pdts_status & 0xF) <= 0x8)
349 TLOG() <<
"Timing endpoint sync failed (try " << nTries <<
")" << std::endl;
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
357 TLOG() <<
"Timing endpoint synced!" << std::endl;
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
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;
367 TLOG() <<
"Woke up from 2 seconds of sleep and Waiting for endpoint to reach status 0x8..."
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;
376 while ((pdts_status & 0xF) != 0x8) {
378 TLOG() <<
"Wrong PDTS status!" << std::endl;
382 TLOG() <<
"Woke up from 2 seconds of sleep and Waiting for endpoint to reach status 0x8..."
384 fDevice->DeviceRead(duneReg.
pdts_status, &pdts_status);
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;
390 TLOG() <<
"Endpoint is in running state, continuing with configuration!" << std::endl;
391 TLOG() <<
"SSP LED Calib Device Interface Configured complete.";