c语言实现循环数组fifo,单片机的FIFO(先入先出)循环队列实现

本文介绍了如何使用C语言实现循环数组形式的FIFO(先入先出)队列,包括队列初始化、入队、出队操作。通过示例代码详细展示了FIFO队列在单片机中的应用。
摘要由CSDN通过智能技术生成

//

// 文件:config.h

//

#ifndef __CONFIG_H

#define __CONFIG_H

//这一段无需改动

//This segment should not be modified

#ifndef TRUE

#define TRUE 1

#endif

#ifndef FALSE

#define FALSE 0

#endif

typedef unsigned char uint8;

typedef signed char int8;

typedef unsigned short uint16;

typedef signed short int16;

typedef unsigned int uint32;

typedef signed int int32;

typedef float fp32;

#include "FIFOQUEUE.h"

#endif

//

// 文件:FIFOQUEUE.h

//

#ifndef _FIFOQUEUE_H

#define _FIFOQUEUE_H

#define ElemType uint8

#define QueueSize 20 //fifo队列的大小

#define QueueFull 0 //fifo满置0

#define QueueEmpty 1 //FIFO空置1

#define QueueOperateOk 2 //队列操作完成 赋值为2

struct FifoQueue

{

uint16 front; //队列头

uint16 rear; //队列尾

uint16 count; //队列计数

ElemType dat[QueueSize];

};

//Queue Initalize

extern void QueueInit(struct FifoQueue *Queue);

// Queue In

extern uint8 QueueIn(struct FifoQueue *Queue,ElemType sdat);

// Queue Out

extern uint8 QueueOut(struct FifoQueue *Queue,ElemType *sdat);

#endif

//

// 文件:FIFOQUEUE.C

//

#include "config.h"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值