⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msg1.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
字号:
/********************************************************************** * *   Copyright (c) 2004, Dy 4 Systems All rights reserved. *   This Source Code is the Property of Dy 4 Systems Inc. and *   can only be used in accordance with Source Code License *   Agreement of Dy 4 Systems Inc. dba (doing business as)  *   CURTISS-WRIGHT CONTROLS EMBEDDED COMPUTING, "CWCEC". * **********************************************************************//*********************************************************************************  Filename: demo/msg1.c  **  Copyright 2004 by DY4 Systems.  All Rights Reserved.**  Project Name: 182/145 BSP**  Target:  182/145**  Description: On-board CPU communication library**  Usage:      **  Log: *  2003-10-06-JCS        Initial revision ********************************************************************************//*modification history--------------------01a,29nov04,tis -add nsupport for CCA-145*/#include "vxWorks.h"#include "taskLib.h"#include "sysLib.h"#include "tickLib.h"#include "logLib.h"#include "errnoLib.h"#include "h/drv/dy4/boardName.h"#ifdef VME_182#include "dy4182.h"#include "intCtrl182_dy4.h"#endif#ifdef CCA_145#include "cca145.h"#include "intCtrl145.h"#endif#include "h/drv/mms/dy4mmsMP.h"#include "h/drv/dy4Debug/dy4Debug.h"#define MAX_LOOPS	1000000#define LOOP_MOD	1000#if 0    #define TEST_TIMEOUT	(sysClkRateGet() * 2)#else    #define TEST_TIMEOUT	WAIT_FOREVER#endif#define PERFint tst1    (    void    )    {    void        *sendMsg;    void        *recvMsg;    int         size, loop;    ULONG       startTime, stopTime;    float       time;#ifndef PERF    int         i;#endif    dy4mmsClearStats();    /*      * CPU0     *      - Malloc memory for a message     *      - for( MAX_LOOPS )     *      -    Fill the message with 0x5a5a5a5a     *      -    Send the message to CPU1     *      -    Wait for CPU1 to send a message back     *      -    Test the message with 0xa5a5a5a5     *      - Free the memory     * CPU1     *      - for( MAX_LOOPS )     *      -    Wait for CPU0 message     *      -    Compare the message content with 0x5a5a5a5a     *      -    Fill the message with 0xa5a5a5a5      *      -    Send the message to CPU0     */    if (sysProcId == CPU_ID_0)        {	/*          * allocate 100 bytes message          */	DEBUGIP(("\n"));	DEBUGIP(("Calling dy4mmsMalloc\n"));	if (dy4mmsMalloc(&sendMsg, 100) == ERROR)	    {	    DEBUGEP(("dy4mmsTest: dy4mmsMalloc error 0x%08x\n", errnoGet()));	    dy4mmsShow();	    taskDelay( 10 * sysClkRateGet() );	    return( ERROR );	    }	else            {	    DEBUGIP(("dy4mmsTest: dy4mmsMalloc returns 0x%08X\n",(int)sendMsg));            }        DEBUGMP(("This test ping-pongs a buffer for %d loops\n", MAX_LOOPS));        DEBUGMP(("Each loop consists of a send and recv\n\n"));        taskDelay( 1 ); /* sync to fence post */        startTime = tickGet();        for( loop = 0; loop < MAX_LOOPS; loop++ )            {#ifndef PERF            if(( loop % LOOP_MOD) == 0 )                {                DEBUGMP(("Loop %d\n", loop ));                }	    /* 	     * fill message with pattern	     */	    for (i = 0; i < 100/4; i++)		{		*((int *)sendMsg + i) = 0x5a5a5a5a;		}            CACHE_FLUSH(DATA_CACHE, sendMsg, 100 );#endif	    /* 	     * send the message to CPU 1	     */	    DEBUGIP(("\n"));	    DEBUGIP(("Calling dy4mmsMsgSend\n"));	    if (dy4mmsMsgSend(0,                               sendMsg, 			      100, 			      TEST_TIMEOUT, 			      DY4MMS_LOW_PRIORITY) 		== ERROR)		{		DEBUGEP(("dy4mmsTest: dy4mmsMsgSend error 0x%08x\n",                          errnoGet()));		dy4mmsShow();		taskDelay( 10 * sysClkRateGet() );		return( ERROR );		}	    /* 	     * get the response back from CPU 1	     */	    DEBUGIP(("\n"));	    DEBUGIP(("Calling dy4mmsMsgRecv\n"));	    if (dy4mmsMsgRecv(0, &recvMsg, &size, TEST_TIMEOUT) == ERROR)		{		DEBUGEP(("dy4mmsTest: dy4mmsMsgRecv error 0x%08x\n",                          errnoGet()));		dy4mmsShow();		taskDelay( 10 * sysClkRateGet() );		return( ERROR );		}	    else		{		DEBUGIP(("dy4mmsTest: dy4mmsMsgRecv returns 0x%08X %d\n",                          (int)recvMsg, size));		}#ifndef PERF	    /* 	     * test the receive message 	     */            CACHE_INVALIDATE(DATA_CACHE, recvMsg, 100 );	    for (i = 0; i < 100/4; i++)		{		if (*((int *)recvMsg + i) != 0xa5a5a5a5)		    {		    DEBUGEP(("dy4mmsTest: Error in receive message %d 0x%08X\n",			   i, *((int *)recvMsg + i)));		    dy4mmsShow();		    taskDelay( 10 * sysClkRateGet() );		    return( ERROR );		    }		}#endif	    }        stopTime   = tickGet();        time       =  ((((float)stopTime) -                       ((float)startTime)) / ((float)(sysClkRateGet())));        DEBUGMP(("MsgSend/Recv:Time %0.3fs, loopcount %d\n", time, MAX_LOOPS));        DEBUGMP(("MsgSend/Recv:time/loop %0.9fs, loops/sec %0.2f \n",                time / ((float)(MAX_LOOPS)), ((float)(MAX_LOOPS)) / time));        DEBUGMP(("MsgSend/Recv:time/call %0.9fs, calls/sec %0.2f \n\n",                time / ((float)(2 * MAX_LOOPS)),                 ((float)(2 * MAX_LOOPS)) / time));	DEBUGIP(("\n"));	DEBUGIP(("Calling dy4mmsFree\n"));	if (dy4mmsFree(recvMsg) == ERROR)            {	    DEBUGEP(("dy4mmsTest: recvMsg dy4mmsFree error 0x%08x\n",                      errnoGet()));	    dy4mmsShow();	    taskDelay( 10 * sysClkRateGet() );	    return( ERROR );            }        }    else /* sysProcId == CPU_ID_1 */        {        DEBUGMP(("This test ping-pongs a buffer for %d loops\n", MAX_LOOPS));        DEBUGMP(("Each loop consists of a recv and send\n\n"));        taskDelay( 1 ); /* sync to fence post */        startTime = tickGet();        for( loop = 0; loop < MAX_LOOPS; loop++ )            {#ifndef PERF            if(( loop % LOOP_MOD) == 0 )                {                DEBUGMP(("Loop %d\n", loop ));                }#endif	    DEBUGIP(("\n"));	    DEBUGIP(("Calling dy4mmsMsgRecv\n"));	    if (dy4mmsMsgRecv(0, &recvMsg, &size, TEST_TIMEOUT) == ERROR)		{		DEBUGEP(("dy4mmsTest: dy4mmsMsgRecv error 0x%08x\n", errnoGet()));		dy4mmsShow();		taskDelay( 10 * sysClkRateGet() );		return( ERROR );		}	    else		{		DEBUGIP(("dy4mmsTest: dy4mmsMsgRecv returns 0x%08X %d\n",                      (int)recvMsg, size));		}#ifndef PERF	    /* 	     * test the receive message 	     */            CACHE_INVALIDATE(DATA_CACHE, recvMsg, 100 );	    for (i = 0; i < 100/4; i++)		{		if (*((int *)recvMsg + i) != 0x5a5a5a5a)		    {		    DEBUGEP(("dy4mmsTest: Error in receive message %d 0x%08X\n",		       i, *((int *)recvMsg + i)));		    dy4mmsShow();		    taskDelay( 10 * sysClkRateGet() );		    return( ERROR );		    }		}	    /* 	     * fill message with pattern	     */	    for (i = 0; i < 100/4; i++)		{		*((int *)recvMsg + i) = 0xa5a5a5a5;		}            CACHE_FLUSH(DATA_CACHE, recvMsg, 100 );#endif	    DEBUGIP(("\n"));	    DEBUGIP(("Calling dy4mmsMsgSend\n"));	    if (dy4mmsMsgSend(0,                               recvMsg,                               100,                               TEST_TIMEOUT,                               DY4MMS_LOW_PRIORITY )                 == ERROR)		{		DEBUGEP(("dy4mmsTest: dy4mmsMsgSend error 0x%08x\n", 		       errnoGet()));		dy4mmsShow();		taskDelay( 10 * sysClkRateGet() );		return( ERROR );		}	    }        stopTime   = tickGet();        time       =  ((((float)stopTime) -                       ((float)startTime)) / ((float)(sysClkRateGet())));        DEBUGMP(("MsgSend/Recv:Time %0.3fs, loopcount %d\n", time, MAX_LOOPS));        DEBUGMP(("MsgSend/Recv:time/loop %0.9fs, loops/sec %0.2f \n",                time / ((float)(MAX_LOOPS)), ((float)(MAX_LOOPS)) / time));        DEBUGMP(("MsgSend/Recv:time/call %0.9fs, calls/sec %0.2f \n\n",                time / ((float)(2 * MAX_LOOPS)),                 ((float)(2 * MAX_LOOPS)) / time));	}    dy4mmsShow();    taskDelay( 10 * sysClkRateGet() );    return( OK );    }    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -