From b954c4c13310c4c2b6d9a01777a4df99a77eddcf Mon Sep 17 00:00:00 2001 From: aleph Date: Fri, 4 Jun 2004 12:54:29 +0000 Subject: [PATCH] Move all functions to .h as inline functions git-svn-id: https://src.develer.com/svnoss/bertos/trunk@15 38d2e660-2303-0410-9eaa-f027e97ec537 --- mware/fifobuf.c | 140 ------------------------------------------------ 1 file changed, 140 deletions(-) delete mode 100755 mware/fifobuf.c diff --git a/mware/fifobuf.c b/mware/fifobuf.c deleted file mode 100755 index e20b1e5b..00000000 --- a/mware/fifobuf.c +++ /dev/null @@ -1,140 +0,0 @@ -/*! - * \file - * - * - * \version $Id$ - * - * \author Bernardo Innocenti - * - * \brief FIFO buffer handling routines - */ - -/* - * $Log$ - * Revision 1.2 2004/06/03 11:27:09 bernie - * Add dual-license information. - * - * Revision 1.1 2004/05/23 15:43:16 bernie - * Import mware modules. - * - */ - -#include "fifobuf.h" -#include "compiler.h" -#include - -void fifo_init(volatile FIFOBuffer *fb, unsigned char *buf, size_t size) -{ - fb->head = fb->tail = fb->begin = buf; - fb->end = buf + size - 1; -} - - -/*! - * Pop a character from the fifo buffer. - * - * \note Calling \c fifo_push() on a full buffer is undefined. - * The caller must make sure the buffer has at least - * one free slot before calling this function. - * - * \note It is safe to call fifo_pop() and fifo_push() from - * concurrent contexts. - */ -void fifo_push(volatile FIFOBuffer *fb, unsigned char c) -{ -#pragma interrupt called - /* Write at tail position */ - *(fb->tail) = c; - - if (fb->tail == fb->end) - /* wrap tail around */ - fb->tail = fb->begin; - else - /* Move tail forward */ - fb->tail++; -} - -/*! - * Pop a character from the fifo buffer. - * - * \note Calling \c fifo_pop() on an empty buffer is undefined. - * The caller must make sure the buffer contains at least - * one character before calling this function. - * - * \note It is safe to call fifo_pop() and fifo_push() from - * concurrent contexts. - */ -unsigned char fifo_pop(volatile FIFOBuffer *fb) -{ -#pragma interrupt called - if (fb->head == fb->end) - { - /* wrap head around */ - fb->head = fb->begin; - return *(fb->end); - } - else - /* move head forward */ - return *(fb->head++); -} - - -#if 0 - -/* untested */ -void fifo_pushblock(volatile FIFOBuffer *fb, unsigned char *block, size_t len) -{ - size_t freelen; - - /* Se c'e' spazio da tail alla fine del buffer */ - if (fb->tail >= fb->head) - { - freelen = fb->end - fb->tail + 1; - - /* C'e' abbastanza spazio per scrivere tutto il blocco? */ - if (freelen < len) - { - /* Scrivi quello che entra fino alla fine del buffer */ - memcpy(fb->tail, block, freelen); - block += freelen; - len -= freelen; - fb->tail = fb->begin; - } - else - { - /* Scrivi tutto il blocco */ - memcpy(fb->tail, block, len); - fb->tail += len; - return; - } - } - - for(;;) - { - while (!(freelen = fb->head - fb->tail - 1)) - Delay(FIFO_POLLDELAY); - - /* C'e' abbastanza spazio per scrivere tutto il blocco? */ - if (freelen < len) - { - /* Scrivi quello che entra fino alla fine del buffer */ - memcpy(fb->tail, block, freelen); - block += freelen; - len -= freelen; - fb->tail += freelen; - } - else - { - /* Scrivi tutto il blocco */ - memcpy(fb->tail, block, len); - fb->tail += len; - return; - } - } -} - -#endif /* UNUSED */ -- 2.25.1