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

📄 c5416databuff.c

📁 DSP与VXWORKS平台的通信
💻 C
字号:
/**************************************************************************
Copyright 2002-2007 TGL Ltd. All rights reserved

c5416DataBuff.c   -- the source file for c5416DataBuff

DESCRIPTION


modification history
--------------------
2007-10-24, Lixiaoke, v1.0 initial version
--------------------

**************************************************************************/
#include <msgQLib.h>
#include "c5416DataBuff.h"

static MSG_Q_ID msgQRecvedDataId    = NULL;
static MSG_Q_ID msgQSendDataId      = NULL;

int dataBufInit( void )
{
    if( msgQRecvedDataId == NULL )
    {
        if( ( msgQRecvedDataId = msgQCreate( 700, 14, MSG_Q_FIFO ) ) == NULL )
        {
            printf( "[ dataBufInit ] : create msgQRecvedDataId error!\n" );
            return( 0 );
        }
    }
    if( msgQSendDataId == NULL )
    {
        if( ( msgQSendDataId = msgQCreate( 700, 14, MSG_Q_FIFO ) ) == NULL )
        {
            printf( "[ dataBufInit ] : create msgQSendDataId error!\n" );
            return( 0 );
        }
    }  
    return( 1 ); 
}

int dataBufDInit( void )
{
    if( msgQRecvedDataId != NULL )
    {
        if( msgQDelete( msgQRecvedDataId ) == ERROR )
        {
            printf("[ dataBufDInit ] : delete msgQRecvedDataId error!\n" );
        }
        msgQRecvedDataId = NULL;
    }
    if( msgQSendDataId != NULL )
    {
        if( msgQDelete( msgQSendDataId ) == ERROR )
        {
            printf("[ dataBufDInit ] : delete msgQSendDataId error!\n" );
        }
        msgQSendDataId = NULL;
    }    
    return( 1 );
}

int c5416WriteDataToRecvBuf( unsigned short *pusSendBuf, unsigned short usSendDataLen )
{
    if( msgQSend( msgQRecvedDataId,( char * ) pusSendBuf, usSendDataLen, WAIT_FOREVER, MSG_PRI_NORMAL ) == ERROR )
    {
        printf( "[ c5416WriteDataToRecvBuf ] : msgQSend msgQRecvedDataId error!\n" );
        dataBufDInit();
        return( 0 );
    }
    return( usSendDataLen );
}

int c5416ReadDataFromRecvBuf( unsigned short * pusTransferBuf, unsigned short usTransferBufLen )
{
    if( msgQReceive( msgQRecvedDataId, ( char * )pusTransferBuf, usTransferBufLen, WAIT_FOREVER ) == ERROR )
    {
        printf( "[ c5416ReadDataFromRecvBuf ] : msgQReceive msgQRecvedDataId error!\n" );
        dataBufDInit();
        return( 0 );
    }
    return( usTransferBufLen );
}
int c5416SendDataToSendBuf( unsigned short * pusTransferBuf, unsigned short usTransferBufLen )
{
    if( msgQSend( msgQSendDataId,( char * ) pusTransferBuf, usTransferBufLen, WAIT_FOREVER, MSG_PRI_NORMAL ) == ERROR )
    {
        printf( "[ c5416WriteDataToSendBuf ] : msgQSend msgQSendDataId error!\n" );
        dataBufDInit();
        return( 0 );
    }
    return( usTransferBufLen );
}
int c5416ReadDataFromSendBuf( unsigned short *pusRecvBuf, unsigned short usRecvBufLen )
{
    if( msgQReceive( msgQSendDataId, ( char * )pusRecvBuf, usRecvBufLen, WAIT_FOREVER ) == ERROR )
    {
        printf( "[ c5416ReadDataFromSendBuf ] : msgQReceive msgQSendDataId error!\n" );
        dataBufDInit();
        return( 0 );
    }
    return( usRecvBufLen );
}

⌨️ 快捷键说明

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