From 520a8a5b17dc53819feff86d0a1f1423d83563b5 Mon Sep 17 00:00:00 2001 From: gstellenberg Date: Wed, 21 Oct 2009 21:03:16 -0500 Subject: [PATCH] Added support for WPC switch matrix columns 8 and 9. --- include/pinproc.h | 2 ++ src/PRDevice.cpp | 14 ++++++++++++++ src/PRHardware.cpp | 6 +++++- src/PRHardware.h | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/pinproc.h b/include/pinproc.h index cf7ef7f..35dab09 100644 --- a/include/pinproc.h +++ b/include/pinproc.h @@ -294,6 +294,8 @@ PR_EXPORT int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents); typedef struct PRSwitchConfig { bool_t clear; // Drive the clear output bool_t hostEventsEnable; // Drive the clear output + bool_t use_column_9; // Use switch matrix column 9 + bool_t use_column_8; // Use switch matrix column 8 uint8_t directMatrixScanLoopTime; // milliseconds uint8_t pulsesBeforeCheckingRX; uint8_t inactivePulsesAfterBurst; diff --git a/src/PRDevice.cpp b/src/PRDevice.cpp index 06eebd7..33925c4 100644 --- a/src/PRDevice.cpp +++ b/src/PRDevice.cpp @@ -303,6 +303,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint int rowEnableSelect; int lastCoilDriverGroup; + DEBUG(PRLog(kPRLogError, "In Defaults:, machineType = %x.\n", machineType)); switch (machineType) { case kPRMachineWPC: @@ -349,6 +350,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint break; } } + DEBUG(PRLog(kPRLogError, "Defaults:, setup done.\n", machineType)); memset(&driverGlobalConfig, 0x00, sizeof(PRDriverGlobalConfig)); for (i = 0; i < kPRDriverCount; i++) @@ -360,6 +362,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint if (resetFlags & kPRResetFlagUpdateDevice) res = DriverUpdateState(driver); } + DEBUG(PRLog(kPRLogError, "Defaults:, Drivers done.\n", machineType)); for (i = 0; i < kPRDriverGroupsMax; i++) { PRDriverGroupConfig *group = &driverGroups[i]; @@ -367,6 +370,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint group->groupNum = i; group->polarity = globalPolarity; } + DEBUG(PRLog(kPRLogError, "Defaults:, Drivers groups set up.\n", machineType)); PRDriverGlobalConfig globals; globals.enableOutputs = false; @@ -382,6 +386,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint globals.watchdogExpired = false; globals.watchdogEnable = true; globals.watchdogResetTime = watchdogResetTime; + DEBUG(PRLog(kPRLogError, "Defaults:, Drivers globals set up.\n", machineType)); // 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: @@ -398,6 +403,8 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint res = DriverUpdateGlobalConfig(&globals); else driverGlobalConfig = globals; + + DEBUG(PRLog(kPRLogError, "Defaults:, Drivers globals programmed.\n", machineType)); // Configure the groups. Each group corresponds to 8 consecutive drivers, starting // with driver #32. The following 6 groups are configured for coils/flashlamps. @@ -419,7 +426,10 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint res = DriverUpdateGroupConfig(&group); else driverGroups[i] = group; + DEBUG(PRLog(kPRLogError, "Defaults: group %x programmed.\n", i)); } + + DEBUG(PRLog(kPRLogError, "Defaults: First groups programmed.\n", machineType)); // The following 8 groups are configured for the feature lamp matrix. for (i = 10; i < 10 + numMatrixGroups; i++) { @@ -437,7 +447,9 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint res = DriverUpdateGroupConfig(&group); else driverGroups[i] = group; + DEBUG(PRLog(kPRLogError, "Defaults: group %x programmed.\n", i)); } + DEBUG(PRLog(kPRLogError, "Defaults: last groups programmed.\n", machineType)); return res; } @@ -798,6 +810,8 @@ PRResult PRDevice::Open() PRSwitchConfig switchConfig; switchConfig.clear = false; + switchConfig.use_column_9 = false; + switchConfig.use_column_8 = false; switchConfig.hostEventsEnable = false; switchConfig.directMatrixScanLoopTime = 2; // milliseconds switchConfig.pulsesBeforeCheckingRX = 10; diff --git a/src/PRHardware.cpp b/src/PRHardware.cpp index 2f26b68..ef9df31 100644 --- a/src/PRHardware.cpp +++ b/src/PRHardware.cpp @@ -162,7 +162,11 @@ int32_t CreateSwitchUpdateConfigBurst ( uint32_t * burst, PRSwitchConfig *switch (switchConfig->pulsesPerBurst << P_ROC_SWITCH_CONFIG_PULSES_PER_BURST_SHIFT) | (switchConfig->pulseHalfPeriodTime << - P_ROC_SWITCH_CONFIG_MS_PER_PULSE_HALF_PERIOD_SHIFT); + P_ROC_SWITCH_CONFIG_MS_PER_PULSE_HALF_PERIOD_SHIFT) | + (switchConfig->use_column_8 << + P_ROC_SWITCH_CONFIG_USE_COLUMN_8) | + (switchConfig->use_column_9 << + P_ROC_SWITCH_CONFIG_USE_COLUMN_9); burst[2] = CreateBurstCommand (P_ROC_BUS_STATE_CHANGE_PROC_SELECT, P_ROC_STATE_CHANGE_CONFIG_ADDR, 1 ); burst[3] = switchConfig->hostEventsEnable; diff --git a/src/PRHardware.h b/src/PRHardware.h index 6d67d21..f7fc449 100644 --- a/src/PRHardware.h +++ b/src/PRHardware.h @@ -172,6 +172,8 @@ const uint32_t P_ROC_DRIVER_CONFIG_PATTER_ENABLE_SHIFT = 30; const uint32_t P_ROC_DRIVER_CONFIG_TABLE_DRIVER_NUM_SHIFT = 1; const uint32_t P_ROC_SWITCH_CONFIG_CLEAR_SHIFT = 31; +const uint32_t P_ROC_SWITCH_CONFIG_USE_COLUMN_9 = 30; +const uint32_t P_ROC_SWITCH_CONFIG_USE_COLUMN_8 = 29; const uint32_t P_ROC_SWITCH_CONFIG_MS_PER_DM_SCAN_LOOP_SHIFT = 24; const uint32_t P_ROC_SWITCH_CONFIG_PULSES_BEFORE_CHECKING_RX_SHIFT = 18; const uint32_t P_ROC_SWITCH_CONFIG_INACTIVE_PULSES_AFTER_BURST_SHIFT = 12;