Initial import of STM32 IoT sensor node
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#ifndef __QUEUE_H
|
||||
#define __QUEUE_H
|
||||
|
||||
#define QUEUE_DATA_SIZE (64) // 定义队列内存储空间
|
||||
|
||||
struct queue
|
||||
{
|
||||
char data[QUEUE_DATA_SIZE]; // 用来保存数据
|
||||
unsigned short int head; // 队列头位置索引。
|
||||
unsigned short int tail; // 队列尾位置索引。
|
||||
};
|
||||
// 1. 初始化队列
|
||||
void queue_init(struct queue *pq);
|
||||
|
||||
// 2. 队列空判断, 空返回1, 否则返回0
|
||||
int queue_is_empty(struct queue *pq);
|
||||
// 3. 队列满判断, 满返回1, 否则返回0
|
||||
int queue_is_full(struct queue *pq);
|
||||
|
||||
// 4. 入队, 成功返回1 ,失败返回0
|
||||
int queue_enqueue(struct queue *pq, int value);
|
||||
|
||||
// 5. 出队, 成功返回1 ,失败返回0
|
||||
int queue_dequeue(struct queue *pq, int *pvalue);
|
||||
|
||||
// 7. 清空队列
|
||||
void queue_clear(struct queue *pq);
|
||||
|
||||
#endif // _QUEUE_H
|
||||
Reference in New Issue
Block a user