1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-24 18:25:23 +01:00

Cleanup for VerifyChipID logic.

This commit is contained in:
gstellenberg
2009-10-25 15:24:33 -05:00
parent 9550ba1223
commit a6ac5122e5
2 changed files with 11 additions and 8 deletions

View File

@@ -823,8 +823,15 @@ PRResult PRDevice::Open()
// the verify still fails, do a bunch of flushes. // the verify still fails, do a bunch of flushes.
res = FlushReadBuffer(); res = FlushReadBuffer();
uint32_t verify_ctr = 0; uint32_t verify_ctr = 0;
res = kPRSuccess; res = VerifyChipID();
while (VerifyChipID() == kPRFailure && verify_ctr++ < 50) { while (res == kPRFailure && verify_ctr++ < 50) {
// Only send init pattern once.
if (verify_ctr == 1) {
temp_word = P_ROC_INIT_PATTERN_A;
res = WriteData(&temp_word, 1);
temp_word = P_ROC_INIT_PATTERN_B;
res = WriteData(&temp_word, 1);
}
// Since the FPGA didn't appear to be responding properly, send the FPGA's FTDI // Since the FPGA didn't appear to be responding properly, send the FPGA's FTDI
// initialization sequence. This is a set of bytes the FPGA is waiting to receive // initialization sequence. This is a set of bytes the FPGA is waiting to receive
// before it allows access deeper into the chip. This keeps garbage from getting // before it allows access deeper into the chip. This keeps garbage from getting
@@ -833,10 +840,6 @@ PRResult PRDevice::Open()
DEBUG(PRLog(kPRLogInfo, "Initializing P-ROC...\n")); DEBUG(PRLog(kPRLogInfo, "Initializing P-ROC...\n"));
res = FlushReadBuffer(); res = FlushReadBuffer();
PRSleep(100); PRSleep(100);
temp_word = P_ROC_INIT_PATTERN_A;
res = WriteData(&temp_word, 1);
temp_word = P_ROC_INIT_PATTERN_B;
res = WriteData(&temp_word, 1);
res = VerifyChipID(); res = VerifyChipID();
if (res == kPRFailure) if (res == kPRFailure)
DEBUG(PRLog(kPRLogWarning, "Unable to read Chip ID - P-ROC could not be initialized.\n")); DEBUG(PRLog(kPRLogWarning, "Unable to read Chip ID - P-ROC could not be initialized.\n"));
@@ -1074,7 +1077,7 @@ PRResult PRDevice::FlushReadBuffer()
//uint32_t rd_buffer[3]; //uint32_t rd_buffer[3];
numBytes = CollectReadData(); numBytes = CollectReadData();
k = 0; k = 0;
DEBUG(PRLog(kPRLogError, "Flushing Read Buffer\n", rc)); DEBUG(PRLog(kPRLogError, "Flushing Read Buffer: %d bytes trashed\n", numBytes));
//while (k < numBytes) { //while (k < numBytes) {
// rc = ReadData(rd_buffer, 1); // rc = ReadData(rd_buffer, 1);

View File

@@ -42,7 +42,7 @@ const int32_t FTDI_FT245RL_PRODUCT_ID = 0x6001;
const int32_t FTDI_BUFFER_SIZE = 2048; const int32_t FTDI_BUFFER_SIZE = 2048;
const uint32_t P_ROC_INIT_PATTERN_A = 0x801F1122; const uint32_t P_ROC_INIT_PATTERN_A = 0x801F1122;
const uint32_t P_ROC_INIT_PATTERN_B = 0x345678AB; const uint32_t P_ROC_INIT_PATTERN_B = 0x345678AB;
const uint32_t P_ROC_CHIP_ID = 0xFEEDBEEF; const uint32_t P_ROC_CHIP_ID = 0xfeedbeef;
const uint32_t P_ROC_AUTO_STERN_DETECT_SHIFT = 8; const uint32_t P_ROC_AUTO_STERN_DETECT_SHIFT = 8;
const uint32_t P_ROC_AUTO_STERN_DETECT_MASK = 0x00000100; const uint32_t P_ROC_AUTO_STERN_DETECT_MASK = 0x00000100;