X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Ffifobuf.h;h=4bd205d0cf2dd16b105a213e64c036ff70d27808;hb=1997bcac9db9a289afa5ca6d4fea4b75aef329d6;hp=efb8f10315e2476783d39ec0efbf413160c745b0;hpb=a3a3a24dd211a7e17f27bcd8fd84b6e005c7144d;p=bertos.git diff --git a/bertos/struct/fifobuf.h b/bertos/struct/fifobuf.h index efb8f103..4bd205d0 100644 --- a/bertos/struct/fifobuf.h +++ b/bertos/struct/fifobuf.h @@ -30,6 +30,10 @@ * Copyright 2001, 2008 Bernie Innocenti * --> * + * \defgroup fifobuf FIFO buffer + * \ingroup struct + * \{ + * * \brief General pourpose FIFO buffer implemented with a ring buffer * * \li \c begin points to the first buffer element; @@ -60,12 +64,11 @@ * location and head points to the first one: * \code head == begin && tail == end \endcode * - * \version $Id: fifobuf.h 1532 2008-08-04 07:21:26Z bernie $ * \author Bernie Innocenti */ -#ifndef MWARE_FIFO_H -#define MWARE_FIFO_H +#ifndef STRUCT_FIFO_H +#define STRUCT_FIFO_H #include #include @@ -89,6 +92,19 @@ typedef struct FIFOBuffer ) +/** + * Define a static fifo buffer + */ +#define DEFINE_FIFO(_name, _ptr, _size) \ + FIFOBuffer _name = \ + { \ + .head = (_ptr), \ + .tail = (_ptr), \ + .begin = (_ptr), \ + .end = (_ptr) + (_size) - 1, \ + }; \ + STATIC_ASSERT((_size) > 1) + /** * Check whether the fifo is empty * @@ -355,5 +371,6 @@ void fifo_pushblock(FIFOBuffer *fb, unsigned char *block, size_t len) } #endif -#endif /* MWARE_FIFO_H */ +/** \} */ /* defgroup fifobuf */ +#endif /* STRUCT_FIFO_H */