Added Software projects

git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
Matthias
2008-12-23 10:34:08 +00:00
parent ee5a771818
commit 373a8c32b2
348 changed files with 86781 additions and 0 deletions
@@ -0,0 +1,333 @@
/* ---------------------------------------------------------------------------
* remote_analogue.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: remote analogue test sequence
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "remote_analogue.h"
#include "adc.h"
#include "dac.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
UINT32 remoteAioReadResult = 0;
BOOLEAN remoteAnalogueInitialised = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void remoteAioInit (void)
{
UINT32 loopcnt;
RESULT set_mb;
RESULT set_eb;
remoteAnalogueInitialised = TRUE; /* Mark driver as initialised */
sendString (SerOutPort, TRUE, importantMessage,
NewLine, "Initialise analogue remote buffers", Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tInputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_AI; loopcnt++)
{
remoteAnalogueInputs[loopcnt] = 0;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tOutputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_AO; loopcnt++)
{
remoteAnalogueInputs[loopcnt] = 0;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
vSemaphoreCreateBinary (remoteAnalogueSemaphore);
sendString (SerOutPort, TRUE, importantMessage,
"Take analogue semaphore... ", Dummy, Dummy);
if (xSemaphoreTake(remoteAnalogueSemaphore, 0) == pdTRUE)
{
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, importantMessage,
"Failed", Dummy, Dummy);
}
sendString(SerOutPort, TRUE, importantMessage,
"reset remote analogue outputs...", Dummy, Dummy);
set_mb = remoteAioWriteAll (remoteDeviceNumber, analogue_mb, 0);
set_eb = remoteAioWriteAll (remoteDeviceNumber, analogue_eb, 0);
if ((set_mb == OK) && (set_eb == OK))
{
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
}
else
{
sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy);
}
}
RESULT remoteAioWrite (UINT8 device, UINT8 channel, INT32 value)
{
INT32 sendArray[2];
RESULT returnValue;
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32) channel;
sendArray[1] = (INT32) value;
bpSendCallRpc(handleBus1, device, 22, 2, sendArray);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "analogue write was not successful", Dummy);
returnValue = ERROR;
}
else
{
remoteAnalogueOutputs[channel] = value;
returnValue = OK;
}
return (returnValue);
}
RESULT remoteAioWriteAll(UINT8 device, t_boardtype_analogue board, BOOLEAN value)
{
INT32 sendArray[2];
UINT8 loopcnt = 0;
UINT8 loopend = 0;
RESULT returnValue;
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)board;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 25, 2, sendArray);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString(SerOutPort, TRUE, importantMessage, s_tab,
"analogue write was not successful", Dummy);
returnValue = ERROR;
}
else
{
switch (board)
{
case analogue_mb:
loopcnt = 0;
loopend = NUMBER_OF_AO_MB;
break;
case analogue_eb:
loopcnt = NUMBER_OF_AO_MB;
loopend = NUMBER_OF_TOTAL_AO;
break;
}
for (loopcnt; loopcnt < loopend; loopcnt++)
{
remoteAnalogueOutputs[loopcnt] = value;
// \TODO IS THIS LOOP WORKING??
}
returnValue = OK;
}
return (returnValue);
}
UINT32 remoteAioRead (UINT8 device, UINT8 channel)
{
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return (ERROR);
}
bpSendCallRpc(handleBus1, device, 23, 1, (INT32)&channel);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "analogue read did not receive a readback", Dummy);
}
else
{
remoteAnalogueInputs[channel] = remoteAioReadResult;
}
return (remoteAioReadResult);
}
void remoteAioReadAll (UINT8 device, t_boardtype_analogue board)
{
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
bpSendCallRpc(handleBus1, device, 27, 1, (INT32)&board);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "analogue read all did not receive a readback", Dummy);
}
else
{
sendString (SerOutPort, TRUE, importantMessage,
f_tab, "analogue read all finished receiving", Dummy);
}
}
void remoteAnalogueSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
xSemaphoreGive (remoteAnalogueSemaphore);
}
void analogueReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* nrOfResults = 2
* results[0]: analogue input value
*/
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
/* Asign remote analogue input result to local variable */
remoteAioReadResult = (UINT32) results[0];
xSemaphoreGive (remoteAnalogueSemaphore);
}
void analogueReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* nrOfResults = maxDI_Channels
* results[x]: analogue input x value
*/
UINT32 loopcnt;
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
for (loopcnt = 0; loopcnt < maxDAC_Channels; loopcnt++)
{
/* Copy read result to value array */
remoteAnalogueInputs[loopcnt] = results[loopcnt];
}
xSemaphoreGive (remoteAnalogueSemaphore);
}
@@ -0,0 +1,85 @@
/* ---------------------------------------------------------------------------
* remote_analogue.h (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.
* ---------------------------------------------------------------------------
*/
#ifndef REMOTE_ANALOGUE_H_
#define REMOTE_ANALOGUE_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define NUMBER_OF_AI_MB 8
#define NUMBER_OF_AO_MB 8
#define NUMBER_OF_AI_EB 4
#define NUMBER_OF_AO_EB 4
#define NUMBER_OF_TOTAL_AI (NUMBER_OF_AI_MB + NUMBER_OF_AI_EB)
#define NUMBER_OF_TOTAL_AO (NUMBER_OF_AO_MB + NUMBER_OF_AO_EB)
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef enum
{
analogue_mb = 0,
analogue_eb = 1
} t_boardtype_analogue;
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
INT32 remoteAnalogueInputs[(NUMBER_OF_TOTAL_AI)];
INT32 remoteAnalogueOutputs[(NUMBER_OF_TOTAL_AO)];
xSemaphoreHandle remoteAnalogueSemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void remoteAioInit (void);
RESULT remoteAioWrite (UINT8 device, UINT8 channel, INT32 value);
RESULT remoteAioWriteAll (UINT8 device, t_boardtype_analogue board, BOOLEAN value);
UINT32 remoteAioRead (UINT8 device, UINT8 channel);
void remoteAioReadAll (UINT8 device, t_boardtype_analogue board);
void remoteAnalogueSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void analogueReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void analogueReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /*REMOTE_ANALOGUE_H_*/
@@ -0,0 +1,376 @@
/* ---------------------------------------------------------------------------
* remote_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: remote digital test sequence
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "remote_digital.h"
#include "dio.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalInitialised = FALSE;
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDioReadResult = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void remoteDioInit (void)
{
UINT32 loopcnt;
RESULT set_mb;
RESULT set_eb;
remoteDigitalInitialised = TRUE; /* Mark driver as initialised */
sendString (SerOutPort, TRUE, importantMessage,
NewLine, "Initialise digital remote buffers", Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tInputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_DI; loopcnt++)
{
remoteDigitalInputs[loopcnt] = FALSE;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tOutputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_DO; loopcnt++)
{
remoteDigitalOutputs[loopcnt] = FALSE;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
vSemaphoreCreateBinary (remoteDigitalSemaphore);
sendString (SerOutPort, TRUE, importantMessage,
"Take digital semaphore... ", Dummy, Dummy);
if (xSemaphoreTake(remoteDigitalSemaphore, 0) == pdTRUE)
{
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, importantMessage,
"Failed", Dummy, Dummy);
}
sendString(SerOutPort, TRUE, importantMessage,
"reset remote digital outputs...", Dummy, Dummy);
set_mb = remoteDioWriteAll (remoteDeviceNumber, digital_mb, FALSE);
set_eb = remoteDioWriteAll (remoteDeviceNumber, digital_eb, FALSE);
if ((set_mb == OK) && (set_eb == OK))
{
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
}
else
{
sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy);
}
}
RESULT remoteDioWrite (UINT8 device, UINT8 channel, BOOLEAN value)
{
INT32 sendArray[2];
RESULT returnValue;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32) channel;
sendArray[1] = (INT32) value;
bpSendCallRpc(handleBus1, device, 20, 2, sendArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "digital write was not successful", Dummy);
returnValue = ERROR;
}
else
{
remoteDigitalOutputs[channel] = value;
returnValue = OK;
}
return (returnValue);
}
RESULT remoteDioWriteAll(UINT8 device, t_boardtype_digital board, BOOLEAN value)
{
INT32 sendArray[2];
UINT8 loopcnt = 0;
UINT8 loopend = 0;
RESULT returnValue;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)board;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 21, 2, sendArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString(SerOutPort, TRUE, importantMessage, s_tab,
"digital write was not successful", Dummy);
returnValue = ERROR;
}
else
{
switch (board)
{
case digital_mb:
loopcnt = 0;
loopend = NUMBER_OF_DO_MB;
break;
case digital_eb:
loopcnt = NUMBER_OF_DO_MB;
loopend = NUMBER_OF_TOTAL_DO;
break;
}
for (loopcnt; loopcnt < loopend; loopcnt++)
{
remoteDigitalOutputs[loopcnt] = value;
// \TODO IS THIS LOOP WORKING??
}
returnValue = OK;
}
return (returnValue);
}
BOOLEAN remoteDioRead (UINT8 device, INT32 channel)
{
INT32 channelArray[1];
channelArray[0] = channel;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return (ERROR);
}
bpSendCallRpc(handleBus1, device, 22, 1, channelArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "digital read did not receive a readback", Dummy);
}
else
{
remoteDigitalInputs[channel] = remoteDioReadResult;
}
return (remoteDioReadResult);
}
void remoteDioReadAll (UINT8 device, t_boardtype_digital board)
{
INT32 boardArray[1];
boardArray[0] = board;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
bpSendCallRpc(handleBus1, device, 23, 1, boardArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "digital read all did not receive a readback", Dummy);
}
else
{
sendString (SerOutPort, TRUE, importantMessage,
f_tab, "digital read all finished receiving", Dummy);
}
}
void remoteDigitalSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
xSemaphoreGive (remoteDigitalSemaphore);
}
void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
/* nrOfResults = 2
* results[0]: digital input value (0: LOW, !0: HIGH)
*/
if (results[0] == 0)
{
/* Remote digital input is LOW */
remoteDioReadResult = FALSE;
}
else
{
/* Remote digital input is HIGH */
remoteDioReadResult = TRUE;
}
xSemaphoreGive (remoteDigitalSemaphore);
}
void digitalReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* nrOfResults = 2
* results[0]: boardType (0: MB; 1: EB)
* results[1]: digital input value
*/
UINT32 loopcnt;
UINT32 tempValue;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital real all: ", ItoHStr (results[1]), Dummy);
if (results[0] == 0)
{
/* Incoming Results are from Mainboard */
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_MB; loopcnt++)
{
tempValue = (results[1] & (0x0000 | (1 << loopcnt)));
if (tempValue == 0)
{
remoteDigitalInputs[loopcnt] = FALSE;
}
else
{
remoteDigitalInputs[loopcnt] = TRUE;
}
}
}
else if (results[0] == 1)
{
/* Incoming Results are from Extensionboard */
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_EB; loopcnt++)
{
tempValue = (results[1] & (0x0000 | (1 << loopcnt)));
if (tempValue == 0)
{
remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] = FALSE;
}
else
{
remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] = TRUE;
}
}
}
xSemaphoreGive (remoteDigitalSemaphore);
}
@@ -0,0 +1,86 @@
/* ---------------------------------------------------------------------------
* remote_digital.h (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, Nov 11, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef DIGITAL_TEST_H_
#define DIGITAL_TEST_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define NUMBER_OF_DI_MB 8
#define NUMBER_OF_DO_MB 8
#define NUMBER_OF_DI_EB 4
#define NUMBER_OF_DO_EB 4
#define NUMBER_OF_TOTAL_DI (NUMBER_OF_DI_MB + NUMBER_OF_DI_EB)
#define NUMBER_OF_TOTAL_DO (NUMBER_OF_DO_MB + NUMBER_OF_DO_EB)
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef enum
{
digital_mb = 0,
digital_eb = 1
} t_boardtype_digital;
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalInputs[(NUMBER_OF_TOTAL_DI)];
BOOLEAN remoteDigitalOutputs[(NUMBER_OF_TOTAL_DO)];
xSemaphoreHandle remoteDigitalSemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void remoteDioInit (void);
RESULT remoteDioWrite (UINT8 device, UINT8 channel, BOOLEAN value);
RESULT remoteDioWriteAll (UINT8 device, t_boardtype_digital board, BOOLEAN value);
BOOLEAN remoteDioRead (UINT8 device, INT32 channel);
void remoteDioReadAll (UINT8 device, t_boardtype_digital board);
void remoteDigitalSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void digitalReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /*DIGITAL_TEST_H_*/
+144
View File
@@ -0,0 +1,144 @@
/* ---------------------------------------------------------------------------
* remote_misc.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, Nov 11, 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 "BusProtocol.h"
#include "protocolfunctions.h"
#include "remote_misc.h"
#include "SerOut.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
#define ident_calibrated 0x55
#define ident_default 0xAA
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
extern UINT32 UINT32result; /* from topoftests.c */
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
BOOLEAN makeHandshake (void)
{
/* Make Handshake with first Slave device.
* Take Semaphore, call remote function and take Semaphore again with
* waitcycle. Semaphore can just be taken when remote function
* finished and returns call to release Semaphore.
*/
BOOLEAN handshakeResult;
xSemaphoreTake(generalSemaphore, 1); /* Take generalSemaphore */
bpSendCallRpc (handleBus1, 2, 1, 0, NULL); /* Call Slaves Handshake */
if (xSemaphoreTake(generalSemaphore, 2000) == pdPASS)
{ /* Wait for Handshake done */
handshakeResult = TRUE;
}
else
{
handshakeResult = FALSE;
}
return (handshakeResult);
}
#endif
UINT8 returnRemoteCalibrationStatus (INT32 correctionType)
{
xSemaphoreTake(generalSemaphore, 0);
bpSendCallRpc(handleBus1, 2, 13, 1, &correctionType);
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
/* Semaphore is not released, timeout in transmission */
xSemaphoreGive (generalSemaphore);
UINT32result = 0;
}
else
{
if (UINT32result & ident_default)
{
}
else if (UINT32result & ident_calibrated)
{
}
else
{
}
}
return ((UINT8) UINT32result);
}
UINT8 showRemoteCalibrationStatus (INT32 correctionType)
{
xSemaphoreTake(generalSemaphore, 0);
bpSendCallRpc(handleBus1, 2, 13, 1, &correctionType);
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
/* Semaphore is not released, timeout in transmission */
xSemaphoreGive (generalSemaphore);
}
else
{
if (UINT32result & ident_default)
{
sendString (SerOutPort, FALSE, testMessage,
"Values are in DEFAULT Mode", Dummy, Dummy);
}
else if (UINT32result & ident_calibrated)
{
sendString (SerOutPort, FALSE, testMessage,
"Values are in CALIBRATED Mode", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, testMessage,
"NO VALID VALUES IN EEPROM", Dummy, Dummy);
}
}
return ((UINT8) UINT32result);
}
@@ -0,0 +1,73 @@
/* ---------------------------------------------------------------------------
* remote_misc.h (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, Nov 11, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: makeHandshake
*
* Functions Calls first Attached Function on Slave, which is sending an
* Answer back to Master
*
* Parameter: void
*
* Return: BOOLEAN - Result of Handshake
* ---------------------------------------------------------------------------
*/
BOOLEAN makeHandshake (void);
UINT8 returnRemoteCalibrationStatus (INT32 correctionType);
UINT8 showRemoteCalibrationStatus (INT32 correctionType);
void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#ifndef REMOTE_MISC_H_
#define REMOTE_MISC_H_
#endif /*REMOTE_MISC_H_*/
@@ -0,0 +1,221 @@
/* ---------------------------------------------------------------------------
* remote_relay.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 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
#include "remote_relay.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteRelayInitialised = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void remoteRelayInit(void)
{
UINT32 loopcnt;
RESULT set_mb;
RESULT set_eb;
remoteRelayInitialised = TRUE;
sendString(SerOutPort, TRUE, importantMessage, NewLine,
"Initialise relay remote buffers...", Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_RLY; loopcnt++)
{
remoteRelayInputs[loopcnt] = 0;
}
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
vSemaphoreCreateBinary (remoteRelaySemaphore);
sendString (SerOutPort, TRUE, importantMessage,
"Take relay semaphore... ", Dummy, Dummy);
if (xSemaphoreTake(remoteRelaySemaphore, 0) == pdTRUE)
{
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, importantMessage,
"Failed", Dummy, Dummy);
}
sendString(SerOutPort, TRUE, importantMessage,
"reset remote relays...", Dummy, Dummy);
set_mb = remoteRelaySetAll (remoteDeviceNumber, relay_mb, FALSE);
set_eb = remoteRelaySetAll (remoteDeviceNumber, relay_eb, FALSE);
if ((set_mb == OK) && (set_eb == OK))
{
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
}
else
{
sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy);
}
}
RESULT remoteRelaySet (UINT8 device, UINT8 channel, BOOLEAN value)
{
INT32 sendArray[2];
RESULT returnValue;
if (remoteRelayInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\trelay not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)channel;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 28, 2, sendArray);
if (xSemaphoreTake(remoteRelaySemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "relay set was not successful", Dummy);
returnValue = ERROR;
}
else
{
remoteRelayInputs[channel] = value;
returnValue = OK;
}
return (returnValue);
}
BOOLEAN remoteRelayRead (UINT8 device, UINT8 channel)
{
if (remoteRelayInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\trelay not intialised", Dummy, Dummy);
return;
}
}
RESULT remoteRelaySetAll(UINT8 device, t_boardtype_relay board, BOOLEAN value)
{
INT32 sendArray[2];
UINT32 loopcnt = 0;
UINT32 loopend = 0;
RESULT returnValue;
if (remoteRelayInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\trelay not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)board;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 29, 2, sendArray);
if (xSemaphoreTake(remoteRelaySemaphore, 3000) != pdTRUE)
{
sendString(SerOutPort, TRUE, importantMessage, s_tab,
"relay set was not successful", Dummy);
returnValue = ERROR;
}
else
{
switch (board)
{
case relay_mb:
loopcnt = 0;
loopend = NUMBER_OF_RLY_MB;
break;
case relay_eb:
loopcnt = NUMBER_OF_RLY_MB;
loopend = NUMBER_OF_TOTAL_RLY;
break;
}
for (loopcnt; loopcnt < loopend; loopcnt++)
{
remoteRelayInputs[loopcnt] = value;
}
returnValue = OK;
}
return (returnValue);
}
void remoteRelaySemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
xSemaphoreGive (remoteRelaySemaphore);
}
@@ -0,0 +1,73 @@
/* ---------------------------------------------------------------------------
* remote_relay.h (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 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef REMOTE_RELAY_H_
#define REMOTE_RELAY_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define NUMBER_OF_RLY_MB 4
#define NUMBER_OF_RLY_EB 2
#define NUMBER_OF_TOTAL_RLY (NUMBER_OF_RLY_MB + NUMBER_OF_RLY_EB)
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef enum
{
relay_mb = 0,
relay_eb = 1
} t_boardtype_relay;
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteRelayInputs[(NUMBER_OF_TOTAL_RLY)];
xSemaphoreHandle remoteRelaySemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void remoteRelayInit(void);
RESULT remoteRelaySet (UINT8 device, UINT8 channel, BOOLEAN value);
BOOLEAN remoteRelayRead (UINT8 device, UINT8 channel);
RESULT remoteRelaySetAll (UINT8 device, t_boardtype_relay board, BOOLEAN value);
void remoteRelaySemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /*REMOTE_RELAY_H_*/
@@ -0,0 +1,331 @@
/* ---------------------------------------------------------------------------
* remote_tests.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: Function to call single tests on remote system
*
* NOTE: allMemoryUseSameLED is defined in taskfunctions.h
*
* ---------------------------------------------------------------------------
* Version(s): 0.1, Aug 29, 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 "remote_tests.h"
#include "SerOut.h"
#include "dio.h"
#include "ledfunctions.h"
#include "protocolfunctions.h"
#include "taskfunctions.h"
#include "BusProtocol.h"
/* Test includes */
#include "testLED.h"
#include "testdio.h"
#include "testaio.h"
#include "testBUS.h"
#include "testeeprom.h"
#include "testMMC.h"
#include "testpower.h"
#include "testrtc.h"
#include "remote_analogue.h"
#include "remote_digital.h"
#include "remote_relay.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
extern BOOLEAN auto_testResult;
extern BOOLEAN GotoNewLine;
extern BOOLEAN block_SpinningWheel;
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void r_TestInit (void)
{
remoteDioInit();
vTaskDelay (200);
remoteAioInit();
vTaskDelay (200);
remoteRelayInit();
vTaskDelay (200);
}
void r_BatteryTest (BOOLEAN * batterytest)
{
/* Test for Battery and batterysupplied Memory */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "Battery Test");
bpSendCallRpc(handleBus1, 2, 17, 0, NULL); /* Write on Battery Memory */
sendString(SerOutPort, TRUE, noteMessage,
NewLine, "\t\tSwitch SLAVE OFF for 5 Seconds", Dummy);
if (xSemaphoreTake(slaveRestartSemaphore, 60000) == pdPASS)
{ /* Wait for slave Restart */
bpSendCallRpc(handleBus1, 2, 18, 0, NULL); /* Read from Memory */
xSemaphoreTake(generalSemaphore, 3000);
}
else
{
auto_testResult = FALSE;
xSemaphoreGive (slaveRestartSemaphore);
}
*batterytest = auto_testResult;
#if (allMemoryUseSameLED == 1)
postpareTest(*batterytest, &d_batteryled, BATTERYLED, (void *)dioToggle,
(pUINT8) "batteryerror", &batteryled);
#endif
bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */
sendString (SerOutPort, TRUE, resultMessage,
"n\rBATTERY Test Result: ", s_lines, BoolRestoStr (*batterytest));
}
void r_LEDTest (BOOLEAN * ledtest)
{
/* Local Variable declaration */
UINT8 buffer = 0;
UINT8 captureDio;
UINT8 dioAllOn = 0xFF;
BOOLEAN receive = FALSE;
/* Test for all accessable LEDs */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "LED TEST");
captureDio = dioCapture();
diotaskssuspend();
dioResume (dioAllOn);
bpSendCallRpc(handleBus1, 2, 21, 0, NULL); /* Call ledTest() */
sendString (SerOutPort, TRUE, noteMessage,
"\n\tAre all LEDs turned on? ",
"\n\r\tPRESS y (YES) oder n (NO): ",
NewLine);
do /* do-while loop for String input */
{
vTaskDelay (10);
buffer = 0;
receive = serGet(SerOutPort, &buffer);
} while ((buffer != 121) && (buffer != 110));
if (buffer == 121) /* 121 = y (ScanCode) */
{
*ledtest = TRUE;
}
else if (buffer == 110) /* 110 = n (ScanCode) */
{
*ledtest = FALSE;
}
xSemaphoreTake(generalSemaphore, 5000);
dioResume(captureDio);
diotasksresume();
bpSendCallRpc(handleBus1, 2, 32, 0, NULL); /* Postpare Test on Slave */
postpareTest(*ledtest, &d_ledtestled, LEDTESTLED, (void *)dioToggle,
(pUINT8) "LEDerror", &ledtestled);
bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */
sendString (SerOutPort, GotoNewLine, resultMessage,
"n\rLED Test Result: ", s_lines, BoolRestoStr (*ledtest));
}
void r_EEPROMTest (BOOLEAN * eepromtest)
{
/* Test for EEPROM Memory */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "EEPROM");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 22, 0, NULL); /* Call eepromTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString (SerOutPort, TRUE, importantMessage,
"\tTimeout occoured!", Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*eepromtest = auto_testResult;
#if (allMemoryUseSameLED == 0)
postpareTest(*eepromtest, &d_eepromled, EEPROMLED, (void *)dioToggle,
(pUINT8) "EEPROMerror", eepromled);
#else
postpareTest(*eepromtest, &d_memoryled, MEMORYLED, (void *)dioToggle,
(pUINT8) "memoryerror", &memoryled);
#endif
bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rEEPROM Test Result:",
s_lines, BoolRestoStr(*eepromtest));
}
void r_MMCTest(BOOLEAN * mmctest)
{
/* Test for Multimedia Card */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "MMC");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 27, 0, NULL); /* Call MMCTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString(SerOutPort, TRUE, importantMessage, "\tTimeout occoured!",
Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*mmctest = auto_testResult;
postpareTest(*mmctest, &d_mmcled, MMCLED, (void *)dioToggle,
(pUINT8) "MMCerror", &mmcled);
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rMMC Test Result: ", s_lines, BoolRestoStr(*mmctest));
}
void r_PowerTest (BOOLEAN * powertest)
{ /* Test for Power Supply */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "Power Supply");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 28, 0, NULL); /* Call eepromTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString (SerOutPort, TRUE, importantMessage,
"\tTimeout occoured!", Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*powertest = auto_testResult;
postpareTest(*powertest, &d_powerled, POWERLED, (void *)dioToggle,
(pUINT8) "POWERerror", &powerled);
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rPower Supply Test Result:",
f_lines, BoolRestoStr(*powertest));
}
void r_RTCTest (BOOLEAN * rtctest)
{ /* Test for Real Time Clock */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "RealTimeClock");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 29, 0, NULL); /* Call eepromTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString (SerOutPort, TRUE, importantMessage,
"\tTimeout occoured!", Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*rtctest = auto_testResult;
postpareTest(*rtctest, &d_rtcled, RTCLED, (void *)dioToggle,
(pUINT8) "RTCerror", &rtcled);
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rRealTimeClock Test Result:",
f_lines, BoolRestoStr(*rtctest));
}
/* Function to handle all necessary commands and calculations after a
* single test. Because these are all the same, they are done in a
* extra function
*/
void postpareTest (BOOLEAN TestResult, portBASE_TYPE *basetype,
UINT32 LEDNumber, pdTASK_CODE TaskCode,
pUINT8 taskname, xTaskHandle *pTaskHandler)
{
if (TestResult == TRUE)
{ /* if Test is passed */
if (*basetype == pdPASS) /* If defined Task exists */
{
vTaskDelete (*pTaskHandler);/* Delete defined Task */
*basetype = 0; /* Reset corresponding bastetype */
}
dioWrite( 0, LEDNumber, TRUE); /* illume corresponding LED */
}
else
{ /* if DIO Test fails */
if (*basetype == pdPASS)
{
/* Task already exists, so do nothing */
}
else
{
*basetype = xTaskCreate((void *)TaskCode,
( signed portCHAR * ) taskname,
configMINIMAL_STACK_SIZE, (UINT16 *)LEDNumber,
tskIDLE_PRIORITY + 2, pTaskHandler);
} /* Create Task to flash LED */
}
}
@@ -0,0 +1,104 @@
/* ---------------------------------------------------------------------------
* remote_tests.h (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, Aug 29, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef REMOTE_TESTS_H_
#define REMOTE_TESTS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void r_TestInit (void);
/* ---------------------------------------------------------------------------
* Function: r_xyzTest
*
* Functions that call the corresponding test on remote Device and handle
* some optical commands like Result printout and LED controlling
*
* Parameter: BOOLEAN * xyztest - Test Result is written to this variable
*
* Return: void
* ---------------------------------------------------------------------------
*/
void r_BatteryTest (BOOLEAN * batterytest);
void r_LEDTest (BOOLEAN * ledtest);
void r_framTest (BOOLEAN * framtest);
void r_EEPROMTest (BOOLEAN * eepromtest);
void r_FLASHTest (BOOLEAN * flashtest);
void r_LogTest (BOOLEAN *logtest);
void r_DIOTest (BOOLEAN * diotest);
void r_AIOTest (BOOLEAN * aiotest);
void r_MMCTest (BOOLEAN * mmctest);
void r_PowerTest (BOOLEAN * powertest);
void r_RTCTest (BOOLEAN * rtctest);
/* ---------------------------------------------------------------------------
* Function: postpareTest
*
* Function to manage all needed things after a Test - e.g. Restore
* DIO-Results or Create/Resume Tasks.
*
* Parameter: BOOLEAN TestResult - Testresult of current Test
* portBASE_TYPE *basetype - TaskCreation Result
* UINT32 LEDNumber - LEDNumber to be used for that Test
* pdTASK_CODE TaskCode - Function, that should be tasked
* pUINT8 taskname - Name for the Task
* xTaskHandle *pTaskHandler - TaskHandler
*
* Return: void
* ---------------------------------------------------------------------------
*/
void postpareTest (BOOLEAN TestResult, portBASE_TYPE *basetype,
UINT32 LEDNumber, pdTASK_CODE TaskCode,
pUINT8 taskname, xTaskHandle *pTaskHandler);
#endif /*REMOTE_TESTS_H_*/
@@ -0,0 +1,341 @@
/* ---------------------------------------------------------------------------
* test_analogue.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_analogue.h"
#include "remote_analogue.h"
#include "adc.h"
#include "dac.h"
#include "remote_tests.h"
#include "SerOut.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
#define cTestvalue 15000
#define cNullvalue 0
#define ciTolerance_null 50
#define ciTolerance_uncal 3500
#define ciTolerance_cal 50
#define coTolerance_null 50
#define coTolerance_uncal 3500
#define coTolerance_cal 50
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteAnalogueLinetestMBExecute (void)
{
BOOLEAN returnValue;
BOOLEAN remoteAnalogueOutput;
BOOLEAN remoteAnalogueInput;
remoteAnalogueOutput = remoteAnalogueOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue output test: ", f_tab, BoolRestoStr(remoteAnalogueOutput));
remoteAnalogueInput = remoteAnalogueInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue input test: ", f_tab, BoolRestoStr(remoteAnalogueInput));
if ((remoteAnalogueOutput == TRUE) && (remoteAnalogueInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
}
BOOLEAN remoteAnalogueLinetestEBExecute (void)
{
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
BOOLEAN remoteAnalogueOutput;
BOOLEAN remoteAnalogueInput;
remoteAnalogueOutput = remoteAnalogueOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue output test: ", f_tab, BoolRestoStr(remoteAnalogueOutput));
remoteAnalogueInput = remoteAnalogueInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue input test: ", f_tab, BoolRestoStr(remoteAnalogueInput));
if ((remoteAnalogueOutput == TRUE) && (remoteAnalogueInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
#else
sendString (SerOutPort, TRUE, importantMessage,
"Extension Board test not available on this device", Dummy, Dummy);
return (FALSE);
#endif
}
BOOLEAN remoteAnalogueOutputTest_MB (void)
{
UINT32 loopcnt;
UINT32 channelcnt;
UINT32 testTolerance;
UINT32 lowRead;
UINT32 highRead;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \TODO SET TEST TOLERANCE DEPENDING ON THE CALIBRATION STATUS
testTolerance = coTolerance_uncal;
adcModeAll(adcCURRENT); /* Set local ADC to mode CURRENT*/
remoteAioWriteAll(remoteDeviceNumber, analogue_mb, cNullvalue);
vTaskDelay (500);
sendString (SerOutPort, FALSE, testMessage, NewLine,
"\tCurrent Test Value: ", ItoDStr (cTestvalue));
sendString (SerOutPort, FALSE, testMessage,
"\t\tTolerance: ", ItoDStr (testTolerance), Dummy);
for (channelcnt = 0; channelcnt < NUMBER_OF_AO_MB; channelcnt++)
{
lowRead = adcRead(thisDeviceNumber, channelcnt);
if (lowRead < (cNullvalue + coTolerance_null))
{
/* Read a null-like value - LOW test passed */
}
else
{
/* Read a too high value - LOW test failed */
Low_Test = FALSE;
}
remoteAioWrite(remoteDeviceNumber, channelcnt, cTestvalue);
vTaskDelay (500);
highRead = adcRead(thisDeviceNumber, channelcnt);
if ((highRead < (cTestvalue + testTolerance)) && (highRead > (cTestvalue - testTolerance)))
{
/* Read a value within the test tolerances - High test passed */
}
else
{
/* read a value out of the test tolerances - High test failed */
High_Test = FALSE;
}
for (loopcnt = 0; loopcnt < NUMBER_OF_AO_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip actual test channel */
}
else
{
/* Check channel for remaining LOW */
if (adcRead(thisDeviceNumber, loopcnt) >= (cNullvalue + coTolerance_null))
{
/* Actual channels value too high, AllOther test failed */
AllOther_Test = FALSE;
}
}
}
remoteAioWrite(remoteDeviceNumber, channelcnt, cNullvalue);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tCurrent Test for Analogue Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (lowRead));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (highRead));
sendString (SerOutPort, FALSE, testMessage,
" All Other: ", Dummy, BoolRestoStr (AllOther_Test));
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
BOOLEAN remoteAnalogueInputTest_MB (void)
{
UINT32 loopcnt;
UINT32 channelcnt;
UINT32 testTolerance;
UINT32 lowRead;
UINT32 highRead;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \TODO SET TEST TOLERANCE DEPENDING ON THE CALIBRATION STATUS
testTolerance = coTolerance_uncal;
dacModeAll(dacCURRENT); /* Set local DAC to mode CURRENT*/
/* Reset all local DAC channels to zero ampere */
for (loopcnt = 0; loopcnt < maxDAC_Channels; loopcnt++)
{
dacWrite(thisDeviceNumber, loopcnt, cNullvalue);
}
vTaskDelay (500);
sendString (SerOutPort, FALSE, testMessage, NewLine,
"\tCurrent Test Value: ", ItoDStr (cTestvalue));
sendString (SerOutPort, FALSE, testMessage,
"\t\tTolerance: ", ItoDStr (testTolerance), Dummy);
for (channelcnt = 0; channelcnt < NUMBER_OF_AI_MB; channelcnt++)
{
lowRead = remoteAioRead(remoteDeviceNumber, channelcnt);
if (lowRead < (cNullvalue + testTolerance))
{
/* Read a null-like value - LOW test passed */
Low_Test = TRUE;
}
else
{
/* Read a too high value - LOW test failed */
Low_Test = FALSE;
}
dacWrite(thisDeviceNumber, channelcnt, cTestvalue);
vTaskDelay (200);
highRead = remoteAioRead(remoteDeviceNumber, channelcnt);
if ((highRead < (cTestvalue + testTolerance)) && (highRead > (cTestvalue - testTolerance)))
{
/* Read a value within the test tolerances - High test passed */
High_Test = TRUE;
}
else
{
/* read a value out of the test tolerances - High test failed */
High_Test = FALSE;
}
remoteAioReadAll(remoteDeviceNumber, analogue_mb);
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_AO_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (remoteAnalogueOutputs[loopcnt] >= (cNullvalue + ciTolerance_null))
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
dacWrite(thisDeviceNumber, channelcnt, cNullvalue);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tCurrent Test for Analogue Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (lowRead));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (highRead));
sendString (SerOutPort, FALSE, testMessage,
" All Other: ", Dummy, BoolRestoStr (AllOther_Test));
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
BOOLEAN remoteAnalogueOutputTest_EB (void)
{
}
@@ -0,0 +1,69 @@
/* ---------------------------------------------------------------------------
* test_analogue.h (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.
* ---------------------------------------------------------------------------
*/
#ifndef TEST_ANALOGUE_H_
#define TEST_ANALOGUE_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteAnalogueLinetestMBExecute (void);
BOOLEAN remoteAnalogueLinetestEBExecute (void);
BOOLEAN remoteAnalogueOutputTest_MB (void);
BOOLEAN remoteAnalogueInputTest_MB (void);
BOOLEAN remoteAnalogueOutputTest_EB (void);
BOOLEAN remoteAnalogueInputTest_EB (void);
#endif /*TEST_ANALOGUE_H_*/
@@ -0,0 +1,499 @@
/* ---------------------------------------------------------------------------
* 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;
remoteDigitalOutput = remoteDigitalOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput));
remoteDigitalInput = remoteDigitalInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb input test: ", f_tab, BoolRestoStr(remoteDigitalInput));
if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
}
BOOLEAN remoteDigitalLinetestEBExecute (void)
{
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
BOOLEAN returnValue;
BOOLEAN remoteDigitalOutput;
BOOLEAN remoteDigitalInput;
remoteDigitalOutput = remoteDigitalOutputTest_EB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_eb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput));
remoteDigitalInput = remoteDigitalInputTest_EB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_eb input test: ", f_tab, BoolRestoStr(remoteDigitalInput));
if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
#else
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 (200);
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;
}
}
}
remoteDioWrite(remoteDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input ", 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 ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
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);
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;
}
vTaskDelay (200);
dioWrite(thisDeviceNumber, channelcnt, TRUE);
vTaskDelay(200);
if (remoteDioRead(remoteDeviceNumber, channelcnt) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
vTaskDelay(500);
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
vTaskDelay(500);
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 ", 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 ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
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)
dio_inMuxEn (TRUE); /* Switch dio to Extension Board*/
#endif
/* Reset all remote digital outputs to LOW/OFF */
remoteDioWriteAll(remoteDeviceNumber, digital_eb, FALSE);
vTaskDelay (200);
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 Input ", 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 ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
dio_inMuxEn (FALSE); /* Switch dio back to main Board*/
#endif
return (returnResult);
}
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)
dio_outMuxEn (TRUE); /* Switch dio to Extension Board*/
#endif
dioClean(); /* Clean local digital outputs */
vTaskDelay (500);
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;
}
vTaskDelay (200);
dioWrite(thisDeviceNumber, channelcnt, TRUE);
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;
}
remoteDioReadAll(remoteDeviceNumber, digital_eb);
vTaskDelay (200);
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 ", 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 ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
dio_outMuxEn (FALSE); /* Switch dio back to main Board*/
#endif
return (returnResult);
}
@@ -0,0 +1,61 @@
/* ---------------------------------------------------------------------------
* test_digital.h (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.
* ---------------------------------------------------------------------------
*/
#ifndef TEST_DIGITAL_H_
#define TEST_DIGITAL_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalLinetestMBExecute (void);
BOOLEAN remoteDigitalLinetestEBExecute (void);
BOOLEAN remoteDigitalOutputTest_MB (void);
BOOLEAN remoteDigitalInputTest_MB (void);
BOOLEAN remoteDigitalOutputTest_EB (void);
#endif /*TEST_DIGITAL_H_*/
+140
View File
@@ -0,0 +1,140 @@
/* ---------------------------------------------------------------------------
* test_leds.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: remote LED test sequence
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
#include "remote_analogue.h"
#include "remote_digital.h"
#include "remote_relay.h"
#include "dio.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteLEDTestMBexecute (void)
{
UINT32 loopcnt;
UINT8 buffer;
BOOLEAN ledTest = TRUE;
BOOLEAN receive = FALSE;
/* Drive LEDs to status ON */
sendString (SerOutPort, GotoNewLine, testMessage,
"Set local digital outputs to HIGH... ", Dummy, Dummy);
/* Set digital input LEDs to ON */
for (loopcnt = 0; loopcnt < maxDO_Channels; loopcnt++)
{
dioWrite(thisDeviceNumber, loopcnt, TRUE);
}
sendString (SerOutPort, FALSE, testMessage,
"Done", Dummy, Dummy);
/* Set remote digital output LEDs to on */
sendString (SerOutPort, GotoNewLine, testMessage,
"Set remote digital outputs to HIGH... ", Dummy, Dummy);
if (remoteDioWriteAll(remoteDeviceNumber, digital_mb, TRUE) == OK)
{
sendString (SerOutPort, FALSE, testMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, testMessage,
"Failed", Dummy, Dummy);
}
/* Set remote relay througput LEDs to on */
sendString (SerOutPort, GotoNewLine, testMessage,
"Set remote relay outputs to HIGH... ", Dummy, Dummy);
if (remoteRelaySetAll(remoteDeviceNumber, relay_mb, TRUE) == OK)
{
sendString (SerOutPort, FALSE, testMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, testMessage,
"Failed", Dummy, Dummy);
}
sendString (SerOutPort, TRUE, noteMessage,
"\tAre all LEDs turned on? ",
"\n\r\tPRESS y (YES) oder n (NO): ",
NewLine);
do /* do-while loop for String input */
{
receive = serGet(SerOutPort, &buffer);
} while ((buffer != 121) && (buffer != 110));
if (buffer == 121) /* 121 = y (ScanCode) */
{
sendString (SerOutPort, TRUE, noteMessage,
"All LEDs working", Dummy, Dummy);
ledTest = TRUE;
}
else if (buffer == 110) /* 110 = n (ScanCode) */
{
sendString (SerOutPort, TRUE, noteMessage,
"LEDs broken", Dummy, Dummy);
ledTest = FALSE;
}
// \TODO CALCULATE RESULT
}
+56
View File
@@ -0,0 +1,56 @@
/* ---------------------------------------------------------------------------
* test_leds.h (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 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TEST_LEDS_H_
#define TEST_LEDS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteLEDTestMBexecute (void);
#endif /*TEST_LEDS_H_*/