| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /**
- ******************************** STM32F0xx *********************************
- * @文件名 : queue.h
- * @作者 : sun
- * @库版本 : V1.5.0
- * @文件版本 : V1.0.0
- * @日期 : 2016年06月10日
- * @摘要 :Lorausart头文件
- ******************************************************************************/
- /* 定义防止递归包含 ----------------------------------------------------------*/
- #ifndef _QUEUE_H
- #define _QUEUE_H
- //#define QUEUE_DEBUG_EN 1
- #ifdef QUEUE_DEBUG_EN
- #include <stdio.h>
- #define QUEUE_DEBUG(fmt, x...) \
- do \
- { \
- printf(fmt,##x); \
- }while(0)
- #define QUEUE_DEBUG1(fmt, x...) \
- do \
- { \
- printf("%s(Line %d): "fmt,__FUNCTION__,__LINE__, ##x); \
- }while(0)
- #define QUEUE_DEBUG_F(fmt, x...) \
- do \
- { \
- printf("%s %s(Line %d): "fmt,__FILE__,__FUNCTION__,__LINE__, ##x); \
- }while(0)
- #else
- #define QUEUE_DEBUG(fmt, x...)
- #define QUEUE_DEBUG1(fmt, x...)
- #define QUEUE_DEBUG_F(fmt, x...)
- #endif
- /* 包含的头文件 --------------------------------------------------------------*/
- #include "stm32f10x.h"
- #define SQ_DEPTH 32
- #define SQ_WIDTH 128
- typedef struct
- {
- //uint8_t data[SQ_DEPTH][SQ_WIDTH]; //队列储存区
- uint8_t **data; //队列储存区
- uint8_t front; //出队标记
- uint8_t rear; //入队标记
- uint8_t sum; //数量标记
- uint8_t depth; //数量标记
- uint8_t width; //数量标记
- }sequeue_t;
- /********************************
- 创建空循环队列
- ********************************/
- sequeue_t * Create_Empty_Sequeue(uint8_t row,uint8_t col);
- /********************************
- 检查循环队列是否为空
- ********************************/
- int8_t Check_Seqeue_Empty(sequeue_t * sq);
- /********************************
- 检查循环队列是否为满
- ********************************/
- int8_t Check_Seqeue_Full(sequeue_t * sq);
- /********************************
- 插入队列,插入1条记录
- ********************************/
- int8_t En_Queue(sequeue_t *sq ,uint8_t *p,uint8_t sizeof_p,uint8_t l);
- /********************************
- 出队列,读取1条记录,队列改变
- ********************************/
- int8_t De_Queue(sequeue_t * sq,uint8_t *p,uint8_t sizeof_p,uint8_t *l);
- /********************************
- 读取队列,读取1条记录,队列不改变
- ********************************/
- int8_t Read_Queue(sequeue_t * sq,uint8_t *p,uint8_t *l);
- /********************************
- 添加1条空记录到队列,记录第0个元素代表长度,初始长度为0
- ********************************/
- int8_t Add_Blank_Queue(sequeue_t *sq);
- /********************************
- 当前操作的为记录内容,记录尾元添加1个元素,且长度加1
- ********************************/
- uint8_t Update_Queue(sequeue_t *sq ,uint8_t mode,uint8_t val);
- #endif
|