Christina Quast | 4db82e0 | 2015-04-11 18:14:41 +0200 | [diff] [blame] | 1 | #ifndef SIMTRACE_RINGBUF_H |
| 2 | #define SIMTRACE_RINGBUF_H |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | #include <stdbool.h> |
| 6 | #include <sys/types.h> |
| 7 | |
Christina Quast | 2b8a18b | 2015-04-12 09:31:36 +0200 | [diff] [blame] | 8 | #define RING_BUFLEN 1024 |
Christina Quast | 4db82e0 | 2015-04-11 18:14:41 +0200 | [diff] [blame] | 9 | |
| 10 | typedef struct ringbuf { |
| 11 | uint8_t buf[RING_BUFLEN]; |
| 12 | size_t ird; |
| 13 | size_t iwr; |
| 14 | } ringbuf; |
| 15 | |
| 16 | void rbuf_reset(volatile ringbuf *rb); |
| 17 | uint8_t rbuf_read(volatile ringbuf *rb); |
Christina Quast | 7a7f98c | 2015-05-02 14:10:13 +0200 | [diff] [blame^] | 18 | uint8_t rbuf_peek(volatile ringbuf *rb); |
Christina Quast | 4db82e0 | 2015-04-11 18:14:41 +0200 | [diff] [blame] | 19 | void rbuf_write(volatile ringbuf *rb, uint8_t item); |
| 20 | bool rbuf_is_empty(volatile ringbuf *rb); |
| 21 | bool rbuf_is_full(volatile ringbuf *rb); |
| 22 | |
| 23 | #endif /* end of include guard: SIMTRACE_RINGBUF_H */ |