/*
**#############################################################################
** SVN Information
**
** Checked In : 2017-12-27
**
** Author : Fan
**
** Revision : V1.1
**
** Release Information : Loop queue head file(.h)
**#############################################################################
*/
#ifndef _RING_QUEUE_H_
#define _RING_QUEUE_H_
#define QUEUE_MAX_LENGTH 256 // The max length of queue
//---------------- Loop queue states
typedef enum _LoopQueueStateType
{
EMPTY = 0x50000000, // Queue is empty
FULL, // Queue is full
DONE, // Queue operating is done
UNDONE, // Queue operating is not done
}LoopQueueStateType;
//---------------- Loop queue struct
typedef struct _LoopQueue
{
unsigned char putIndex; // Put data index
unsigned char getIndex; // Get data index
unsigned int dataNumber; // Current data number
unsigned char queueFIFO[QUEUE_MAX_LENGTH]; // Loop queue FIFO
}LoopQueue;
//---------------- Loop queue initialization
extern void LoopQueueInit(LoopQueue *queue);
//---------------- Loop queue clear
extern void LoopQueueClear(LoopQueue *queue);
//---------------- Loop queue write data by pointer and length of data
extern LoopQueueStateType LoopQueueWrite(LoopQueue *queue, unsigned char *data, unsigned int length);
//---------------- Loop queue read data and put data by it's pointer
extern LoopQueueStateType LoopQueueRead(LoopQueue *queue, unsigned char *addr ,unsigned int length);
//---------------- Loop queue write one data
extern LoopQueueStateType LoopQueueWriteOne(LoopQueue *queue, unsigned char data);
//---------------- Loop read once
extern LoopQueueStateType LoopQueueReadOne(LoopQueue *queue, unsigned char *addr);
//---------------- Get the data length with queue pointer
extern unsigned int LoopQueueGetLength(LoopQueue *queue);
#endif
|