circ.c

来自「DSP/BIOS Driver Developer Kit 1.11 The 」· C语言 代码 · 共 61 行

C
61
字号
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DDK 1.11.00.00 11-04-03 (ddk-b13)" */
/*
 *  ======== circ.c ========
 */

#include <std.h>

#include <atm.h>
#include <circ.h>

/*
 *  ======== CIRC_new ========
 *
 *  Initializes the circular buffer structure
 */
Void CIRC_new(CIRC_Handle circ)
{
    circ->writeIndex = 0;
    circ->readIndex = 0;
    circ->charCount = 0;
    circ->size = CIRC_BUFSIZE;
}

/*
 *  ======== CIRC_readChar ========
 *
 *  Reads a character from the circular buffer.
 */
Char CIRC_readChar(CIRC_Handle circ)
{
    Char c;

    /* read character and increment the character count */
    c = circ->buf[circ->readIndex];
    circ->readIndex = CIRC_nextIndex(circ,circ->readIndex);
    ATM_decu(&circ->charCount);

    return (c);
}

/*
 *  ======== CIRC_writeChar ========
 *
 *  Writes a character into the circular buffer 
 */
Void CIRC_writeChar(CIRC_Handle circ, Char c)
{
    /* write character and decrement the character count */
    circ->buf[circ->writeIndex] = c;
    circ->writeIndex = CIRC_nextIndex(circ,circ->writeIndex);
    ATM_incu(&circ->charCount);
}

⌨️ 快捷键说明

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