1
0
mirror of https://github.com/preble/libpinproc synced 2026-04-15 23:35:23 +02:00

add new PRWriteDataUnbuffered to libpinproc

This commit is contained in:
Jan Kantert
2020-02-22 13:07:29 +01:00
parent 5bb2146d3e
commit 031109f5ec
4 changed files with 143 additions and 120 deletions

View File

@@ -138,6 +138,9 @@ PINPROC_API PRResult PRFlushWriteData(PRHandle handle);
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */ /** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
PINPROC_API PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer); PINPROC_API PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
/** Write data buffered to P-ROC (does require a call to PRFlushWriteData). */
PINPROC_API PRResult PRWriteDataUnbuffered(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
/** Read data from the P-ROC. */ /** Read data from the P-ROC. */
PINPROC_API PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer); PINPROC_API PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);

View File

@@ -71,15 +71,15 @@ PRDevice* PRDevice::Create(PRMachineType machineType)
if (machineType != kPRMachineCustom && machineType != kPRMachinePDB && if (machineType != kPRMachineCustom && machineType != kPRMachinePDB &&
// Don't accept if requested type is WPC/WPC95 but read machine is not. // Don't accept if requested type is WPC/WPC95 but read machine is not.
( (((machineType == kPRMachineWPC) || ( (((machineType == kPRMachineWPC) ||
(machineType == kPRMachineWPC95) || (machineType == kPRMachineWPC95) ||
(machineType == kPRMachineWPCAlphanumeric)) && (machineType == kPRMachineWPCAlphanumeric)) &&
(readMachineType != kPRMachineWPC && (readMachineType != kPRMachineWPC &&
readMachineType != kPRMachineWPC95 && readMachineType != kPRMachineWPC95 &&
readMachineType != kPRMachineWPCAlphanumeric)) || readMachineType != kPRMachineWPCAlphanumeric)) ||
// Also don't accept if the requested is not WPC/WPC95 but the P-ROC is. // Also don't accept if the requested is not WPC/WPC95 but the P-ROC is.
(machineType != kPRMachineWPC && (machineType != kPRMachineWPC &&
machineType != kPRMachineWPC95 && machineType != kPRMachineWPC95 &&
machineType != kPRMachineWPCAlphanumeric && machineType != kPRMachineWPCAlphanumeric &&
readMachineType == kPRMachineWPC) ) ) readMachineType == kPRMachineWPC) ) )
{ {
@@ -95,7 +95,7 @@ PRDevice* PRDevice::Create(PRMachineType machineType)
PRResult PRDevice::Reset(uint32_t resetFlags) PRResult PRDevice::Reset(uint32_t resetFlags)
{ {
int i; int i;
// Initialize buffer pointers // Initialize buffer pointers
collected_bytes_rd_addr = 0; collected_bytes_rd_addr = 0;
collected_bytes_wr_addr = 0; collected_bytes_wr_addr = 0;
@@ -106,12 +106,12 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
while (!requestedDataQueue.empty()) requestedDataQueue.pop(); while (!requestedDataQueue.empty()) requestedDataQueue.pop();
num_collected_bytes = 0; num_collected_bytes = 0;
numPreparedWriteWords = 0; numPreparedWriteWords = 0;
if (machineType != kPRMachineCustom && machineType != kPRMachinePDB) DriverLoadMachineTypeDefaults(machineType, resetFlags); if (machineType != kPRMachineCustom && machineType != kPRMachinePDB) DriverLoadMachineTypeDefaults(machineType, resetFlags);
// Disable dmd events if updating the device. // Disable dmd events if updating the device.
#if 0 #if 0
if (resetFlags & kPRResetFlagUpdateDevice) if (resetFlags & kPRResetFlagUpdateDevice)
{ {
PRDMDConfig *dmdConfig = &(this->dmdConfig); PRDMDConfig *dmdConfig = &(this->dmdConfig);
dmdConfig->enableFrameEvents = false; dmdConfig->enableFrameEvents = false;
@@ -121,9 +121,9 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
// Make sure the free list is empty. // Make sure the free list is empty.
while (!freeSwitchRuleIndexes.empty()) freeSwitchRuleIndexes.pop(); while (!freeSwitchRuleIndexes.empty()) freeSwitchRuleIndexes.pop();
memset(switchRules, 0x00, sizeof(PRSwitchRuleInternal) * maxSwitchRules); memset(switchRules, 0x00, sizeof(PRSwitchRuleInternal) * maxSwitchRules);
for (i = 0; i < kPRSwitchRulesCount; i++) for (i = 0; i < kPRSwitchRulesCount; i++)
{ {
PRSwitchRuleInternal *switchRule = &switchRules[i]; PRSwitchRuleInternal *switchRule = &switchRules[i];
@@ -137,15 +137,15 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
// However, some of the switches are always optos and don't need to be debounced. // However, some of the switches are always optos and don't need to be debounced.
// So the debounced rule resources for those switches are available for linked rules. // So the debounced rule resources for those switches are available for linked rules.
if (switchRule->switchNum >= kPRSwitchNeverDebounceFirst && if (switchRule->switchNum >= kPRSwitchNeverDebounceFirst &&
(switchRule->eventType == kPREventTypeSwitchClosedDebounced || (switchRule->eventType == kPREventTypeSwitchClosedDebounced ||
switchRule->eventType == kPREventTypeSwitchOpenDebounced)) switchRule->eventType == kPREventTypeSwitchOpenDebounced))
freeSwitchRuleIndexes.push(ruleIndex); freeSwitchRuleIndexes.push(ruleIndex);
} }
// Create empty switch rule for clearing the rules in the device. // Create empty switch rule for clearing the rules in the device.
PRSwitchRule emptySwitchRule; PRSwitchRule emptySwitchRule;
memset(&emptySwitchRule, 0x00, sizeof(PRSwitchRule)); memset(&emptySwitchRule, 0x00, sizeof(PRSwitchRule));
for (i = 0; i < kPRSwitchCount; i++) for (i = 0; i < kPRSwitchCount; i++)
{ {
// Send blank rule for each event type to Device if necessary // Send blank rule for each event type to Device if necessary
@@ -177,7 +177,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
uint32_t event_data = unrequestedDataQueue.front(); uint32_t event_data = unrequestedDataQueue.front();
unrequestedDataQueue.pop(); unrequestedDataQueue.pop();
int type; int type;
bool open, debounced; bool open, debounced;
if (version >= 2) { if (version >= 2) {
@@ -205,7 +205,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced; events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced;
else else
events[i].type = debounced ? kPREventTypeSwitchClosedDebounced : kPREventTypeSwitchClosedNondebounced; events[i].type = debounced ? kPREventTypeSwitchClosedDebounced : kPREventTypeSwitchClosedNondebounced;
break; break;
} }
case P_ROC_EVENT_TYPE_DMD: case P_ROC_EVENT_TYPE_DMD:
@@ -219,7 +219,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
//fprintf(stderr, "\nBurst event"); //fprintf(stderr, "\nBurst event");
if (open) events[i].type = kPREventTypeBurstSwitchOpen; if (open) events[i].type = kPREventTypeBurstSwitchOpen;
else events[i].type = kPREventTypeBurstSwitchClosed; else events[i].type = kPREventTypeBurstSwitchClosed;
break; break;
} }
case P_ROC_EVENT_TYPE_ACCELEROMETER: case P_ROC_EVENT_TYPE_ACCELEROMETER:
@@ -255,8 +255,8 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
} }
default: events[i].type = kPREventTypeInvalid; default: events[i].type = kPREventTypeInvalid;
} }
} }
return i; return i;
} }
@@ -324,7 +324,7 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
int32_t rc; int32_t rc;
// Don't allow Constant Pulse (non-schedule with time = 0) for known high current drivers. // Don't allow Constant Pulse (non-schedule with time = 0) for known high current drivers.
// Note, the driver numbers depend on the driver group settings from DriverLoadMachineTypeDefaults. // Note, the driver numbers depend on the driver group settings from DriverLoadMachineTypeDefaults.
// TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults. // TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults.
DEBUG(PRLog(kPRLogInfo, "Updating driver #%d\n", driverState->driverNum)); DEBUG(PRLog(kPRLogInfo, "Updating driver #%d\n", driverState->driverNum));
@@ -347,10 +347,10 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
{ {
int i; int i;
PRResult res = kPRSuccess; PRResult res = kPRSuccess;
//const int WPCDriverLoopTime = 4; // milliseconds //const int WPCDriverLoopTime = 4; // milliseconds
//const int SternDriverLoopTime = 2; // milliseconds //const int SternDriverLoopTime = 2; // milliseconds
const int mappedWPCDriverGroupEnableIndex[] = {0, 0, 0, 0, 0, 2, 4, 3, 1, 5, 7, 7, 7, 7, 7, 7, 7, 7, 8, 0, 0, 0, 0, 0, 0, 0}; const int mappedWPCDriverGroupEnableIndex[] = {0, 0, 0, 0, 0, 2, 4, 3, 1, 5, 7, 7, 7, 7, 7, 7, 7, 7, 8, 0, 0, 0, 0, 0, 0, 0};
const int mappedSternDriverGroupEnableIndex[] = {0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9}; const int mappedSternDriverGroupEnableIndex[] = {0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9};
const bool mappedWPCDriverGroupPolarity[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}; const bool mappedWPCDriverGroupPolarity[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
@@ -361,9 +361,9 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
const int mappedSternDriverGroupSlowTime[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400}; const int mappedSternDriverGroupSlowTime[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400};
const int mappedWPCDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0}; const int mappedWPCDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0};
const int mappedSternDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; const int mappedSternDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7};
const int watchdogResetTime = 1000; // milliseconds const int watchdogResetTime = 1000; // milliseconds
int mappedDriverGroupEnableIndex[kPRDriverGroupsMax]; int mappedDriverGroupEnableIndex[kPRDriverGroupsMax];
bool mappedDriverGroupPolarity[kPRDriverGroupsMax]; bool mappedDriverGroupPolarity[kPRDriverGroupsMax];
int mappedDriverGroupSlowTime[kPRDriverGroupsMax]; int mappedDriverGroupSlowTime[kPRDriverGroupsMax];
@@ -380,51 +380,51 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
int rowEnableSelect; int rowEnableSelect;
int lastCoilDriverGroup; int lastCoilDriverGroup;
switch (machineType) switch (machineType)
{ {
case kPRMachineWPC: case kPRMachineWPC:
case kPRMachineWPC95: case kPRMachineWPC95:
case kPRMachineWPCAlphanumeric: case kPRMachineWPCAlphanumeric:
{ {
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex, memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex,
sizeof(mappedDriverGroupEnableIndex)); sizeof(mappedDriverGroupEnableIndex));
memcpy(mappedDriverGroupPolarity,mappedWPCDriverGroupPolarity, memcpy(mappedDriverGroupPolarity,mappedWPCDriverGroupPolarity,
sizeof(mappedDriverGroupPolarity)); sizeof(mappedDriverGroupPolarity));
rowEnableIndex1 = 6; // Unused in WPC rowEnableIndex1 = 6; // Unused in WPC
rowEnableIndex0 = 6; rowEnableIndex0 = 6;
tickleSternWatchdog = false; tickleSternWatchdog = false;
globalPolarity = false; globalPolarity = false;
activeLowMatrixRows = true; activeLowMatrixRows = true;
driverLoopTime = 4; // milliseconds driverLoopTime = 4; // milliseconds
memcpy(mappedDriverGroupSlowTime,mappedWPCDriverGroupSlowTime, memcpy(mappedDriverGroupSlowTime,mappedWPCDriverGroupSlowTime,
sizeof(mappedDriverGroupSlowTime)); sizeof(mappedDriverGroupSlowTime));
memcpy(mappedDriverGroupActivateIndex,mappedWPCDriverGroupActivateIndex, memcpy(mappedDriverGroupActivateIndex,mappedWPCDriverGroupActivateIndex,
sizeof(mappedDriverGroupActivateIndex)); sizeof(mappedDriverGroupActivateIndex));
numMatrixGroups = 8; numMatrixGroups = 8;
encodeEnables = false; encodeEnables = false;
rowEnableSelect = 0; rowEnableSelect = 0;
lastCoilDriverGroup = lastWPCCoilDriverGroup; lastCoilDriverGroup = lastWPCCoilDriverGroup;
break; break;
} }
case kPRMachineSternWhitestar: case kPRMachineSternWhitestar:
case kPRMachineSternSAM: case kPRMachineSternSAM:
{ {
memcpy(mappedDriverGroupEnableIndex,mappedSternDriverGroupEnableIndex, memcpy(mappedDriverGroupEnableIndex,mappedSternDriverGroupEnableIndex,
sizeof(mappedDriverGroupEnableIndex)); sizeof(mappedDriverGroupEnableIndex));
memcpy(mappedDriverGroupPolarity,mappedSternDriverGroupPolarity, memcpy(mappedDriverGroupPolarity,mappedSternDriverGroupPolarity,
sizeof(mappedDriverGroupPolarity)); sizeof(mappedDriverGroupPolarity));
rowEnableIndex1 = 6; // Unused in Stern rowEnableIndex1 = 6; // Unused in Stern
rowEnableIndex0 = 10; rowEnableIndex0 = 10;
tickleSternWatchdog = true; tickleSternWatchdog = true;
globalPolarity = true; globalPolarity = true;
activeLowMatrixRows = false; activeLowMatrixRows = false;
driverLoopTime = 1; // milliseconds driverLoopTime = 1; // milliseconds
memcpy(mappedDriverGroupSlowTime,mappedSternDriverGroupSlowTime, memcpy(mappedDriverGroupSlowTime,mappedSternDriverGroupSlowTime,
sizeof(mappedDriverGroupSlowTime)); sizeof(mappedDriverGroupSlowTime));
memcpy(mappedDriverGroupActivateIndex,mappedSternDriverGroupActivateIndex, memcpy(mappedDriverGroupActivateIndex,mappedSternDriverGroupActivateIndex,
sizeof(mappedDriverGroupActivateIndex)); sizeof(mappedDriverGroupActivateIndex));
numMatrixGroups = 16; numMatrixGroups = 16;
encodeEnables = true; encodeEnables = true;
rowEnableSelect = 0; rowEnableSelect = 0;
@@ -439,7 +439,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
return kPRSuccess; return kPRSuccess;
} }
memset(&driverGlobalConfig, 0x00, sizeof(PRDriverGlobalConfig)); memset(&driverGlobalConfig, 0x00, sizeof(PRDriverGlobalConfig));
for (i = 0; i < kPRDriverCount; i++) for (i = 0; i < kPRDriverCount; i++)
{ {
@@ -448,7 +448,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
driver->driverNum = i; driver->driverNum = i;
driver->polarity = mappedDriverGroupPolarity[i/8]; driver->polarity = mappedDriverGroupPolarity[i/8];
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Driver: %d is %x.", i,driver->polarity)); DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Driver: %d is %x.", i,driver->polarity));
if (resetFlags & kPRResetFlagUpdateDevice) if (resetFlags & kPRResetFlagUpdateDevice)
res = DriverUpdateState(driver); res = DriverUpdateState(driver);
} }
for (i = 0; i < kPRDriverGroupsMax; i++) for (i = 0; i < kPRDriverGroupsMax; i++)
@@ -458,11 +458,11 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
group->groupNum = i; group->groupNum = i;
group->polarity = mappedDriverGroupPolarity[i]; group->polarity = mappedDriverGroupPolarity[i];
} }
// Configure the groups. Each group corresponds to 8 consecutive drivers, starting // Configure the groups. Each group corresponds to 8 consecutive drivers, starting
// with driver #32. The following 6 groups are configured for coils/flashlamps. // with driver #32. The following 6 groups are configured for coils/flashlamps.
PRDriverGroupConfig group; PRDriverGroupConfig group;
for (i = 4; i <= lastCoilDriverGroup; i++) for (i = 4; i <= lastCoilDriverGroup; i++)
{ {
@@ -475,7 +475,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
group.polarity = mappedDriverGroupPolarity[i]; group.polarity = mappedDriverGroupPolarity[i];
group.active = 1; group.active = 1;
group.disableStrobeAfter = false; group.disableStrobeAfter = false;
if (resetFlags & kPRResetFlagUpdateDevice) { if (resetFlags & kPRResetFlagUpdateDevice) {
res = DriverUpdateGroupConfig(&group); res = DriverUpdateGroupConfig(&group);
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity)); DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity));
@@ -484,7 +484,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
driverGroups[i] = group; driverGroups[i] = group;
} }
// The following 8 groups are configured for the feature lamp matrix. // The following 8 groups are configured for the feature lamp matrix.
for (i = 10; i < 10 + numMatrixGroups; i++) { for (i = 10; i < 10 + numMatrixGroups; i++) {
DriverGetGroupConfig(i, &group); DriverGetGroupConfig(i, &group);
@@ -496,7 +496,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
group.polarity = mappedDriverGroupPolarity[i]; group.polarity = mappedDriverGroupPolarity[i];
group.active = 1; group.active = 1;
group.disableStrobeAfter = mappedDriverGroupSlowTime[i] != 0; group.disableStrobeAfter = mappedDriverGroupSlowTime[i] != 0;
if (resetFlags & kPRResetFlagUpdateDevice) { if (resetFlags & kPRResetFlagUpdateDevice) {
res = DriverUpdateGroupConfig(&group); res = DriverUpdateGroupConfig(&group);
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity)); DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity));
@@ -517,7 +517,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
group.polarity = mappedDriverGroupPolarity[i]; group.polarity = mappedDriverGroupPolarity[i];
group.active = 1; group.active = 1;
group.disableStrobeAfter = false; group.disableStrobeAfter = false;
if (resetFlags & kPRResetFlagUpdateDevice) { if (resetFlags & kPRResetFlagUpdateDevice) {
res = DriverUpdateGroupConfig(&group); res = DriverUpdateGroupConfig(&group);
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.\n", i,group.polarity)); DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.\n", i,group.polarity));
@@ -540,16 +540,16 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
globals.watchdogExpired = false; globals.watchdogExpired = false;
globals.watchdogEnable = true; globals.watchdogEnable = true;
globals.watchdogResetTime = watchdogResetTime; globals.watchdogResetTime = watchdogResetTime;
// We want to start up safely, so we'll update the global driver config twice. // 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: // When we toggle enableOutputs like this P-ROC will reset the polarity:
// Enable now without the outputs enabled: // Enable now without the outputs enabled:
if (resetFlags & kPRResetFlagUpdateDevice) if (resetFlags & kPRResetFlagUpdateDevice)
res = DriverUpdateGlobalConfig(&globals); res = DriverUpdateGlobalConfig(&globals);
else else
driverGlobalConfig = globals; driverGlobalConfig = globals;
// Now enable the outputs to protect against the polarity being driven incorrectly: // Now enable the outputs to protect against the polarity being driven incorrectly:
globals.enableOutputs = true; globals.enableOutputs = true;
if (resetFlags & kPRResetFlagUpdateDevice) if (resetFlags & kPRResetFlagUpdateDevice)
@@ -559,7 +559,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
// If WPCAlphanumeric, select Aux functionality for the dual-purpose Aux/DMD // If WPCAlphanumeric, select Aux functionality for the dual-purpose Aux/DMD
// pins. // pins.
managerConfig.reuse_dmd_data_for_aux = (machineType == kPRMachineWPCAlphanumeric); managerConfig.reuse_dmd_data_for_aux = (machineType == kPRMachineWPCAlphanumeric);
managerConfig.invert_dipswitch_1 = false; managerConfig.invert_dipswitch_1 = false;
ManagerUpdateConfig(&managerConfig); ManagerUpdateConfig(&managerConfig);
@@ -599,11 +599,11 @@ PRResult PRDevice::DriverWatchdogTickle()
const int burstWords = 2; const int burstWords = 2;
uint32_t burst[burstWords]; uint32_t burst[burstWords];
int32_t rc; int32_t rc;
rc = CreateWatchdogConfigBurst(burst, driverGlobalConfig.watchdogExpired, rc = CreateWatchdogConfigBurst(burst, driverGlobalConfig.watchdogExpired,
driverGlobalConfig.watchdogEnable, driverGlobalConfig.watchdogEnable,
driverGlobalConfig.watchdogResetTime); driverGlobalConfig.watchdogResetTime);
return PrepareWriteData(burst, burstWords); return PrepareWriteData(burst, burstWords);
} }
@@ -635,8 +635,8 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
// Updates a single rule with the associated linked driver state changes. // Updates a single rule with the associated linked driver state changes.
const int burstSize = 4; const int burstSize = 4;
uint32_t burst[burstSize]; uint32_t burst[burstSize];
// If more the base rule will link to others, ensure free indexes exists for // If more the base rule will link to others, ensure free indexes exists for
// the links. // the links.
if (numDrivers > 0 && freeSwitchRuleIndexes.size() < (uint32_t)(numDrivers-1)) // -1 because the first switch rule holds the first driver. if (numDrivers > 0 && freeSwitchRuleIndexes.size() < (uint32_t)(numDrivers-1)) // -1 because the first switch rule holds the first driver.
{ {
@@ -646,46 +646,46 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
PRResult res = kPRSuccess; PRResult res = kPRSuccess;
uint32_t newRuleIndex = CreateSwitchRuleIndex(switchNum, eventType); uint32_t newRuleIndex = CreateSwitchRuleIndex(switchNum, eventType);
// Because we're redefining the rule chain, we need to remove all previously existing links and return the indexes to the free list. // Because we're redefining the rule chain, we need to remove all previously existing links and return the indexes to the free list.
PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex); PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex);
uint16_t oldLinkIndex; uint16_t oldLinkIndex;
while (oldRule->linkActive) while (oldRule->linkActive)
{ {
// Save old link index so it can freed after the linked rule is retrieved. // Save old link index so it can freed after the linked rule is retrieved.
oldLinkIndex = oldRule->linkIndex; oldLinkIndex = oldRule->linkIndex;
oldRule = GetSwitchRuleByIndex(oldRule->linkIndex); oldRule = GetSwitchRuleByIndex(oldRule->linkIndex);
freeSwitchRuleIndexes.push(oldLinkIndex); freeSwitchRuleIndexes.push(oldLinkIndex);
if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory. if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory.
{ {
PRSetLastErrorText("Too many free switch rule indicies!"); PRSetLastErrorText("Too many free switch rule indicies!");
return kPRFailure; return kPRFailure;
} }
} }
// Create a pointer for new rules. // Create a pointer for new rules.
PRSwitchRuleInternal *newRule; PRSwitchRuleInternal *newRule;
// Process each driver who's state should change in response to the switch event. // Process each driver who's state should change in response to the switch event.
if (numDrivers > 0) if (numDrivers > 0)
{ {
uint32_t ruleIndex, savedRuleIndex; uint32_t ruleIndex, savedRuleIndex;
// Need to program the main rule last just in case drive_outputs_now is true. // Need to program the main rule last just in case drive_outputs_now is true.
// Otherwise, the hardware could try to access the linked rules before they're // Otherwise, the hardware could try to access the linked rules before they're
// programmed. So, program the rules in reverse order. // programmed. So, program the rules in reverse order.
// Move to last driver // Move to last driver
linkedDrivers += (numDrivers - 1); linkedDrivers += (numDrivers - 1);
int totalNumDrivers = numDrivers; int totalNumDrivers = numDrivers;
while (numDrivers > 0) while (numDrivers > 0)
{ {
if (numDrivers > 1) if (numDrivers > 1)
{ {
ruleIndex = freeSwitchRuleIndexes.front(); ruleIndex = freeSwitchRuleIndexes.front();
freeSwitchRuleIndexes.pop(); freeSwitchRuleIndexes.pop();
newRule = GetSwitchRuleByIndex(ruleIndex); newRule = GetSwitchRuleByIndex(ruleIndex);
newRule->driver = linkedDrivers[0]; newRule->driver = linkedDrivers[0];
@@ -741,7 +741,7 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
DEBUG(PRLog(kPRLogError, "Failed to disable.\n")); DEBUG(PRLog(kPRLogError, "Failed to disable.\n"));
return res; return res;
} }
linkedDrivers--; linkedDrivers--;
numDrivers--; numDrivers--;
} }
@@ -762,7 +762,7 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
// Write the rule: // Write the rule:
res = PrepareWriteData(burst, burstSize); res = PrepareWriteData(burst, burstSize);
} }
return res; return res;
} }
@@ -775,7 +775,7 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
// Request one state word and one debounce word at a time. Could make more efficient // Request one state word and one debounce word at a time. Could make more efficient
// use of the USB bus by requesting a burst of state words and then a burst of debounce // use of the USB bus by requesting a burst of state words and then a burst of debounce
// words, but doing one word at a time makes it easier to process each switch when the // words, but doing one word at a time makes it easier to process each switch when the
// data returns. Also, this function shouldn't be called during timing sensitive // data returns. Also, this function shouldn't be called during timing sensitive
// situations; so the inefficiencies are acceptable. // situations; so the inefficiencies are acceptable.
for (i = 0; i < numSwitches / 32; i++) for (i = 0; i < numSwitches / 32; i++)
@@ -783,36 +783,36 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
if (chip_id == P_ROC_CHIP_ID) if (chip_id == P_ROC_CHIP_ID)
{ {
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT, rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1); P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
if (combinedVersionRevision < P_ROC_VER_REV_FIXED_SWITCH_STATE_READS) { if (combinedVersionRevision < P_ROC_VER_REV_FIXED_SWITCH_STATE_READS) {
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT, rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P_ROC_SWITCH_CTRL_OLD_DEBOUNCE_BASE_ADDR + i, 1); P_ROC_SWITCH_CTRL_OLD_DEBOUNCE_BASE_ADDR + i, 1);
} }
else { else {
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT, rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1); P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
} }
} }
else // chip == P3_ROC_CHIP_ID) else // chip == P3_ROC_CHIP_ID)
{ {
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT, rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1); P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT, rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1); P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
} }
} }
// Expect 4 words for each 32 switches. The state and debounce words, // Expect 4 words for each 32 switches. The state and debounce words,
// and the address words for both. // and the address words for both.
uint16_t numWords = 4 * (numSwitches / 32); uint16_t numWords = 4 * (numSwitches / 32);
i = 0; // Reset i so it can be used to prevent an infinite loop below i = 0; // Reset i so it can be used to prevent an infinite loop below
// Wait for data to return. Give it 10 loops before giving up. // Wait for data to return. Give it 10 loops before giving up.
while (requestedDataQueue.size() < numWords && i++ < 10) while (requestedDataQueue.size() < numWords && i++ < 10)
{ {
PRSleep (10); // 10 milliseconds should be plenty of time. PRSleep (10); // 10 milliseconds should be plenty of time.
if (SortReturningData() != kPRSuccess) if (SortReturningData() != kPRSuccess)
@@ -820,7 +820,7 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
} }
// Make sure all of the requested words are available before processing them. // Make sure all of the requested words are available before processing them.
// Too many words is just as bad as not enough words. // Too many words is just as bad as not enough words.
// If too many come back, can they be trusted? // If too many come back, can they be trusted?
if (requestedDataQueue.size() == numWords) if (requestedDataQueue.size() == numWords)
{ {
@@ -829,10 +829,10 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
{ {
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word. requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
stateWord = requestedDataQueue.front(); // This is the switch state word. stateWord = requestedDataQueue.front(); // This is the switch state word.
requestedDataQueue.pop(); requestedDataQueue.pop();
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word. requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
debounceWord = requestedDataQueue.front(); // This is the debounce word. debounceWord = requestedDataQueue.front(); // This is the debounce word.
requestedDataQueue.pop(); requestedDataQueue.pop();
// Loop through each bit of the words, combining them into an eventType // Loop through each bit of the words, combining them into an eventType
for (j = 0; j < 32; j++) for (j = 0; j < 32; j++)
@@ -993,8 +993,8 @@ PRResult PRDevice::Open()
// Attempt to turn off events. This is necessary if P-ROC wasn't shut down // Attempt to turn off events. This is necessary if P-ROC wasn't shut down
// properly previously. If the P-ROC isn't initialized, this request will // properly previously. If the P-ROC isn't initialized, this request will
// be ignored. // be ignored.
PRDMDConfig dmdConfig; PRDMDConfig dmdConfig;
dmdConfig.numRows = 32; // Doesn't matter. dmdConfig.numRows = 32; // Doesn't matter.
dmdConfig.numColumns = 128; // Doesn't matter dmdConfig.numColumns = 128; // Doesn't matter
@@ -1016,7 +1016,7 @@ PRResult PRDevice::Open()
switchConfig.pulseHalfPeriodTime = 13; // milliseconds switchConfig.pulseHalfPeriodTime = 13; // milliseconds
SwitchUpdateConfig(&switchConfig); SwitchUpdateConfig(&switchConfig);
// Flush read data to ensure VerifyChipID starts with clean buffer. // Flush read data to ensure VerifyChipID starts with clean buffer.
// It's possible the P-ROC has a lot of data stored up in internal buffers. So if // It's possible the P-ROC has a lot of data stored up in internal buffers. So if
// the verify still fails, do a bunch of flushes. // the verify still fails, do a bunch of flushes.
res = FlushReadBuffer(); res = FlushReadBuffer();
@@ -1074,7 +1074,7 @@ PRResult PRDevice::VerifyChipID()
max_count = 0; max_count = 0;
// Wait for data to return. Give it 10 loops before giving up. // Wait for data to return. Give it 10 loops before giving up.
while (requestedDataQueue.size() < 5 && max_count++ < max_count_limit) while (requestedDataQueue.size() < 5 && max_count++ < max_count_limit)
{ {
PRSleep (10); // 10 milliseconds should be plenty of time. PRSleep (10); // 10 milliseconds should be plenty of time.
if (SortReturningData() != kPRSuccess) if (SortReturningData() != kPRSuccess)
@@ -1088,10 +1088,10 @@ PRResult PRDevice::VerifyChipID()
buffer[i] = requestedDataQueue.front(); buffer[i] = requestedDataQueue.front();
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address. requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
} }
if (buffer[1] != P_ROC_CHIP_ID && buffer[1] != P3_ROC_CHIP_ID) if (buffer[1] != P_ROC_CHIP_ID && buffer[1] != P3_ROC_CHIP_ID)
{ {
DEBUG(PRLog(kPRLogError, "Error in VerifyID(): Dumping buffer\n")); DEBUG(PRLog(kPRLogError, "Error in VerifyID(): Dumping buffer\n"));
for (i = 0; i < bufferWords; i++) for (i = 0; i < bufferWords; i++)
DEBUG(PRLog(kPRLogError, "buffer[%d]: 0x%x\n", i, buffer[i])); DEBUG(PRLog(kPRLogError, "buffer[%d]: 0x%x\n", i, buffer[i]));
rc = kPRFailure; rc = kPRFailure;
} }
@@ -1114,7 +1114,7 @@ PRResult PRDevice::VerifyChipID()
rc = kPRFailure; rc = kPRFailure;
} }
} }
else else
{ {
// Return failure without logging; calling function must log. // Return failure without logging; calling function must log.
DEBUG(PRLog(kPRLogError, "Verify Chip ID took too long to receive data\n")); DEBUG(PRLog(kPRLogError, "Verify Chip ID took too long to receive data\n"));
@@ -1132,7 +1132,7 @@ PRResult PRDevice::RequestData(uint32_t module_select, uint32_t start_addr, int3
PRResult PRDevice::PrepareWriteData(uint32_t * words, int32_t numWords) PRResult PRDevice::PrepareWriteData(uint32_t * words, int32_t numWords)
{ {
if (numWords > maxWriteWords) if (numWords > maxWriteWords)
{ {
PRSetLastErrorText("%d words Exceeds write capabilities. Restrict write requests to %d words.", numWords, maxWriteWords); PRSetLastErrorText("%d words Exceeds write capabilities. Restrict write requests to %d words.", numWords, maxWriteWords);
return kPRFailure; return kPRFailure;
} }
@@ -1195,7 +1195,7 @@ PRResult PRDevice::WriteData(uint32_t * words, int32_t numWords)
} }
} }
PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer) PRResult PRDevice::WriteDataRawUnbuffered(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{ {
PRResult res; PRResult res;
uint32_t * buffer; uint32_t * buffer;
@@ -1208,6 +1208,19 @@ PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, in
return res; return res;
} }
PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{
PRResult res;
uint32_t * buffer;
buffer = (uint32_t *)malloc((numWriteWords * 4) + 4);
buffer[0] = CreateBurstCommand(moduleSelect, startingAddr, numWriteWords);
memcpy(buffer+1, writeBuffer, numWriteWords * 4);
res = WriteData(buffer, numWriteWords + 1);
free (buffer);
return res;
}
PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer) PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
{ {
uint32_t rc; uint32_t rc;
@@ -1220,7 +1233,7 @@ PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int
// Wait for data to return. Give it 10 loops before giving up. // Wait for data to return. Give it 10 loops before giving up.
// Expect numReadWords + 1 word with the address. // Expect numReadWords + 1 word with the address.
while (requestedDataQueue.size() < (uint32_t)((numReadWords + 1)) && i++ < 10) while (requestedDataQueue.size() < (uint32_t)((numReadWords + 1)) && i++ < 10)
{ {
PRSleep (10); // 10 milliseconds should be plenty of time. PRSleep (10); // 10 milliseconds should be plenty of time.
if (SortReturningData() != kPRSuccess) if (SortReturningData() != kPRSuccess)
@@ -1228,15 +1241,15 @@ PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int
} }
// Make sure all of the requested words are available before processing them. // Make sure all of the requested words are available before processing them.
// Too many words is just as bad as not enough words. // Too many words is just as bad as not enough words.
// If too many come back, can they be trusted? // If too many come back, can they be trusted?
if (requestedDataQueue.size() == (uint32_t)(numReadWords + 1)) if (requestedDataQueue.size() == (uint32_t)(numReadWords + 1))
{ {
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address. requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
for (i = 0; i < numReadWords; i++) for (i = 0; i < numReadWords; i++)
{ {
readBuffer[i] = requestedDataQueue.front(); readBuffer[i] = requestedDataQueue.front();
requestedDataQueue.pop(); requestedDataQueue.pop();
} }
return kPRSuccess; return kPRSuccess;
} }
@@ -1282,7 +1295,7 @@ PRResult PRDevice::FlushReadBuffer()
numBytes = CollectReadData(); numBytes = CollectReadData();
k = 0; k = 0;
DEBUG(PRLog(kPRLogError, "Flushing Read Buffer: %d bytes trashed\n", numBytes)); 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);
// k++; // k++;

View File

@@ -60,6 +60,7 @@ public:
PRResult FlushWriteData(); PRResult FlushWriteData();
PRResult WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer); PRResult WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
PRResult WriteDataRawUnbuffered(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
PRResult ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer); PRResult ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
PRResult ManagerUpdateConfig(PRManagerConfig *managerConfig); PRResult ManagerUpdateConfig(PRManagerConfig *managerConfig);
@@ -108,7 +109,7 @@ protected:
// Raw write and read methods // Raw write and read methods
// //
/** Schedules data to be written to the P-ROC. */ /** Schedules data to be written to the P-ROC. */
PRResult PrepareWriteData(uint32_t * buffer, int32_t numWords); PRResult PrepareWriteData(uint32_t * buffer, int32_t numWords);
@@ -174,7 +175,7 @@ protected:
PRDriverGroupConfig driverGroups[maxDriverGroups]; PRDriverGroupConfig driverGroups[maxDriverGroups];
PRDriverState drivers[maxDrivers]; PRDriverState drivers[maxDrivers];
PRDMDConfig dmdConfig; PRDMDConfig dmdConfig;
PRSwitchConfig switchConfig; PRSwitchConfig switchConfig;
PRSwitchRuleInternal switchRules[maxSwitchRules]; PRSwitchRuleInternal switchRules[maxSwitchRules];
queue<uint32_t> freeSwitchRuleIndexes; /**< Indexes of available switch rules. */ queue<uint32_t> freeSwitchRuleIndexes; /**< Indexes of available switch rules. */

View File

@@ -51,7 +51,7 @@ void PRLog(PRLogLevel level, const char *format, ...)
{ {
if (level < logLevel) if (level < logLevel)
return; return;
char line[MAX_TEXT]; char line[MAX_TEXT];
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
@@ -119,12 +119,18 @@ PRResult PRFlushWriteData(PRHandle handle)
return handleAsDevice->FlushWriteData(); return handleAsDevice->FlushWriteData();
} }
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData */ /** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer) PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{ {
return handleAsDevice->WriteDataRaw(moduleSelect, startingAddr, numWriteWords, writeBuffer); return handleAsDevice->WriteDataRaw(moduleSelect, startingAddr, numWriteWords, writeBuffer);
} }
/** Write data buffered to P-ROC (does require a call to PRFlushWriteData). */
PRResult PRWriteDataUnbuffered(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{
return handleAsDevice->WriteDataRawUnbuffered(moduleSelect, startingAddr, numWriteWords, writeBuffer);
}
/** Read data from the P-ROC. */ /** Read data from the P-ROC. */
PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer) PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
{ {
@@ -358,8 +364,8 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
else if ( strlen(str) == 4) else if ( strlen(str) == 4)
x = (str[2]-'0') * 10 + (str[3]-'0'); x = (str[2]-'0') * 10 + (str[3]-'0');
else return atoi(str); else return atoi(str);
if ((machineType == kPRMachineWPC) || if ((machineType == kPRMachineWPC) ||
(machineType == kPRMachineWPC95) || (machineType == kPRMachineWPC95) ||
(machineType == kPRMachineWPCAlphanumeric)) (machineType == kPRMachineWPCAlphanumeric))
{ {
@@ -381,7 +387,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
case 'm': case 'm':
return 32; return 32;
default: default:
return 33; return 33;
} }
default: default:
switch (str[3]) switch (str[3])
@@ -390,7 +396,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
case 'm': case 'm':
return 34; return 34;
default: default:
return 35; return 35;
} }
} }
default: default:
@@ -404,7 +410,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
case 'm': case 'm':
return 36; return 36;
default: default:
return 37; return 37;
} }
default: default:
switch (str[3]) switch (str[3])
@@ -413,7 +419,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
case 'm': case 'm':
return 38; return 38;
default: default:
return 39; return 39;
} }
} }
} }
@@ -432,7 +438,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
if (machineType == kPRMachineWPC95) if (machineType == kPRMachineWPC95)
//return x + 7; //return x + 7;
return x + 31; return x + 31;
else else
return x + 107; // WPC 37-44 use 8-driver board (mapped to drivers 144-151) return x + 107; // WPC 37-44 use 8-driver board (mapped to drivers 144-151)
} }
else return x + 108; else return x + 108;
@@ -473,7 +479,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
{ {
case 'D': case 'D':
case 'd': case 'd':
if (strlen(str) == 3) if (strlen(str) == 3)
return (str[2]-'0') + 7; return (str[2]-'0') + 7;
else return x + 7; else return x + 7;
default: default:
@@ -502,7 +508,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
{ {
case 'D': case 'D':
case 'd': case 'd':
if (strlen(str) == 3) if (strlen(str) == 3)
return (str[2]-'0') + 7; return (str[2]-'0') + 7;
else return x + 7; else return x + 7;
default: default: