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

📄 buff.c

📁 Real Time Operating System for Hi-Tech C compiler.
💻 C
字号:
/************************************************************ 
Copyright (C) 1995-2002 Pumpkin, Inc. and its
Licensor(s). Freely distributable.

$Source: C:\\RCS\\D\\salvo\\demo\\d5\\buff.c,v $
$Author: aek $
$Revision: 1.2 $
$Date: 2001-10-25 19:56:53-07 $

Support file.

************************************************************/

#ifndef BUFF_C_INCLUDES
#define BUFF_C_INCLUDES

#include "d5.h"
#include "main.h"
#include "salvo.h"

#if ( RECEIVERS >= 1 ) || ( TRANSMITTERS >= 1 )
/************************************************************
****                                                     ****
**                                                         **
InitBcb()

Initialize the specified buffer by setting the buffer's
control parameters, which reside in the buffer control block.

Not compatible with buffer functions called from ISR().

**                                                         **
****                                                     ****
************************************************************/
void InitBcb( typeBcbP bcbP, typeSize size )
{
    bcbP->count = 0;
    bcbP->inP   = 0;
    bcbP->outP  = 0;
    bcbP->size  = size;
}


/************************************************************
****                                                     ****
**                                                         **
GetBuff()

Get char from buffer and wrap pointer if necessary.

**                                                         **
****                                                     ****
************************************************************/
unsigned char GetBuff( unsigned char * dataP,
                       typeBcbP        bcbP,
                       typeBuffP       buffP )
{
    if ( bcbP->count ) {
        *dataP = buffP[bcbP->outP++];

        if ( bcbP->outP >= bcbP->size )
            bcbP->outP = 0;
            
        bcbP->count--;
        
        return TRUE;
    }
    else
        return FALSE;
}

                             
/************************************************************
****                                                     ****
**                                                         **
PutBuff()

Insert char into buffer and wrap pointer if necessary.

**                                                         **
****                                                     ****
************************************************************/
unsigned char PutBuff( unsigned char data,
                       typeBcbP      bcbP,
                       typeBuffP     buffP )
{
    if ( bcbP->count < bcbP->size ) 
    {
        buffP[bcbP->inP++] = data;
        
        if ( bcbP->inP >= bcbP->size )
            bcbP->inP = 0;
            
        bcbP->count++;
        
        return TRUE;
    }
    else
        return FALSE;
}
#endif


#endif

⌨️ 快捷键说明

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