SingingCat
0
application
include
ringbuffer.h
1
#ifndef RINGBUFFER_H
2
#define RINGBUFFER_H
3
#include "stdint.h"
4
typedef
struct
ringbuffer
{
5
char
buf[1024];
6
uint16_t readptr;
7
uint16_t
volatile
writeptr;
// point to next position to write
8
uint32_t
volatile
bytes;
// number of bytes readable
9
}
_ringbuffer
;
10
11
/* \brief add a byte to the ringbuffer, if buffer is full, overwrites oldest byte */
12
void
ringbuffer_add_byte(
struct
ringbuffer
*r, uint8_t b);
13
14
/* \brief return a byte. if return value is >255, no value is available */
15
uint16_t ringbuffer_get_byte(
struct
ringbuffer
*r);
16
17
void
ringbuffer_init(
struct
ringbuffer
*r);
18
/*
19
*\brief get upto a delimiter, return number of chars.
20
*/
21
int
ringbuffer_get_to_delimiter(
struct
ringbuffer
*r,
char
delimiter,
char
*outbuf,
int
outbufsize);
22
23
#endif
ringbuffer
Definition:
ringbuffer.h:4
Generated on Tue May 28 2024 19:13:43 for SingingCat by
1.9.4