From dd6e2f3911e6bdd4905bd2173492be3119a3e491 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 16 May 2009 11:53:48 +0000 Subject: 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 --- src/include/queues.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'src') 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 @@ -102,6 +102,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. @@ -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 -- cgit v1.2.3