aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-05-16 11:53:48 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-05-16 11:53:48 +0000
commitdd6e2f3911e6bdd4905bd2173492be3119a3e491 (patch)
tree137633dad699149bd717806d1165d35d5eefb676 /src
parent2706d240bbea25b21dac8e0bc123de9cb2080a13 (diff)
downloadChibiOS-dd6e2f3911e6bdd4905bd2173492be3119a3e491.tar.gz
ChibiOS-dd6e2f3911e6bdd4905bd2173492be3119a3e491.tar.bz2
ChibiOS-dd6e2f3911e6bdd4905bd2173492be3119a3e491.zip
Added static initializers to input and output queues.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@976 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/include/queues.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/include/queues.h b/src/include/queues.h
index 886707e7d..d6c7d46fc 100644
--- a/src/include/queues.h
+++ b/src/include/queues.h
@@ -103,6 +103,36 @@ typedef GenericQueue InputQueue;
#define chIQGet(iqp) chIQGetTimeout(iqp, TIME_INFINITE)
/**
+ * @brief Data part of a static input queue initializer.
+ * @details This macro should be used when statically initializing an
+ * input queue that is part of a bigger structure.
+ * @param name the name of the input queue variable
+ * @param buffer pointer to the queue buffer area
+ * @param size size of the queue buffer area
+ * @param inotify input notification callback pointer
+ */
+#define _INPUTQUEUE_DATA(name, buffer, size, inotify) { \
+ buffer, \
+ buffer + size, \
+ buffer, \
+ buffer, \
+ _SEMAPHORE_DATA(name.q_sem, 0), \
+ inotify \
+}
+
+/**
+ * @brief Static input queue initializer.
+ * @details Statically initialized input queues require no explicit
+ * initialization using @p chIQInit().
+ * @param name the name of the input queue variable
+ * @param buffer pointer to the queue buffer area
+ * @param size size of the queue buffer area
+ * @param inotify input notification callback pointer
+ */
+#define INPUTQUEUE_DECL(name, buffer, size, inotify) \
+ InputQueue name = _INPUTQUEUE_DATA(name, buffer, size, inotify)
+
+/**
* @brief Output queue structure.
* @details This structure represents a generic asymmetrical output queue.
* Reading from the queue is non-blocking and can be performed from
@@ -134,6 +164,36 @@ typedef GenericQueue OutputQueue;
*/
#define chOQPut(oqp, b) chOQPutTimeout(oqp, b, TIME_INFINITE)
+/**
+ * @brief Data part of a static output queue initializer.
+ * @details This macro should be used when statically initializing an
+ * output queue that is part of a bigger structure.
+ * @param name the name of the output queue variable.
+ * @param buffer pointer to the queue buffer area
+ * @param size size of the queue buffer area
+ * @param onotify output notification callback pointer
+ */
+#define _OUTPUTQUEUE_DATA(name, buffer, size, onotify) { \
+ buffer, \
+ buffer + size, \
+ buffer, \
+ buffer, \
+ _SEMAPHORE_DATA(name.q_sem, size), \
+ onotify \
+}
+
+/**
+ * @brief Static output queue initializer.
+ * @details Statically initialized output queues require no explicit
+ * initialization using @p chOQInit().
+ * @param name the name of the output queue variable
+ * @param buffer pointer to the queue buffer area
+ * @param size size of the queue buffer area
+ * @param onotify output notification callback pointer
+ */
+#define OUTPUTQUEUE_DECL(name, buffer, size, onotify) \
+ InputQueue name = _OUTPUTQUEUE_DATA(name, buffer, size, onotify)
+
#ifdef __cplusplus
extern "C" {
#endif