Files
diplomarbeit/Tester/SW/Eclipse/Applications/remote/test_digital.c
T
Matthias f468e09499 Added Altium Project files
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@131 9fe90eed-be63-e94b-8204-d34ff4c2ff93
2009-01-15 10:28:29 +00:00

557 lines
21 KiB
C

/* ---------------------------------------------------------------------------
* test_digital.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "test_digital.h"
#include "remote_digital.h"
#include "dio.h"
#include "remote_tests.h"
#include "SerOut.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "ledfunctions.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalLinetestMBExecute (void)
{
BOOLEAN returnValue;
BOOLEAN remoteDigitalOutput;
BOOLEAN remoteDigitalInput;
/* Call mainboard digital output test and print out result afterwards */
remoteDigitalOutput = remoteDigitalOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb output: ", f_tab, BoolRestoStr(remoteDigitalOutput));
/* Call mainboard digital input test and print out result afterwards */
remoteDigitalInput = remoteDigitalInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb input: ", f_tab, BoolRestoStr(remoteDigitalInput));
/* Calculate test result */
if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE))
{
/* Test is passed */
returnValue = TRUE;
}
else
{
/* Test is passed */
returnValue = FALSE;
}
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb test: ", f_tab, BoolRestoStr(remoteDigitalInput));
return (returnValue);
}
BOOLEAN remoteDigitalLinetestEBExecute (void)
{
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
/* Extensionboard Test is available only on the specified test device */
BOOLEAN returnValue;
BOOLEAN remoteDigitalOutput;
BOOLEAN remoteDigitalInput;
/* Call extensionboard digital output test and print result afterwards */
remoteDigitalOutput = remoteDigitalOutputTest_EB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_eb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput));
/* Call extensionboard digital input test and print result afterwards */
remoteDigitalInput = remoteDigitalInputTest_EB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_eb input test: ", f_tab, BoolRestoStr(remoteDigitalInput));
/* Calculate test result */
if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE))
{
/* Test is passed */
returnValue = TRUE;
}
else
{
/* Test is failed */
returnValue = FALSE;
}
return (returnValue);
#else
/* If other board than specific tester, printf out "test unavailable" text */
sendString (SerOutPort, TRUE, importantMessage,
"Extension Board test not available on this device", Dummy, Dummy);
return (FALSE);
#endif
}
BOOLEAN remoteDigitalOutputTest_MB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
/* Reset all remote digital outputs to LOW/OFF */
remoteDioWriteAll(remoteDeviceNumber, digital_mb, FALSE);
vTaskDelay (500); /* Wait for reset remote outputs*/
/* Test each channel individually within a loop
* Loop-condition is the number of digital outputs on the test item
*/
for (channelcnt = 0; channelcnt < NUMBER_OF_DO_MB; channelcnt++)
{
/* Read remote digital channel value for LOW test */
if (dioRead(thisDeviceNumber, channelcnt) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
/* Drive testchannel to HIGH Output value */
remoteDioWrite(remoteDeviceNumber, channelcnt, TRUE);
vTaskDelay (200); /* Assure command was executed */
if (dioRead(thisDeviceNumber, channelcnt) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
vTaskDelay (200);
/* Check all other channels for remaining at LOW */
for (loopcnt = 0; loopcnt < NUMBER_OF_DO_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (dioRead(thisDeviceNumber, loopcnt) == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Re-set remote digital output to LOW */
remoteDioWrite(remoteDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Output (MB) ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
/* If one of the individual tests fails, calculate a negative
* over-all test result
*/
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult); /* Return test result to caller */
}
BOOLEAN remoteDigitalInputTest_MB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
dioClean(); /* Clean local digital outputs */
vTaskDelay (500); /* Wait for local outputs */
/* Test each channel individually within a loop
* Loop-condition is the number of digital inputs on the test item
*/
for (channelcnt = 0; channelcnt < NUMBER_OF_DI_MB; channelcnt++)
{
if (remoteDioRead(remoteDeviceNumber, channelcnt) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
/* Write local output to HIGH state */
dioWrite(thisDeviceNumber, channelcnt, TRUE);
vTaskDelay(200); /* Wait for local output */
if (remoteDioRead(remoteDeviceNumber, channelcnt) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
remoteDioReadAll(remoteDeviceNumber, digital_mb);
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (remoteDigitalInputs[loopcnt] == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Return to LOW channel value */
dioWrite (thisDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input (MB) ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
/* If one of the individual tests fails, calculate a negative
* over-all test result
*/
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult); /* Return test result */
}
BOOLEAN remoteDigitalOutputTest_EB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
/* Necessary due to compiling on alternative boards */
dio_inMuxEn (TRUE); /* Switch dio to Extension Board*/
#endif
/* Reset all remote digital outputs to LOW/OFF */
remoteDioWriteAll(remoteDeviceNumber, digital_eb, FALSE);
vTaskDelay (200);
/* Test each channel individually within a loop
* Loop-condition is the total number of digital outputs on the test item
* The remote digital write/read function counts up to 12 (8 MB + 4 EB),
* the local write/read only to 8. The 4 extension board connections
* must be switche manually. That is why the loop counting starts with
* the number of the mainboard outputs, which represents the first
* extensionboard output.
*/
for (channelcnt = NUMBER_OF_DO_MB; channelcnt < NUMBER_OF_TOTAL_DO; channelcnt++)
{
if (dioRead(thisDeviceNumber, (channelcnt - NUMBER_OF_DO_MB)) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
/* Drive testchannel to HIGH Output value */
remoteDioWrite(remoteDeviceNumber, channelcnt, TRUE);
vTaskDelay (200); /* Assure command was executed */
if (dioRead(remoteDeviceNumber, (channelcnt - NUMBER_OF_DO_MB)) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_DO_EB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (dioRead(thisDeviceNumber, loopcnt) == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Ouput(EB) ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
/* If one of the individual tests fails, calculate a negative
* over-all test result
*/
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
/* Necessary due to compiling on alternative boards */
dio_inMuxEn (FALSE); /* Switch dio back to main Board*/
#endif
return (returnResult); /* Return test result */
}
BOOLEAN remoteDigitalInputTest_EB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
/* Necessary due to compiling on alternative boards */
dio_outMuxEn (TRUE); /* Switch dio to Extension Board*/
#endif
dioClean(); /* Clean local digital outputs */
vTaskDelay (500); /* assure that cleaning is done */
/* Test each channel individually within a loop
* Loop-condition is the number of digital inputs available on the
* extension board. The remote digital write/read function counts up
* to 12 (8 MB + 4 EB), the local write/read only to 8. The 4 extension
* board connections must be switched manually (first 4 local inputs).
* This is why the remote channel number is added with the number of
* the digital inputs available on the mainboard.
*/
for (channelcnt = 0; channelcnt < NUMBER_OF_DI_EB; channelcnt++)
{
if (remoteDioRead(remoteDeviceNumber, (channelcnt + NUMBER_OF_DI_MB)) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
/* Set local digital output to HIGH stat */
dioWrite(thisDeviceNumber, channelcnt, TRUE);
vTaskDelay(200); /* Wait for command is finished */
if (remoteDioRead(remoteDeviceNumber, (channelcnt + NUMBER_OF_DI_MB)) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
/* Read all remote digital inputs */
remoteDioReadAll(remoteDeviceNumber, digital_eb);
vTaskDelay (200); /* Wait for command is finished */
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_EB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Return to LOW channel value */
dioWrite (thisDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input (EB) ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
/* If one of the individual tests fails, calculate a negative
* over-all test result
*/
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
/* Necessary due to compiling on alternative boards */
dio_outMuxEn (FALSE); /* Switch dio back to main Board*/
#endif
return (returnResult); /* Return test result */
}