From 4b6e936c8a66da4fc25f35914b0e9b9e66a31359 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 17 Mar 2016 10:00:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9129 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/nil/include/ch.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'os/nil') diff --git a/os/nil/include/ch.h b/os/nil/include/ch.h index 419822471..507128186 100644 --- a/os/nil/include/ch.h +++ b/os/nil/include/ch.h @@ -854,6 +854,33 @@ struct nil_system { #define US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec)) /** @} */ +/** + * @name Semaphores macros + * @{ + */ +/** + * @brief Data part of a static semaphore initializer. + * @details This macro should be used when statically initializing a semaphore + * that is part of a bigger structure. + * + * @param[in] name the name of the semaphore variable + * @param[in] n the counter initial value, this value must be + * non-negative + */ +#define _SEMAPHORE_DATA(name, n) {n} + +/** + * @brief Static semaphore initializer. + * @details Statically initialized semaphores require no explicit + * initialization using @p chSemInit(). + * + * @param[in] name the name of the semaphore variable + * @param[in] n the counter initial value, this value must be + * non-negative + */ +#define SEMAPHORE_DECL(name, n) semaphore_t name = _SEMAPHORE_DATA(name, n) +/** @} */ + /** * @name Macro Functions * @{ -- cgit v1.2.3