mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Merge branch 'dev' of git@github.com:preble/libpinproc into dev
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#ifndef __WIND32__
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
PRDevice::PRDevice(PRMachineType machineType) : machineType(machineType)
|
||||
{
|
||||
@@ -264,9 +266,9 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
|
||||
// Note, the driver numbers depend on the driver group settings from DriverLoadMachineTypeDefaults.
|
||||
// TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults.
|
||||
switch (readMachineType) {
|
||||
kPRMachineWPC:
|
||||
kPRMachineWPC95:
|
||||
kPRMachineWPCAlphanumeric:{
|
||||
case kPRMachineWPC:
|
||||
case kPRMachineWPC95:
|
||||
case kPRMachineWPCAlphanumeric:{
|
||||
if ((driverState->driverNum >= 40 && driverState->driverNum <= 47) ||
|
||||
(driverState->driverNum == 32) ||
|
||||
(driverState->driverNum == 34) ||
|
||||
@@ -276,8 +278,8 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
|
||||
}
|
||||
break;
|
||||
}
|
||||
kPRMachineSternWhitestar:
|
||||
kPRMachineSternSAM: {
|
||||
case kPRMachineSternWhitestar:
|
||||
case kPRMachineSternSAM: {
|
||||
if (driverState->driverNum >= 32 && driverState->driverNum <= 47) {
|
||||
if (driverState->timeslots == 0 && driverState->outputDriveTime == 0) return kPRFailure;
|
||||
}
|
||||
@@ -588,7 +590,7 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
||||
|
||||
// If more the base rule will link to others, ensure free indexes exists for
|
||||
// the links.
|
||||
if (numDrivers > 0 && freeSwitchRuleIndexes.size() < 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.
|
||||
{
|
||||
PRSetLastErrorText("Not enough free switch rule indexes: %d available, need %d", freeSwitchRuleIndexes.size(), numDrivers);
|
||||
return kPRFailure;
|
||||
@@ -881,7 +883,7 @@ PRResult PRDevice::PRJTAGGetStatus(PRJTAGStatus * status)
|
||||
|
||||
PRResult PRDevice::Open()
|
||||
{
|
||||
uint32_t temp_word,i;
|
||||
uint32_t temp_word;
|
||||
PRResult res = PRHardwareOpen();
|
||||
if (res == kPRSuccess)
|
||||
{
|
||||
@@ -961,7 +963,7 @@ PRResult PRDevice::VerifyChipID()
|
||||
{
|
||||
PRResult rc;
|
||||
const int bufferWords = 5;
|
||||
uint32_t buffer[bufferWords];
|
||||
uint32_t buffer[bufferWords] = {0};
|
||||
//uint32_t temp_word;
|
||||
uint32_t max_count, i;
|
||||
const uint32_t max_count_limit = 10;
|
||||
@@ -1119,7 +1121,7 @@ PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int
|
||||
|
||||
// Wait for data to return. Give it 10 loops before giving up.
|
||||
// Expect numReadWords + 1 word with the address.
|
||||
while (requestedDataQueue.size() < (numReadWords + 1) && i++ < 10)
|
||||
while (requestedDataQueue.size() < (uint32_t)((numReadWords + 1)) && i++ < 10)
|
||||
{
|
||||
PRSleep (10); // 10 milliseconds should be plenty of time.
|
||||
if (SortReturningData() != kPRSuccess)
|
||||
@@ -1129,7 +1131,7 @@ PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int
|
||||
// Make sure all of the requested words are available before processing them.
|
||||
// Too many words is just as bad as not enough words.
|
||||
// If too many come back, can they be trusted?
|
||||
if (requestedDataQueue.size() == numReadWords + 1)
|
||||
if (requestedDataQueue.size() == (uint32_t)(numReadWords + 1))
|
||||
{
|
||||
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
|
||||
for (i = 0; i < numReadWords; i++)
|
||||
@@ -1176,7 +1178,7 @@ int32_t PRDevice::ReadData(uint32_t *buffer, int32_t num_words)
|
||||
|
||||
PRResult PRDevice::FlushReadBuffer()
|
||||
{
|
||||
int32_t numBytes,rc,k;
|
||||
int32_t numBytes,rc=0,k;
|
||||
//uint32_t rd_buffer[3];
|
||||
numBytes = CollectReadData();
|
||||
k = 0;
|
||||
@@ -1260,6 +1262,7 @@ PRResult PRDevice::SortReturningData()
|
||||
int PRDevice::CalcCombinedVerRevision()
|
||||
{
|
||||
combinedVersionRevision = (version * 0x10000) + revision;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PRDevice::GetVersionInfo(uint16_t *verPtr, uint16_t *revPtr, uint16_t *combinedPtr)
|
||||
@@ -1267,4 +1270,5 @@ int PRDevice::GetVersionInfo(uint16_t *verPtr, uint16_t *revPtr, uint16_t *combi
|
||||
*verPtr = version;
|
||||
*revPtr = revision;
|
||||
*combinedPtr = combinedVersionRevision;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -553,11 +553,11 @@ int PRHardwareRead(uint8_t *buffer, int maxBytes)
|
||||
ftStatus = FT_GetQueueStatus(ftHandle,&bytesToRead);
|
||||
if (ftStatus != FT_OK) return 0;
|
||||
|
||||
if (maxBytes < bytesToRead) bytesToRead = maxBytes;
|
||||
if ((DWORD)maxBytes < bytesToRead) bytesToRead = maxBytes;
|
||||
ftStatus = FT_Read(ftHandle, buffer, bytesToRead, &bytesRead);
|
||||
if (ftStatus == FT_OK) {
|
||||
DEBUG(PRLog(kPRLogVerbose,"Read %d bytes:\n",bytesRead));
|
||||
for (i=0; i<bytesRead; i++) {
|
||||
for (i=0; (DWORD)i<bytesRead; i++) {
|
||||
DEBUG(PRLog(kPRLogVerbose,"Read byte: %x\n",buffer[i]));
|
||||
}
|
||||
return (int)bytesRead;
|
||||
@@ -578,7 +578,7 @@ int PRHardwareWrite(uint8_t *buffer, int bytes)
|
||||
DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes:\n",bytesWritten));
|
||||
if (bytesWritten != bytes) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes));
|
||||
else {
|
||||
for (i=0; i<bytesWritten; i++) {
|
||||
for (i=0; (DWORD)i<bytesWritten; i++) {
|
||||
DEBUG(PRLog(kPRLogVerbose,"Wrote byte: %x\n",buffer[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,35 +175,35 @@ PR_EXPORT PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum)
|
||||
return handleAsDevice->DriverUpdateGroupConfig(&driverGroup);
|
||||
}
|
||||
// Driver Helper functions:
|
||||
PR_EXPORT PRResult PRDriverDisable(PRHandle handle, uint16_t driverNum)
|
||||
PR_EXPORT PRResult PRDriverDisable(PRHandle handle, uint8_t driverNum)
|
||||
{
|
||||
PRDriverState driver;
|
||||
handleAsDevice->DriverGetState(driverNum, &driver);
|
||||
PRDriverStateDisable(&driver);
|
||||
return handleAsDevice->DriverUpdateState(&driver);
|
||||
}
|
||||
PR_EXPORT PRResult PRDriverPulse(PRHandle handle, uint16_t driverNum, uint8_t milliseconds)
|
||||
PR_EXPORT PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds)
|
||||
{
|
||||
PRDriverState driver;
|
||||
handleAsDevice->DriverGetState(driverNum, &driver);
|
||||
PRDriverStatePulse(&driver, milliseconds);
|
||||
return handleAsDevice->DriverUpdateState(&driver);
|
||||
}
|
||||
PR_EXPORT PRResult PRDriverSchedule(PRHandle handle, uint16_t driverNum, uint32_t schedule, uint8_t cycleSeconds, bool_t now)
|
||||
PR_EXPORT PRResult PRDriverSchedule(PRHandle handle, uint8_t driverNum, uint32_t schedule, uint8_t cycleSeconds, bool_t now)
|
||||
{
|
||||
PRDriverState driver;
|
||||
handleAsDevice->DriverGetState(driverNum, &driver);
|
||||
PRDriverStateSchedule(&driver, schedule, cycleSeconds, now);
|
||||
return handleAsDevice->DriverUpdateState(&driver);
|
||||
}
|
||||
PR_EXPORT PRResult PRDriverPatter(PRHandle handle, uint16_t driverNum, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t originalOnTime)
|
||||
PR_EXPORT PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime)
|
||||
{
|
||||
PRDriverState driver;
|
||||
handleAsDevice->DriverGetState(driverNum, &driver);
|
||||
PRDriverStatePatter(&driver, millisecondsOn, millisecondsOff, originalOnTime);
|
||||
return handleAsDevice->DriverUpdateState(&driver);
|
||||
}
|
||||
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint16_t driverNum, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t duration)
|
||||
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t duration)
|
||||
{
|
||||
PRDriverState driver;
|
||||
handleAsDevice->DriverGetState(driverNum, &driver);
|
||||
@@ -296,7 +296,7 @@ PR_EXPORT void PRDriverStateSchedule(PRDriverState *driver, uint32_t schedule, u
|
||||
driver->patterOffTime = 0;
|
||||
driver->patterEnable = false;
|
||||
}
|
||||
PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t originalOnTime)
|
||||
PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime)
|
||||
{
|
||||
driver->state = true;
|
||||
driver->timeslots = 0;
|
||||
@@ -307,7 +307,7 @@ PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint16_t millisecondsO
|
||||
driver->patterEnable = true;
|
||||
}
|
||||
|
||||
PR_EXPORT void PRDriverStatePulsedPatter(PRDriverState *driver, uint16_t millisecondsOn, uint16_t millisecondsOff, uint16_t patterTime)
|
||||
PR_EXPORT void PRDriverStatePulsedPatter(PRDriverState *driver, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime)
|
||||
{
|
||||
driver->state = false;
|
||||
driver->timeslots = 0;
|
||||
|
||||
Reference in New Issue
Block a user