-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathringbuffer.h
32 lines (26 loc) · 881 Bytes
/
ringbuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* ringbuffer.h
*
* Created on: Jul 19, 2018
* Author: fkyburz
*/
#ifndef RINGBUFFER_H_
#define RINGBUFFER_H_
#include <stdint.h>
typedef struct {
uint16_t * buffer;
uint16_t head;
uint16_t tail;
uint16_t size;
} ringbuffer_t;
extern int32_t ringbuffer_reset(ringbuffer_t * rbuf);
extern int32_t ringbuffer_put(ringbuffer_t * rbuf, uint16_t data);
extern int32_t ringbuffer_put_array(ringbuffer_t * rbuf,
uint16_t * data, uint16_t size);
extern int32_t ringbuffer_get(ringbuffer_t * rbuf, uint16_t * data);
extern int32_t ringbuffer_empty(ringbuffer_t * rbuf);
extern int32_t ringbuffer_full(ringbuffer_t * rbuf);
extern int32_t ringbuffer_length(ringbuffer_t * rbuf);
extern int32_t ringbuffer_data(ringbuffer_t * rbuf,
uint16_t *data, uint16_t pos);
#endif /* RINGBUFFER_H_ */