📄 fifo.h
字号:
//******************************************************************************
//*
//* System On Chip(SOC)
//*
//* Copyright (c) 2002 sjsunny, Inc.
//* All rights reserved.
//*
//* This software is the confidential and proprietary information of Sjsunny Sci&Tech
//* , Inc("Confidential Information"). You Shall not disclose such
//* Confidential Information and shall use it only in accordance with the terms
//* of the license agreement you agreed with sjsunny.
//*
//*-----------------------------------------------------------------------------
//*
//* PG9315 BSP (Windows CE.NET)
//*
//* SJA1000 can bus control driver
//*
//* @author WZL@sjsunny.com
//*
//* @date 2005/04/01
//*
//* Log:
//* 2005/04/01 Start
//*
//******************************************************************************/
#ifndef __PGFIFO_H__
#define __PGFIFO_H__
typedef struct tagRXFIFO
{
unsigned int reg[13];
}RXFIFO,*PFIFO;
/*
class CFifo
{
public:
CFifo(int FifoSize=256)
{
m_nMaxSize = FifoSize;
m_pCont = (RXFIFO*)malloc(FifoSize*sizeof(RXFIFO));
if(!m_pCont)
return;
m_nHead = m_nTail = 0;
}
~CFifo()
{
free(m_pCont);
}
int Increment(int Index)
{
Index++;
if(Index == m_nMaxSize) Index = 0;
return Index;
}
int IsEmpty(void) { return m_nHead == m_nTail; };
int Push(RXFIFO Val)
{
int tmp;
tmp = Increment(m_nTail);
if(tmp == m_nHead) return 0;
m_pCont[m_nTail] = Val;
m_nTail = tmp;
return 1;
}
RXFIFO Pull()
{
RXFIFO val;
if(IsEmpty()) return -1;
val = m_pCont[m_nHead];
//memcpy( &val, m_pCont[m_nHead], sizeof( RXFIFO) );
m_nHead = Increment(m_nHead);
return val;
}
private:
int m_nMaxSize;
RXFIFO *m_pCont;
int m_nHead, m_nTail;
};
*/
#endif // __PGFIFO_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -