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

📄 avrxfifo.h

📁 一个基于AVR 单片机的操作系统,有组于了解操作系统在单片机上运行的内幕.
💻 H
字号:
#ifndef _AvrXFifo_h_
#define _AvrXFifo_h_
#include "avrx.h"
/*
    Buffered BYTE oriented FIFO

	Uses providers/consumer model.  When an interrupt
	drives the consumer/provider side use the interrupt calls

	The fifo needs to be both declared and initialized.
*/

typedef struct AvrXFifo
{
	Mutex	Producer;
	Mutex	Consumer;
	uint8_t in;
	uint8_t out;
	uint8_t size;
	uint8_t buf[1];
}
AvrXFifo, *pAvrXFifo;

enum
{
	FIFO_OK,
	FIFO_ERR = -1	// Same as stdio EOF
};

#define AVRX_DECL_FIFO(Name, Size)					\
uint8_t Name##Fifo[Size + sizeof(AvrXFifo) - 1];	\
const pAvrXFifo Name = (pAvrXFifo)Name##Fifo;		\
static const uint8_t Name##FifoSz = Size;

#define AVRX_INIT_FIFO(Name)		\
	AvrXFlushFifo(Name);			\
	Name->size = Name##FifoSz

#define AVRX_EXT_FIFO(Name)			\
	extern uint8_t Name##Fifo[];	\
	static const pAvrXFifo Name = (pAvrXFifo)Name##Fifo

int16_t AvrXPutFifo(pAvrXFifo, uint8_t);
int16_t AvrXPullFifo(pAvrXFifo);
void AvrXWaitPutFifo(pAvrXFifo, uint8_t);
int16_t AvrXWaitPullFifo(pAvrXFifo);
int16_t AvrXPeekFifo(pAvrXFifo);
int16_t AvrXStatFifo(pAvrXFifo);
void AvrXFlushFifo(pAvrXFifo);

#endif	// _AvrXFifo_h_

⌨️ 快捷键说明

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