blob: 31d00cf120d1aac96aea37b3047d7bb9d81067b6 (
plain)
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
|
#ifndef RINGBUFFER_H
#define RINGBUFFER_H
#include <stdint.h>
#include <stdbool.h>
// Simple FIRST IN FIRST OUT
// requires kballoc - block allocation
typedef struct ringbuffer_struct
{
uint32_t size;
uint32_t front;
uint32_t back;
uint8_t *data;
}ringbuffer;
// create new fifo of given size (in blocks)
ringbuffer ringbuffer_init(uint32_t blocks);
// true on success
bool ringbuffer_put(ringbuffer*,uint8_t);
uint8_t ringbuffer_get(ringbuffer*); // blocking
bool ringbuffer_has(ringbuffer*); // check if somehting waiting?
#endif
|