Added Software projects
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
@@ -0,0 +1,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);
|
||||
}
|
||||
Reference in New Issue
Block a user