mppt/Drivers/RingQueue/ring_queue.h

47 lines
1.0 KiB
C
Raw Normal View History

2024-07-11 06:58:55 +00:00
/*
* ring_queue.h
*
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>21<EFBFBD><EFBFBD>
* Author: psx
*/
#ifndef DRIVERS_RINGQUEUE_RING_QUEUE_H_
#define DRIVERS_RINGQUEUE_RING_QUEUE_H_
//#define RING_QUEUE_DEBUG //<2F><><EFBFBD><EFBFBD><E5B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡRingQueue<75>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϣ
#define RQ_OK 1
#define RQ_ERROR 0
#define RQ_OVERFLOW -2
typedef unsigned char RQ_ElementType;//Ԫ<><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef struct _ring_queue
{
RQ_ElementType *elems;
int size;
volatile int front, rear;
}RingQueue;
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><EFBFBD><EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>Ľṹq<E1B9B9><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>buffer<65><72>buffer<65><72>С
int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size);
#define RingQueueFull(q) (((q)->rear+1) % (q)->size == (q)->front)
#define RingQueueEmpty(q) ((q)->front == (q)->rear)
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><C3A3>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD>޸ĵ<DEB8>rear<61>ȶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
int ShowRingQueue(RingQueue *q);
//<2F><><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>e
int InRingQueue(RingQueue *q,RQ_ElementType e);
//<2F>Ӷ<EFBFBD><D3B6><EFBFBD>ɾ<EFBFBD><C9BE>Ԫ<EFBFBD><D4AA>
int OutRingQueue(RingQueue *q, RQ_ElementType *e);
//<2F><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
int RingQueueLength(RingQueue *q);
#endif /* DRIVERS_RINGQUEUE_RING_QUEUE_H_ */