mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Keep track of chip_id and use it when retrieving switch states.
This commit is contained in:
@@ -164,7 +164,10 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
||||
int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
||||
{
|
||||
if (SortReturningData() != kPRSuccess)
|
||||
{
|
||||
PRSetLastErrorText("GetEvents ERROR: Error in CollectReadData");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// The unrequestedDataQueue only has unrequested switch event data. Pop
|
||||
// events out 1 at a time, interpret them, and populate the outgoing list with them.
|
||||
@@ -795,6 +798,9 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
|
||||
// data returns. Also, this function shouldn't be called during timing sensitive
|
||||
// situations; so the inefficiencies are acceptable.
|
||||
for (i = 0; i < numSwitches / 32; i++)
|
||||
{
|
||||
|
||||
if (chip_id == P_ROC_CHIP_ID)
|
||||
{
|
||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||
P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
||||
@@ -808,6 +814,15 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
|
||||
P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
||||
}
|
||||
}
|
||||
else // chip == P3_ROC_CHIP_ID)
|
||||
{
|
||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||
P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
||||
|
||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||
P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Expect 4 words for each 32 switches. The state and debounce words,
|
||||
// and the address words for both.
|
||||
@@ -1102,6 +1117,7 @@ PRResult PRDevice::VerifyChipID()
|
||||
else rc = kPRSuccess;
|
||||
//std::cout << rc << " words read. \n"
|
||||
DEBUG(PRLog(kPRLogError, "FPGA Chip ID: 0x%x\n", buffer[1]));
|
||||
chip_id = buffer[1];
|
||||
revision = buffer[2] & 0xffff;
|
||||
version = buffer[2] >> 16;
|
||||
CalcCombinedVerRevision();
|
||||
|
||||
@@ -147,6 +147,7 @@ protected:
|
||||
|
||||
uint16_t version;
|
||||
uint16_t revision;
|
||||
uint32_t chip_id;
|
||||
uint32_t combinedVersionRevision;
|
||||
/**
|
||||
* Calculated combined Version/Revision number.
|
||||
|
||||
@@ -154,6 +154,8 @@ const uint32_t P_ROC_JTAG_TDI_MEMORY_BASE_ADDR = 0x800;
|
||||
const uint32_t P_ROC_SWITCH_CTRL_STATE_BASE_ADDR = 4;
|
||||
const uint32_t P_ROC_SWITCH_CTRL_OLD_DEBOUNCE_BASE_ADDR = 11;
|
||||
const uint32_t P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR = 12;
|
||||
const uint32_t P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR = 16;
|
||||
const uint32_t P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR = 32;
|
||||
|
||||
const uint32_t P_ROC_EVENT_TYPE_SWITCH = 0;
|
||||
const uint32_t P_ROC_EVENT_TYPE_DMD = 1;
|
||||
|
||||
Reference in New Issue
Block a user