mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Added kPRMachineTypeWPCAlphanumeric to differentiate between WPC machines needing an Aux port for alphanumeric control versus those using a DMD. Also added default driver code to configure the FPGA's Manager Config register.
This commit is contained in:
@@ -65,11 +65,16 @@ PRDevice* PRDevice::Create(PRMachineType machineType)
|
||||
if (machineType != kPRMachineCustom &&
|
||||
|
||||
// Don't accept if requested type is WPC/WPC95 but read machine is not.
|
||||
( ((machineType == kPRMachineWPC) || (machineType == kPRMachineWPC95)) &&
|
||||
( (((machineType == kPRMachineWPC) ||
|
||||
(machineType == kPRMachineWPC95) ||
|
||||
(machineType == kPRMachineWPCAlphanumeric)) &&
|
||||
(readMachineType != kPRMachineWPC &&
|
||||
readMachineType != kPRMachineWPC95) ||
|
||||
readMachineType != kPRMachineWPC95 &&
|
||||
readMachineType != kPRMachineWPCAlphanumeric)) ||
|
||||
// Also don't accept if the requested is not WPC/WPC95 but the P-ROC is.
|
||||
(machineType != kPRMachineWPC && machineType != kPRMachineWPC95 &&
|
||||
(machineType != kPRMachineWPC &&
|
||||
machineType != kPRMachineWPC95 &&
|
||||
machineType != kPRMachineWPCAlphanumeric &&
|
||||
readMachineType == kPRMachineWPC) ) )
|
||||
{
|
||||
dev->Close();
|
||||
@@ -189,6 +194,17 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
||||
return i;
|
||||
}
|
||||
|
||||
PRResult PRDevice::ManagerUpdateConfig(PRManagerConfig *managerConfig)
|
||||
{
|
||||
const int burstWords = 2;
|
||||
uint32_t burst[burstWords];
|
||||
int32_t rc;
|
||||
DEBUG(PRLog(kPRLogInfo, "Setting Manager Config Register\n"));
|
||||
this->managerConfig = *managerConfig;
|
||||
rc = CreateManagerUpdateConfigBurst(burst, managerConfig);
|
||||
return PrepareWriteData(burst, burstWords);
|
||||
}
|
||||
|
||||
PRResult PRDevice::DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalConfig)
|
||||
{
|
||||
const int burstWords = 4;
|
||||
@@ -245,7 +261,8 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
|
||||
// TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults.
|
||||
switch (readMachineType) {
|
||||
kPRMachineWPC:
|
||||
kPRMachineWPC95: {
|
||||
kPRMachineWPC95:
|
||||
kPRMachineWPCAlphanumeric:{
|
||||
if ((driverState->driverNum >= 40 && driverState->driverNum <= 47) ||
|
||||
(driverState->driverNum == 32) ||
|
||||
(driverState->driverNum == 34) ||
|
||||
@@ -321,6 +338,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
||||
{
|
||||
case kPRMachineWPC:
|
||||
case kPRMachineWPC95:
|
||||
case kPRMachineWPCAlphanumeric:
|
||||
{
|
||||
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex,
|
||||
sizeof(mappedDriverGroupEnableIndex));
|
||||
@@ -485,6 +503,13 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
||||
else
|
||||
driverGlobalConfig = globals;
|
||||
|
||||
// If WPCAlphanumeric, select Aux functionality for the dual-purpose Aux/DMD
|
||||
// pins.
|
||||
|
||||
managerConfig.reuse_dmd_data_for_aux = (machineType == kPRMachineWPCAlphanumeric);
|
||||
managerConfig.invert_dipswitch_1 = false;
|
||||
ManagerUpdateConfig(&managerConfig);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
PRResult WriteDataRaw(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 ManagerUpdateConfig(PRManagerConfig *managerConfig);
|
||||
|
||||
PRResult DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalConfig);
|
||||
PRResult DriverGetGroupConfig(uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig);
|
||||
PRResult DriverUpdateGroupConfig(PRDriverGroupConfig *driverGroupConfig);
|
||||
@@ -154,6 +156,7 @@ protected:
|
||||
|
||||
// Local Device State
|
||||
PRMachineType machineType;
|
||||
PRManagerConfig managerConfig;
|
||||
PRDriverGlobalConfig driverGlobalConfig;
|
||||
PRDriverGroupConfig driverGroups[maxDriverGroups];
|
||||
PRDriverState drivers[maxDrivers];
|
||||
|
||||
@@ -54,6 +54,19 @@ uint32_t CreateBurstCommand ( uint32_t select, uint32_t addr, uint32_t num_words
|
||||
(addr << P_ROC_ADDR_SHIFT) );
|
||||
}
|
||||
|
||||
int32_t CreateManagerUpdateConfigBurst ( uint32_t * burst, PRManagerConfig *manager_config) {
|
||||
uint32_t addr;
|
||||
|
||||
addr = P_ROC_REG_DIPSWITCH_ADDR;
|
||||
burst[0] = CreateBurstCommand (P_ROC_MANAGER_SELECT, addr, 1 );
|
||||
burst[1] = ( (manager_config->reuse_dmd_data_for_aux <<
|
||||
P_ROC_MANAGER_REUSE_DMD_DATA_FOR_AUX_SHIFT) |
|
||||
(manager_config->invert_dipswitch_1 <<
|
||||
P_ROC_MANAGER_INVERT_DIPSWITCH_1_SHIFT) );
|
||||
|
||||
return kPRSuccess;
|
||||
}
|
||||
|
||||
int32_t CreateDriverUpdateGlobalConfigBurst ( uint32_t * burst, PRDriverGlobalConfig *driver_globals) {
|
||||
uint32_t addr;
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ const uint32_t P_ROC_REG_DIPSWITCH_ADDR = 3;
|
||||
const uint32_t P_ROC_MANAGER_WATCHDOG_EXPIRED_SHIFT = 30;
|
||||
const uint32_t P_ROC_MANAGER_WATCHDOG_ENABLE_SHIFT = 14;
|
||||
const uint32_t P_ROC_MANAGER_WATCHDOG_RESET_TIME_SHIFT = 0;
|
||||
const uint32_t P_ROC_MANAGER_REUSE_DMD_DATA_FOR_AUX_SHIFT = 10;
|
||||
const uint32_t P_ROC_MANAGER_INVERT_DIPSWITCH_1_SHIFT = 9;
|
||||
|
||||
const uint32_t P_ROC_JTAG_SHIFT_EXIT_SHIFT = 16;
|
||||
const uint32_t P_ROC_JTAG_SHIFT_NUM_BITS_SHIFT = 0;
|
||||
@@ -241,6 +243,7 @@ typedef struct PRSwitchRuleInternal {
|
||||
bool_t IsStern (uint32_t hardware_data);
|
||||
uint32_t CreateRegRequestWord( uint32_t select, uint32_t addr, uint32_t num_words);
|
||||
uint32_t CreateBurstCommand ( uint32_t select, uint32_t addr, uint32_t num_words);
|
||||
int32_t CreateManagerUpdateConfigBurst ( uint32_t * burst, PRManagerConfig *manager_config);
|
||||
int32_t CreateDriverUpdateGlobalConfigBurst ( uint32_t * burst, PRDriverGlobalConfig *driver_globals);
|
||||
int32_t CreateDriverUpdateGroupConfigBurst ( uint32_t * burst, PRDriverGroupConfig *driver_group);
|
||||
int32_t CreateDriverUpdateBurst ( uint32_t * burst, PRDriverState *driver);
|
||||
|
||||
@@ -131,6 +131,12 @@ PR_EXPORT int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents)
|
||||
return handleAsDevice->GetEvents(eventsOut, maxEvents);
|
||||
}
|
||||
|
||||
// Manager
|
||||
PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig)
|
||||
{
|
||||
return handleAsDevice->ManagerUpdateConfig(managerConfig);
|
||||
}
|
||||
|
||||
// Drivers
|
||||
PR_EXPORT PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig)
|
||||
{
|
||||
@@ -302,7 +308,9 @@ PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
|
||||
x = (str[2]-'0') * 10 + (str[3]-'0');
|
||||
else return atoi(str);
|
||||
|
||||
if ((machineType == kPRMachineWPC) || (machineType == kPRMachineWPC95))
|
||||
if ((machineType == kPRMachineWPC) ||
|
||||
(machineType == kPRMachineWPC95) ||
|
||||
(machineType == kPRMachineWPCAlphanumeric))
|
||||
{
|
||||
switch (str[0])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user