Rename macro to more appropiate name.
[bertos.git] / bertos / struct / fifobuf.h
index b2f8fa503e7334448f6d7b0481f4da1f50eef755..4bd205d0cf2dd16b105a213e64c036ff70d27808 100644 (file)
  * Copyright 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
  * -->
  *
+ * \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;
@@ -88,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
  *
@@ -354,4 +371,6 @@ void fifo_pushblock(FIFOBuffer *fb, unsigned char *block, size_t len)
 }
 #endif
 
+/** \} */ /* defgroup fifobuf */
+
 #endif /* STRUCT_FIFO_H */