fifo.h

来自「windows ce 下 can总线驱动源码」· C头文件 代码 · 共 98 行

H
98
字号
//******************************************************************************
//*
//* 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 + =
减小字号Ctrl + -
显示快捷键?