Added Software projects

git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
Matthias
2008-12-23 10:34:08 +00:00
parent ee5a771818
commit 373a8c32b2
348 changed files with 86781 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+85
View File
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Applications</name>
<comment></comment>
<projects>
<project>BusProtocol</project>
<project>Drivers</project>
<project>FreeRTOS</project>
<project>inc</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/Applications/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
</natures>
</projectDescription>
+146
View File
@@ -0,0 +1,146 @@
/* Sample initialization file */
.extern main
.extern exit
.text
.code 32
.align 4
.extern __bss_beg__
.extern __bss_end__
.extern __stack_end__
.extern __data_beg__
.extern __data_end__
.extern __data+beg_src__
.global start
.global endless_loop
/* Stack Sizes */
.set UND_STACK_SIZE, 0x00000004
.set ABT_STACK_SIZE, 0x00000004
.set FIQ_STACK_SIZE, 0x00000004
.set IRQ_STACK_SIZE, 0X00000100
.set SVC_STACK_SIZE, 0x00000100
/* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs */
.set MODE_USR, 0x10 /* User Mode */
.set MODE_FIQ, 0x11 /* FIQ Mode */
.set MODE_IRQ, 0x12 /* IRQ Mode */
.set MODE_SVC, 0x13 /* Supervisor Mode */
.set MODE_ABT, 0x17 /* Abort Mode */
.set MODE_UND, 0x1B /* Undefined Mode */
.set MODE_SYS, 0x1F /* System Mode */
.equ I_BIT, 0x80 /* when I bit is set, IRQ is disabled */
.equ F_BIT, 0x40 /* when F bit is set, FIQ is disabled */
start:
_start:
_mainCRTStartup:
/* Setup a stack for each mode - note that this only sets up a usable stack
for system/user, SWI and IRQ modes. Also each mode is setup with
interrupts initially disabled. */
ldr r0, .LC6
msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode
mov sp, r0
sub r0, r0, #UND_STACK_SIZE
msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */
mov sp, r0
sub r0, r0, #ABT_STACK_SIZE
msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */
mov sp, r0
sub r0, r0, #FIQ_STACK_SIZE
msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */
mov sp, r0
sub r0, r0, #IRQ_STACK_SIZE
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
mov sp, r0
sub r0, r0, #SVC_STACK_SIZE
msr CPSR_c, #MODE_SYS|I_BIT|F_BIT /* System Mode */
mov sp, r0
/* We want to start in supervisor mode. Operation will switch to system
mode when the first task starts. */
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT
/* Clear BSS. */
mov a2, #0 /* Fill value */
mov fp, a2 /* Null frame pointer */
mov r7, a2 /* Null frame pointer for Thumb */
ldr r1, .LC1 /* Start of memory block */
ldr r3, .LC2 /* End of memory block */
subs r3, r3, r1 /* Length of block */
beq .end_clear_loop
mov r2, #0
.clear_loop:
strb r2, [r1], #1
subs r3, r3, #1
bgt .clear_loop
.end_clear_loop:
/* Initialise data. */
ldr r1, .LC3 /* Start of memory block */
ldr r2, .LC4 /* End of memory block */
ldr r3, .LC5
subs r3, r3, r1 /* Length of block */
beq .end_set_loop
.set_loop:
ldrb r4, [r2], #1
strb r4, [r1], #1
subs r3, r3, #1
bgt .set_loop
.end_set_loop:
mov r0, #0 /* no arguments */
mov r1, #0 /* no argv either */
bl main
endless_loop:
b endless_loop
.align 0
.LC1:
.word __bss_beg__
.LC2:
.word __bss_end__
.LC3:
.word __data_beg__
.LC4:
.word __data_beg_src__
.LC5:
.word __data_end__
.LC6:
.word __stack_end__
/* Setup vector table. Note that undf, pabt, dabt, fiq just execute
a null loop. */
.section .startup,"ax"
.code 32
.align 0
.word 0x11111111 /* +0x0, product_id */
.word 0x10101010 /* +0x4, version */
.word 0x0 /* +0x8, length (filled by firmware loader) */
.word 0x0 /* +0xC, CRC (filled by firmware loader) */
.word 0x0 /* +0x10, reserved */
.word 0x0 /* +0x14, reserved */
.word 0x0 /* +0x18, reserved */
.word 0x0 /* +0x1C, reserved */
b _start /* +0x20, Firmware start */
@@ -0,0 +1,274 @@
/* ---------------------------------------------------------------------------
* ledfunctions.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:
* Some handy Functions for the status and the Digital Output LEDs
* ---------------------------------------------------------------------------
* 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 "leds.h"
#include "dio.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void LEDPauseFlash (t_led_ids LEDnum, UINT8 counts, INT16 delay_length)
{
/* Local Variable Declaration */
UINT16 loopcnt; /* loop index */
for ( loopcnt=0; loopcnt <= (counts*2); loopcnt++)
{
if (LEDnum == LED0) /* RED LED */
{
ledToggle (LED0); /* Toggle LED Status */
vTaskDelay (delay_length); /* Wait for defined time */
}
if (LEDnum == LED1) /* GREEN LED */
{
ledToggle (LED1);
vTaskDelay (delay_length);
}
}
if (ledGet (LED1) == FALSE) /* GREEN LED should be switched on */
{
ledToggle (LED1);
}
}
void LEDResult (BOOLEAN TestResult)
{
if (TestResult == TRUE) /* If Test was passed */
{
ledSet (LED0, 1); /* switch on RED LED */
}
if (TestResult == FALSE) /* If test failed */
{
ledSet (LED0, 0); /* Switch off RED LED */
}
}
void LEDResultDIO (BOOLEAN TestResult, UINT16 dioNo)
{
if (TestResult == TRUE) /* If Test was passed */
{
dioWrite (0, dioNo, TRUE); /* switch on DIO LED */
}
if (TestResult == FALSE) /* If test failed */
{
dioWrite (0, dioNo, FALSE); /* Switch off DIO LED */
}
}
void LEDToggleForever (void)
{
ledSet (LED0, FALSE); /* Set both LEDs to StartUp */
ledSet (LED1, TRUE);
vTaskDelay (500); /* Wait for 500 ms */
for (;;) /* endless loop */
{
ledToggle (LED0); /* Toggle RED LED */
ledToggle (LED1); /* Toggle GREEN LED */
vTaskDelay (500);
}
}
void LEDToggle (UINT16 cnts)
{
/* Local Variable Declaration */
UINT16 loopcnt; /* loop index */
ledSet (LED0, FALSE); /* Set both LEDs to StartUp */
ledSet (LED1, TRUE);
vTaskDelay (500); /* Wait for 500 ms */
for ( loopcnt = 0; loopcnt <= cnts; loopcnt++)
{
ledToggle(LED0); /* Toggle RED LED */
ledToggle(LED1); /* Toggle GREEN LED */
vTaskDelay (500);
}
}
void LEDShowStatus (UINT16 status)
{
/* Local Variable Declaration */
UINT16 loopcnt; /* loop index */
if (ledGet (LED0) == TRUE) /* If current LED Status is TRUE */
{
ledSet( LED0, FALSE); /* Switch of RED LED */
vTaskDelay (500); /* Wait for 500 ms */
}
for (loopcnt = 0; loopcnt <= (status*2); loopcnt++)
{
ledToggle (LED0); /* Toggle RED LED */
vTaskDelay (500);
}
vTaskDelay (1000);
}
void gLEDToggle (UINT16 time)
{
for (;;) /* Endless loop */
{
ledToggle (LED1); /* Toggle GREEN LED */
vTaskDelay (time); /* Wait for defined time */
}
}
void rLEDToggle (UINT16 time)
{
for (;;) /* Endless loop */
{
ledToggle (LED0); /* Toggle RED LED */
vTaskDelay (time); /* Wait for defined Time */
}
}
void dioToggle (UINT16 LEDnr)
{
UINT16 time = 100; /* LED Toggle-time definition */
for (;;) /* Endless loop */
{
dioWrite (0, LEDnr, TRUE); /* Write defined digitalOut to HIGH */
vTaskDelay (time); /* Wait for defined Toggle-time */
dioWrite (0, LEDnr, FALSE); /* Write defined digitalOut to LOW */
vTaskDelay (time);
}
}
void dioToggleNC (UINT16 LEDnr)
{
UINT16 time = 1000; /* LED Toggle-time definition */
for (;;) /* Endless loop */
{
dioWrite (0, LEDnr, TRUE); /* Write defined digitalOut to HIGH */
vTaskDelay (time); /* Wait for defined Toggle-time */
dioWrite (0, LEDnr, FALSE); /* Write defined digitalOut to LOW */
vTaskDelay (time);
}
}
void dio2x4 (UINT32 ToggleTime)
{
for (;;) /* endless loop */
{
dioWrite (0,0,TRUE); /* ON-OFF-ON-OFF-ON-OFF-ON-OFF */
dioWrite (0,1,FALSE);
dioWrite (0,2,TRUE);
dioWrite (0,3,FALSE);
dioWrite (0,4,TRUE);
dioWrite (0,5,FALSE);
dioWrite (0,6,TRUE);
dioWrite (0,7,FALSE);
vTaskDelay(ToggleTime); /* Wait Toggle Time */
dioWrite (0,0,FALSE); /* OFF-ON-OFF-ON-OFF-ON-OFF-ON */
dioWrite (0,1,TRUE);
dioWrite (0,2,FALSE);
dioWrite (0,3,TRUE);
dioWrite (0,4,FALSE);
dioWrite (0,5,TRUE);
dioWrite (0,6,FALSE);
dioWrite (0,7,TRUE);
vTaskDelay (ToggleTime);
}
}
void dioClean (void)
{
dioWrite (0,0,FALSE); /* Write digital Output to LOW */
dioWrite (0,1,FALSE);
dioWrite (0,2,FALSE);
dioWrite (0,3,FALSE);
dioWrite (0,4,FALSE);
dioWrite (0,5,FALSE);
dioWrite (0,6,FALSE);
dioWrite (0,7,FALSE);
}
UINT8 dioCapture (void)
{
/* Local Variable Declaration */
UINT8 dioCaptureResult = 0;
dioCaptureResult |= (dioReadBack (0,0) << 0); /*Save current DIO Status */
dioCaptureResult |= (dioReadBack (0,1) << 1);
dioCaptureResult |= (dioReadBack (0,2) << 2);
dioCaptureResult |= (dioReadBack (0,3) << 3);
dioCaptureResult |= (dioReadBack (0,4) << 4);
dioCaptureResult |= (dioReadBack (0,5) << 5);
dioCaptureResult |= (dioReadBack (0,6) << 6);
dioCaptureResult |= (dioReadBack (0,7) << 7);
return dioCaptureResult; /* Return saved DIO Status */
}
void dioResume (UINT8 dioResumeValue)
{
dioWrite (0,0,((dioResumeValue >> 0) & 1)); /* Set DIO to defined Value */
dioWrite (0,1,((dioResumeValue >> 1) & 1));
dioWrite (0,2,((dioResumeValue >> 2) & 1));
dioWrite (0,3,((dioResumeValue >> 3) & 1));
dioWrite (0,4,((dioResumeValue >> 4) & 1));
dioWrite (0,5,((dioResumeValue >> 5) & 1));
dioWrite (0,6,((dioResumeValue >> 6) & 1));
dioWrite (0,7,((dioResumeValue >> 7) & 1));
}
@@ -0,0 +1,220 @@
/* ---------------------------------------------------------------------------
* ledfunctions.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 ledfunctions.c
* ---------------------------------------------------------------------------
* Version(s): 0.1, Mar 11, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef LEDFUNCTIONS_H_
#define LEDFUNCTIONS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
#include "leds.h"
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: LEDPauseFlash
*
* Function that flashes either the RED or the GREEN LED in user defined
* length and number.
*
* Parameters: t_led_ids LEDnum - Defines the LED to flash
* UINT8 counts - Number of flash events
* INT16 delay_length - length of single flash event
*
* Return: void
* ---------------------------------------------------------------------------
*/
void LEDPauseFlash(t_led_ids LEDnum, UINT8 counts, INT16 delay_length);
/* ---------------------------------------------------------------------------
* Function: LEDResult
*
* Function to display a BOOLEAN Variable either on RED or GREEN LED
*
* Parameters: BOOLEAN TestResult - Gives the BOOLEAN Variable to display
*
* Return: void
* ---------------------------------------------------------------------------
*/
void LEDResult (BOOLEAN TestResult);
/* ---------------------------------------------------------------------------
* Function: LEDResultDIO
*
* Function to display a BOOLEAN Variable on a DIO LED
*
* Parameters: BOOLEAN TestResult - Gives the BOOLEAN Variable to display
* UINT 16 dioNo - Number of DIO channel
*
* Return: void
* ---------------------------------------------------------------------------
*/
void LEDResultDIO (BOOLEAN TestResult, UINT16 dioNo);
/* ---------------------------------------------------------------------------
* Function: LEDToggleForever
*
* Function that simply toggles RED and GREEN LED in an endless loop
*
* Parameters: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void LEDToggleForever( void);
/* ---------------------------------------------------------------------------
* Function: LEDToggle
*
* Function that simply toggles RED and GREEN LED for user defined number
*
* Parameters: UINT16 cnts - user defined toggle number
*
* Return: void
* ---------------------------------------------------------------------------
*/
void LEDToggle( UINT16 cnts);
/* ---------------------------------------------------------------------------
* Function: LEDShowStatus
*
* Function to display a Variable value by flashing that amount of.
*
* Parameters: UINT16 status - Value of Variable to flash like
*
* Return: void
* ---------------------------------------------------------------------------
*/
void LEDShowStatus (UINT16 status);
/* ---------------------------------------------------------------------------
* Functions: gLEDToggle / rLEDToggle
*
* Functions to toggle either RED or GREEN LED forever with user defined
* flash time
*
* Parameters: UINT16 time
*
* Return: void
* ---------------------------------------------------------------------------
*/
void gLEDToggle (UINT16 time);
void rLEDToggle (UINT16 time);
/* ---------------------------------------------------------------------------
* Function: dioToggle
*
* Function to toggle LED Status of a user defined Digital Output with 100 ms
* flash time.
*
* Parameters: UINT16 LEDnr
*
* Return: void
* ---------------------------------------------------------------------------
*/
void dioToggle (UINT16 LEDnr);
/* ---------------------------------------------------------------------------
* Function: dioToggleNC
*
* Function to toggle LED Status of a user defined Digital Output with 1000 ms
* flash time.
*
* Parameters: UINT16 LEDnr
*
* Return: void
* ---------------------------------------------------------------------------
*/
void dioToggleNC (UINT16 LEDnr);
/* ---------------------------------------------------------------------------
* Function: dio2x4
*
* Function to constantly flash the DIO LEDs in ON-OFF-ON-OFF pattern with
* userdefined toggle Time.
* Normaly used to note the user for something
*
* Parameters: UINT32 ToggleTime
*
* Return: void
* ---------------------------------------------------------------------------
*/
void dio2x4 (UINT32 ToggleTime);
/* ---------------------------------------------------------------------------
* Function: dioClean
*
* Sets all Digital Outputs back to LOW
*
* Parameters: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void dioClean (void);
/* ---------------------------------------------------------------------------
* Function: dioCapture
*
* Function to capture and save up to all 8 Digital Output Levels
*
* Parameters: void
*
* Return: UINT8 - up to all 8 Digital Output Levels
* ---------------------------------------------------------------------------
*/
UINT8 dioCapture (void);
/* ---------------------------------------------------------------------------
* Function: dioResume
*
* Function to set or restore up to all 8 Digital Output Levels
*
* Parameters: UINT8 dioResumeValue - Value for setting Output Levels
*
* Return: void
* ---------------------------------------------------------------------------
*/
void dioResume (UINT8 dioResumeValue);
#endif /*LEDFUNCTIONS_H_*/
@@ -0,0 +1,176 @@
/* ---------------------------------------------------------------------------
* protocolfunctions.c - v0.1 (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: Initialisation and direct usage of the Bus Protocol
* ---------------------------------------------------------------------------
* Version(s): 0.1, Jun 2, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "adc.h"
#include "dac.h"
#include "bus.h"
#include "dio.h"
#include "serial.h"
#include "SerOut.h"
#include "topoftest.h"
#include "remote_digital.h"
#include "remote_analogue.h"
#include "remote_relay.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
extern BOOLEAN auto_testResult;
extern UINT32 UINT32result;
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void protocolInit (t_bus_devices BUS_ID, UINT32 DEV_ID, UINT32 MAX_ID)
{
/* Create both needed Semaphores to be able to use them */
vSemaphoreCreateBinary (generalSemaphore);
vSemaphoreCreateBinary (slaveRestartSemaphore);
/* Init Device as Master of BUS1 System */
handleBus1 = bpInit (BUS2, BUS1, DEV_ID, MAX_ID, 16);
/* Attach basicly needed Handshake Functions */
bpAttachRpc (handleBus1, 1, "AvailableID", (t_rpc_remote_procedure_call) availableBusID, 0);
bpAttachRpcResult(handleBus1, 1, (t_bp_rpcresult_callback) generalResultFunction, 0);
/* Following Attachments depend on Device ID */
if (DEV_ID == 1)
{
/* If Device is Master, attach these functions */
/* Attach Slave Result Functions (called by Slave on the Master) */
bpAttachRpcResult(handleBus1, 2, (t_bp_rpcresult_callback) testResultFunction, 1);
bpAttachRpcResult(handleBus1, 3, (t_bp_rpcresult_callback) slaveRestartFunction, 0);
bpAttachRpcResult(handleBus1, 4, (t_bp_rpcresult_callback) UINT32ResultFunction, 1);
bpAttachRpcResult(handleBus1, 9, (t_bp_rpcresult_callback) receiveRemoteAttachedFunctions, 1);
/* Attach test result functions */
bpAttachRpcResult(handleBus1, 11, (t_bp_rpcresult_callback) digitalReadResult, 1);
bpAttachRpcResult(handleBus1, 12, (t_bp_rpcresult_callback) analogueReadResult, 1);
bpAttachRpcResult(handleBus1, 13, (t_bp_rpcresult_callback) digitalReadAllResult, maxDI_Channels);
bpAttachRpcResult(handleBus1, 14, (t_bp_rpcresult_callback) analogueReadAllResult, maxDAC_Channels);
/* Attach semaphore release functions */
bpAttachRpcResult(handleBus1, 20, (t_bp_rpcresult_callback) remoteDigitalSemaphoreRelease, 0);
bpAttachRpcResult(handleBus1, 21, (t_bp_rpcresult_callback) remoteAnalogueSemaphoreRelease, 0);
bpAttachRpcResult(handleBus1, 22, (t_bp_rpcresult_callback) remoteRelaySemaphoreRelease, 0);
}
if (DEV_ID > 1)
{
/* If Device is Slave, attach these functions */
}
}
void availableBusID (UINT8 senderId, UINT8 targetId, UINT8 requestNr,
UINT8 functionId, UINT8 nrOfParams, UINT32 *params)
{
/* Just call first Result Function on Slave */
bpSendRpcResult(handleBus1, 2, 1, 1, 0, NULL);
}
/* generalResultFunction is the easiest Way to realise a Handshake between
* Master and Slave. Master software takes a Semaphore and calls a function
* on Slave, that is only calling generalResultfunction() on Master. If this
* happens, the Semaphore will be released and Handshake is done
*/
void generalResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* If called, release the generalSemaphore */
if (xSemaphoreGive (generalSemaphore) == pdTRUE)
{
}
else
{
}
}
/* Test functions called on Slave will return their Test Results with a
* call on this function. Results on Slave are from type BOOLEAN
*/
void testResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* Set Slave Test result depending on what slave sends back as parameter*/
if (*results == 1)
{
/* Test was successfull */
auto_testResult = TRUE;
}
else
{
/* Test was a failure */
auto_testResult = FALSE;
}
}
void slaveRestartFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* Release slaveRestartSemaphore if Slave calls this Function on Reboot */
if (xSemaphoreGive (slaveRestartSemaphore) == pdTRUE)
{
}
else
{
}
}
void UINT32ResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
UINT32result = *results;
}
void receiveRemoteAttachedFunctions (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
sendString (SerOutPort, TRUE, importantMessage, (char *) results, Dummy, Dummy);
}
@@ -0,0 +1,162 @@
/* ---------------------------------------------------------------------------
* protocolfunctions.h - v0.1 (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, Jun 2, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef __PROTOCOLTEST_H__
#define __PROTOCOLTEST_H__
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
#include "Bus.h"
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
int handleBus1;
UINT8 remoteDeviceNumber;
UINT8 thisDeviceNumber;
xSemaphoreHandle generalSemaphore;
xSemaphoreHandle slaveRestartSemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: protocolInit
*
* Function to calibrate slaves Voltage Output
*
* Parameters: t_bus_devices BUS_ID - ID of the BUS system
* UINT32 DEV_ID - ID of the local Device
* UINT32 MAX_ID - Max ID in System
*
* Return: void
* ---------------------------------------------------------------------------
*/
void protocolInit (t_bus_devices BUS_ID, UINT32 DEV_ID, UINT32 MAX_ID);
/* ---------------------------------------------------------------------------
* Function: availableBusID
*
* Function that just calls a Result on the Caller. It's just a Handshake
*
* Parameters: UINT8 senderId - ID of Caller
* UINT8 targetId - ID of Target
* UINT8 requestNr - Number of the request
* UINT8 functionId - Numer of function to call
* UINT8 nrOfParams - Number of attached Paramters
* UINT32 *params - Attached Paramters
*
* Return: void
* ---------------------------------------------------------------------------
*/
void availableBusID (UINT8 senderId, UINT8 targetId, UINT8 requestNr,
UINT8 functionId, UINT8 nrOfParams, UINT32 *params);
/* ---------------------------------------------------------------------------
* Function: generalResultfunction
*
* Function that is called be Slave on the Master to release a Semaphore
*
* Parameters: UINT8 requestNr - number of the request
* UINT8 nrOfResult - Number of Attached Results
* UIN32 *results - Attached Results
*
* Return: void
* ---------------------------------------------------------------------------
*/
void generalResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
/* ---------------------------------------------------------------------------
* Function: testResultfunction
*
* Function that is called be Slave for telling a Test Result
*
* Parameters: UINT8 requestNr - number of the request
* UINT8 nrOfResult - Number of Attached Results
* UIN32 *results - Attached Results
*
* Return: void
* ---------------------------------------------------------------------------
*/
void testResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
/* ---------------------------------------------------------------------------
* Function: slaveRestartfunction
*
* Function that is called be Slave on the Master to tell about a Restart
*
* Parameters: UINT8 requestNr - number of the request
* UINT8 nrOfResult - Number of Attached Results
* UIN32 *results - Attached Results
*
* Return: void
* ---------------------------------------------------------------------------
*/
void slaveRestartFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
/* ---------------------------------------------------------------------------
* Function: UINT32ResultFunction
*
* Function to receive a UINT32 Result from Slave. Result is stored then in
* the global variable UINT32 UINT32result
*
* Parameters: UINT8 requestNr - number of the request
* UINT8 nrOfResult - Number of Attached Results
* UIN32 *results - Attached Results
*
* Return: void
* ---------------------------------------------------------------------------
*/
void UINT32ResultFunction (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void receiveRemoteAttachedFunctions (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /* __PROTOCOLTEST_H__ */
@@ -0,0 +1,284 @@
/* ---------------------------------------------------------------------------
* taskfunctions.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 Functions to control the TestLED Tasks
* ---------------------------------------------------------------------------
* Version(s): 0.1, Apr 09, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "task.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "taskfunctions.h"
#include "dio.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void taskInit (void)
{
d_gLED = 0; /* Initialize TaskStatus with 0 */
d_ledtestled = 0;
d_dioled = 0;
d_aioled = 0;
d_busled = 0;
d_eepromled = 0;
d_flashled = 0;
d_mmcled = 0;
d_logled = 0;
d_comled = 0;
d_powerled = 0;
d_rtcled = 0;
}
void diotasksdelete(void)
{
if (d_dioled == pdPASS) /* If defined Task exists */
{
vTaskDelete (dioled); /* Delete Task */
dioWrite (0,DIOLED,FALSE); /* Switch off corresponding DIO-LED */
d_dioled = 0; /* Set TaskStatus to 0 */
}
if (d_ledtestled == pdPASS)
{
vTaskDelete (ledtestled);
dioWrite (0,LEDTESTLED,FALSE);
d_ledtestled = 0;
}
if (d_aioled == pdPASS)
{
vTaskDelete (aioled);
dioWrite (0,AIOLED,FALSE);
d_aioled = 0;
}
if (d_busled == pdPASS)
{
vTaskDelete (busled);
dioWrite (0,BUSLED,FALSE);
d_busled = 0;
}
#if (allMemoryUseSameLED == 0)
if (d_eepromled == pdPASS)
{
vTaskDelete (eepromled);
dioWrite (0,EEPROMLED,FALSE);
d_eepromled = 0;
}
if (d_flashled == pdPASS)
{
vTaskDelete (flashled);
dioWrite (0,FLASHLED,FALSE);
d_flashled = 0;
}
if (d_logled == pdPASS)
{
vTaskDelete (logled);
dioWrite (0,LOGLED,FALSE);
d_logled = 0;
}
#else
if (d_batteryled == pdPASS)
{
vTaskDelete (batteryled);
dioWrite (0,BATTERYLED,FALSE);
d_batteryled = 0;
}
if (d_memoryled == pdPASS)
{
vTaskDelete (memoryled);
dioWrite (0,MEMORYLED,FALSE);
d_memoryled = 0;
}
#endif
if (d_mmcled == pdPASS)
{
vTaskDelete (mmcled);
dioWrite (0,MMCLED,FALSE);
d_mmcled = 0;
}
if (d_comled == pdPASS)
{
vTaskDelete (comled);
dioWrite (0,COMLED,FALSE);
d_comled = 0;
}
if (d_powerled == pdPASS)
{
vTaskDelete (powerled);
dioWrite (0,POWERLED,FALSE);
d_powerled = 0;
}
if (d_rtcled == pdPASS)
{
vTaskDelete (rtcled);
dioWrite (0,RTCLED,FALSE);
d_rtcled = 0;
}
}
void diotaskssuspend(void)
{
if (d_dioled == pdPASS) /* If defined Task exists */
{
vTaskSuspend (dioled); /* Suspend Task */
dioWrite (0,DIOLED,FALSE); /* Switch off corresponding DIO-LED */
}
if (d_ledtestled == pdPASS)
{
vTaskSuspend (ledtestled);
dioWrite (0,LEDTESTLED,FALSE);
}
if (d_aioled == pdPASS)
{
vTaskSuspend (aioled);
dioWrite (0,AIOLED,FALSE);
}
if (d_busled == pdPASS)
{
vTaskSuspend (busled);
dioWrite (0,BUSLED,FALSE);
}
#if (allMemoryUseSameLED == 0)
if (d_eepromled == pdPASS)
{
vTaskSuspend (eepromled);
dioWrite (0,EEPROMLED,FALSE);
}
if (d_flashled == pdPASS)
{
vTaskSuspend (flashled);
dioWrite (0,FLASHLED,FALSE);
}
if (d_logled == pdPASS)
{
vTaskSuspend (logled);
dioWrite (0,LOGLED,FALSE);
}
#else
if (d_batteryled == pdPASS)
{
vTaskSuspend (batteryled);
dioWrite (0,BATTERYLED,FALSE);
}
if (d_memoryled == pdPASS)
{
vTaskSuspend (memoryled);
dioWrite (0,MEMORYLED,FALSE);
}
#endif
if (d_mmcled == pdPASS)
{
vTaskSuspend (mmcled);
dioWrite (0,MMCLED,FALSE);
}
if (d_comled == pdPASS)
{
vTaskSuspend (comled);
dioWrite (0,COMLED,FALSE);
}
if (d_powerled == pdPASS)
{
vTaskSuspend (powerled);
dioWrite (0,POWERLED,FALSE);
}
if (d_rtcled == pdPASS)
{
vTaskSuspend (rtcled);
dioWrite (0,RTCLED,FALSE);
}
}
void diotasksresume(void)
{
if (d_batteryled == pdPASS) /* If defined Task exists */
{
vTaskResume(batteryled); /* Resume Task */
}
if (d_dioled == pdPASS)
{
vTaskResume(dioled);
}
if (d_ledtestled == pdPASS)
{
vTaskResume(ledtestled);
}
if (d_aioled == pdPASS)
{
vTaskResume(aioled);
}
if (d_busled == pdPASS)
{
vTaskResume(busled);
}
if (d_eepromled == pdPASS)
{
vTaskResume(eepromled);
}
if (d_flashled == pdPASS)
{
vTaskResume(flashled);
}
if (d_logled == pdPASS)
{
vTaskResume(logled);
}
if (d_memoryled == pdPASS)
{
vTaskResume (memoryled);
}
if (d_mmcled == pdPASS)
{
vTaskResume(mmcled);
}
if (d_comled == pdPASS)
{
vTaskResume(comled);
}
if (d_powerled == pdPASS)
{
vTaskResume(powerled);
}
if (d_rtcled == pdPASS)
{
vTaskResume(rtcled);
}
}
@@ -0,0 +1,177 @@
/* ---------------------------------------------------------------------------
* taskfunctions.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 taskfunctions.c
* ---------------------------------------------------------------------------
* Version(s): 0.1, Apr 09, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TASKFUNCTIONS_H_
#define TASKFUNCTIONS_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.
* ---------------------------------------------------------------------------
*/
#define allMemoryUseSameLED 1
/* Allocation of digital Output LEDs to a single Test */
/* LED Setting correspond to if all memory Test should share the same LED */
#if (allMemoryUseSameLED == 0)
#define LEDTESTLED 0
#define EEPROMLED 1
#define FLASHLED 2
#define LOGLED 3
#define DIOLED 4
#define MMCLED 5
#define POWERLED 6
#define RTCLED 7
#define AIOLED 8
#define BUSLED 8
#define COMLED 8
#else
#define BATTERYLED 0
#define LEDTESTLED 1
#define MEMORYLED 2
#define DIOLED 3
#define AIOLED 4
#define MMCLED 5
#define POWERLED 6
#define RTCLED 7
#define BUSLED 8
#define COMLED 8
#endif
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* Taskhandler
* Last Argument called in xTaskCreate
* Needed to identify a Task
*/
xTaskHandle batteryled;
xTaskHandle gLED;
xTaskHandle ledtestled;
xTaskHandle dioled;
xTaskHandle aioled;
xTaskHandle busled;
xTaskHandle eepromled;
xTaskHandle flashled;
xTaskHandle logled;
xTaskHandle memoryled;
xTaskHandle mmcled;
xTaskHandle comled;
xTaskHandle powerled;
xTaskHandle rtcled;
xTaskHandle spinWheel;
/* BaseType
* Return of xTaskCreate
* Indicates wether a Function was created (=pdPASS) oder not (= 0)
*/
portBASE_TYPE d_batteryled;
portBASE_TYPE d_gLED;
portBASE_TYPE d_ledtestled;
portBASE_TYPE d_dioled;
portBASE_TYPE d_aioled;
portBASE_TYPE d_busled;
portBASE_TYPE d_eepromled;
portBASE_TYPE d_flashled;
portBASE_TYPE d_logled;
portBASE_TYPE d_memoryled;
portBASE_TYPE d_mmcled;
portBASE_TYPE d_comled;
portBASE_TYPE d_powerled;
portBASE_TYPE d_rtcled;
portBASE_TYPE d_spinWheel;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: taskInit
*
* Function to initialize TaskStatus Variables
*
* Parameter: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void taskInit (void);
/* ---------------------------------------------------------------------------
* Function: diotasksdelete
*
* Function to delete ALL existing Tasks flashing a DIO-LED
*
* Parameter: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void diotasksdelete(void);
/* ---------------------------------------------------------------------------
* Function: diotaskssuspend
*
* Function to suspend ALL existing Tasks flashing a DIO-LED
*
* Parameter: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void diotaskssuspend (void);
/* ---------------------------------------------------------------------------
* Function: diotasksresume
*
* Function to resume ALL existing and suspended Tasks flashing a DIO-LED
*
* Parameter: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void diotasksresume (void);
#endif /*TASKFUNCTIONS_H_*/
+347
View File
@@ -0,0 +1,347 @@
/*
FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
See http://www.FreeRTOS.org for documentation, latest information, license
and contact details. Please ensure to read the configuration and relevant
port sections of the online documentation.
Also see http://www.SafeRTOS.com a version that has been certified for use
in safety critical systems, plus commercial licensing, development and
support options.
***************************************************************************
*/
/* ---------------------------------------------------------------------------
* Description: MAIN File to Application Project
* ---------------------------------------------------------------------------
* Version(s): 0.1, Jul 07, 2008, MMi
*
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "types.h"
#include "sys_config.h"
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
/* Drivers */
#include "adc.h"
#include "bus.h"
#include "BusProtocol.h"
#include "calibrateaio.h"
#include "can.h"
#include "dac.h"
#include "dio.h"
#include "eeprom.h"
#include "ElecStatusCache.h"
#include "ethernet.h"
#include "irq.h"
#include "leds.h"
#include "menuargs.h"
#include "mmc.h"
#include "power.h"
#include "relay.h"
#include "rtc.h"
#include "serial.h"
#include "SerOut.h"
#include "ssp0.h"
#include "ssp1.h"
/* testfiles */
#include "topoftest.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* Demo application definitions. */
#define mainQUEUE_SIZE ( 3 )
#define mainCHECK_DELAY (( portTickType ) 5000 / portTICK_RATE_MS )
#define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 6 )
/* Task priorities. */
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
/* Constants to setup the PLL. */
#define mainPLL_ENABLE (( unsigned portLONG ) 0x0001 )
#define mainPLL_CONNECT ((( unsigned portLONG ) 0x0002 ) | mainPLL_ENABLE )
#define mainPLL_FEED_BYTE1 (( unsigned portLONG ) 0xaa )
#define mainPLL_FEED_BYTE2 (( unsigned portLONG ) 0x55 )
#define mainPLL_LOCK (( unsigned portLONG ) 0x4000000 )
#define mainPLL_CONNECTED (( unsigned portLONG ) 0x2000000 )
#define mainOSC_ENABLE (( unsigned portLONG ) 0x20 )
#define mainOSC_STAT (( unsigned portLONG ) 0x40 )
#define mainOSC_SELECT (( unsigned portLONG ) 0x01 )
/* Constants to setup the MAM. */
#define mainMAM_TIM_3 (( unsigned portCHAR ) 0x03 )
#define mainMAM_MODE_FULL (( unsigned portCHAR ) 0x02 )
#define SWI_RAM_ADDR 0x40000008
#define SWI_RAM_FUNC_ADDR 0x40000028
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN StopFlashing= FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
extern void vPortYieldProcessor (void);
/* Configure Hardware */
static inline void prvSetVectors (void);
static void prvSetupHardware (void);
static void prvSetupDrivers (void);
/* Main Task */
static void ExecuteTestsTask (void *pvParameters);
/*-----------------------------------------------------------*/
extern void *pvPortMalloc(size_t xWantedSize);
int main(void)
{
static portBASE_TYPE taskCreationResult = -20;
prvSetVectors();
prvSetupHardware();
/* Start the tasks defined within this file/specific to this demo. */
taskCreationResult = xTaskCreate(ExecuteTestsTask,
( signed portCHAR * ) "Tests", configMINIMAL_STACK_SIZE + 400,
NULL, mainCHECK_TASK_PRIORITY - 1, NULL);
/* Start the scheduler. */
vTaskStartScheduler();
/* Will only get here if there was insufficient memory to create
* the idle task.
*/
return 0;
}
/*-----------------------------------------------------------*/
void vApplicationTickHook(void)
{
}
/*-----------------------------------------------------------*/
void ExecuteTestsTask(void *pvParameters)
{
prvSetupDrivers();
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
ledSet(LED1, 1);
ledSet(LED0, 1);
#endif
mainInit();
/* IDLE MODE */
for (;;)
{
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
vTaskDelay (1000);
ledSet (LED0, FALSE);
vTaskDelay (1000);
ledSet (LED1, TRUE);
#else
vTaskDelay (100);
#endif
}
}
/*-----------------------------------------------------------*/
inline void prvSetVectors()
{
unsigned int *ptr;
// Set vectors of interrupt and software interupt
// Set interrupt vectors
ptr = (unsigned int *)SWI_RAM_ADDR;
*ptr = 0xE59FF018; // This is a ldr pc, [pc,#24] instruction
// Put SWI, IRQ vectors in RAM
ptr = (unsigned int *)SWI_RAM_FUNC_ADDR;
*ptr = (unsigned int)&vPortYieldProcessor; // Reserved for FreeRTOS
}
/*-----------------------------------------------------------*/
void prvSetupHardware(void)
{
//UINT32 i = 0;
//volatile UINT32 *vect_addr, *vect_prio;
#ifdef RUN_FROM_RAM
/* Remap the interrupt vectors to RAM if we are are running from RAM. */
SCB_MEMMAP = 2;
#endif
/* Disable the PLL. */
PLLCON = 0;
PLLFEED = mainPLL_FEED_BYTE1;
PLLFEED = mainPLL_FEED_BYTE2;
/* Configure clock source. */
SCS |= mainOSC_ENABLE;
while ( !( SCS & mainOSC_STAT ))
;
CLKSRCSEL = mainOSC_SELECT;
/* Setup the PLL to multiply the XTAL input by 4. */
PLLCFG = ( PLL_MUL | PLL_DIV );
PLLFEED = mainPLL_FEED_BYTE1;
PLLFEED = mainPLL_FEED_BYTE2;
/* Turn on and wait for the PLL to lock... */
PLLCON = mainPLL_ENABLE;
PLLFEED = mainPLL_FEED_BYTE1;
PLLFEED = mainPLL_FEED_BYTE2;
CCLKCFG = CCLK_DIV;
while ( !( PLLSTAT & mainPLL_LOCK ))
;
/* Connecting the clock. */
PLLCON = mainPLL_CONNECT;
PLLFEED = mainPLL_FEED_BYTE1;
PLLFEED = mainPLL_FEED_BYTE2;
while ( !( PLLSTAT & mainPLL_CONNECTED ))
;
/* Setup and turn on the MAM. Three cycle access is used due to the fast
PLL used. It is possible faster overall performance could be obtained by
tuning the MAM and PLL settings. */
MAMCR = 0;
MAMTIM = mainMAM_TIM_3;
MAMCR = mainMAM_MODE_FULL;
// Enable power on ethernet chip for using its RAM
PCONP |= (1 << 30);
init_VIC();
}
void prvSetupDrivers(void)
{
#if (PINSET_TESTER == 0)
/* Load Inits necessary for the Olimex DemoBoard */
ssp0Init();
ssp0Enable();
ssp1Init();
ssp1Enable();
rtcInit();
MmcInit();
CANInit(CANBitrate125k_12MHz);
CANSetFilter (0x00000101);
// ethInit();
#endif
#if (PINSET_TESTER == 1)
/* Load Inits necessary and available on IO Controller --> REV_C <-- */
bpecInit();
dioInit();
ledInit();
ssp0Init();
ssp0Enable();
ssp1Init();
ssp1Enable();
eepromInit();
adcInit();
dacInit();
powerInit();
rtcInit();
MmcInit();
calibrationInit();
#endif
#if (PINSET_TESTER == 2)
/* Load Inits necessary and available on QUA_2475_TESTER */
bpecInit();
dioInit();
rlyInit();
ledInit();
ssp0Init();
ssp0Enable();
ssp1Init();
ssp1Enable();
eepromInit();
adcInit();
dacInit();
powerInit();
rtcInit();
MmcInit();
calibrationInit();
CANInit(CANBitrate125k_12MHz);
// ethInit();
#endif
menuInit(); /* Init the Menu in every Case */
// Open both COM-ports
serInit(COM1, B115200, UART_8N1, UART_FIFO_8);
serInit(COM2, B115200, UART_8N1, UART_FIFO_8);
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
/* BusInit only necessary on IO_CTRL or TESTER, DemoBoard got no Busses */
busInit(BUS1);
busInit(BUS2);
#endif
}
+422
View File
@@ -0,0 +1,422 @@
/* ---------------------------------------------------------------------------
* menu.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, Apr 01, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
/* Compiler includes */
#include <string.h>
#include <stdlib.h>
/* Hardware includes */
#include "lpc23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "topoftest.h"
#include "menu.h"
#include "menufunctions.h"
#include "menuargs.h"
#include "dac.h"
#include "adc.h"
#include "dio.h"
#include "logging.h"
#include "SerOut.h"
#include "ledfunctions.h"
#include "taskfunctions.h"
#include "BusProtocol.h"
#include "remote_tests.h"
#include "remote_misc.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
extern const char *command_table[NUMBER_OF_COMMANDS];
extern const fpointer command_pointer[NUMBER_OF_COMMANDS];
extern UINT8 cmd_table_offset[ALPHABET_DIGITS];
extern const char * menuHelptextArray [NUMBER_OF_COMMANDS];
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
UINT32 arg1 = 0;
UINT32 arg2 = 0;
UINT32 arg3 = 0;
BOOLEAN quit = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void TABfunction (char * command);
void CallMenu(void)
{
/* local Variable Declaration */
UINT32 bytesreceived = 0;
static UINT8 receiveString[60];
static UINT8 backupString[60];
UINT8 buffer;
BOOLEAN receive;
char separator[] = " ";
char *commandt;
char *pcmd;
char *arg1t;
char *arg2t;
char *arg3t;
UINT8 command[15];
UINT8 cmd_len;
UINT8 loopcnt;
BOOLEAN callhelp = FALSE;
do /* do-while loop for Main Menu */
{
/* Display PROMPT to Console */
serWrite(MenuPort, strlen("\n\r\n\rCMD> "), (UINT8 *)"\n\r\n\rCMD> ");
/* Reset String input Variables */
buffer = 0;
bytesreceived = 0;
commandt = 0;
cmd_len = 0;
arg1 = 0;
arg2 = 0;
arg3 = 0;
do /* do-while loop for String input */
{
if ((receive = serGet(MenuPort, &buffer) == TRUE))
{
if (buffer == '\t')
{
receiveString[bytesreceived] = '\0';
TABfunction((char *) receiveString);
}
/* Detection of Escape characters. VT100 Commands are 4 Bytes,
* so software takes out three more bytes from the buffer.
*/
else if (buffer == 27)
{
serGet(MenuPort, &buffer);
serGet(MenuPort, &buffer);
// serGet(MenuPort, &buffer);
/* Detection for LEFT and RIGHT Arrow keys.
* Future implementation may be done for advanced shell
*/
if (buffer =='A')
{
serWrite(MenuPort, strlen("\x1B[1B"), (UINT8 *)"\x1B[1B");
/* UP arrow Key detected */
if (bytesreceived == 0)
{
/* If Cursor is on the beginning position */
strcpy ((char *)receiveString, (char *)backupString);
bytesreceived = strlen((char *)backupString);
serWrite(MenuPort, bytesreceived, backupString);
}
}
// else if (buffer == 'B')
// {
// /* DOWN arrow Key detected */
// }
//
// else if (buffer == 'C')
// {
// /* RIGHT arrow Key detected */
// bytesreceived++;
// }
// else if (buffer == 'D')
// {
// /* LEFT arrow Key detected */
// if (bytesreceived > 0)
// {
// /* If cursor is not on first position */
// bytesreceived--;
// }
// else
// {
// /* Move Cursor one position to right (VT100) */
// serWrite(SerOutPort, sizeof("\x1B[1C"), "\x1B[1C");
// }
// }
else
{
/* Any other Control Key detected. Read and ignore */
serGet(MenuPort, &buffer);
}
}
else if (buffer == 127)
{
/* If pressed key was BackSpace (NOTE KEYCODE, NOT 0x08)*/
if (bytesreceived > 0)
{
/* Cursor is not first position, step back in array */
receiveString[bytesreceived--] = 0;
}
else
{
/* Cursor ist on first position, do not step back */
/* Move Cursor one position to right (VT100) */
serWrite(SerOutPort, strlen("\x1B[1C"), (UINT8 *)"\x1B[1C");
}
}
else if (buffer == 13)
{
receiveString[bytesreceived] = '\0';
}
else
{
/* Write Byte in String and increase String index */
receiveString[bytesreceived] = buffer;
bytesreceived++;
}
vTaskDelay(10); /* Share Calculation Time */
}
}while (buffer != 13); /*Read input until ENTER-Key */
writeLog(LogInput, MenuPort, menuMessage, (char *)receiveString);
/* Copy actual received command string to a backup string */
strcpy ((char *)backupString, (char *)receiveString);
sendString (MenuPort, GotoNewLine, menuMessage,
"receiveString: ", (char *)receiveString, Dummy);
sendString (MenuPort, GotoNewLine, menuMessage,
"backupString: ", (char *)backupString, Dummy);
/* Split command and arguments with strtok() function, where a
* SPACE letter is used as devider.
*/
commandt = strtok ((char *)receiveString, (char *)separator);
arg1t = strtok (NULL, (char *)separator);
arg2t = strtok (NULL, (char *)separator);
arg3t = strtok (NULL, (char *)separator);
if ((pcmd = strstr ((char *)commandt, "_help")) != NULL)
{
callhelp = TRUE;
sendString (MenuPort, GotoNewLine, menuMessage,
"Help Stat recognised ", Dummy, Dummy);
/* Copy command to an own string */
cmd_len = strlen (commandt);
strncpy ((char *)command, commandt, (cmd_len - 5));
command[cmd_len - 5] = '\0';
}
else
{
callhelp = FALSE;
/* Copy command to an own string */
strcpy ((char *)command, commandt);
/* Detect if arguments are given dezimal or hexadezimal. Detection
* looks for a leading "0x" on the string. Afterwards, the given
* Value is transformed to an integer value with sscanf. No Error
* checking. The value is transformed step by step until the string-
* end token or the first not-hex symbol.
*/
if ((arg1t[0] == 48) && (arg1t[1] == 120))
{
/* First Argument is given in Hex, transform value */
sscanf((char *)(arg1t), "%x", &arg1);
}
else
{
/* First argument is given dezimal, cast to integer */
arg1 = (UINT32) atoi((char *) (arg1t));
}
if ((arg2t[0] == 48) && (arg2t[1] == 120))
{
/* Second Argument is given in Hex, transform value */
sscanf((char *)(arg2t), "%x", &arg2);
}
else
{
/* Second argument is given dezimal, cast to integer */
arg2 = (UINT32) atoi((char *) (arg2t));
}
if ((arg3t[0] == 48) && (arg3t[1] == 120))
{
/* Third Argument is given in Hex, transform value */
sscanf((char *)(arg3t), "%x", &arg3);
}
else
{
/* Third argument is given dezimal, cast to integer */
arg3 = (UINT32) atoi((char *) (arg3t));
}
}
sendString (MenuPort, GotoNewLine, menuMessage,
"commandt: ", (char *)commandt, Dummy);
sendString (MenuPort, FALSE, menuMessage,
"\tcommand: ", (char *)command, Dummy);
sendString (MenuPort, GotoNewLine, menuMessage,
"arg1t: ", (char *)arg1t, Dummy);
sendString (MenuPort, FALSE, menuMessage,
"\targ1: ", ItoDStr(arg1), Dummy);
sendString (MenuPort, GotoNewLine, menuMessage,
"arg2t: ", (char *)arg2t, Dummy);
sendString (MenuPort, FALSE, menuMessage,
"\targ2: ", ItoDStr(arg2), Dummy);
sendString (MenuPort, GotoNewLine, menuMessage,
"arg3t: ", (char *)arg3t, Dummy);
sendString (MenuPort, FALSE, menuMessage,
"\targ3: ", ItoDStr(arg3), Dummy);
/* Advanced Search algorithm for commands */
/* Menu structure is based on 2 tables for the commands and one more
* as offset.
* The given command is first checked on a valid first letter. If
* valid, this letter is compared with the offset table. If an offset
* is defines for the first letter, at least commands with this first
* letter exist. Do a string compare starting at the address in the
* command array given by the offset for the first letter. This
* prevents of scanning all commands beginning with a different letter
*/
if ((command[0] >= 97) && (command[0] <= 122))
{
/* First sign of command is within specified Range */
if (cmd_table_offset[(command[0] - 97)] != 0xFF)
{
/* If Offset for specified letter is available */
for (loopcnt = (cmd_table_offset[(command[0] - 97)]);
loopcnt < NUMBER_OF_COMMANDS;
loopcnt++)
{
/* Try to find the typed in command starting on the
* offset position given with the first letter.
*/
if (strcmp ((char *)command, command_table[loopcnt]) == 0)
{
/* Found a valid command!
* Use the found array-index to grip the corresponding
* function pointer from pointer-array
*/
if (callhelp == FALSE)
{
(*command_pointer[loopcnt])();
}
else
{
sendString (MenuPort, TRUE, importantMessage,
(char *) menuHelptextArray[loopcnt], Dummy, Dummy);
// debugPrint((char *)menuHelptextArray[loopcnt]);
}
break;
}
if (loopcnt == (NUMBER_OF_COMMANDS - 1))
{
/* No valid command was found. give Error Emssage */
sendString (MenuPort, TRUE, importantMessage,
(char *) command," - No such command!", Dummy);
}
}
}
else
{
/* No Offset available for the specified letter */
sendString (MenuPort, TRUE, importantMessage,
(char *) command," - No such command!", Dummy);
}
}
else
{
/* First letter is out of the specified Range */
sendString (MenuPort, TRUE, importantMessage,
(char *) command," - No such command!", Dummy);
}
receiveString[0] = '\0';
vTaskDelay(100);
} while (quit == FALSE);
}
void TABfunction (char * command)
{
UINT32 loopcnt;
UINT32 commandlength;
commandlength = strlen (command);
serWrite (MenuPort, strlen ("\n\r\t\t"), (UINT8 *)"\n\r\t\t");
if ((command[0] >= 97) && (command[0] <= 122))
{
/* First sign of command is within specified Range */
if (cmd_table_offset[(command[0] - 97)] != 0xFF)
{
/* If Offset for specified letter is available */
for (loopcnt = (cmd_table_offset[(command[0] - 97)]);
loopcnt < NUMBER_OF_COMMANDS;
loopcnt++)
{
if (strncmp ((char *)command, command_table[loopcnt], commandlength) == 0)
{
sendString (MenuPort, FALSE, importantMessage,
" ", (char *)command_table[loopcnt], Dummy);
}
}
}
else
{
}
}
/* Display PROMPT to Console */
serWrite(MenuPort, strlen("\n\r\n\rCMD> "), (UINT8 *)"\n\r\n\rCMD> ");
serWrite (MenuPort, strlen (command), (UINT8 *)command);
}
+68
View File
@@ -0,0 +1,68 @@
/* ---------------------------------------------------------------------------
* testmenu.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:
* Headfile for the CMD Prompt File testmenu.c
* ---------------------------------------------------------------------------
* Version(s): 0.1, Apr 01, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TESTMENU_H_
#define TESTMENU_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: CallMenu
*
* Function to display a simplyfied PROMPT on COM-Port.
*
* Parameter: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void CallMenu(void);
#endif /*TESTMENU_H_*/
+383
View File
@@ -0,0 +1,383 @@
/* ---------------------------------------------------------------------------
* menuargs.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 13, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
/* Compiler includes */
#include <string.h>
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "menuargs.h"
#include "menufunctions.h"
#include "SerOut.h"
#include "can.h"
#include "remote_tests.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
#define ASCII_START 97
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* Make Sure that at least the first letter of this is in alphabetical order*/
const char *command_table[NUMBER_OF_COMMANDS] =
{
"aio",
"battery",
"bus",
"canread",
"cantest",
"canwrite",
"ccin",
"ccout",
"cdel",
"cload",
"confin",
"confout",
"cslave",
"curout",
"curin",
"cvin",
"cvout",
"digiin",
"digiout",
"dio",
"eeprom",
"fattest",
"help",
"initSD",
"initTest",
"ledclean",
"ledtest",
"listlocal",
// "listremoteattach",
"logenable",
"logmount",
"logstart",
"logstop",
"ls",
"menudebug",
"mmc",
"power",
"quit",
"readrtc",
"remotecall",
"rtc",
"run",
"stat_cal",
"stat_def",
"stat_kill",
"stat_show",
"stat_showall",
"setmux",
"setrtc",
"tasksdelete",
"volin",
"volout"
};
/* Make Sure that at least the first letter of this is in alphabetical order*/
const fpointer command_pointer[NUMBER_OF_COMMANDS] =
{
m_aio,
m_battery,
m_bus,
m_canread,
m_cantest,
m_canwrite,
m_ccin,
m_ccout,
m_cdel,
m_cload,
m_confin,
m_confout,
m_cslave,
m_curout,
m_curin,
m_cvin,
m_cvout,
m_digiin,
m_digiout,
m_dio,
m_eeprom,
m_fattest,
m_help,
m_initSD,
r_TestInit,
m_clean,
m_ledtest,
m_listLocalattachments,
// m_listremoteattachments,
m_logEnable,
m_sdMount,
m_logStart,
m_logStop,
m_loglist,
m_menuDebug,
m_mmc,
m_power,
m_quit,
m_readRTC,
m_callRemoteFunction,
m_rtc,
m_run,
m_c_cal,
m_c_def,
m_c_kill,
m_c_stat,
m_c_show,
m_switchMux,
m_setRTC,
m_tasksdelete,
m_volin,
m_volout,
};
/* Array to store the offsets to the first letters of commands */
UINT8 cmd_table_offset[ALPHABET_DIGITS];
const char * menuHelptextArray [NUMBER_OF_COMMANDS] =
{
"\n\r\n\r\taio arg1 arg2\n\r\ttests the analogue in- and outputs"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test"
"\n\r\t\targ2: test type (0: MB, 1: EB) (Only on remote test)",
"\n\r\n\r\tbattery arg1\n\r\ttests the battery supply of a remote device"
"\n\r\n\r\t\targ1: device number. 0 is self device",
"\n\r\n\r\tbus\n\r\ttests the local bus connections with transmit and receive strings",
"\n\r\n\r\tcanread\n\r\tPrints out the actual frame received on CAN",
"\n\r\n\r\tcantest\n\r\tTests the CAN interface with a Self Test",
"\n\r\n\r\tcanwrite arg1 arg2 arg3\n\r\twrites a message in a CAN frame"
"\n\r\n\r\t\targ1 - Bits 0-10: Identifier, 13-15: Interface Number, 16-19: Data Length"
"\n\r\t\targ2 - first 4 Bytes of Message"
"\n\r\t\targ3 - last 4 Bytes of Message",
"\n\r\n\r\tccin\n\r\tcalibrate the local analogue current inputs"
"\n\r\tPut calibration Value (e.g.20 mA) on each line separately when asked for",
"\n\r\n\r\tccout\n\r\tcalibrate the local analogue current outputs"
"\n\r\tOnly useful with already calibrated analogue current inputs"
"\n\r\tConnect outputs 0-5 to inputs 0-5. Software works automated",
"\n\r\n\r\tcdel arg1 arg2\n\r\tDeletes and resets the calibration values in eeprom"
"\n\r\n\r\t\targ1: number of target device"
"\n\r\t\targ2=0-3: kind of values to reset - 0=VI, 1=VO, 2=CI, 3=CO",
"\n\r\n\r\tcload arg1 arg2\n\r\treloads calibration values from EEPROM to system"
"\n\r\n\r\t\targ1: number of target device"
"\n\r\t\targ2=0-3: kind of values to reset - 0=VI, 1=VO, 2=CI, 3=CO",
"\n\r\n\r\tconfin arg1 arg2\n\r\tConfigures an analogue input on local device"
"\n\r\n\r\t\targ1=0-7, 9: chose channel 0-7 or chose all channels with 9"
"\n\r\t\targ2=0-1: 0: Sets mode to Voltage, 1: Sets mode to Current",
"\n\r\n\r\tconfout arg1 arg2\n\r\tConfigures an analogue input on local device"
"\n\r\n\r\t\targ1=0-5, 9: chose channel 0-7 or chose all channels with 9"
"\n\r\t\targ2=0-1: 0: Sets mode to Voltage, 1: Sets mode to Current",
"\n\r\n\r\tcslave\n\r\tcalibrates the slave with number 2",
"\n\r\n\r\tcurout arg1 arg2 arg3\n\r\tDrives an analogue Output with current value"
"\n\r\n\r\t\targ1: device number"
"\n\r\t\targ2=0-5: channel number"
"\n\r\t\targ3=0-20000: value",
"\n\r\n\r\tcurin arg1 arg2\n\r\t Reads the actual current value from a analogue input"
"\n\r\n\r\t\targ1: device number"
"\n\r\t\targ2: channel number",
"\n\r\n\r\tcvin\n\r\tCalibrates the analogue voltage inputs"
"\n\r\tPut calibration value (e.g.10 V) on all inputs at the same time."
"\n\r\tSoftware works automated",
"\n\r\n\r\tcvout\n\r\tCalibrate the analogue voltage outputs"
"\n\r\tOnly useful with already calibrated analogue voltage inputs"
"\n\r\tConnect outputs 0-5 to inputs 0-5. Software works automated",
"\n\r\n\r\tdigiin arg1 arg2\n\r\tReads the actual value of a digital input"
"\n\r\n\r\t\targ1: device number"
"\n\r\t\targ2: channel number",
"\n\r\n\r\tdigiout arg1 arg2 arg3\n\r\tWrites to a digital output"
"\n\r\n\r\t\targ1: device number"
"\n\r\t\targ2: channel number"
"\n\r\t\targ3=0-1: 0: FALSE/LOW, 1: TRUE/HIGH",
"\n\r\n\r\tdio arg1 arg2\n\r\tTests the digital in- and outputs"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test"
"\n\r\t\targ2: test type (0: MB, 1: EB) (Only on remote test)",
"\n\r\n\r\teeprom arg1\n\r\tTests the connection and algorithms of the EEPROM"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test",
"\n\r\n\r\tfattest\n\r\tTest sequence for FAT Filesystem on SD/MMC",
"\n\r\n\r\thelp\n\r\tCALLS HELP, WHAT ELSE???",
"\n\r\n\r\tinitSD\n\r\tInitialises the SD Card",
"\n\r\n\r\tinitTest\n\r\tInitialises the remote test applications",
"\n\r\n\r\tledclean arg1\n\r\tSets all digital output LEDs to OFF"
"\n\r\n\r\t\targ1: device number",
"\n\r\n\r\tledtest arg1\n\r\tTests all LEDs available"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test",
"\n\r\n\r\tlistlocalattach\n\r\tLists all local bus-attached functions",
// "\n\r\n\r\tlistremoteattach\n\r\tLists all remote bus-attached functions",
"\n\r\n\r\tlogenable arg1\n\r\tEnables/Disables Output logging"
"\n\r\n\r\targ1=0-1: 0: disable, 1: enable",
"\n\r\n\r\tlogmount\n\r\tmounts the SD Card to file system",
"\n\r\n\r\tlogstart arg1\n\r\tStarts logging on file"
"\n\r\n\r\targ1: serial number of device and filename of log-file",
"\n\r\n\r\tlogstop\n\r\tstops logging on file",
"\n\r\n\r\tls\n\rlists all existing logfiles",
"\n\r\n\r\tmenudebug arg1\n\r\tEnables detailed messages from the menu"
"\n\r\n\r\t\targ1=0-1: 1: enable, 0: disable",
"\n\r\n\r\tmmc arg1\n\r\tTests the memory card interface"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test",
"\n\r\n\r\tpower arg1\n\r\tTests the devices power connections"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test",
"\n\r\n\r\tquit\n\r\tEXITS MENU",
"\n\r\n\r\treadrtc\n\r\tReads the RTC",
"\n\r\n\r\tremotecall arg1 arg2 arg3\n\r\tCalls remote functions on Salve"
"\n\r\n\r\t\targ1: Remote function number"
"\n\r\t\targ2: Number of function parameters"
"\n\r\t\targ3: Function paramters",
"\n\r\n\r\trtc arg1\n\r\tTests the RealTime Clock"
"\n\r\n\r\t\targ1: device number. 0 sets up a self test",
"\n\r\n\r\trun\n\r\tRuns a complete test sequence",
"\n\r\n\r\tstat_cal arg1\n\r\tSets the status of the analogue in- and outputs to CALIBRATED"
"\n\r\n\r\t\targ1: device number. 0 is self device",
"\n\r\n\r\tstat_def arg1\n\r\tSets the status of the analogue in- and outputs to DEFAULT"
"\n\r\n\r\t\targ1: device number. 0 is self device",
"\n\r\n\r\tstat_kill arg1\n\r\tDeletes the status of the analogue in- and outputs"
"\n\r\n\r\targ1: device number. 0 is self device",
"\n\r\n\r\tstat_show arg1 arg2\n\r\tShows the status of the analogue in- and outputs"
"\n\r\n\r\t\targ1: device number"
"\n\r\t\targ2: Status type - 0=VI, 1=VO, 2=CI, 3=CO",
"\n\r\n\r\tstat_showall arg1\n\r\tShows the status of ALL analogue in- and outputs"
"\n\r\n\r\t\targ1: device number",
"\n\r\n\r\tsetMux arg1 arg2\n\r\tSets the in- and ouput mux devices"
"\n\r\n\r\t\targ1: Mux type (0: DI; 1: DO; 2: AI; 3: AO)"
"\n\r\t\targ2: Mode (0: Main board; 1: Extension board)",
"\n\r\n\r\tsetRTC arg1 arg2 arg3\n\r\tSets Date and Time in the RTC"
"\n\r\n\r\targ1:|day|hour|minutes|seconds| (each 8 bit)"
"\n\r\targ2: |0|0|0|0|month|dayOfWeek (each 8 bit)"
"\n\r\targ3: |dayOfYear|year| (each 16 bit)",
"\n\r\n\r\ttasksdelete\n\r\tDeletes all testLED tasks",
"\n\r\n\r\tvolin arg1 arg2\n\r\tReads actual value on analogue voltage input"
"\n\r\n\r\t\targ1: device number. 0 is self device"
"\n\r\t\targ2=0-7: channel number",
"\n\r\n\r\tvolout arg1 arg2 arg3\n\r\tDrives analogue voltage output"
"\n\r\n\r\t\targ1: device number. 0 is self device"
"\n\r\t\targ2=0-5: channel number"
"\n\r\t\targ3=0-10000: Value"
};
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void menuInit (void)
{
UINT8 loopcnt = 0;
UINT8 asciicnt;
BOOLEAN breakout;
/* Calculate Array-Offsets for each possible first letter
* The actual Letter is mentioned in asciicnt, which starts with dezimal
* code of the first, small letter (a = 97).
*/
for (asciicnt = ASCII_START; asciicnt < (ASCII_START + ALPHABET_DIGITS); asciicnt++)
{
loopcnt = 0;
breakout = FALSE;
/* Perform search as long as no accordance was found or array ends */
while (breakout == FALSE)
{
if (loopcnt < NUMBER_OF_COMMANDS)
{
if (command_table[loopcnt][0] == asciicnt)
{
/* Accordance found! Save Offset in offset-array */
cmd_table_offset[(asciicnt - ASCII_START)] = loopcnt;
breakout = TRUE; /* Enable breakout of loop */
}
}
else
{
/* No Accordance found. Save "NO OFFSET" to offset-array */
cmd_table_offset[(asciicnt - ASCII_START)] = 0xFF;
breakout = TRUE; /* Enable breakout of loop */
}
loopcnt++;
}
}
}
+54
View File
@@ -0,0 +1,54 @@
/* ---------------------------------------------------------------------------
* menuargs.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 13, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef MENUARGS_H_
#define MENUARGS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define ALPHABET_DIGITS 26
#define NUMBER_OF_COMMANDS 55
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef void (*fpointer)(void);
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void menuInit (void);
#endif /*MENUARGS_H_*/
File diff suppressed because it is too large Load Diff
+119
View File
@@ -0,0 +1,119 @@
/* ---------------------------------------------------------------------------
* menufunctions.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 14, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef MENUFUNCTIONS_H_
#define MENUFUNCTIONS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void m_run (void);
/*
* INPUT AND OUTPUT SECTION
*/
void m_confout (void);
void m_confin (void);
void m_switchMux(void);
void m_curout (void);
void m_volout (void);
void m_digiout (void);
void m_volin (void);
void m_curin (void);
void m_digiin (void);
void m_canread (void);
void m_canwrite (void);
/*
* CALIBRATION SECTION
*/
void m_cvout (void);
void m_cvin (void);
void m_ccout (void);
void m_ccin (void);
void m_cdel (void);
void m_cload (void);
void m_c_stat (void);
void m_c_kill (void);
void m_c_def (void);
void m_c_cal (void);
void m_c_show (void);
void m_cslave(void);
/*
* TEST COMMAND SECTION
*/
void m_battery (void);
void m_ledtest (void);
void m_dio (void);
void m_aio(void);
void m_bus (void);
void m_cantest (void);
void m_eeprom (void);
void m_mmc (void);
void m_power(void);
void m_rtc (void);
void m_fattest (void);
/*
* LOGGING SECTION
*/
void m_initSD (void);
void m_sdMount (void);
void m_logEnable (void);
void m_logStart (void);
void m_logStop (void);
void m_loglist (void);
/*
* MISC SECTION
*/
void m_setRTC (void);
void m_readRTC (void);
void m_callRemoteFunction (void);
void m_listLocalattachments (void);
void m_clean(void);
void m_tasksdelete(void);
void m_quit(void);
void m_help(void);
void m_menuDebug (void);
#endif /*MENUFUNCTIONS_H_*/
@@ -0,0 +1,333 @@
/* ---------------------------------------------------------------------------
* remote_analogue.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description: remote analogue test sequence
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "remote_analogue.h"
#include "adc.h"
#include "dac.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
UINT32 remoteAioReadResult = 0;
BOOLEAN remoteAnalogueInitialised = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void remoteAioInit (void)
{
UINT32 loopcnt;
RESULT set_mb;
RESULT set_eb;
remoteAnalogueInitialised = TRUE; /* Mark driver as initialised */
sendString (SerOutPort, TRUE, importantMessage,
NewLine, "Initialise analogue remote buffers", Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tInputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_AI; loopcnt++)
{
remoteAnalogueInputs[loopcnt] = 0;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tOutputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_AO; loopcnt++)
{
remoteAnalogueInputs[loopcnt] = 0;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
vSemaphoreCreateBinary (remoteAnalogueSemaphore);
sendString (SerOutPort, TRUE, importantMessage,
"Take analogue semaphore... ", Dummy, Dummy);
if (xSemaphoreTake(remoteAnalogueSemaphore, 0) == pdTRUE)
{
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, importantMessage,
"Failed", Dummy, Dummy);
}
sendString(SerOutPort, TRUE, importantMessage,
"reset remote analogue outputs...", Dummy, Dummy);
set_mb = remoteAioWriteAll (remoteDeviceNumber, analogue_mb, 0);
set_eb = remoteAioWriteAll (remoteDeviceNumber, analogue_eb, 0);
if ((set_mb == OK) && (set_eb == OK))
{
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
}
else
{
sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy);
}
}
RESULT remoteAioWrite (UINT8 device, UINT8 channel, INT32 value)
{
INT32 sendArray[2];
RESULT returnValue;
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32) channel;
sendArray[1] = (INT32) value;
bpSendCallRpc(handleBus1, device, 22, 2, sendArray);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "analogue write was not successful", Dummy);
returnValue = ERROR;
}
else
{
remoteAnalogueOutputs[channel] = value;
returnValue = OK;
}
return (returnValue);
}
RESULT remoteAioWriteAll(UINT8 device, t_boardtype_analogue board, BOOLEAN value)
{
INT32 sendArray[2];
UINT8 loopcnt = 0;
UINT8 loopend = 0;
RESULT returnValue;
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)board;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 25, 2, sendArray);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString(SerOutPort, TRUE, importantMessage, s_tab,
"analogue write was not successful", Dummy);
returnValue = ERROR;
}
else
{
switch (board)
{
case analogue_mb:
loopcnt = 0;
loopend = NUMBER_OF_AO_MB;
break;
case analogue_eb:
loopcnt = NUMBER_OF_AO_MB;
loopend = NUMBER_OF_TOTAL_AO;
break;
}
for (loopcnt; loopcnt < loopend; loopcnt++)
{
remoteAnalogueOutputs[loopcnt] = value;
// \TODO IS THIS LOOP WORKING??
}
returnValue = OK;
}
return (returnValue);
}
UINT32 remoteAioRead (UINT8 device, UINT8 channel)
{
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return (ERROR);
}
bpSendCallRpc(handleBus1, device, 23, 1, (INT32)&channel);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "analogue read did not receive a readback", Dummy);
}
else
{
remoteAnalogueInputs[channel] = remoteAioReadResult;
}
return (remoteAioReadResult);
}
void remoteAioReadAll (UINT8 device, t_boardtype_analogue board)
{
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
bpSendCallRpc(handleBus1, device, 27, 1, (INT32)&board);
if (xSemaphoreTake(remoteAnalogueSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "analogue read all did not receive a readback", Dummy);
}
else
{
sendString (SerOutPort, TRUE, importantMessage,
f_tab, "analogue read all finished receiving", Dummy);
}
}
void remoteAnalogueSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
xSemaphoreGive (remoteAnalogueSemaphore);
}
void analogueReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* nrOfResults = 2
* results[0]: analogue input value
*/
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
/* Asign remote analogue input result to local variable */
remoteAioReadResult = (UINT32) results[0];
xSemaphoreGive (remoteAnalogueSemaphore);
}
void analogueReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* nrOfResults = maxDI_Channels
* results[x]: analogue input x value
*/
UINT32 loopcnt;
if (remoteAnalogueInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tanalogue not intialised", Dummy, Dummy);
return;
}
for (loopcnt = 0; loopcnt < maxDAC_Channels; loopcnt++)
{
/* Copy read result to value array */
remoteAnalogueInputs[loopcnt] = results[loopcnt];
}
xSemaphoreGive (remoteAnalogueSemaphore);
}
@@ -0,0 +1,85 @@
/* ---------------------------------------------------------------------------
* remote_analogue.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef REMOTE_ANALOGUE_H_
#define REMOTE_ANALOGUE_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define NUMBER_OF_AI_MB 8
#define NUMBER_OF_AO_MB 8
#define NUMBER_OF_AI_EB 4
#define NUMBER_OF_AO_EB 4
#define NUMBER_OF_TOTAL_AI (NUMBER_OF_AI_MB + NUMBER_OF_AI_EB)
#define NUMBER_OF_TOTAL_AO (NUMBER_OF_AO_MB + NUMBER_OF_AO_EB)
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef enum
{
analogue_mb = 0,
analogue_eb = 1
} t_boardtype_analogue;
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
INT32 remoteAnalogueInputs[(NUMBER_OF_TOTAL_AI)];
INT32 remoteAnalogueOutputs[(NUMBER_OF_TOTAL_AO)];
xSemaphoreHandle remoteAnalogueSemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void remoteAioInit (void);
RESULT remoteAioWrite (UINT8 device, UINT8 channel, INT32 value);
RESULT remoteAioWriteAll (UINT8 device, t_boardtype_analogue board, BOOLEAN value);
UINT32 remoteAioRead (UINT8 device, UINT8 channel);
void remoteAioReadAll (UINT8 device, t_boardtype_analogue board);
void remoteAnalogueSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void analogueReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void analogueReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /*REMOTE_ANALOGUE_H_*/
@@ -0,0 +1,376 @@
/* ---------------------------------------------------------------------------
* remote_digital.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description: remote digital test sequence
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "remote_digital.h"
#include "dio.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalInitialised = FALSE;
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDioReadResult = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void remoteDioInit (void)
{
UINT32 loopcnt;
RESULT set_mb;
RESULT set_eb;
remoteDigitalInitialised = TRUE; /* Mark driver as initialised */
sendString (SerOutPort, TRUE, importantMessage,
NewLine, "Initialise digital remote buffers", Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tInputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_DI; loopcnt++)
{
remoteDigitalInputs[loopcnt] = FALSE;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
sendString (SerOutPort, FALSE, importantMessage,
"\tOutputs...", Dummy, Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_DO; loopcnt++)
{
remoteDigitalOutputs[loopcnt] = FALSE;
}
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
vSemaphoreCreateBinary (remoteDigitalSemaphore);
sendString (SerOutPort, TRUE, importantMessage,
"Take digital semaphore... ", Dummy, Dummy);
if (xSemaphoreTake(remoteDigitalSemaphore, 0) == pdTRUE)
{
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, importantMessage,
"Failed", Dummy, Dummy);
}
sendString(SerOutPort, TRUE, importantMessage,
"reset remote digital outputs...", Dummy, Dummy);
set_mb = remoteDioWriteAll (remoteDeviceNumber, digital_mb, FALSE);
set_eb = remoteDioWriteAll (remoteDeviceNumber, digital_eb, FALSE);
if ((set_mb == OK) && (set_eb == OK))
{
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
}
else
{
sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy);
}
}
RESULT remoteDioWrite (UINT8 device, UINT8 channel, BOOLEAN value)
{
INT32 sendArray[2];
RESULT returnValue;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32) channel;
sendArray[1] = (INT32) value;
bpSendCallRpc(handleBus1, device, 20, 2, sendArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "digital write was not successful", Dummy);
returnValue = ERROR;
}
else
{
remoteDigitalOutputs[channel] = value;
returnValue = OK;
}
return (returnValue);
}
RESULT remoteDioWriteAll(UINT8 device, t_boardtype_digital board, BOOLEAN value)
{
INT32 sendArray[2];
UINT8 loopcnt = 0;
UINT8 loopend = 0;
RESULT returnValue;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)board;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 21, 2, sendArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString(SerOutPort, TRUE, importantMessage, s_tab,
"digital write was not successful", Dummy);
returnValue = ERROR;
}
else
{
switch (board)
{
case digital_mb:
loopcnt = 0;
loopend = NUMBER_OF_DO_MB;
break;
case digital_eb:
loopcnt = NUMBER_OF_DO_MB;
loopend = NUMBER_OF_TOTAL_DO;
break;
}
for (loopcnt; loopcnt < loopend; loopcnt++)
{
remoteDigitalOutputs[loopcnt] = value;
// \TODO IS THIS LOOP WORKING??
}
returnValue = OK;
}
return (returnValue);
}
BOOLEAN remoteDioRead (UINT8 device, INT32 channel)
{
INT32 channelArray[1];
channelArray[0] = channel;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return (ERROR);
}
bpSendCallRpc(handleBus1, device, 22, 1, channelArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "digital read did not receive a readback", Dummy);
}
else
{
remoteDigitalInputs[channel] = remoteDioReadResult;
}
return (remoteDioReadResult);
}
void remoteDioReadAll (UINT8 device, t_boardtype_digital board)
{
INT32 boardArray[1];
boardArray[0] = board;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
bpSendCallRpc(handleBus1, device, 23, 1, boardArray);
if (xSemaphoreTake(remoteDigitalSemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "digital read all did not receive a readback", Dummy);
}
else
{
sendString (SerOutPort, TRUE, importantMessage,
f_tab, "digital read all finished receiving", Dummy);
}
}
void remoteDigitalSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
xSemaphoreGive (remoteDigitalSemaphore);
}
void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
/* nrOfResults = 2
* results[0]: digital input value (0: LOW, !0: HIGH)
*/
if (results[0] == 0)
{
/* Remote digital input is LOW */
remoteDioReadResult = FALSE;
}
else
{
/* Remote digital input is HIGH */
remoteDioReadResult = TRUE;
}
xSemaphoreGive (remoteDigitalSemaphore);
}
void digitalReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
/* nrOfResults = 2
* results[0]: boardType (0: MB; 1: EB)
* results[1]: digital input value
*/
UINT32 loopcnt;
UINT32 tempValue;
if (remoteDigitalInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital not intialised", Dummy, Dummy);
return;
}
sendString (SerOutPort, TRUE, importantMessage,
"\t\tdigital real all: ", ItoHStr (results[1]), Dummy);
if (results[0] == 0)
{
/* Incoming Results are from Mainboard */
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_MB; loopcnt++)
{
tempValue = (results[1] & (0x0000 | (1 << loopcnt)));
if (tempValue == 0)
{
remoteDigitalInputs[loopcnt] = FALSE;
}
else
{
remoteDigitalInputs[loopcnt] = TRUE;
}
}
}
else if (results[0] == 1)
{
/* Incoming Results are from Extensionboard */
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_EB; loopcnt++)
{
tempValue = (results[1] & (0x0000 | (1 << loopcnt)));
if (tempValue == 0)
{
remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] = FALSE;
}
else
{
remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] = TRUE;
}
}
}
xSemaphoreGive (remoteDigitalSemaphore);
}
@@ -0,0 +1,86 @@
/* ---------------------------------------------------------------------------
* remote_digital.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Nov 11, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef DIGITAL_TEST_H_
#define DIGITAL_TEST_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define NUMBER_OF_DI_MB 8
#define NUMBER_OF_DO_MB 8
#define NUMBER_OF_DI_EB 4
#define NUMBER_OF_DO_EB 4
#define NUMBER_OF_TOTAL_DI (NUMBER_OF_DI_MB + NUMBER_OF_DI_EB)
#define NUMBER_OF_TOTAL_DO (NUMBER_OF_DO_MB + NUMBER_OF_DO_EB)
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef enum
{
digital_mb = 0,
digital_eb = 1
} t_boardtype_digital;
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalInputs[(NUMBER_OF_TOTAL_DI)];
BOOLEAN remoteDigitalOutputs[(NUMBER_OF_TOTAL_DO)];
xSemaphoreHandle remoteDigitalSemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void remoteDioInit (void);
RESULT remoteDioWrite (UINT8 device, UINT8 channel, BOOLEAN value);
RESULT remoteDioWriteAll (UINT8 device, t_boardtype_digital board, BOOLEAN value);
BOOLEAN remoteDioRead (UINT8 device, INT32 channel);
void remoteDioReadAll (UINT8 device, t_boardtype_digital board);
void remoteDigitalSemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
void digitalReadAllResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /*DIGITAL_TEST_H_*/
+144
View File
@@ -0,0 +1,144 @@
/* ---------------------------------------------------------------------------
* remote_misc.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Nov 11, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
#include "Semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "BusProtocol.h"
#include "protocolfunctions.h"
#include "remote_misc.h"
#include "SerOut.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
#define ident_calibrated 0x55
#define ident_default 0xAA
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
extern UINT32 UINT32result; /* from topoftests.c */
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
BOOLEAN makeHandshake (void)
{
/* Make Handshake with first Slave device.
* Take Semaphore, call remote function and take Semaphore again with
* waitcycle. Semaphore can just be taken when remote function
* finished and returns call to release Semaphore.
*/
BOOLEAN handshakeResult;
xSemaphoreTake(generalSemaphore, 1); /* Take generalSemaphore */
bpSendCallRpc (handleBus1, 2, 1, 0, NULL); /* Call Slaves Handshake */
if (xSemaphoreTake(generalSemaphore, 2000) == pdPASS)
{ /* Wait for Handshake done */
handshakeResult = TRUE;
}
else
{
handshakeResult = FALSE;
}
return (handshakeResult);
}
#endif
UINT8 returnRemoteCalibrationStatus (INT32 correctionType)
{
xSemaphoreTake(generalSemaphore, 0);
bpSendCallRpc(handleBus1, 2, 13, 1, &correctionType);
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
/* Semaphore is not released, timeout in transmission */
xSemaphoreGive (generalSemaphore);
UINT32result = 0;
}
else
{
if (UINT32result & ident_default)
{
}
else if (UINT32result & ident_calibrated)
{
}
else
{
}
}
return ((UINT8) UINT32result);
}
UINT8 showRemoteCalibrationStatus (INT32 correctionType)
{
xSemaphoreTake(generalSemaphore, 0);
bpSendCallRpc(handleBus1, 2, 13, 1, &correctionType);
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
/* Semaphore is not released, timeout in transmission */
xSemaphoreGive (generalSemaphore);
}
else
{
if (UINT32result & ident_default)
{
sendString (SerOutPort, FALSE, testMessage,
"Values are in DEFAULT Mode", Dummy, Dummy);
}
else if (UINT32result & ident_calibrated)
{
sendString (SerOutPort, FALSE, testMessage,
"Values are in CALIBRATED Mode", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, testMessage,
"NO VALID VALUES IN EEPROM", Dummy, Dummy);
}
}
return ((UINT8) UINT32result);
}
@@ -0,0 +1,73 @@
/* ---------------------------------------------------------------------------
* remote_misc.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Nov 11, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: makeHandshake
*
* Functions Calls first Attached Function on Slave, which is sending an
* Answer back to Master
*
* Parameter: void
*
* Return: BOOLEAN - Result of Handshake
* ---------------------------------------------------------------------------
*/
BOOLEAN makeHandshake (void);
UINT8 returnRemoteCalibrationStatus (INT32 correctionType);
UINT8 showRemoteCalibrationStatus (INT32 correctionType);
void digitalReadResult (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#ifndef REMOTE_MISC_H_
#define REMOTE_MISC_H_
#endif /*REMOTE_MISC_H_*/
@@ -0,0 +1,221 @@
/* ---------------------------------------------------------------------------
* remote_relay.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
#include "remote_relay.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteRelayInitialised = FALSE;
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void remoteRelayInit(void)
{
UINT32 loopcnt;
RESULT set_mb;
RESULT set_eb;
remoteRelayInitialised = TRUE;
sendString(SerOutPort, TRUE, importantMessage, NewLine,
"Initialise relay remote buffers...", Dummy);
for (loopcnt = 0; loopcnt < NUMBER_OF_TOTAL_RLY; loopcnt++)
{
remoteRelayInputs[loopcnt] = 0;
}
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
vSemaphoreCreateBinary (remoteRelaySemaphore);
sendString (SerOutPort, TRUE, importantMessage,
"Take relay semaphore... ", Dummy, Dummy);
if (xSemaphoreTake(remoteRelaySemaphore, 0) == pdTRUE)
{
sendString (SerOutPort, FALSE, importantMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, importantMessage,
"Failed", Dummy, Dummy);
}
sendString(SerOutPort, TRUE, importantMessage,
"reset remote relays...", Dummy, Dummy);
set_mb = remoteRelaySetAll (remoteDeviceNumber, relay_mb, FALSE);
set_eb = remoteRelaySetAll (remoteDeviceNumber, relay_eb, FALSE);
if ((set_mb == OK) && (set_eb == OK))
{
sendString(SerOutPort, FALSE, importantMessage, "Done", Dummy, Dummy);
}
else
{
sendString(SerOutPort, FALSE, importantMessage, "Failed", Dummy, Dummy);
}
}
RESULT remoteRelaySet (UINT8 device, UINT8 channel, BOOLEAN value)
{
INT32 sendArray[2];
RESULT returnValue;
if (remoteRelayInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\trelay not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)channel;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 28, 2, sendArray);
if (xSemaphoreTake(remoteRelaySemaphore, 3000) != pdTRUE)
{
sendString (SerOutPort, TRUE, importantMessage,
s_tab, "relay set was not successful", Dummy);
returnValue = ERROR;
}
else
{
remoteRelayInputs[channel] = value;
returnValue = OK;
}
return (returnValue);
}
BOOLEAN remoteRelayRead (UINT8 device, UINT8 channel)
{
if (remoteRelayInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\trelay not intialised", Dummy, Dummy);
return;
}
}
RESULT remoteRelaySetAll(UINT8 device, t_boardtype_relay board, BOOLEAN value)
{
INT32 sendArray[2];
UINT32 loopcnt = 0;
UINT32 loopend = 0;
RESULT returnValue;
if (remoteRelayInitialised == FALSE)
{
/* Remote digital driver is not initialised */
sendString (SerOutPort, TRUE, importantMessage,
"\t\trelay not intialised", Dummy, Dummy);
return (ERROR);
}
sendArray[0] = (INT32)board;
sendArray[1] = (INT32)value;
bpSendCallRpc(handleBus1, device, 29, 2, sendArray);
if (xSemaphoreTake(remoteRelaySemaphore, 3000) != pdTRUE)
{
sendString(SerOutPort, TRUE, importantMessage, s_tab,
"relay set was not successful", Dummy);
returnValue = ERROR;
}
else
{
switch (board)
{
case relay_mb:
loopcnt = 0;
loopend = NUMBER_OF_RLY_MB;
break;
case relay_eb:
loopcnt = NUMBER_OF_RLY_MB;
loopend = NUMBER_OF_TOTAL_RLY;
break;
}
for (loopcnt; loopcnt < loopend; loopcnt++)
{
remoteRelayInputs[loopcnt] = value;
}
returnValue = OK;
}
return (returnValue);
}
void remoteRelaySemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results)
{
xSemaphoreGive (remoteRelaySemaphore);
}
@@ -0,0 +1,73 @@
/* ---------------------------------------------------------------------------
* remote_relay.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef REMOTE_RELAY_H_
#define REMOTE_RELAY_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
#define NUMBER_OF_RLY_MB 4
#define NUMBER_OF_RLY_EB 2
#define NUMBER_OF_TOTAL_RLY (NUMBER_OF_RLY_MB + NUMBER_OF_RLY_EB)
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
typedef enum
{
relay_mb = 0,
relay_eb = 1
} t_boardtype_relay;
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteRelayInputs[(NUMBER_OF_TOTAL_RLY)];
xSemaphoreHandle remoteRelaySemaphore;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void remoteRelayInit(void);
RESULT remoteRelaySet (UINT8 device, UINT8 channel, BOOLEAN value);
BOOLEAN remoteRelayRead (UINT8 device, UINT8 channel);
RESULT remoteRelaySetAll (UINT8 device, t_boardtype_relay board, BOOLEAN value);
void remoteRelaySemaphoreRelease (UINT8 requestNr, UINT8 nrOfResults, UINT32 *results);
#endif /*REMOTE_RELAY_H_*/
@@ -0,0 +1,331 @@
/* ---------------------------------------------------------------------------
* remote_tests.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description: Function to call single tests on remote system
*
* NOTE: allMemoryUseSameLED is defined in taskfunctions.h
*
* ---------------------------------------------------------------------------
* Version(s): 0.1, Aug 29, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "remote_tests.h"
#include "SerOut.h"
#include "dio.h"
#include "ledfunctions.h"
#include "protocolfunctions.h"
#include "taskfunctions.h"
#include "BusProtocol.h"
/* Test includes */
#include "testLED.h"
#include "testdio.h"
#include "testaio.h"
#include "testBUS.h"
#include "testeeprom.h"
#include "testMMC.h"
#include "testpower.h"
#include "testrtc.h"
#include "remote_analogue.h"
#include "remote_digital.h"
#include "remote_relay.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
extern BOOLEAN auto_testResult;
extern BOOLEAN GotoNewLine;
extern BOOLEAN block_SpinningWheel;
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void r_TestInit (void)
{
remoteDioInit();
vTaskDelay (200);
remoteAioInit();
vTaskDelay (200);
remoteRelayInit();
vTaskDelay (200);
}
void r_BatteryTest (BOOLEAN * batterytest)
{
/* Test for Battery and batterysupplied Memory */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "Battery Test");
bpSendCallRpc(handleBus1, 2, 17, 0, NULL); /* Write on Battery Memory */
sendString(SerOutPort, TRUE, noteMessage,
NewLine, "\t\tSwitch SLAVE OFF for 5 Seconds", Dummy);
if (xSemaphoreTake(slaveRestartSemaphore, 60000) == pdPASS)
{ /* Wait for slave Restart */
bpSendCallRpc(handleBus1, 2, 18, 0, NULL); /* Read from Memory */
xSemaphoreTake(generalSemaphore, 3000);
}
else
{
auto_testResult = FALSE;
xSemaphoreGive (slaveRestartSemaphore);
}
*batterytest = auto_testResult;
#if (allMemoryUseSameLED == 1)
postpareTest(*batterytest, &d_batteryled, BATTERYLED, (void *)dioToggle,
(pUINT8) "batteryerror", &batteryled);
#endif
bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */
sendString (SerOutPort, TRUE, resultMessage,
"n\rBATTERY Test Result: ", s_lines, BoolRestoStr (*batterytest));
}
void r_LEDTest (BOOLEAN * ledtest)
{
/* Local Variable declaration */
UINT8 buffer = 0;
UINT8 captureDio;
UINT8 dioAllOn = 0xFF;
BOOLEAN receive = FALSE;
/* Test for all accessable LEDs */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "LED TEST");
captureDio = dioCapture();
diotaskssuspend();
dioResume (dioAllOn);
bpSendCallRpc(handleBus1, 2, 21, 0, NULL); /* Call ledTest() */
sendString (SerOutPort, TRUE, noteMessage,
"\n\tAre all LEDs turned on? ",
"\n\r\tPRESS y (YES) oder n (NO): ",
NewLine);
do /* do-while loop for String input */
{
vTaskDelay (10);
buffer = 0;
receive = serGet(SerOutPort, &buffer);
} while ((buffer != 121) && (buffer != 110));
if (buffer == 121) /* 121 = y (ScanCode) */
{
*ledtest = TRUE;
}
else if (buffer == 110) /* 110 = n (ScanCode) */
{
*ledtest = FALSE;
}
xSemaphoreTake(generalSemaphore, 5000);
dioResume(captureDio);
diotasksresume();
bpSendCallRpc(handleBus1, 2, 32, 0, NULL); /* Postpare Test on Slave */
postpareTest(*ledtest, &d_ledtestled, LEDTESTLED, (void *)dioToggle,
(pUINT8) "LEDerror", &ledtestled);
bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */
sendString (SerOutPort, GotoNewLine, resultMessage,
"n\rLED Test Result: ", s_lines, BoolRestoStr (*ledtest));
}
void r_EEPROMTest (BOOLEAN * eepromtest)
{
/* Test for EEPROM Memory */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "EEPROM");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 22, 0, NULL); /* Call eepromTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString (SerOutPort, TRUE, importantMessage,
"\tTimeout occoured!", Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*eepromtest = auto_testResult;
#if (allMemoryUseSameLED == 0)
postpareTest(*eepromtest, &d_eepromled, EEPROMLED, (void *)dioToggle,
(pUINT8) "EEPROMerror", eepromled);
#else
postpareTest(*eepromtest, &d_memoryled, MEMORYLED, (void *)dioToggle,
(pUINT8) "memoryerror", &memoryled);
#endif
bpSendCallRpc(handleBus1, 2, 4, 0, NULL); /* Call dioClean() */
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rEEPROM Test Result:",
s_lines, BoolRestoStr(*eepromtest));
}
void r_MMCTest(BOOLEAN * mmctest)
{
/* Test for Multimedia Card */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "MMC");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 27, 0, NULL); /* Call MMCTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString(SerOutPort, TRUE, importantMessage, "\tTimeout occoured!",
Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*mmctest = auto_testResult;
postpareTest(*mmctest, &d_mmcled, MMCLED, (void *)dioToggle,
(pUINT8) "MMCerror", &mmcled);
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rMMC Test Result: ", s_lines, BoolRestoStr(*mmctest));
}
void r_PowerTest (BOOLEAN * powertest)
{ /* Test for Power Supply */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "Power Supply");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 28, 0, NULL); /* Call eepromTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString (SerOutPort, TRUE, importantMessage,
"\tTimeout occoured!", Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*powertest = auto_testResult;
postpareTest(*powertest, &d_powerled, POWERLED, (void *)dioToggle,
(pUINT8) "POWERerror", &powerled);
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rPower Supply Test Result:",
f_lines, BoolRestoStr(*powertest));
}
void r_RTCTest (BOOLEAN * rtctest)
{ /* Test for Real Time Clock */
sendString(SerOutPort, TRUE, headerMessage,
StartMessage, f_lines, "RealTimeClock");
sendString (SerOutPort, FALSE, importantMessage,
"\t", Dummy, Dummy);
block_SpinningWheel = FALSE;
bpSendCallRpc(handleBus1, 2, 29, 0, NULL); /* Call eepromTest() */
if (xSemaphoreTake(generalSemaphore, 5000) != pdPASS)
{
block_SpinningWheel = TRUE;
sendString (SerOutPort, TRUE, importantMessage,
"\tTimeout occoured!", Dummy, Dummy);
auto_testResult = FALSE;
xSemaphoreGive (generalSemaphore);
}
block_SpinningWheel = TRUE;
*rtctest = auto_testResult;
postpareTest(*rtctest, &d_rtcled, RTCLED, (void *)dioToggle,
(pUINT8) "RTCerror", &rtcled);
sendString(SerOutPort, GotoNewLine, resultMessage,
"\n\rRealTimeClock Test Result:",
f_lines, BoolRestoStr(*rtctest));
}
/* Function to handle all necessary commands and calculations after a
* single test. Because these are all the same, they are done in a
* extra function
*/
void postpareTest (BOOLEAN TestResult, portBASE_TYPE *basetype,
UINT32 LEDNumber, pdTASK_CODE TaskCode,
pUINT8 taskname, xTaskHandle *pTaskHandler)
{
if (TestResult == TRUE)
{ /* if Test is passed */
if (*basetype == pdPASS) /* If defined Task exists */
{
vTaskDelete (*pTaskHandler);/* Delete defined Task */
*basetype = 0; /* Reset corresponding bastetype */
}
dioWrite( 0, LEDNumber, TRUE); /* illume corresponding LED */
}
else
{ /* if DIO Test fails */
if (*basetype == pdPASS)
{
/* Task already exists, so do nothing */
}
else
{
*basetype = xTaskCreate((void *)TaskCode,
( signed portCHAR * ) taskname,
configMINIMAL_STACK_SIZE, (UINT16 *)LEDNumber,
tskIDLE_PRIORITY + 2, pTaskHandler);
} /* Create Task to flash LED */
}
}
@@ -0,0 +1,104 @@
/* ---------------------------------------------------------------------------
* remote_tests.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Aug 29, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef REMOTE_TESTS_H_
#define REMOTE_TESTS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
void r_TestInit (void);
/* ---------------------------------------------------------------------------
* Function: r_xyzTest
*
* Functions that call the corresponding test on remote Device and handle
* some optical commands like Result printout and LED controlling
*
* Parameter: BOOLEAN * xyztest - Test Result is written to this variable
*
* Return: void
* ---------------------------------------------------------------------------
*/
void r_BatteryTest (BOOLEAN * batterytest);
void r_LEDTest (BOOLEAN * ledtest);
void r_framTest (BOOLEAN * framtest);
void r_EEPROMTest (BOOLEAN * eepromtest);
void r_FLASHTest (BOOLEAN * flashtest);
void r_LogTest (BOOLEAN *logtest);
void r_DIOTest (BOOLEAN * diotest);
void r_AIOTest (BOOLEAN * aiotest);
void r_MMCTest (BOOLEAN * mmctest);
void r_PowerTest (BOOLEAN * powertest);
void r_RTCTest (BOOLEAN * rtctest);
/* ---------------------------------------------------------------------------
* Function: postpareTest
*
* Function to manage all needed things after a Test - e.g. Restore
* DIO-Results or Create/Resume Tasks.
*
* Parameter: BOOLEAN TestResult - Testresult of current Test
* portBASE_TYPE *basetype - TaskCreation Result
* UINT32 LEDNumber - LEDNumber to be used for that Test
* pdTASK_CODE TaskCode - Function, that should be tasked
* pUINT8 taskname - Name for the Task
* xTaskHandle *pTaskHandler - TaskHandler
*
* Return: void
* ---------------------------------------------------------------------------
*/
void postpareTest (BOOLEAN TestResult, portBASE_TYPE *basetype,
UINT32 LEDNumber, pdTASK_CODE TaskCode,
pUINT8 taskname, xTaskHandle *pTaskHandler);
#endif /*REMOTE_TESTS_H_*/
@@ -0,0 +1,341 @@
/* ---------------------------------------------------------------------------
* test_analogue.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "test_analogue.h"
#include "remote_analogue.h"
#include "adc.h"
#include "dac.h"
#include "remote_tests.h"
#include "SerOut.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
#define cTestvalue 15000
#define cNullvalue 0
#define ciTolerance_null 50
#define ciTolerance_uncal 3500
#define ciTolerance_cal 50
#define coTolerance_null 50
#define coTolerance_uncal 3500
#define coTolerance_cal 50
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteAnalogueLinetestMBExecute (void)
{
BOOLEAN returnValue;
BOOLEAN remoteAnalogueOutput;
BOOLEAN remoteAnalogueInput;
remoteAnalogueOutput = remoteAnalogueOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue output test: ", f_tab, BoolRestoStr(remoteAnalogueOutput));
remoteAnalogueInput = remoteAnalogueInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue input test: ", f_tab, BoolRestoStr(remoteAnalogueInput));
if ((remoteAnalogueOutput == TRUE) && (remoteAnalogueInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
}
BOOLEAN remoteAnalogueLinetestEBExecute (void)
{
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
BOOLEAN remoteAnalogueOutput;
BOOLEAN remoteAnalogueInput;
remoteAnalogueOutput = remoteAnalogueOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue output test: ", f_tab, BoolRestoStr(remoteAnalogueOutput));
remoteAnalogueInput = remoteAnalogueInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote analogue input test: ", f_tab, BoolRestoStr(remoteAnalogueInput));
if ((remoteAnalogueOutput == TRUE) && (remoteAnalogueInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
#else
sendString (SerOutPort, TRUE, importantMessage,
"Extension Board test not available on this device", Dummy, Dummy);
return (FALSE);
#endif
}
BOOLEAN remoteAnalogueOutputTest_MB (void)
{
UINT32 loopcnt;
UINT32 channelcnt;
UINT32 testTolerance;
UINT32 lowRead;
UINT32 highRead;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \TODO SET TEST TOLERANCE DEPENDING ON THE CALIBRATION STATUS
testTolerance = coTolerance_uncal;
adcModeAll(adcCURRENT); /* Set local ADC to mode CURRENT*/
remoteAioWriteAll(remoteDeviceNumber, analogue_mb, cNullvalue);
vTaskDelay (500);
sendString (SerOutPort, FALSE, testMessage, NewLine,
"\tCurrent Test Value: ", ItoDStr (cTestvalue));
sendString (SerOutPort, FALSE, testMessage,
"\t\tTolerance: ", ItoDStr (testTolerance), Dummy);
for (channelcnt = 0; channelcnt < NUMBER_OF_AO_MB; channelcnt++)
{
lowRead = adcRead(thisDeviceNumber, channelcnt);
if (lowRead < (cNullvalue + coTolerance_null))
{
/* Read a null-like value - LOW test passed */
}
else
{
/* Read a too high value - LOW test failed */
Low_Test = FALSE;
}
remoteAioWrite(remoteDeviceNumber, channelcnt, cTestvalue);
vTaskDelay (500);
highRead = adcRead(thisDeviceNumber, channelcnt);
if ((highRead < (cTestvalue + testTolerance)) && (highRead > (cTestvalue - testTolerance)))
{
/* Read a value within the test tolerances - High test passed */
}
else
{
/* read a value out of the test tolerances - High test failed */
High_Test = FALSE;
}
for (loopcnt = 0; loopcnt < NUMBER_OF_AO_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip actual test channel */
}
else
{
/* Check channel for remaining LOW */
if (adcRead(thisDeviceNumber, loopcnt) >= (cNullvalue + coTolerance_null))
{
/* Actual channels value too high, AllOther test failed */
AllOther_Test = FALSE;
}
}
}
remoteAioWrite(remoteDeviceNumber, channelcnt, cNullvalue);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tCurrent Test for Analogue Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (lowRead));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (highRead));
sendString (SerOutPort, FALSE, testMessage,
" All Other: ", Dummy, BoolRestoStr (AllOther_Test));
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
BOOLEAN remoteAnalogueInputTest_MB (void)
{
UINT32 loopcnt;
UINT32 channelcnt;
UINT32 testTolerance;
UINT32 lowRead;
UINT32 highRead;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \TODO SET TEST TOLERANCE DEPENDING ON THE CALIBRATION STATUS
testTolerance = coTolerance_uncal;
dacModeAll(dacCURRENT); /* Set local DAC to mode CURRENT*/
/* Reset all local DAC channels to zero ampere */
for (loopcnt = 0; loopcnt < maxDAC_Channels; loopcnt++)
{
dacWrite(thisDeviceNumber, loopcnt, cNullvalue);
}
vTaskDelay (500);
sendString (SerOutPort, FALSE, testMessage, NewLine,
"\tCurrent Test Value: ", ItoDStr (cTestvalue));
sendString (SerOutPort, FALSE, testMessage,
"\t\tTolerance: ", ItoDStr (testTolerance), Dummy);
for (channelcnt = 0; channelcnt < NUMBER_OF_AI_MB; channelcnt++)
{
lowRead = remoteAioRead(remoteDeviceNumber, channelcnt);
if (lowRead < (cNullvalue + testTolerance))
{
/* Read a null-like value - LOW test passed */
Low_Test = TRUE;
}
else
{
/* Read a too high value - LOW test failed */
Low_Test = FALSE;
}
dacWrite(thisDeviceNumber, channelcnt, cTestvalue);
vTaskDelay (200);
highRead = remoteAioRead(remoteDeviceNumber, channelcnt);
if ((highRead < (cTestvalue + testTolerance)) && (highRead > (cTestvalue - testTolerance)))
{
/* Read a value within the test tolerances - High test passed */
High_Test = TRUE;
}
else
{
/* read a value out of the test tolerances - High test failed */
High_Test = FALSE;
}
remoteAioReadAll(remoteDeviceNumber, analogue_mb);
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_AO_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (remoteAnalogueOutputs[loopcnt] >= (cNullvalue + ciTolerance_null))
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
dacWrite(thisDeviceNumber, channelcnt, cNullvalue);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tCurrent Test for Analogue Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (lowRead));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, ItoDStr (highRead));
sendString (SerOutPort, FALSE, testMessage,
" All Other: ", Dummy, BoolRestoStr (AllOther_Test));
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
BOOLEAN remoteAnalogueOutputTest_EB (void)
{
}
@@ -0,0 +1,69 @@
/* ---------------------------------------------------------------------------
* test_analogue.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TEST_ANALOGUE_H_
#define TEST_ANALOGUE_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteAnalogueLinetestMBExecute (void);
BOOLEAN remoteAnalogueLinetestEBExecute (void);
BOOLEAN remoteAnalogueOutputTest_MB (void);
BOOLEAN remoteAnalogueInputTest_MB (void);
BOOLEAN remoteAnalogueOutputTest_EB (void);
BOOLEAN remoteAnalogueInputTest_EB (void);
#endif /*TEST_ANALOGUE_H_*/
@@ -0,0 +1,499 @@
/* ---------------------------------------------------------------------------
* test_digital.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "test_digital.h"
#include "remote_digital.h"
#include "dio.h"
#include "remote_tests.h"
#include "SerOut.h"
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "ledfunctions.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalLinetestMBExecute (void)
{
BOOLEAN returnValue;
BOOLEAN remoteDigitalOutput;
BOOLEAN remoteDigitalInput;
remoteDigitalOutput = remoteDigitalOutputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput));
remoteDigitalInput = remoteDigitalInputTest_MB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_mb input test: ", f_tab, BoolRestoStr(remoteDigitalInput));
if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
}
BOOLEAN remoteDigitalLinetestEBExecute (void)
{
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
BOOLEAN returnValue;
BOOLEAN remoteDigitalOutput;
BOOLEAN remoteDigitalInput;
remoteDigitalOutput = remoteDigitalOutputTest_EB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_eb output test: ", f_tab, BoolRestoStr(remoteDigitalOutput));
remoteDigitalInput = remoteDigitalInputTest_EB();
sendString (SerOutPort, TRUE, resultMessage,
"remote digital_eb input test: ", f_tab, BoolRestoStr(remoteDigitalInput));
if ((remoteDigitalOutput == TRUE) && (remoteDigitalInput == TRUE))
{
returnValue = TRUE;
}
else
{
returnValue = FALSE;
}
return (returnValue);
#else
sendString (SerOutPort, TRUE, importantMessage,
"Extension Board test not available on this device", Dummy, Dummy);
return (FALSE);
#endif
}
BOOLEAN remoteDigitalOutputTest_MB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
/* Reset all remote digital outputs to LOW/OFF */
remoteDioWriteAll(remoteDeviceNumber, digital_mb, FALSE);
vTaskDelay (200);
for (channelcnt = 0; channelcnt < NUMBER_OF_DO_MB; channelcnt++)
{
/* Read remote digital channel value for LOW test */
if (dioRead(thisDeviceNumber, channelcnt) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
/* Drive testchannel to HIGH Output value */
remoteDioWrite(remoteDeviceNumber, channelcnt, TRUE);
vTaskDelay (200); /* Assure command was executed */
if (dioRead(thisDeviceNumber, channelcnt) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
vTaskDelay (200);
/* Check all other channels for remaining at LOW */
for (loopcnt = 0; loopcnt < NUMBER_OF_DO_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (dioRead(thisDeviceNumber, loopcnt) == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
remoteDioWrite(remoteDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
BOOLEAN remoteDigitalInputTest_MB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
dioClean(); /* Clean local digital outputs */
vTaskDelay (500);
for (channelcnt = 0; channelcnt < NUMBER_OF_DI_MB; channelcnt++)
{
if (remoteDioRead(remoteDeviceNumber, channelcnt) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
vTaskDelay (200);
dioWrite(thisDeviceNumber, channelcnt, TRUE);
vTaskDelay(200);
if (remoteDioRead(remoteDeviceNumber, channelcnt) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
vTaskDelay(500);
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
vTaskDelay(500);
High_Test = FALSE;
}
remoteDioReadAll(remoteDeviceNumber, digital_mb);
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_MB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (remoteDigitalInputs[loopcnt] == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Return to LOW channel value */
dioWrite (thisDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
return (returnResult);
}
BOOLEAN remoteDigitalOutputTest_EB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
dio_inMuxEn (TRUE); /* Switch dio to Extension Board*/
#endif
/* Reset all remote digital outputs to LOW/OFF */
remoteDioWriteAll(remoteDeviceNumber, digital_eb, FALSE);
vTaskDelay (200);
for (channelcnt = NUMBER_OF_DO_MB; channelcnt < NUMBER_OF_TOTAL_DO; channelcnt++)
{
if (dioRead(thisDeviceNumber, (channelcnt - NUMBER_OF_DO_MB)) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
/* Drive testchannel to HIGH Output value */
remoteDioWrite(remoteDeviceNumber, channelcnt, TRUE);
vTaskDelay (200); /* Assure command was executed */
if (dioRead(remoteDeviceNumber, (channelcnt - NUMBER_OF_DO_MB)) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_DO_EB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (dioRead(thisDeviceNumber, loopcnt) == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
dio_inMuxEn (FALSE); /* Switch dio back to main Board*/
#endif
return (returnResult);
}
BOOLEAN remoteDigitalInputTest_EB (void)
{
UINT32 channelcnt;
UINT32 loopcnt;
BOOLEAN returnResult = TRUE;
BOOLEAN Low_Test = TRUE;
BOOLEAN High_Test = TRUE;
BOOLEAN AllOther_Test = TRUE;
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
dio_outMuxEn (TRUE); /* Switch dio to Extension Board*/
#endif
dioClean(); /* Clean local digital outputs */
vTaskDelay (500);
for (channelcnt = 0; channelcnt < NUMBER_OF_DI_EB; channelcnt++)
{
if (remoteDioRead(remoteDeviceNumber, (channelcnt + NUMBER_OF_DI_MB)) == FALSE)
{
/* Read back a LOW Value, which is correct - LOW test passed */
Low_Test = TRUE;
}
else
{
/* read back a HIGH Value, which is incorrect - LOW test failed */
Low_Test = FALSE;
}
vTaskDelay (200);
dioWrite(thisDeviceNumber, channelcnt, TRUE);
if (remoteDioRead(remoteDeviceNumber, (channelcnt + NUMBER_OF_DI_MB)) == TRUE)
{
/* Read back a HIGH Value, which is correct - HIGH test passed */
High_Test = TRUE;
}
else
{
/* read back a LOW Value, which is incorrect - HIGH test failed */
High_Test = FALSE;
}
remoteDioReadAll(remoteDeviceNumber, digital_eb);
vTaskDelay (200);
for (loopcnt = 0; loopcnt < NUMBER_OF_DI_EB; loopcnt++)
{
if (loopcnt == channelcnt)
{
/* Skip test channel */
}
else
{
/* Check actual channel to remain LOW */
if (remoteDigitalInputs[(loopcnt + NUMBER_OF_DI_MB)] == TRUE)
{
/* Channel should remain LOW - AllOther test failed */
AllOther_Test = FALSE;
break; /* Skip rest of loop */
}
else
{
AllOther_Test = TRUE;
}
}
}
/* Return to LOW channel value */
dioWrite (thisDeviceNumber, channelcnt, FALSE);
/* Message out Test Results */
sendString (SerOutPort, TRUE, testMessage,
"\tLinetest for Digital Input ", ItoDStr(channelcnt), ": ");
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (Low_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (AllOther_Test));
sendString (SerOutPort, FALSE, testMessage,
" ", Dummy, BoolRestoStr (High_Test));
vTaskDelay (50);
if ((Low_Test == FALSE) || (High_Test == FALSE) || (AllOther_Test == FALSE))
{
returnResult = FALSE;
}
}
// \MARK NEW PINSETTINGS FOR TESTER (2)
#if (PINSET_TESTER == 2)
dio_outMuxEn (FALSE); /* Switch dio back to main Board*/
#endif
return (returnResult);
}
@@ -0,0 +1,61 @@
/* ---------------------------------------------------------------------------
* test_digital.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 15, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TEST_DIGITAL_H_
#define TEST_DIGITAL_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "Task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteDigitalLinetestMBExecute (void);
BOOLEAN remoteDigitalLinetestEBExecute (void);
BOOLEAN remoteDigitalOutputTest_MB (void);
BOOLEAN remoteDigitalInputTest_MB (void);
BOOLEAN remoteDigitalOutputTest_EB (void);
#endif /*TEST_DIGITAL_H_*/
+140
View File
@@ -0,0 +1,140 @@
/* ---------------------------------------------------------------------------
* test_leds.c (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description: remote LED test sequence
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* System include files
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "protocolfunctions.h"
#include "BusProtocol.h"
#include "SerOut.h"
#include "remote_analogue.h"
#include "remote_digital.h"
#include "remote_relay.h"
#include "dio.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteLEDTestMBexecute (void)
{
UINT32 loopcnt;
UINT8 buffer;
BOOLEAN ledTest = TRUE;
BOOLEAN receive = FALSE;
/* Drive LEDs to status ON */
sendString (SerOutPort, GotoNewLine, testMessage,
"Set local digital outputs to HIGH... ", Dummy, Dummy);
/* Set digital input LEDs to ON */
for (loopcnt = 0; loopcnt < maxDO_Channels; loopcnt++)
{
dioWrite(thisDeviceNumber, loopcnt, TRUE);
}
sendString (SerOutPort, FALSE, testMessage,
"Done", Dummy, Dummy);
/* Set remote digital output LEDs to on */
sendString (SerOutPort, GotoNewLine, testMessage,
"Set remote digital outputs to HIGH... ", Dummy, Dummy);
if (remoteDioWriteAll(remoteDeviceNumber, digital_mb, TRUE) == OK)
{
sendString (SerOutPort, FALSE, testMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, testMessage,
"Failed", Dummy, Dummy);
}
/* Set remote relay througput LEDs to on */
sendString (SerOutPort, GotoNewLine, testMessage,
"Set remote relay outputs to HIGH... ", Dummy, Dummy);
if (remoteRelaySetAll(remoteDeviceNumber, relay_mb, TRUE) == OK)
{
sendString (SerOutPort, FALSE, testMessage,
"Done", Dummy, Dummy);
}
else
{
sendString (SerOutPort, FALSE, testMessage,
"Failed", Dummy, Dummy);
}
sendString (SerOutPort, TRUE, noteMessage,
"\tAre all LEDs turned on? ",
"\n\r\tPRESS y (YES) oder n (NO): ",
NewLine);
do /* do-while loop for String input */
{
receive = serGet(SerOutPort, &buffer);
} while ((buffer != 121) && (buffer != 110));
if (buffer == 121) /* 121 = y (ScanCode) */
{
sendString (SerOutPort, TRUE, noteMessage,
"All LEDs working", Dummy, Dummy);
ledTest = TRUE;
}
else if (buffer == 110) /* 110 = n (ScanCode) */
{
sendString (SerOutPort, TRUE, noteMessage,
"LEDs broken", Dummy, Dummy);
ledTest = FALSE;
}
// \TODO CALCULATE RESULT
}
+56
View File
@@ -0,0 +1,56 @@
/* ---------------------------------------------------------------------------
* test_leds.h (c) 2008 Micro-key bv
* ---------------------------------------------------------------------------
* Micro-key bv
* Industrieweg 28, 9804 TG Noordhorn
* Postbus 92, 9800 AB Zuidhorn
* The Netherlands
* Tel: +31 594 503020
* Fax: +31 594 505825
* Email: support@microkey.nl
* Web: www.microkey.nl
* ---------------------------------------------------------------------------
* Description:
* ---------------------------------------------------------------------------
* Version(s): 0.1, Dez 16, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TEST_LEDS_H_
#define TEST_LEDS_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "LPC23xx.h"
#include "types.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
BOOLEAN remoteLEDTestMBexecute (void);
#endif /*TEST_LEDS_H_*/
+216
View File
@@ -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_*/
+130
View File
@@ -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_*/
+288
View File
@@ -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_*/
+413
View File
@@ -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 );
}
}
+150
View File
@@ -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_*/
+121
View File
@@ -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_*/
+228
View File
@@ -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);
}
+135
View File
@@ -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_*/
+182
View File
@@ -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_*/
+180
View File
@@ -0,0 +1,180 @@
/* ---------------------------------------------------------------------------
* topoftest.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:
* DesignTest MAIN File
* Contains automatic Test Application
* ---------------------------------------------------------------------------
* Version(s): 0.1, Mar 06, 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"
#include "semphr.h"
/* ---------------------------------------------------------------------------
* Application include files
* ---------------------------------------------------------------------------
*/
#include "topoftest.h"
#include "dio.h"
#include "ledfunctions.h"
#include "taskfunctions.h"
#include "menu.h"
#include "menuargs.h"
#include "serial.h"
#include "SerOut.h"
#include "bus.h"
#include "dac.h"
#include "BusProtocol.h"
#include "protocolfunctions.h"
#include "remote_tests.h"
#include "remote_misc.h"
/*Test includes */
#include "testLED.h"
#include "testdio.h"
#include "testaio.h"
#include "testBUS.h"
#include "testeeprom.h"
#include "testMMC.h"
#include "testpower.h"
#include "testrtc.h"
/* temp includes */
#include "fat_test.h"
#include "mmc_transfer.h"
/* ---------------------------------------------------------------------------
* Local constant and macro definitions
* ---------------------------------------------------------------------------
*/
/* Time in ms between single Tests */
#define TestPause 100
/* BUS Communication IDs */
#define BUS_ID 1 /* 1 for Master, >1 for Slave */
#define BUS_numbers 2 /* Maximum Numbers of Devices */
/* ---------------------------------------------------------------------------
* Global variable definitions
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Local variable definitions
* ---------------------------------------------------------------------------
*/
UINT32 UINT32result;
BOOLEAN auto_testResult;
BOOLEAN placedEB = TRUE; /* Indicate whether Extension Board is connected */
/* ---------------------------------------------------------------------------
* Local function definitions
* ---------------------------------------------------------------------------
*/
void mainInit(void)
{
#if ((PINSET_TESTER == 0) || (PINSET_TESTER == 2))
/* Olimex Board and Tester only have one serial port */
SerOutPort = COM1; /* Set Message ComPort to COM2 */
MenuPort = COM1;
#else
/* IO-CTRL got 2 serial ports to communicate */
SerOutPort = COM2; /* Set Message ComPort to COM2 */
MenuPort = COM2;
#endif
thisDeviceNumber = 0; /* define this device as Master */
remoteDeviceNumber = 2; /* define default remote device */
block_ImportantMessage = FALSE;
block_HeaderMessage = FALSE;
block_ResultMessage = FALSE;
block_NoteMessage = FALSE;
block_TestMessage = FALSE;
block_MenuMessage = TRUE;
block_SpinningWheel = TRUE;
GotoNewLine = TRUE;
/* Do Test Initialisations */
taskInit(); /* Initialize TaskStatus Variables */
protocolInit (BUS1, BUS_ID, BUS_numbers); /* Init Bus System */
/* Indicate Board activity with flashing green LED */
d_gLED = xTaskCreate( (void *)gLEDToggle,
( signed portCHAR * ) "LedToggle",
configMINIMAL_STACK_SIZE, (UINT16 *)500,
tskIDLE_PRIORITY + 2, &gLED);
/* Create Spinning Wheel Task and block it immediately */
d_spinWheel = xTaskCreate( (void *)showSpinningWheel,
( signed portCHAR * ) "SpinningWheel",
configMINIMAL_STACK_SIZE, NULL,
tskIDLE_PRIORITY + 2, &spinWheel);
// dioClean();
CallMenu(); /* Goto Menu */
}
void showSpinningWheel (void)
{
static UINT32 arraycnt = 0;
UINT8 SpinningWheelArray[4] = {'-', '\\', '|', '/'};
for (;;)
{
/* Make it possible to block the PrintOut of the Wheel */
switch (block_SpinningWheel)
{
case TRUE:
break;
case FALSE:
/* Set cursor one Position to left, then Put Character */
/* Don't care about the Warning */
serWrite(SerOutPort, strlen("\x1B[1D"), (UINT8 *)"\x1B[1D");
serPut(SerOutPort, SpinningWheelArray[arraycnt]);
if (arraycnt == 3)
{
arraycnt = 0;
}
else
{
arraycnt += 1;
}
break;
}
vTaskDelay(100);
}
}
+117
View File
@@ -0,0 +1,117 @@
/* ---------------------------------------------------------------------------
* topoftest.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:
* Headfile for Main designtest File topoftest.c
* ---------------------------------------------------------------------------
* Version(s): 0.1, Mar 06, 2008, MMi
* Creation.
* ---------------------------------------------------------------------------
*/
#ifndef TOPOFTEST_H_
#define TOPOFTEST_H_
/* ---------------------------------------------------------------------------
* System include files.
* ---------------------------------------------------------------------------
*/
#include "lpc23xx.h"
#include "types.h"
#include "serial.h"
/* FreeRTOS includes */
#include "FreeRTOS.h"
#include "task.h"
/* ---------------------------------------------------------------------------
* Application include files.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Constant and macro definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Type definitions.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Variable declarations.
* ---------------------------------------------------------------------------
*/
/* Global Test Result Variables */
BOOLEAN g_slaveaiotest;
BOOLEAN g_ledtest;
BOOLEAN g_framtest;
BOOLEAN g_diotest;
BOOLEAN g_aiotest;
BOOLEAN g_cantest;
BOOLEAN g_eepromtest;
BOOLEAN g_flashtest;
BOOLEAN g_comtest;
BOOLEAN g_mmctest;
BOOLEAN g_logtest;
BOOLEAN g_powertest;
BOOLEAN g_rtctest;
BOOLEAN g_batterytest;
/* ---------------------------------------------------------------------------
* Function declarations.
* ---------------------------------------------------------------------------
*/
/* ---------------------------------------------------------------------------
* Function: designtest
*
* Main Function to the design Test.
* Application Initialisations are called from here.
*
* Parameters: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void mainInit(void);
/* ---------------------------------------------------------------------------
* Function: CalcTestResult
*
* Calculates a "PASSED" oder "FAILED" Result out of the single, global
* Test Results
*
* Parameters: void
*
* Return: BOOLEAN - Calculation Result
* ---------------------------------------------------------------------------
*/
BOOLEAN CalcTestResult (void);
/* ---------------------------------------------------------------------------
* Function: showSpinningWheel
*
* Function to show a spinning wheel out of characters '/', '-', '\' and '|'
* The Wheel is used to indecate, that the system is still running but busy
* with a certain task.
*
* Parameter: void
*
* Return: void
* ---------------------------------------------------------------------------
*/
void showSpinningWheel (void);
#endif /*TOPOFTEST_H_*/