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:
@@ -181,6 +181,10 @@ int main(int argc, const char **argv)
|
|||||||
yamlDoc["PRGame"]["machineType"] >> machineTypeString;
|
yamlDoc["PRGame"]["machineType"] >> machineTypeString;
|
||||||
if (machineTypeString == "wpc")
|
if (machineTypeString == "wpc")
|
||||||
machineType = kPRMachineWPC;
|
machineType = kPRMachineWPC;
|
||||||
|
else if (machineTypeString == "wpc95")
|
||||||
|
machineType = kPRMachineWPC95;
|
||||||
|
else if (machineTypeString == "wpcAlphanumeric")
|
||||||
|
machineType = kPRMachineWPCAlphanumeric;
|
||||||
else if(machineTypeString == "sternWhitestar")
|
else if(machineTypeString == "sternWhitestar")
|
||||||
machineType = kPRMachineSternWhitestar;
|
machineType = kPRMachineSternWhitestar;
|
||||||
else if(machineTypeString == "sternSAM")
|
else if(machineTypeString == "sternSAM")
|
||||||
|
|||||||
@@ -95,10 +95,11 @@ PR_EXPORT const char *PRGetLastErrorText();
|
|||||||
typedef enum PRMachineType {
|
typedef enum PRMachineType {
|
||||||
kPRMachineInvalid = 0,
|
kPRMachineInvalid = 0,
|
||||||
kPRMachineCustom = 1,
|
kPRMachineCustom = 1,
|
||||||
kPRMachineWPC = 2,
|
kPRMachineWPCAlphanumeric = 2,
|
||||||
kPRMachineWPC95 = 3,
|
kPRMachineWPC = 3,
|
||||||
kPRMachineSternWhitestar = 4,
|
kPRMachineWPC95 = 4,
|
||||||
kPRMachineSternSAM = 5,
|
kPRMachineSternWhitestar = 5,
|
||||||
|
kPRMachineSternSAM = 6,
|
||||||
} PRMachineType;
|
} PRMachineType;
|
||||||
|
|
||||||
// PRHandle Creation and Deletion
|
// PRHandle Creation and Deletion
|
||||||
@@ -128,6 +129,19 @@ PR_EXPORT PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t
|
|||||||
/** Read data from the P-ROC. */
|
/** Read data from the P-ROC. */
|
||||||
PR_EXPORT PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
PR_EXPORT PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
||||||
|
|
||||||
|
// Manager
|
||||||
|
/** @defgroup Manager
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct PRManagerConfig {
|
||||||
|
bool_t reuse_dmd_data_for_aux;
|
||||||
|
bool_t invert_dipswitch_1;
|
||||||
|
} PRManagerConfig;
|
||||||
|
|
||||||
|
/** Update Manager configuration */
|
||||||
|
PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig);
|
||||||
|
|
||||||
// Drivers
|
// Drivers
|
||||||
/** @defgroup drivers Driver Manipulation
|
/** @defgroup drivers Driver Manipulation
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
@@ -65,11 +65,16 @@ PRDevice* PRDevice::Create(PRMachineType machineType)
|
|||||||
if (machineType != kPRMachineCustom &&
|
if (machineType != kPRMachineCustom &&
|
||||||
|
|
||||||
// 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 == kPRMachineWPC95)) &&
|
( (((machineType == kPRMachineWPC) ||
|
||||||
|
(machineType == kPRMachineWPC95) ||
|
||||||
|
(machineType == kPRMachineWPCAlphanumeric)) &&
|
||||||
(readMachineType != kPRMachineWPC &&
|
(readMachineType != kPRMachineWPC &&
|
||||||
readMachineType != kPRMachineWPC95) ||
|
readMachineType != kPRMachineWPC95 &&
|
||||||
|
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 != kPRMachineWPC95 &&
|
(machineType != kPRMachineWPC &&
|
||||||
|
machineType != kPRMachineWPC95 &&
|
||||||
|
machineType != kPRMachineWPCAlphanumeric &&
|
||||||
readMachineType == kPRMachineWPC) ) )
|
readMachineType == kPRMachineWPC) ) )
|
||||||
{
|
{
|
||||||
dev->Close();
|
dev->Close();
|
||||||
@@ -189,6 +194,17 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
return i;
|
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)
|
PRResult PRDevice::DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalConfig)
|
||||||
{
|
{
|
||||||
const int burstWords = 4;
|
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.
|
// TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults.
|
||||||
switch (readMachineType) {
|
switch (readMachineType) {
|
||||||
kPRMachineWPC:
|
kPRMachineWPC:
|
||||||
kPRMachineWPC95: {
|
kPRMachineWPC95:
|
||||||
|
kPRMachineWPCAlphanumeric:{
|
||||||
if ((driverState->driverNum >= 40 && driverState->driverNum <= 47) ||
|
if ((driverState->driverNum >= 40 && driverState->driverNum <= 47) ||
|
||||||
(driverState->driverNum == 32) ||
|
(driverState->driverNum == 32) ||
|
||||||
(driverState->driverNum == 34) ||
|
(driverState->driverNum == 34) ||
|
||||||
@@ -321,6 +338,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
{
|
{
|
||||||
case kPRMachineWPC:
|
case kPRMachineWPC:
|
||||||
case kPRMachineWPC95:
|
case kPRMachineWPC95:
|
||||||
|
case kPRMachineWPCAlphanumeric:
|
||||||
{
|
{
|
||||||
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex,
|
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex,
|
||||||
sizeof(mappedDriverGroupEnableIndex));
|
sizeof(mappedDriverGroupEnableIndex));
|
||||||
@@ -485,6 +503,13 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
else
|
else
|
||||||
driverGlobalConfig = globals;
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
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 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 DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalConfig);
|
PRResult DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalConfig);
|
||||||
PRResult DriverGetGroupConfig(uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig);
|
PRResult DriverGetGroupConfig(uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig);
|
||||||
PRResult DriverUpdateGroupConfig(PRDriverGroupConfig *driverGroupConfig);
|
PRResult DriverUpdateGroupConfig(PRDriverGroupConfig *driverGroupConfig);
|
||||||
@@ -154,6 +156,7 @@ protected:
|
|||||||
|
|
||||||
// Local Device State
|
// Local Device State
|
||||||
PRMachineType machineType;
|
PRMachineType machineType;
|
||||||
|
PRManagerConfig managerConfig;
|
||||||
PRDriverGlobalConfig driverGlobalConfig;
|
PRDriverGlobalConfig driverGlobalConfig;
|
||||||
PRDriverGroupConfig driverGroups[maxDriverGroups];
|
PRDriverGroupConfig driverGroups[maxDriverGroups];
|
||||||
PRDriverState drivers[maxDrivers];
|
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) );
|
(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) {
|
int32_t CreateDriverUpdateGlobalConfigBurst ( uint32_t * burst, PRDriverGlobalConfig *driver_globals) {
|
||||||
uint32_t addr;
|
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_EXPIRED_SHIFT = 30;
|
||||||
const uint32_t P_ROC_MANAGER_WATCHDOG_ENABLE_SHIFT = 14;
|
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_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_EXIT_SHIFT = 16;
|
||||||
const uint32_t P_ROC_JTAG_SHIFT_NUM_BITS_SHIFT = 0;
|
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);
|
bool_t IsStern (uint32_t hardware_data);
|
||||||
uint32_t CreateRegRequestWord( uint32_t select, uint32_t addr, uint32_t num_words);
|
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);
|
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 CreateDriverUpdateGlobalConfigBurst ( uint32_t * burst, PRDriverGlobalConfig *driver_globals);
|
||||||
int32_t CreateDriverUpdateGroupConfigBurst ( uint32_t * burst, PRDriverGroupConfig *driver_group);
|
int32_t CreateDriverUpdateGroupConfigBurst ( uint32_t * burst, PRDriverGroupConfig *driver_group);
|
||||||
int32_t CreateDriverUpdateBurst ( uint32_t * burst, PRDriverState *driver);
|
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);
|
return handleAsDevice->GetEvents(eventsOut, maxEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manager
|
||||||
|
PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig)
|
||||||
|
{
|
||||||
|
return handleAsDevice->ManagerUpdateConfig(managerConfig);
|
||||||
|
}
|
||||||
|
|
||||||
// Drivers
|
// Drivers
|
||||||
PR_EXPORT PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig)
|
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');
|
x = (str[2]-'0') * 10 + (str[3]-'0');
|
||||||
else return atoi(str);
|
else return atoi(str);
|
||||||
|
|
||||||
if ((machineType == kPRMachineWPC) || (machineType == kPRMachineWPC95))
|
if ((machineType == kPRMachineWPC) ||
|
||||||
|
(machineType == kPRMachineWPC95) ||
|
||||||
|
(machineType == kPRMachineWPCAlphanumeric))
|
||||||
{
|
{
|
||||||
switch (str[0])
|
switch (str[0])
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user