X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/fnordlicht-mini/blobdiff_plain/24562c8a748c379de491019607921e5959459464..745723e4d1fee18fc31d79172fe8357a75628eea:/firmware/fnordlicht-controller/fifo.c diff --git a/firmware/fnordlicht-controller/fifo.c b/firmware/fnordlicht-controller/fifo.c deleted file mode 100644 index e20696b..0000000 --- a/firmware/fnordlicht-controller/fifo.c +++ /dev/null @@ -1,61 +0,0 @@ -/* vim:ts=4 sts=4 et tw=80 - * - * fnordlicht firmware - * - * for additional information please - * see http://lochraster.org/fnordlichtmini - * - * (c) by Alexander Neumann - * Lars Noschinski - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "fifo.h" - -void fifo_init(fifo_t *f) -{ - f->read = 0; - f->write = 0; -} - -void fifo_enqueue(fifo_t *f, fifo_content_t data) -{ - f->buffer[f->write] = data; - f->write = (f->write + 1) % CONFIG_FIFO_SIZE; -} - -fifo_content_t fifo_dequeue(fifo_t *f) -{ - fifo_content_t data = f->buffer[f->read]; - f->read = (f->read + 1) % CONFIG_FIFO_SIZE; - return data; -} - -fifo_size_t fifo_fill(fifo_t *f) -{ - if (f->write >= f->read) - return f->write - f->read; - else - return CONFIG_FIFO_SIZE - (f->read - f->write); -} - -bool fifo_empty(fifo_t *f) -{ - return f->read == f->write; -} - -bool fifo_full(fifo_t *f) -{ - return fifo_fill(f) == CONFIG_FIFO_SIZE-1; -}