使用rtthread
This commit is contained in:
60
source/soft/buff.h
Normal file
60
source/soft/buff.h
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
#ifndef BUFF_H__
|
||||
#define BUFF_H__
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int buff_len;
|
||||
int buff_used;
|
||||
int read_ptr;
|
||||
int save_ptr;
|
||||
int use_frame; //使用帧
|
||||
int frame_start; //帧开始
|
||||
int frame_end; //帧结束
|
||||
int frame_num; //完整帧数
|
||||
int active; //在接收到帧开始之后进入活跃状态
|
||||
uint8_t *buff;
|
||||
void *mutex;
|
||||
} data_buff;
|
||||
|
||||
|
||||
// 初始化一个指定长度的缓冲区,返回0成功
|
||||
int buff_init(data_buff *buff,int size,int use_frame,int frame_start,int frame_end);
|
||||
|
||||
// 去初始化一个指定长度的缓冲区,返回0成功
|
||||
int buff_deinit(data_buff *buff);
|
||||
|
||||
// 获取buff的使用量
|
||||
int buff_get_used(data_buff *buff);
|
||||
|
||||
// 保存一个字节数据,返回0,成功
|
||||
int buff_save_byte(data_buff *buff,uint8_t data);
|
||||
|
||||
// 保存多个字节,返回0成功
|
||||
int buff_save_bytes(data_buff *buff,const uint8_t *data,int len);
|
||||
|
||||
// 读取一个字节数据,返回0,成功
|
||||
int buff_read_byte(data_buff *buff,uint8_t *data);
|
||||
|
||||
// 读取多个字节,返回0,成功
|
||||
int buff_read_bytes(data_buff *buff,uint8_t *data,int len);
|
||||
|
||||
|
||||
// 清除缓冲区,返回0,成功
|
||||
int buff_clear(data_buff *buff);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user