From 324c5ba9098c1010d0aa8c1e26b95509878ce9f2 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Tue, 11 Oct 2011 21:50:49 +0200 Subject: Mini-Octopus build from r@171 --- firmware/fifo.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 firmware/fifo.c (limited to 'firmware/fifo.c') diff --git a/firmware/fifo.c b/firmware/fifo.c new file mode 100644 index 0000000..a1e0f87 --- /dev/null +++ b/firmware/fifo.c @@ -0,0 +1,27 @@ +#include "fifo.h" + +void fifo_init (fifo_t *f, uint8_t *buffer, const uint8_t size) +{ + f->count = 0; + f->pread = f->pwrite = buffer; + f->read2end = f->write2end = f->size = size; +} + +uint8_t fifo_put (fifo_t *f, const uint8_t data) +{ + return _inline_fifo_put (f, data); +} + +uint8_t fifo_get_wait (fifo_t *f) +{ + while (!f->count); + + return _inline_fifo_get (f); +} + +int fifo_get_nowait (fifo_t *f) +{ + if (!f->count) return -1; + + return (int) _inline_fifo_get (f); +} -- cgit v1.2.1