#ifndef _CIRCLE_BUF_H
#define _CIRCLE_BUF_H

#include <stdint.h>
#include <stddef.h>  // for NULL
#include <string.h> //memset

typedef struct {
    volatile uint32_t r;       // 读指针
    volatile uint32_t w;       // 写指针
    uint32_t len;     // 缓冲区大小
    uint8_t *buf;     // 缓冲区指针
} circle_buf_t, *p_circle_buf;


void circle_buf_init(p_circle_buf pCircleBuf, uint32_t len, uint8_t *buf);

int circle_buf_read(p_circle_buf pCircleBuf, uint8_t *pVal);
//int circle_buf_read_2(p_circle_buf_2 pCircleBuf, uint8_t *pVal) ;
int circle_buf_write(p_circle_buf pCircleBuf, uint8_t val);
void circle_buf_clear(p_circle_buf pCircleBuf) ;
//void copy_circle_buf(circle_buf_t *src, circle_buf_t_2 *dst);
#endif /* _CIRCLE_BUF_H */

