mppt/Drivers/RingQueue2/ring_queue2.h

46 lines
1.0 KiB
C
Raw Permalink Normal View History

2024-10-14 02:50:02 +00:00
/*
* ring_queue.h
*
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>21<EFBFBD><EFBFBD>
* Author: psx
*/
#ifndef DRIVERS_RINGQUEUE_RING_QUEUE2_H_
#define DRIVERS_RINGQUEUE_RING_QUEUE2_H_
//#define RING_QUEUE_DEBUG //<2F><><EFBFBD><EFBFBD><E5B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡRingQueue<75>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϣ
//typedef unsigned char RQ_ElementType2;//Ԫ<><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef uint16_t RQ_ElementType2;//Ԫ<><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-10-14 02:50:02 +00:00
typedef struct _ring_queue2
{
RQ_ElementType2 *elems;
int size;
volatile int front, rear;
}RingQueue2;
//<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 InitRingQueue2(RingQueue2 *q, RQ_ElementType2 *buff, int size);
2024-10-14 02:50:02 +00:00
#define RingQueueFull2(q) (((q)->rear+1) % (q)->size == (q)->front)
#define RingQueueEmpty2(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 ShowRingQueue2(RingQueue2 *q);
//<2F><><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>e
int InRingQueue2(RingQueue2 *q,RQ_ElementType2 e);
2024-10-14 02:50:02 +00:00
//<2F>Ӷ<EFBFBD><D3B6><EFBFBD>ɾ<EFBFBD><C9BE>Ԫ<EFBFBD><D4AA>
int OutRingQueue2(RingQueue2 *q, RQ_ElementType2 *e);
2024-10-14 02:50:02 +00:00
//<2F><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
int RingQueueLength2(RingQueue2 *q);
2024-10-14 02:50:02 +00:00
#endif /* DRIVERS_RINGQUEUE_RING_QUEUE_H_ */