27 lines
625 B
C
27 lines
625 B
C
#if !defined __RINGBUFFER_H
|
|
#define __RINGBUFFER_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
typedef struct {
|
|
uint8_t size;
|
|
volatile uint8_t free;
|
|
volatile uint8_t write_idx;
|
|
volatile uint8_t read_idx;
|
|
|
|
void (*idle_func)(void);
|
|
|
|
uint8_t buffer[];
|
|
} ringbuffer_t;
|
|
|
|
|
|
#define RB_BUFSIZE(queue_len) (sizeof(ringbuffer_t)+(queue_len))
|
|
|
|
void ringbuf_init(void *ringbuffer, uint8_t buf_size, void (*IdleFunc)(void));
|
|
int8_t ringbuf_get(void *ringbuffer, uint8_t *ch);
|
|
int8_t ringbuf_get_nb(void *ringbuffer, uint8_t *ch);
|
|
int8_t ringbuf_put_nb(void *ringbuffer, uint8_t ch);
|
|
int8_t ringbuf_get_num_waiting(void * ringbuffer);
|
|
|
|
#endif
|