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

Double flush read buffer on startup.

This commit is contained in:
gstellenberg
2009-10-23 22:18:48 -05:00
parent ac296aab3e
commit dd12016b0f

View File

@@ -303,7 +303,6 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
int rowEnableSelect;
int lastCoilDriverGroup;
DEBUG(PRLog(kPRLogError, "In Defaults:, machineType = %x.\n", machineType));
switch (machineType)
{
case kPRMachineWPC:
@@ -350,7 +349,6 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
break;
}
}
DEBUG(PRLog(kPRLogError, "Defaults:, setup done.\n", machineType));
memset(&driverGlobalConfig, 0x00, sizeof(PRDriverGlobalConfig));
for (i = 0; i < kPRDriverCount; i++)
@@ -362,7 +360,6 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
if (resetFlags & kPRResetFlagUpdateDevice)
res = DriverUpdateState(driver);
}
DEBUG(PRLog(kPRLogError, "Defaults:, Drivers done.\n", machineType));
for (i = 0; i < kPRDriverGroupsMax; i++)
{
PRDriverGroupConfig *group = &driverGroups[i];
@@ -370,7 +367,6 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
group->groupNum = i;
group->polarity = globalPolarity;
}
DEBUG(PRLog(kPRLogError, "Defaults:, Drivers groups set up.\n", machineType));
PRDriverGlobalConfig globals;
globals.enableOutputs = false;
@@ -386,7 +382,6 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
globals.watchdogExpired = false;
globals.watchdogEnable = true;
globals.watchdogResetTime = watchdogResetTime;
DEBUG(PRLog(kPRLogError, "Defaults:, Drivers globals set up.\n", machineType));
// We want to start up safely, so we'll update the global driver config twice.
// When we toggle enableOutputs like this P-ROC will reset the polarity:
@@ -404,7 +399,6 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
else
driverGlobalConfig = globals;
DEBUG(PRLog(kPRLogError, "Defaults:, Drivers globals programmed.\n", machineType));
// Configure the groups. Each group corresponds to 8 consecutive drivers, starting
// with driver #32. The following 6 groups are configured for coils/flashlamps.
@@ -426,10 +420,8 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
res = DriverUpdateGroupConfig(&group);
else
driverGroups[i] = group;
DEBUG(PRLog(kPRLogError, "Defaults: group %x programmed.\n", i));
}
DEBUG(PRLog(kPRLogError, "Defaults: First groups programmed.\n", machineType));
// The following 8 groups are configured for the feature lamp matrix.
for (i = 10; i < 10 + numMatrixGroups; i++) {
@@ -447,9 +439,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
res = DriverUpdateGroupConfig(&group);
else
driverGroups[i] = group;
DEBUG(PRLog(kPRLogError, "Defaults: group %x programmed.\n", i));
}
DEBUG(PRLog(kPRLogError, "Defaults: last groups programmed.\n", machineType));
return res;
}
@@ -821,6 +811,10 @@ PRResult PRDevice::Open()
SwitchUpdateConfig(&switchConfig);
// Flush read data to ensure VerifyChipID starts with clean buffer.
// Do it twice with a delay in between to ensure that any data in the P-ROC
// while the buffer is being flushed the first time is flushed the second time.
res = FlushReadBuffer();
PRSleep(100);
res = FlushReadBuffer();
if (VerifyChipID() == kPRFailure) {
// Since the FPGA didn't appear to be responding properly, send the FPGA's FTDI