Files
checker_slave/source/soft/buff.h
2023-06-10 11:52:00 +08:00

61 lines
1.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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