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:
@@ -0,0 +1,216 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testuart2.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:
|
||||
* Contains BUS System Test Functions
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mar 10, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* APPLICATION NOTE FOR BUS TEST!!!!
|
||||
*
|
||||
* THIS TEST ONLY WILL WORK IF DEVICE IS RUNNING IN A SINGLE MODE. IF DEVICE
|
||||
* IS INITIALIZED WITH BUS PROTOCOL (ANYWAY IF MASTER OR SLAVE), THIS TEST
|
||||
* WILL CAUSE THE HARDWARE TO CRASH
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testBUS.h"
|
||||
#include "bus.h"
|
||||
#include "uart2.h"
|
||||
#include "uart3.h"
|
||||
#include "SerOut.h"
|
||||
#include "taskfunctions.h"
|
||||
#include "ledfunctions.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
char BUS1Buffer[20] = " 'BUSTEST first' "; /* first Teststring */
|
||||
char BUS2Buffer[20] = " 'BUSTEST second' "; /* second Teststring */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void onUart2TxFinished();
|
||||
extern void onUart3TxFinished();
|
||||
|
||||
|
||||
BOOLEAN testbusStart(void)
|
||||
{
|
||||
/*Local Variable Declaration */
|
||||
BOOLEAN BUSTestResult = FALSE;
|
||||
BOOLEAN BUSTest11 = FALSE;
|
||||
BOOLEAN BUSTest12 = FALSE;
|
||||
BOOLEAN BUSTest21 = FALSE;
|
||||
BOOLEAN BUSTest22 = FALSE;
|
||||
BOOLEAN receive;
|
||||
UINT8 buffer;
|
||||
|
||||
|
||||
BUSTest11 = DoBUS1Test(); /* Test Bus1 */
|
||||
BUSTest12 = DoBUS2Test(); /* Test Bus2 */
|
||||
|
||||
|
||||
sendString (SerOutPort, TRUE, noteMessage, /* Send Text notification */
|
||||
NewLine, "\tSWITCH BUS CONNECTOR AND PRESS ENTER", NewLine);
|
||||
|
||||
do /* do-while loop for String input */
|
||||
{
|
||||
receive = serGet(SerOutPort, &buffer);
|
||||
} while (buffer != 13); /*Read input until ENTER-Key */
|
||||
|
||||
BUSTest21 = DoBUS1Test(); /* Test Bus1 */
|
||||
BUSTest22 = DoBUS2Test(); /* Test Bus2 */
|
||||
|
||||
if ((BUSTest11 == TRUE) && (BUSTest12 == TRUE)
|
||||
&&(BUSTest21 == TRUE) && (BUSTest22 == TRUE))
|
||||
{ /* If both Bustests passed */
|
||||
BUSTestResult = TRUE; /* set Test Result to TRUE */
|
||||
}
|
||||
|
||||
return BUSTestResult; /* Return Test Result */
|
||||
}
|
||||
|
||||
BOOLEAN DoBUS1Test (void)
|
||||
{
|
||||
/* Local Variable Declaration */
|
||||
BOOLEAN Uart2TestResult = TRUE;
|
||||
UINT16 B1received_int = 0;
|
||||
UINT16 B1send_int = 0;
|
||||
UINT8 B1receiveBuffer[50];
|
||||
|
||||
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tWrite String ", BUS1Buffer, " on BUS1... ");
|
||||
busWrite ( BUS1, sizeof (BUS1Buffer), (UINT8 *) BUS1Buffer);
|
||||
/* Send Teststring on Bus1 */
|
||||
vTaskDelay (500); /* Wait to InputRegister to be ready*/
|
||||
B1send_int = sizeof (BUS1Buffer); /* calculate Length of Teststring */
|
||||
B1received_int = busRead (BUS2, (UINT8 *)B1receiveBuffer);
|
||||
/* Read Teststring on Bus2 */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tRead ", (char *) B1receiveBuffer, " on BUS2");
|
||||
/* Message out received String */
|
||||
if (B1send_int != B1received_int) /* If received String is a fault */
|
||||
{
|
||||
Uart2TestResult = FALSE; /* Set Bus1 TestResult to FALSE */
|
||||
}
|
||||
return Uart2TestResult; /* Return Test Result */
|
||||
}
|
||||
|
||||
BOOLEAN DoBUS2Test (void)
|
||||
{
|
||||
/* See "DoBUS1Test" for comments */
|
||||
|
||||
BOOLEAN Uart3TestResult = TRUE;
|
||||
UINT16 B2received_int = 0;
|
||||
UINT16 B2send_int = 0;
|
||||
UINT8 B2receiveBuffer[50];
|
||||
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tWrite String ", BUS2Buffer, " on BUS2... ");
|
||||
busWrite ( BUS2, sizeof (BUS2Buffer), (UINT8 *) BUS2Buffer);
|
||||
vTaskDelay( 500 );
|
||||
B2send_int = sizeof (BUS2Buffer);
|
||||
B2received_int = busRead (BUS1, (UINT8 *)B2receiveBuffer);
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tRead ", (char *) B2receiveBuffer, " on BUS1");
|
||||
|
||||
if (B2send_int != B2received_int)
|
||||
{
|
||||
Uart3TestResult = FALSE;
|
||||
}
|
||||
return Uart3TestResult;
|
||||
}
|
||||
|
||||
BOOLEAN Uart2LoopBackTest (void)
|
||||
{
|
||||
/* UART2 is in LoopBack by forcing it to receive its own Transmission */
|
||||
FIO4CLR |= (1 << 1); /* Enable Receiver */
|
||||
FIO4SET |= (1 << 0); /* Enable Transmitter */
|
||||
|
||||
/* Local Variable Declaration */
|
||||
BOOLEAN Result = TRUE; /* LoopBack Test Result */
|
||||
char EBBuffer[10] = "placed"; /* Teststring */
|
||||
UINT16 EBsend_int = 0;
|
||||
UINT16 EBreceived_int = 0;
|
||||
UINT8 EBreceiveBuffer[10];
|
||||
|
||||
uart2Write( (char *)EBBuffer, sizeof(EBBuffer)); /* Write Teststring */
|
||||
EBsend_int = sizeof (EBBuffer); /* Calculate Length */
|
||||
vTaskDelay (500); /* Wait to InputRegister to be ready*/
|
||||
EBreceived_int = busRead (BUS2, (UINT8 *)EBreceiveBuffer);
|
||||
/* Read/Delete received String */
|
||||
EBreceived_int = busRead (BUS1, (UINT8 *)EBreceiveBuffer);
|
||||
/* Read/Delete received String */
|
||||
if (EBsend_int != EBreceived_int) /* If received String is a fault */
|
||||
{
|
||||
Result = FALSE; /* Set Result to FALSE */
|
||||
}
|
||||
|
||||
onUart2TxFinished(); /* Switch back to receive Mode */
|
||||
return Result; /* Return Result */
|
||||
}
|
||||
|
||||
BOOLEAN Uart3LoopBackTest (void)
|
||||
{
|
||||
/* UART3 is in LoopBack by forcing it to receive its own Transmission */
|
||||
FIO4CLR |= (1 << 3); /* Enable Receiver */
|
||||
FIO4SET |= (1 << 2); /* Enable Transmitter */
|
||||
|
||||
BOOLEAN Result = TRUE;
|
||||
|
||||
char EBBuffer[10] = "placed";
|
||||
UINT16 EBsend_int = 0;
|
||||
UINT16 EBreceived_int = 0;
|
||||
UINT8 EBreceiveBuffer[10];
|
||||
|
||||
uart3Write( (char *)EBBuffer, sizeof(EBBuffer));
|
||||
EBsend_int = sizeof (EBBuffer);
|
||||
vTaskDelay (500);
|
||||
EBreceived_int = busRead (BUS1, (UINT8 *)EBreceiveBuffer);
|
||||
EBreceived_int = busRead (BUS2, (UINT8 *)EBreceiveBuffer);
|
||||
if (EBsend_int != EBreceived_int)
|
||||
{
|
||||
Result = FALSE;
|
||||
}
|
||||
onUart3TxFinished();
|
||||
return Result;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testuart2.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:
|
||||
* Headerfile for testBus.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mar 10, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTUART2_H_
|
||||
#define TESTUART2_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testBUSStart
|
||||
*
|
||||
* Main Function of BUS Tests
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testbusStart();
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: DoBUS1Test / DoBUS2Test
|
||||
*
|
||||
* Functions to Test both Busses
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - single Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN DoBUS1Test (void);
|
||||
BOOLEAN DoBUS2Test (void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: Uart2LoopBackTest / Uart3LoopBackTest
|
||||
*
|
||||
* Functions to set either Uart2 or Uart3 in a Loopback Mode to receive it's
|
||||
* own sent Message. Functions contain a Test that checks wether the received
|
||||
* Message equals the sent one.
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN Uart2LoopBackTest (void);
|
||||
BOOLEAN Uart3LoopBackTest (void);
|
||||
|
||||
|
||||
#endif /*TESTUART2_H_*/
|
||||
@@ -0,0 +1,130 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testLED.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, Mei 16, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testLED.h"
|
||||
#include "serial.h"
|
||||
#include "SerOut.h"
|
||||
#include "dio.h"
|
||||
#include "leds.h"
|
||||
#include "taskfunctions.h"
|
||||
#include "ledfunctions.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
BOOLEAN testledStart (void)
|
||||
{
|
||||
BOOLEAN testledResult = FALSE;
|
||||
|
||||
testledResult = doledTest ();
|
||||
|
||||
return (testledResult);
|
||||
}
|
||||
|
||||
BOOLEAN doledTest (void)
|
||||
{
|
||||
UINT8 buffer;
|
||||
UINT8 captureDio;
|
||||
BOOLEAN ledTest = TRUE;
|
||||
BOOLEAN receive = FALSE;
|
||||
|
||||
captureDio = dioCapture();
|
||||
|
||||
|
||||
/* Set all DIOs to HIGH */
|
||||
dioWrite (0, 0, TRUE);
|
||||
dioWrite (0, 1, TRUE);
|
||||
dioWrite (0, 2, TRUE);
|
||||
dioWrite (0, 3, TRUE);
|
||||
dioWrite (0, 4, TRUE);
|
||||
dioWrite (0, 5, TRUE);
|
||||
dioWrite (0, 6, TRUE);
|
||||
dioWrite (0, 7, TRUE);
|
||||
|
||||
ledSet (LED0, 1); /* Set RED Status LED to HIGH */
|
||||
|
||||
if (d_gLED == pdPASS) /* Check for existing LED Task */
|
||||
{
|
||||
vTaskSuspend (gLED); /* Suspend existing Task */
|
||||
}
|
||||
ledSet (LED1, 1); /* Set GREEN Status LED to HIGH */
|
||||
|
||||
|
||||
FIO0DIR |= (1 << 13); /* Set USB_LED PIN as GP Output */
|
||||
FIO0CLR1 |= (1 << 5); /* Drive USB_LED PIN to ZERO */
|
||||
|
||||
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) */
|
||||
{
|
||||
ledTest = TRUE;
|
||||
}
|
||||
else if (buffer == 110) /* 110 = n (ScanCode) */
|
||||
{
|
||||
ledTest = FALSE;
|
||||
}
|
||||
|
||||
vTaskResume (gLED); /* Resume ActiveLED Task */
|
||||
FIO0SET1 |= (1 << 5); /* Drive USB_LED PIN to HIGH */
|
||||
dioResume(captureDio);
|
||||
|
||||
|
||||
return (ledTest);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testLED.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: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mei 16, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTLED_H_
|
||||
#define TESTLED_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.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testledStart
|
||||
*
|
||||
* Main Function of LED test
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testledStart (void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: DoledTest
|
||||
*
|
||||
* Switchs on all accessable LEDs and asks the user to tell result
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - single Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN doledTest (void);
|
||||
|
||||
|
||||
#endif /*TESTLED_H_*/
|
||||
@@ -0,0 +1,288 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testMMC.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:
|
||||
* MemoryCard Test Application
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Apr 24, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Compiler includes */
|
||||
#include <string.h>
|
||||
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testMMC.h"
|
||||
#include "mmc.h"
|
||||
#include "mmc_transfer.h"
|
||||
#include "ledfunctions.h"
|
||||
#include "SerOut.h"
|
||||
#include "dio.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define PageSize 512 /* MMC Card Memory Page Size */
|
||||
#define ArrayLength 0x1000 /* Length of test Arrays */
|
||||
|
||||
#define MaxNumberOfAddress 7 /* Number of Testadresses */
|
||||
#define MaxNumberOfLength 7 /* Number of Testlengths */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Array contains all Adresses, where Data should be written to */
|
||||
UINT32 AddressArray[MaxNumberOfAddress] =
|
||||
{
|
||||
0x00,
|
||||
0x10,
|
||||
0x200,
|
||||
0x23E,
|
||||
0x3FF,
|
||||
0x400,
|
||||
0x401,
|
||||
};
|
||||
|
||||
/* Array contains all Lengths, that should be written to the Testadresses */
|
||||
UINT32 LengthArray[MaxNumberOfLength]=
|
||||
{
|
||||
0x00,
|
||||
0x80,
|
||||
0x199,
|
||||
0x200,
|
||||
0x201,
|
||||
0x800,
|
||||
0x1000
|
||||
};
|
||||
|
||||
UINT8 Write[0x1000]; /* used with MMC Write Function */
|
||||
UINT8 Read[0x1000]; /* used with MMC Read Function */
|
||||
UINT8 nullarray[0x1000];
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOLEAN testmmcStart(void)
|
||||
{
|
||||
BOOLEAN testMMCResult = FALSE;
|
||||
|
||||
testMMCResult = DoMMCTest();
|
||||
|
||||
return (testMMCResult);
|
||||
}
|
||||
|
||||
BOOLEAN DoMMCTest (void)
|
||||
{
|
||||
UINT32 loopcnt;
|
||||
UINT32 AddressIndex= 0;
|
||||
UINT32 LengthIndex = 0;
|
||||
UINT8 character = 4;
|
||||
BOOLEAN MMCTestResult = FALSE;
|
||||
BOOLEAN RWTest = TRUE;
|
||||
BOOLEAN LengthTest = TRUE;
|
||||
BOOLEAN MBSTest = TRUE;
|
||||
BOOLEAN PresentTest = TRUE;
|
||||
MmcState_t WriteStatus;
|
||||
MmcState_t ReadStatus;
|
||||
MmcState_t DiscStatus;
|
||||
|
||||
/* Prepare Read and Write Array with writing Zero to every Position */
|
||||
for (loopcnt = 0; loopcnt < ArrayLength; loopcnt++)
|
||||
{
|
||||
Read[loopcnt] = 0;
|
||||
Write[loopcnt] = 0;
|
||||
nullarray[loopcnt] = 0;
|
||||
|
||||
}
|
||||
|
||||
/* Fill WriteArray with Characters */
|
||||
for (loopcnt = 0; loopcnt < ArrayLength; loopcnt++)
|
||||
{
|
||||
Write[loopcnt] = character;
|
||||
character += 3;
|
||||
}
|
||||
|
||||
MMC_StatusOut (DiscStatus = MmcInitMedia()); /* Init Card, give Status */
|
||||
|
||||
if (DiscStatus == MmcNoPresent)
|
||||
{
|
||||
/* disc is not inserted, so Test will be aborted here */
|
||||
PresentTest = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Nested Test
|
||||
* Array "Write" is written with all available Lengths in LengthArray
|
||||
* to all available Adresses in AdressArray.
|
||||
*/
|
||||
while (AddressIndex < MaxNumberOfAddress)
|
||||
{
|
||||
LengthIndex = 0; /* Reset LengthIndex */
|
||||
while (LengthIndex < MaxNumberOfLength)
|
||||
{
|
||||
WriteStatus = CardWrite ((pUINT8)Write, AddressArray[AddressIndex],
|
||||
LengthArray[LengthIndex]); /* Write to MMC */
|
||||
|
||||
ReadStatus = CardRead ((pUINT8)Read, AddressArray[AddressIndex],
|
||||
LengthArray[LengthIndex]); /* Read from MMC */
|
||||
|
||||
/* Check Status of Read and Write Events */
|
||||
if ((ReadStatus == MmcOk) && (WriteStatus == MmcOk))
|
||||
{
|
||||
for (loopcnt = 0; loopcnt < LengthArray[LengthIndex]; loopcnt++)
|
||||
{ /* Compare both Arrays */
|
||||
if (Read[loopcnt] != Write[loopcnt])
|
||||
{ /* If miscompare occures */
|
||||
dioWrite(0, 6, TRUE);
|
||||
RWTest = FALSE;
|
||||
}
|
||||
else /* Everything's OK */
|
||||
{
|
||||
dioWrite(0, 7, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if Length-Control in MMC-Read/Write works correctly*/
|
||||
else if (((LengthArray[LengthIndex] % PageSize) != 0)
|
||||
|| (LengthArray[LengthIndex] == 0))
|
||||
{
|
||||
if ((WriteStatus == MmcMiscompare)
|
||||
&& (ReadStatus == MmcMiscompare))
|
||||
{
|
||||
dioWrite (0,5,TRUE); /* Length Control works */
|
||||
}
|
||||
else
|
||||
{
|
||||
dioWrite (0,4,TRUE); /* Length Control works not */
|
||||
LengthTest = FALSE;
|
||||
}
|
||||
}
|
||||
/* Check if MasterBootSector Protection works */
|
||||
else if ((AddressArray[AddressIndex] < 0x200)
|
||||
&& (LengthArray[LengthIndex] != 0))
|
||||
{
|
||||
if (WriteStatus == MmcCardError)
|
||||
{
|
||||
dioWrite (0,3,TRUE); /* MBS Protection works */
|
||||
}
|
||||
else
|
||||
{
|
||||
dioWrite (0,2,TRUE); /* MBS Protection works not */
|
||||
MBSTest = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
dioWrite (0,1,TRUE);
|
||||
dioWrite (0,0,TRUE);
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\t Length: ", s_tab, ItoDStr (LengthArray[LengthIndex]));
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\t Address: ", s_tab, ItoDStr (AddressArray[AddressIndex]));
|
||||
MMC_StatusOut (WriteStatus);
|
||||
MMC_StatusOut (ReadStatus);
|
||||
RWTest = FALSE;
|
||||
}
|
||||
|
||||
LengthIndex++;
|
||||
} // End LENGTH WHILE-LOOP
|
||||
AddressIndex++;
|
||||
} // End ADDRESS WHILE-LOOP
|
||||
}
|
||||
|
||||
|
||||
vTaskDelay (1000);
|
||||
/* Test Result Message Output */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\t Disc present: ", s_tab, BoolRestoStr (PresentTest));
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\t Read and Write Test: ", f_tab, BoolRestoStr(RWTest));
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\t Length Status Check: ", f_tab, BoolRestoStr(LengthTest));
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\t MBS Defend Check: ", f_tab, BoolRestoStr(MBSTest));
|
||||
|
||||
/* Calculate complete Test Result out of single Tests */
|
||||
if ((RWTest == TRUE) && (LengthTest == TRUE)
|
||||
&& (MBSTest == TRUE) && (PresentTest == TRUE))
|
||||
{
|
||||
MMCTestResult = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
MMCTestResult = FALSE;
|
||||
}
|
||||
|
||||
|
||||
return (MMCTestResult);
|
||||
}
|
||||
|
||||
void MMC_StatusOut (MmcState_t Status)
|
||||
{
|
||||
switch (Status)
|
||||
{
|
||||
case MmcOk:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"MMC is OK", Dummy, Dummy);
|
||||
break;
|
||||
case MmcNoPresent:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"MMC is not present", Dummy, Dummy);
|
||||
break;
|
||||
case MmcNoResponse:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"MMC not responding", Dummy, Dummy);
|
||||
break;
|
||||
case MmcCardError:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"MMC Card Error", Dummy, Dummy);
|
||||
break;
|
||||
case MmcMiscompare:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"MMC Miscompare", Dummy, Dummy);
|
||||
break;
|
||||
case MmcDmaError:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"MMC DMA Error", Dummy, Dummy);
|
||||
break;
|
||||
case MmcProtect:
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"Card is Protected", Dummy, Dummy);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testMMC.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, Apr 24, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTMMC_H_
|
||||
#define TESTMMC_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "mmc.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testmmcStart
|
||||
*
|
||||
* Main Function of MemoryCard Test Application
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testmmcStart (void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function:DoMMCTest
|
||||
*
|
||||
* Contains test Application
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN DoMMCTest (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* MMC_StatusOut
|
||||
*
|
||||
* Function to Printout MMC Status
|
||||
*
|
||||
* Parameters: MmcState_t Status - MMC Status to print out
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void MMC_StatusOut (MmcState_t Status);
|
||||
|
||||
|
||||
|
||||
#endif /*TESTMMC_H_*/
|
||||
@@ -0,0 +1,413 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testaio.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:
|
||||
* Analogue Test File
|
||||
*
|
||||
* Note:
|
||||
* Output 0 is connected to Input 0 and 4
|
||||
* Output 1 is connected to Input 1 and 5
|
||||
* Output 2 is connected to Input 2 and 6
|
||||
* Output 3 is connected to Input 3 and 7
|
||||
*
|
||||
*
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Sep 08, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "adc.h"
|
||||
#include "dac.h"
|
||||
#include "dio.h"
|
||||
#include "testaio.h"
|
||||
#include "calibrateaio.h"
|
||||
|
||||
#include "SerOut.h"
|
||||
#include "BusProtocol.h"
|
||||
|
||||
#include "remote_misc.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define NumberOfAIs maxADC_Channels /* See adc.h */
|
||||
#define NumberOfAIOs maxDAC_Channels /* See dac.h */
|
||||
|
||||
#define vTestValue 5000 /* Value for Test Voltage Output in mV */
|
||||
#define cTestValue 10000 /* Value for Test Current Output in uA */
|
||||
#define vNullValue 0
|
||||
#define cNullValue 0
|
||||
|
||||
#define vLimit 20 /* Test Limit for Voltage Test */
|
||||
#define cLimit 100 /* Test Limit for Current Test */
|
||||
|
||||
#define vNullLimit 50 /* Test Limit for NULL-Voltage Test */
|
||||
#define cNullLimit 50 /* Test Limit for NULL-Current Test */
|
||||
|
||||
#define TestDelay 200
|
||||
|
||||
#define VoltageOutputCalibrationValue 10000 /* Calibration Value for V */
|
||||
#define CurrentOutputCalibrationValue 20000 /* Calibration Value for C */
|
||||
|
||||
#define VoltageOutputTestValue 7000 /* Remote Test Value for V */
|
||||
#define CurrentOutputTestValue 15000 /* Remote Test Value for C */
|
||||
|
||||
#define ident_calibrated 0x55 /* Calibrated status identifier */
|
||||
#define ident_default 0xAA /* Default status identifier */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Bus informations from protocolfunctions.c */
|
||||
extern UINT8 remoteDeviceNumber;
|
||||
extern UINT8 thisDeviceNumber;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOLEAN testaioStart (void)
|
||||
{
|
||||
BOOLEAN AIOTestResult = FALSE; /* BOOLEAN Variable to return Result*/
|
||||
BOOLEAN VoltageTest_MB;
|
||||
BOOLEAN CurrentTest_MB;
|
||||
BOOLEAN VoltageTest_EB;
|
||||
BOOLEAN CurrentTest_EB;
|
||||
|
||||
/* Do analogue line test for Mainboard Connectors */
|
||||
VoltageTest_MB = doAIOVoltageTest(); /* Call Test Function */
|
||||
CurrentTest_MB = doAIOCurrentTest();
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
/* Enable extension-board channels by switching multiplexers */
|
||||
adc_MuxEn(TRUE);
|
||||
dac_MuxEn(TRUE);
|
||||
|
||||
/* Do analogue line test for extension Board Connectors */
|
||||
VoltageTest_EB = doAIOVoltageTest(); /* Call Test Function */
|
||||
CurrentTest_EB = doAIOCurrentTest();
|
||||
|
||||
/* Switch off multiplexers again to main-board connectors */
|
||||
adc_MuxEn(FALSE);
|
||||
dac_MuxEn(FALSE);
|
||||
#endif
|
||||
|
||||
if ((VoltageTest_MB == TRUE) && (CurrentTest_MB == TRUE)
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
&& (VoltageTest_EB == TRUE) && (CurrentTest_EB == TRUE)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
AIOTestResult = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
AIOTestResult = FALSE;
|
||||
}
|
||||
|
||||
return (AIOTestResult); /* Return Test Result */
|
||||
}
|
||||
|
||||
BOOLEAN doAIOVoltageTest (void)
|
||||
{
|
||||
UINT32 aiocnt;
|
||||
BOOLEAN AIOLineTestResult = FALSE;
|
||||
BOOLEAN LowTest = TRUE;
|
||||
BOOLEAN AllOtherTest = TRUE;
|
||||
BOOLEAN HighTest = TRUE;
|
||||
UINT32 LowBuffer;
|
||||
BOOLEAN AllOtherBuffer;
|
||||
UINT32 HighBuffer;
|
||||
|
||||
SetAnalogueInput(FALSE); /* Set Analogue Input to Voltage */
|
||||
dacMode (0, dacVOLTAGE); /* Set Output Types to Voltage */
|
||||
dacMode (1, dacVOLTAGE);
|
||||
dacMode (2, dacVOLTAGE);
|
||||
dacMode (3, dacVOLTAGE);
|
||||
|
||||
dacWrite (thisDeviceNumber, 0, vNullValue); /* Write 0 Volts to Output */
|
||||
dacWrite (thisDeviceNumber, 1, vNullValue);
|
||||
dacWrite (thisDeviceNumber, 2, vNullValue);
|
||||
dacWrite (thisDeviceNumber, 3, vNullValue);
|
||||
vTaskDelay (TestDelay);
|
||||
|
||||
sendString (SerOutPort, FALSE, testMessage, NewLine,
|
||||
"\tVoltage Test Value: ", ItoDStr (vTestValue));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t\tTolerance: ", ItoDStr (vLimit), Dummy);
|
||||
|
||||
for (aiocnt = 0; aiocnt < NumberOfAIs; aiocnt++) /*Test Line by Line */
|
||||
{
|
||||
/* Test if Input Voltage is below NullLimit */
|
||||
if ((LowBuffer = adcRead (thisDeviceNumber, aiocnt)) > vNullLimit)
|
||||
{
|
||||
LowTest = FALSE; /* Failed, then set Test failed */
|
||||
}
|
||||
|
||||
/* Write chosen Output to Test Value */
|
||||
if (aiocnt < NumberOfAIOs)
|
||||
{
|
||||
dacWrite (thisDeviceNumber, aiocnt, vTestValue);
|
||||
}
|
||||
else /* if selected Input is > possible */
|
||||
{ /* Outputs, restart at Output 0 */
|
||||
dacWrite (thisDeviceNumber, (aiocnt - NumberOfAIOs), vTestValue);
|
||||
}
|
||||
vTaskDelay (TestDelay); /* Wait for Output to be set */
|
||||
|
||||
/* Check if all other Inputs are Zero */
|
||||
if ((AllOtherBuffer = CheckAllOtherAIOZero(aiocnt, TRUE)) == FALSE)
|
||||
{
|
||||
AllOtherTest = FALSE;
|
||||
}
|
||||
|
||||
/* Read Test Level on Input */
|
||||
HighBuffer = adcRead (thisDeviceNumber, aiocnt);
|
||||
if ((HighBuffer < (vTestValue - vLimit))
|
||||
|| (HighBuffer > (vTestValue + vLimit))) // \TODO is this working???
|
||||
{ /* Is read Value in the Limits? */
|
||||
HighTest = FALSE;
|
||||
}
|
||||
|
||||
/* Write chosen Output back to Null */
|
||||
if (aiocnt < NumberOfAIOs)
|
||||
{
|
||||
dacWrite (thisDeviceNumber, aiocnt, vNullValue);
|
||||
}
|
||||
else /* if selected Input is > possible */
|
||||
{ /* Outputs, restart at Output 0 */
|
||||
dacWrite (thisDeviceNumber, (aiocnt - NumberOfAIOs), vNullValue);
|
||||
}
|
||||
|
||||
/* Message out Test Results */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tVoltage Test for Analogue Input ", ItoDStr(aiocnt), ": ");
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, ItoDStr (LowBuffer));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, ItoDStr (HighBuffer));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" All Other: ", Dummy, BoolRestoStr (AllOtherBuffer));
|
||||
|
||||
vTaskDelay (TestDelay);
|
||||
}
|
||||
|
||||
/* Set complete LineTestResult */
|
||||
if ((LowTest == TRUE) && (HighTest == TRUE) && (AllOtherTest == TRUE))
|
||||
{
|
||||
AIOLineTestResult = TRUE;
|
||||
}
|
||||
|
||||
return (AIOLineTestResult);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN doAIOCurrentTest (void)
|
||||
{
|
||||
UINT32 aiocnt;
|
||||
UINT32 LowBuffer;
|
||||
UINT32 HighBuffer;
|
||||
BOOLEAN AIOCurrentTest = TRUE;
|
||||
BOOLEAN LowTest;
|
||||
BOOLEAN HighTest;
|
||||
|
||||
|
||||
|
||||
dacMode (0, dacCURRENT); /* Set Output Types to Current */
|
||||
dacMode (1, dacCURRENT);
|
||||
dacMode (2, dacCURRENT);
|
||||
dacMode (3, dacCURRENT);
|
||||
|
||||
dacWrite (thisDeviceNumber, 0, cNullValue); /* Write 0 uA to Output */
|
||||
dacWrite (thisDeviceNumber, 1, cNullValue);
|
||||
dacWrite (thisDeviceNumber, 2, cNullValue);
|
||||
dacWrite (thisDeviceNumber, 3, cNullValue);
|
||||
vTaskDelay (TestDelay);
|
||||
|
||||
sendString (SerOutPort, TRUE, testMessage, NewLine,
|
||||
"\tCurrent Test Value: ", ItoDStr (cTestValue));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t\tTolerance: ", ItoDStr (cLimit), Dummy);
|
||||
|
||||
for (aiocnt = 0; aiocnt < NumberOfAIs; aiocnt++)
|
||||
{
|
||||
adcMode( aiocnt, adcCURRENT ); /* Inputs set to Current */
|
||||
vTaskDelay (200);
|
||||
|
||||
/* Read back the low Value on Input */
|
||||
LowBuffer = adcRead (thisDeviceNumber, aiocnt);
|
||||
if (LowBuffer < cNullLimit)
|
||||
{
|
||||
/* If read Value is within the Limit, test passed */
|
||||
LowTest = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If read Value is out of Limit, test failed */
|
||||
LowTest = FALSE;
|
||||
}
|
||||
|
||||
/* Write Output to defined Test Value */
|
||||
if (aiocnt < NumberOfAIOs)
|
||||
{
|
||||
dacWrite(thisDeviceNumber, aiocnt, cTestValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
dacWrite(thisDeviceNumber, (aiocnt - NumberOfAIOs), cTestValue);
|
||||
}
|
||||
vTaskDelay (500);
|
||||
|
||||
HighBuffer = adcRead(thisDeviceNumber, aiocnt);
|
||||
if ((HighBuffer < (cTestValue - cLimit))
|
||||
|| (HighBuffer > (cTestValue + cLimit)))
|
||||
{
|
||||
/* If read Value is within the Limit, test passed */
|
||||
HighTest = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If read Value is out of Limit, test failed */
|
||||
HighTest = TRUE;
|
||||
}
|
||||
|
||||
/* Drive Output back to Zero Value */
|
||||
if (aiocnt < NumberOfAIOs)
|
||||
{
|
||||
dacWrite(thisDeviceNumber, aiocnt, cNullValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
dacWrite(thisDeviceNumber, (aiocnt - NumberOfAIOs), cNullValue);
|
||||
}
|
||||
/* Set Input Mode to Voltage to prevent of leek Current */
|
||||
adcMode (aiocnt, adcVOLTAGE);
|
||||
|
||||
/* Message out Test Results */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tCurrent Test for Analogue Input ", ItoDStr(aiocnt), ": ");
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, ItoDStr (LowBuffer));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, ItoDStr (HighBuffer));
|
||||
|
||||
/* Set complete LineTestResult */
|
||||
if ((LowTest != TRUE) || (HighTest != TRUE))
|
||||
{
|
||||
AIOCurrentTest = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return (AIOCurrentTest);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN CheckAllOtherAIOZero (UINT32 AIONumber, BOOLEAN local)
|
||||
{
|
||||
|
||||
UINT32 loopcnt;
|
||||
BOOLEAN AllZeroResult = TRUE;
|
||||
|
||||
for (loopcnt = 0; loopcnt < NumberOfAIs; loopcnt++) /* Test Line by Line*/
|
||||
{
|
||||
if ((loopcnt == AIONumber) || /* except currently tested Input */
|
||||
(loopcnt == (AIONumber + NumberOfAIOs)) ||
|
||||
(loopcnt == (AIONumber - NumberOfAIOs)))
|
||||
{
|
||||
if (loopcnt < (NumberOfAIOs - 1))
|
||||
{
|
||||
loopcnt++; /* Skip currently tested Output */
|
||||
}
|
||||
else
|
||||
{
|
||||
break; /* If tested Output is the last one,*/
|
||||
} /* simply break out of loop */
|
||||
}
|
||||
if (local == TRUE)
|
||||
{
|
||||
if (adcRead (thisDeviceNumber, loopcnt) > vNullLimit)
|
||||
{ /* If Input Value exceeds Limit */
|
||||
AllZeroResult = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (adcRead (remoteDeviceNumber, loopcnt) > vNullLimit)
|
||||
{ /* If Input Value exceeds Limit */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"line: ", ItoDStr (loopcnt), Dummy);
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"Value: ",
|
||||
ItoDStr (adcRead (remoteDeviceNumber, loopcnt)), Dummy);
|
||||
|
||||
AllZeroResult = FALSE;
|
||||
}
|
||||
vTaskDelay (100);
|
||||
}
|
||||
}
|
||||
return (AllZeroResult);
|
||||
}
|
||||
|
||||
|
||||
void SetAnalogueInput(BOOLEAN isCurrent)
|
||||
{
|
||||
if (isCurrent == TRUE)
|
||||
{
|
||||
adcMode( 0, adcCURRENT ); /* Inputs set to Current */
|
||||
adcMode( 1, adcCURRENT );
|
||||
adcMode( 2, adcCURRENT );
|
||||
adcMode( 3, adcCURRENT );
|
||||
adcMode( 4, adcCURRENT );
|
||||
adcMode( 5, adcCURRENT );
|
||||
adcMode( 6, adcCURRENT );
|
||||
adcMode( 7, adcCURRENT );
|
||||
}
|
||||
else
|
||||
{
|
||||
adcMode( 0, adcVOLTAGE ); /* Inputs set to Voltage */
|
||||
adcMode( 1, adcVOLTAGE );
|
||||
adcMode( 2, adcVOLTAGE );
|
||||
adcMode( 3, adcVOLTAGE );
|
||||
adcMode( 4, adcVOLTAGE );
|
||||
adcMode( 5, adcVOLTAGE );
|
||||
adcMode( 6, adcVOLTAGE );
|
||||
adcMode( 7, adcVOLTAGE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testaio.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:
|
||||
* Headerfile for analogue Testfile testaio.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Sep 08, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTAIO_H_
|
||||
#define TESTAIO_H_
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testioStart
|
||||
*
|
||||
* Main Function of Analogue Tests.
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return : BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testaioStart (void); /* Test analog Input/Output */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: doAIOVoltageTest / doAIOCurrentTest
|
||||
*
|
||||
* Function to test every single analogue Output and Input (either V or C)
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return : BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN doAIOVoltageTest (void);
|
||||
|
||||
BOOLEAN doAIOCurrentTest (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: CheckAllOtherAIOZero
|
||||
*
|
||||
* Function to check if all other analogue Inputs but the chosen one is
|
||||
* Zero or below a certain test Limit.
|
||||
*
|
||||
* Parameters: UINT32 AIONumber - currently tested Input
|
||||
* BOOLEAN local - check either local or remote lines
|
||||
*
|
||||
* Return : BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN CheckAllOtherAIOZero (UINT32 AIONumber, BOOLEAN local);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: Set AnalogueInput
|
||||
*
|
||||
* Function to set Inputs either to Voltage or Current Mode
|
||||
*
|
||||
* Parameters: BOOLEAN isCurrent - Indicates if Voltage or Current Mode
|
||||
*
|
||||
* Return : void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void SetAnalogueInput(BOOLEAN isCurrent);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testSlaveAnalogueLines
|
||||
*
|
||||
* Main function to remote AIO Test
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return : BOOLEAN - TestResult
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testSlaveAnalogueLines (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: remoteaioOutput
|
||||
*
|
||||
* Function to test remote analogue Outputs
|
||||
*
|
||||
* Parameters: BOOLEAN testmodeVOLTAGE - test in voltage (TRUE) or current
|
||||
* (FALSE) mode
|
||||
*
|
||||
* Return : BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN remoteaioOutput (BOOLEAN testmodeVOLTAGE);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: remoteaioInput
|
||||
*
|
||||
* Function to test remote analogue Inputs
|
||||
*
|
||||
* Parameters: BOOLEAN testmodeVOLTAGE - test in voltage (TRUE) or current
|
||||
* (FALSE) mode
|
||||
*
|
||||
* Return : BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN remoteaioInput (BOOLEAN testmodeVOLTAGE);
|
||||
|
||||
#endif /*TESTAIO_H_*/
|
||||
@@ -0,0 +1,121 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testcan.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 17, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testcan.h"
|
||||
#include "can.h"
|
||||
#include "SerOut.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define CAN_FILTER1 0x00000101
|
||||
#define CAN_MSGLNG 0x00050000
|
||||
#define CAN_DATAA 0x01234567
|
||||
#define CAN_DATAB 0xFEDCBA98
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOLEAN testCanStart (void)
|
||||
{
|
||||
BOOLEAN canResult;
|
||||
|
||||
canResult = canSelftest ();
|
||||
|
||||
return (canResult);
|
||||
}
|
||||
|
||||
BOOLEAN canSelftest (void)
|
||||
{
|
||||
CAN_MSG SendMessage;
|
||||
CAN_MSG ReceiveMessage;
|
||||
|
||||
/* Set CAN2 in SelfTest Mode - CAN2 must be in RESET mode for that */
|
||||
CAN2MOD |= (1 << 0); /* Set Mode to Reset (Bit 0) */
|
||||
CAN2MOD |= (1 << 2); /* Set bit "selftest" */
|
||||
CAN2MOD &=~(1 << 0); /* Set Mode to normal */
|
||||
|
||||
vTaskDelay (500);
|
||||
|
||||
// SendMessage.Dat1 = 0x00080102L; // 8 bytes, ID 0x102
|
||||
// SendMessage.DatA = 0x00000000L; // all zeros
|
||||
// SendMessage.DatB = 0x00000000L; // all zeros
|
||||
|
||||
SendMessage.Dat1 = (CAN_FILTER1 | CAN_MSGLNG); /* Set Length and Filter */
|
||||
SendMessage.DatA = CAN_DATAA; /* Define first 4 Bytes */
|
||||
SendMessage.DatB = CAN_DATAB; /* Define last 4 bytes */
|
||||
|
||||
CANPushMessage (&SendMessage);
|
||||
|
||||
vTaskDelay (1000);
|
||||
|
||||
CANPullMessage (&ReceiveMessage);
|
||||
|
||||
if (SendMessage.Dat1 == ReceiveMessage.Dat1)
|
||||
{
|
||||
debugPrint("Dat1 is OK\n\r");
|
||||
if (SendMessage.DatA == ReceiveMessage.DatA)
|
||||
{
|
||||
debugPrint("DataA is OK\n\r");
|
||||
if (SendMessage.DatB == ReceiveMessage.DatB)
|
||||
{
|
||||
debugPrint("DataB is OK\n\r");
|
||||
}
|
||||
else
|
||||
{
|
||||
debugPrint("DataB is not OK\n\r");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debugPrint("DataA is not OK\n\r");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debugPrint("Dat1 is not OK\n\r;");
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testcan.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 17, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTCAN_H_
|
||||
#define TESTCAN_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOLEAN testCanStart (void);
|
||||
|
||||
BOOLEAN canSelftest (void);
|
||||
|
||||
|
||||
#endif /*TESTCAN_H_*/
|
||||
@@ -0,0 +1,228 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testdio.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:
|
||||
* Contains the digital Input/Output test Function
|
||||
*
|
||||
*
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mar 06, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "dio.h"
|
||||
#include "testdio.h"
|
||||
#include "SerOut.h"
|
||||
#include "ledfunctions.h"
|
||||
#include "BusProtocol.h"
|
||||
#include "protocolfunctions.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define NumberOfDIOs 8
|
||||
#else
|
||||
#define NumberOfDIOs 11 /* Number of digital Inputs */
|
||||
#endif
|
||||
#define NumberOfDOs 8 /* Number of digital Outputs */
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOLEAN testdioStart (void)
|
||||
{
|
||||
BOOLEAN DIOTestResult;
|
||||
BOOLEAN DIOTestResult_MB = FALSE;
|
||||
BOOLEAN DIOTestResult_EB = FALSE;
|
||||
|
||||
DIOTestResult_MB = doDIOLineTest();
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
dio_inMuxEn();
|
||||
|
||||
/* Do digital line test for extension Board Connectors */
|
||||
DIOTestResult_EB = doDIOLineTest();
|
||||
|
||||
dio_outMuxEn();
|
||||
#endif
|
||||
|
||||
if ((DIOTestResult_MB == TRUE)
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
&& (DIOTestResult_EB == TRUE)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
DIOTestResult = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DIOTestResult = FALSE;
|
||||
}
|
||||
|
||||
return (DIOTestResult);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN doDIOLineTest (void)
|
||||
{
|
||||
UINT32 diocnt = 0;
|
||||
BOOLEAN LineTestResult = FALSE;
|
||||
BOOLEAN LowTest = TRUE;
|
||||
BOOLEAN AllOther = TRUE;
|
||||
BOOLEAN HighTest = TRUE;
|
||||
BOOLEAN LowBuffer;
|
||||
BOOLEAN AllOtherBuffer;
|
||||
BOOLEAN HighBuffer;
|
||||
|
||||
dioClean();
|
||||
vTaskDelay (100);
|
||||
|
||||
|
||||
for (diocnt = 0; diocnt < NumberOfDIOs; diocnt++)
|
||||
{
|
||||
/* Read LOW Value on selected Digital Input and set Read Result */
|
||||
if ((LowBuffer = !dioRead (thisDeviceNumber, diocnt)) == FALSE)
|
||||
{ /* LowBuffer contains Read Result */
|
||||
LowTest = FALSE;
|
||||
}
|
||||
|
||||
/* Drive selected Digital Output to HIGH. */
|
||||
if (diocnt >= NumberOfDOs)
|
||||
{
|
||||
dioWrite (thisDeviceNumber, (diocnt - NumberOfDOs), TRUE);
|
||||
}
|
||||
else /* if selected Input is > possible */
|
||||
{ /* Outputs, restart at Output 0 */
|
||||
dioWrite (thisDeviceNumber, diocnt, TRUE);
|
||||
}
|
||||
vTaskDelay (50); /* small Delay */
|
||||
|
||||
/* Check if all Lines but the selected one are LOW */
|
||||
if ((AllOtherBuffer = CheckAllOtherDIOZero(diocnt, TRUE)) == FALSE)
|
||||
{
|
||||
AllOther = FALSE;
|
||||
}
|
||||
|
||||
/* Read HIGH Value on selected Digital Input and set Read Result */
|
||||
if ((HighBuffer = dioRead (thisDeviceNumber, diocnt)) == FALSE)
|
||||
{
|
||||
HighTest = FALSE;
|
||||
}
|
||||
|
||||
/* Set selected digital Input back to LOW */
|
||||
if (diocnt >= NumberOfDOs)
|
||||
{
|
||||
dioWrite (thisDeviceNumber, (diocnt - NumberOfDOs), FALSE);
|
||||
}
|
||||
else /* if selected Input is > possible */
|
||||
{ /* Outputs, restart at Output 0 */
|
||||
dioWrite (thisDeviceNumber, diocnt, FALSE);
|
||||
}
|
||||
|
||||
/* Message out Test Results */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tLinetest for Digital Input ", ItoDStr(diocnt), ": ");
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, BoolRestoStr (LowBuffer));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, BoolRestoStr (AllOtherBuffer));
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
" ", Dummy, BoolRestoStr (HighBuffer));
|
||||
vTaskDelay (50);
|
||||
}
|
||||
|
||||
/* Set complete LineTestResult */
|
||||
if ((LowTest == TRUE) && (HighTest == TRUE) && (AllOther == TRUE))
|
||||
{
|
||||
LineTestResult = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
LineTestResult = FALSE;
|
||||
}
|
||||
|
||||
return (LineTestResult);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN CheckAllOtherDIOZero (UINT32 DIONumber, BOOLEAN local)
|
||||
{
|
||||
UINT32 loopcnt = 0;
|
||||
BOOLEAN allZeroResult = TRUE;
|
||||
|
||||
for (loopcnt = 0; loopcnt < NumberOfDIOs; loopcnt++) /*Test Line by Line*/
|
||||
{
|
||||
if ((loopcnt == DIONumber) || /* except currently tested Input */
|
||||
(loopcnt == (DIONumber + NumberOfDOs)) ||
|
||||
(loopcnt == (DIONumber - NumberOfDOs)))
|
||||
{
|
||||
if (loopcnt < (NumberOfDIOs - 1))
|
||||
{
|
||||
loopcnt++; /* Skip currently tested Input */
|
||||
}
|
||||
else
|
||||
{
|
||||
break; /* If currently tested Input is the */
|
||||
} /* last one, simply break out */
|
||||
}
|
||||
|
||||
if (local == TRUE)
|
||||
{
|
||||
if (dioRead (thisDeviceNumber, loopcnt) == TRUE)
|
||||
{
|
||||
allZeroResult = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dioRead (remoteDeviceNumber, loopcnt) == TRUE)
|
||||
{
|
||||
allZeroResult = FALSE;
|
||||
}
|
||||
vTaskDelay (100);
|
||||
}
|
||||
}
|
||||
return (allZeroResult);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testdio.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:
|
||||
* Headerfile for digital Input/Output Test testdio.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mar 06, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef TESTDIO_H_
|
||||
#define TESTDIO_H_
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testdioStart
|
||||
*
|
||||
* Main Function for Digital Tests
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testdioStart(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: doDIOLineTest
|
||||
*
|
||||
* Function to test LOW and HIGH Level on every single digital Input
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN doDIOLineTest (void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: CheckAllOtherDIOZero
|
||||
*
|
||||
* Function to test if all other Inputs but the chosen one is LOW
|
||||
*
|
||||
* Parameters: UINT32 DIONumber - currently tested Input
|
||||
* BOOLEAN local - Check local or remote lines
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN CheckAllOtherDIOZero (UINT32 DIONumber, BOOLEAN local);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testremotedioStart
|
||||
*
|
||||
* Main function to remote Digital IO Test
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testremotedioStart (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: remotedioOutput
|
||||
*
|
||||
* Remote digital Output test
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN remotedioOutput (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: remotedioInput
|
||||
*
|
||||
* Remote digital Input test
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN remotedioInput (void);
|
||||
|
||||
|
||||
|
||||
#endif /*TESTDIO_H_*/
|
||||
@@ -0,0 +1,172 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testeeprom.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, Mar 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testeeprom.h"
|
||||
#include "eeprom.h"
|
||||
#include "SerOut.h"
|
||||
#include "dio.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Use same Arrays as Flash Test to minimize Memory usage */
|
||||
// \MARK ARRAYS NOT NECESSARY ON OLIMEXBOARD
|
||||
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
|
||||
UINT8 eepromResponseString[3000];
|
||||
UINT8 eepromTestString[3000];
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT16 adres_var[2];
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
BOOLEAN testeepromStart(void)
|
||||
{
|
||||
BOOLEAN eepromTestResult;
|
||||
|
||||
eepromTestResult = doeepromTest();
|
||||
|
||||
return (eepromTestResult);
|
||||
}
|
||||
|
||||
BOOLEAN doeepromTest (void)
|
||||
{
|
||||
BOOLEAN testFailed= FALSE;
|
||||
|
||||
// \MARK TEST NOT NECESSARY ON OLIMEXBOARD
|
||||
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
|
||||
/*Local Variable Declaration */
|
||||
UINT8 testByte;
|
||||
UINT8 testString[] = "Dit is een oefening";
|
||||
UINT16 index;
|
||||
UINT8 oneByte = 0;
|
||||
|
||||
sendString (COM2, TRUE, testMessage,
|
||||
"\tWrite Byte 0x34 to Adress 256", Dummy, Dummy);
|
||||
eepromWrite (256, 0x34); /* Write one Byte to EEPROM */
|
||||
eepromRead (256, &testByte); /* Read written Byte from EEPROM */
|
||||
testFailed = (testByte != 0x34); /* compare read and written Bytes */
|
||||
if (testFailed == FALSE)
|
||||
{
|
||||
sendString (COM2, FALSE, testMessage,
|
||||
"\t DONE", Dummy, Dummy);
|
||||
dioWrite (0, 1, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendString (COM2, FALSE, testMessage,
|
||||
"\t FAILURE", Dummy, Dummy);
|
||||
dioWrite (0, 0, TRUE);
|
||||
}
|
||||
|
||||
if (!testFailed) /* If no Test fail up to here */
|
||||
{
|
||||
sendString (COM2, TRUE, testMessage,
|
||||
"\tWrite 10 Bytes to Adress 511", Dummy, Dummy);
|
||||
eepromWriteBuffer( 511, testString, 10);
|
||||
/* Write Teststring to EEPROM with */
|
||||
/* width of 10 Bytes */
|
||||
eepromReadBuffer( 511, eepromResponseString, 10);
|
||||
/* Read written String from EEPROM */
|
||||
|
||||
for (index = 0; index < 10; index++)
|
||||
{ /* Compare both Strings */
|
||||
if (eepromResponseString[index] != testString[index])
|
||||
{ /* If Strings are not equal */
|
||||
testFailed = TRUE; /* Set Test Result to FALSE */
|
||||
}
|
||||
}
|
||||
if (testFailed == FALSE)
|
||||
{
|
||||
sendString (COM2, FALSE, testMessage,
|
||||
"\t DONE", Dummy, Dummy);
|
||||
dioWrite (0, 3, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendString (COM2, FALSE, testMessage,
|
||||
"\t FAILURE", Dummy, Dummy);
|
||||
dioWrite (0, 2, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!testFailed) /* If no Test fail up to here */
|
||||
{
|
||||
sendString (COM2, TRUE, testMessage,
|
||||
"\tWrite 3000 Byte to Adress 500", Dummy, Dummy);
|
||||
int loopcnt;
|
||||
for (loopcnt=0; loopcnt < 3000; loopcnt++)
|
||||
{ /* Fill flashTestString */
|
||||
eepromTestString[loopcnt] = oneByte++;
|
||||
}
|
||||
eepromWriteBuffer( 500, eepromTestString, 3000);
|
||||
/* Write flashTestString to EEPROM */
|
||||
/* with width of 3000 Bytes */
|
||||
eepromReadBuffer( 500, eepromResponseString, 3000);
|
||||
/* Read written String from EEPROM */
|
||||
|
||||
for (index = 0; index < 3000; index++)
|
||||
{ /* Compare both Strings */
|
||||
if (eepromResponseString[index] != eepromTestString[index])
|
||||
{ /* If Strings are not equal */
|
||||
testFailed = TRUE; /* Set Test Result to FALSE */
|
||||
}
|
||||
}
|
||||
if (testFailed == FALSE)
|
||||
{
|
||||
sendString (COM2, FALSE, testMessage, "\t DONE", Dummy, Dummy);
|
||||
dioWrite (0, 5, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendString (COM2, FALSE, testMessage, "\t FAILURE", Dummy, Dummy);
|
||||
dioWrite (0, 4, TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (!testFailed); /* Return Test Result */
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testeeprom.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:
|
||||
* Headerfile for the EEPROMtest File testeeprom.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mar 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTEEPROM_H_
|
||||
#define TESTEEPROM_H_
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testeepromStart
|
||||
*
|
||||
* Main Function for EEPROM Tests
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: BOOLEAN - Test result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testeepromStart(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: doeepromTest
|
||||
*
|
||||
* Function containing EEPROM Test routines
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: BOOLEAN - Test result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN doeepromTest (void);
|
||||
|
||||
|
||||
#endif /*TESTEEPROM_H_*/
|
||||
@@ -0,0 +1,120 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testpower.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, Mar 25, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testpower.h"
|
||||
#include "power.h"
|
||||
#include "SerOut.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define lowerlimit5V 4800 /* Lower VCC Limit */
|
||||
#define higherlimit5V 5200 /* Higher VCC Limit */
|
||||
|
||||
#define lowerlimit24V 23000 /* Lower 24V Limit */
|
||||
#define higherlimit24V 25000 /* Higher 24V Limit */
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static UINT8 PWRTest; /* Debugable Variable, to show Bus Test Result */
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
BOOLEAN testpowerStart(void)
|
||||
{
|
||||
BOOLEAN PowerTestResult; /* BOOLEAN Variable for Test Result */
|
||||
|
||||
PowerTestResult = DoVoltageTest(); /* Do Power Test */
|
||||
return PowerTestResult; /* Return Test Result */
|
||||
}
|
||||
BOOLEAN DoVoltageTest (void)
|
||||
{
|
||||
/* Local Variable Declaration */
|
||||
BOOLEAN VTestResult = TRUE;
|
||||
static UINT16 vMeasure5V; /* Debugable */
|
||||
static UINT16 vMeasure24V;
|
||||
|
||||
PWRTest = 0x11;
|
||||
|
||||
/* Test for 5 V VCC Power Supply */
|
||||
vMeasure5V = powerVccVoltage(); /* Read current VCC Voltage */
|
||||
/* Message out Measure Value and Test Limits */
|
||||
sendString (SerOutPort, TRUE, testMessage, "\t5V Powertest", NewLine,
|
||||
"\tLimits (lower/higher): ");
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
ItoDStr (lowerlimit5V), devider, Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
Dummy, Dummy, ItoDStr (higherlimit5V));
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tDetected ", ItoDStr(vMeasure5V), " mV");
|
||||
|
||||
if ((vMeasure5V < lowerlimit5V) || (vMeasure5V > higherlimit5V))
|
||||
{ /* If measured Value out of Limits */
|
||||
VTestResult = FALSE; /* Set Test Result to FALSE */
|
||||
PWRTest &= ~(0x01);
|
||||
}
|
||||
|
||||
vTaskDelay (500); /* Wait for 500 ms */
|
||||
|
||||
/* Test for 24 V Power Supply */
|
||||
vMeasure24V = powerV24Voltage(); /* Read current power supply Voltage*/
|
||||
/* Message out Measure Value and Test Limits */
|
||||
sendString (SerOutPort, TRUE, testMessage, "\n\r\t24V Powertest", NewLine,
|
||||
"\tLimits (lower/higher): ");
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
ItoDStr (lowerlimit24V), devider, Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
Dummy, Dummy, ItoDStr (higherlimit24V));
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tDetected ", ItoDStr(vMeasure24V), " mV");
|
||||
|
||||
if ((vMeasure24V < lowerlimit24V) || (vMeasure24V > higherlimit24V))
|
||||
{ /* If measured Value out of Limits */
|
||||
VTestResult = FALSE; /* Set Test Result to FALSE */
|
||||
PWRTest &= ~(0x10);
|
||||
}
|
||||
|
||||
return VTestResult; /* Return Test Result */
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testpower.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:
|
||||
* Headerfile for powertest File testpower.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mar 25, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTPOWER_H_
|
||||
#define TESTPOWER_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testpowerStart
|
||||
*
|
||||
* Main Function for Power Tests
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testpowerStart(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: DoVoltageTest
|
||||
*
|
||||
* Function to test VCC and 24V Power Supply
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN DoVoltageTest (void);
|
||||
|
||||
|
||||
#endif /*TESTPOWER_H_*/
|
||||
@@ -0,0 +1,48 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testrly.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 17, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -0,0 +1,52 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testrly.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 17, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTRLY_H_
|
||||
#define TESTRLY_H_
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#endif /*TESTRLY_H_*/
|
||||
@@ -0,0 +1,182 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testrtc.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, Feb 26, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "testrtc.h"
|
||||
#include "rtc.h"
|
||||
#include "SerOut.h"
|
||||
#include "ledfunctions.h"
|
||||
#include "dio.h"
|
||||
#include "testdio.h"
|
||||
#include "taskfunctions.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Clock defines to set Clock to a known Value */
|
||||
#define dsec 5
|
||||
#define dmin 10
|
||||
#define dhour 15
|
||||
#define dday 20
|
||||
#define ddow 2
|
||||
#define dmon 3
|
||||
#define dyear 3250
|
||||
#define ddoy 350
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
t_rtc rtcWriteValue = /* Variable of RTC-used Type to set */
|
||||
{ dsec, /* RTC to a known Value */
|
||||
dmin,
|
||||
dhour,
|
||||
dday,
|
||||
ddow,
|
||||
dmon,
|
||||
dday,
|
||||
dyear,
|
||||
ddoy};
|
||||
|
||||
t_rtc rtcReadValue; /* Variable of RTC-used Type to */
|
||||
/* read RTC Values */
|
||||
t_rtc *rtcPtr; /* Pointer of RTC-Used Type */
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testrtcStart(void)
|
||||
{
|
||||
BOOLEAN testrtcResult = TRUE; /* BOOLEAN Variable for Test Result */
|
||||
|
||||
DoRTCWrite(); /* Write known Value to RTC */
|
||||
dioWrite (0, 1, TRUE);
|
||||
dioWrite (0, 3, TRUE);
|
||||
testrtcResult = DoRTCRead(); /* Read RTC Values */
|
||||
|
||||
return (testrtcResult); /* Return Test Result */
|
||||
}
|
||||
|
||||
|
||||
void DoRTCWrite (void)
|
||||
{
|
||||
rtcPtr = &rtcWriteValue; /* Set Pointer */
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tWrite Custom CLOCK Data to RTC Register",
|
||||
Dummy, NewLine); /* Message Output */
|
||||
rtcWrite (rtcPtr); /* Write Values to RTC */
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN DoRTCRead (void)
|
||||
{
|
||||
BOOLEAN rtcReadResult;
|
||||
rtcPtr = &rtcReadValue; /* Set Pointer */
|
||||
|
||||
sendString (SerOutPort, TRUE, testMessage,
|
||||
"\tAttempt to read RTC Values: ",
|
||||
Dummy, Dummy); /* Message Output */
|
||||
|
||||
rtcRead (rtcPtr); /* Read RTC Values */
|
||||
|
||||
/* Message out all read Values compared with written Values */
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Seconds: ",
|
||||
ItoDStr (rtcReadValue.sec), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (dsec), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Minutes: ",
|
||||
ItoDStr (rtcReadValue.min), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (dmin), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Hours: ",
|
||||
ItoDStr (rtcReadValue.hour), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (dhour), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Day: ",
|
||||
ItoDStr (rtcReadValue.day), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (dday), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Day of Week: ",
|
||||
ItoDStr (rtcReadValue.dow), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (ddow), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Month: ",
|
||||
ItoDStr (rtcReadValue.mon), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (dmon), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Year: ",
|
||||
ItoDStr (rtcReadValue.year), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (dyear), ")");
|
||||
vTaskDelay (200);
|
||||
sendString (SerOutPort, TRUE, testMessage, "\tRTC Day of Year: ",
|
||||
ItoDStr (rtcReadValue.doy), Dummy);
|
||||
sendString (SerOutPort, FALSE, testMessage,
|
||||
"\t(Should be: ", ItoDStr (ddoy), ")");
|
||||
|
||||
if ((dsec == rtcReadValue.sec) && /* Compare read Values with */
|
||||
(dmin == rtcReadValue.min) && /* written Values */
|
||||
(dhour == rtcReadValue.hour) &&
|
||||
(dday == rtcReadValue.day) &&
|
||||
(ddow == rtcReadValue.dow) &&
|
||||
(dmon == rtcReadValue.mon) &&
|
||||
(dyear == rtcReadValue.year) &&
|
||||
(ddoy == rtcReadValue.doy))
|
||||
{ /* If all Values equals */
|
||||
|
||||
rtcRead (rtcPtr); /* Read RTC Values again */
|
||||
if (dsec != rtcReadValue.sec) /* If RTC runs (seconds-compare) */
|
||||
{
|
||||
rtcReadResult = TRUE; /* Set Test Result to TRUE */
|
||||
}
|
||||
else /* If Run Test fails */
|
||||
{
|
||||
rtcReadResult = FALSE; /* Set Test Result to FALSE */
|
||||
}
|
||||
}
|
||||
else /* If Read Test Fails */
|
||||
{
|
||||
rtcReadResult = FALSE; /* Set Test Result to FALSE */
|
||||
}
|
||||
|
||||
return rtcReadResult; /* Return Test Result */
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* testrtc.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:
|
||||
* Headerfile for RTC test File testrtc.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 26, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TESTRTC_H_
|
||||
#define TESTRTC_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.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: testrtcStart
|
||||
*
|
||||
* Main Function for RTC Tests
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN testrtcStart(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: DoRTCWrite
|
||||
*
|
||||
* Writes defined Values to the RTC
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void DoRTCWrite (void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: DoRTCRead
|
||||
*
|
||||
* Reads Values from the RTC and compares them with written Values. Also does
|
||||
* a check if RTC is running
|
||||
*
|
||||
* Parameter: void
|
||||
*
|
||||
* Return: BOOLEAN - Test Result
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN DoRTCRead (void);
|
||||
|
||||
#endif /*TESTRTC_H_*/
|
||||
Reference in New Issue
Block a user