|
ChibiOS/RT
2.5.1 |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 00003 2011,2012 Giovanni Di Sirio. 00004 00005 This file is part of ChibiOS/RT. 00006 00007 ChibiOS/RT is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 ChibiOS/RT is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 /* 00021 Concepts and parts of this file have been contributed by Leon Woestenberg. 00022 */ 00023 00024 /** 00025 * @file chcond.h 00026 * @brief Condition Variables macros and structures. 00027 * 00028 * @addtogroup condvars 00029 * @{ 00030 */ 00031 00032 #ifndef _CHCOND_H_ 00033 #define _CHCOND_H_ 00034 00035 #if CH_USE_CONDVARS || defined(__DOXYGEN__) 00036 00037 /* 00038 * Module dependencies check. 00039 */ 00040 #if !CH_USE_MUTEXES 00041 #error "CH_USE_CONDVARS requires CH_USE_MUTEXES" 00042 #endif 00043 00044 /** 00045 * @brief CondVar structure. 00046 */ 00047 typedef struct CondVar { 00048 ThreadsQueue c_queue; /**< @brief CondVar threads queue.*/ 00049 } CondVar; 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 void chCondInit(CondVar *cp); 00055 void chCondSignal(CondVar *cp); 00056 void chCondSignalI(CondVar *cp); 00057 void chCondBroadcast(CondVar *cp); 00058 void chCondBroadcastI(CondVar *cp); 00059 msg_t chCondWait(CondVar *cp); 00060 msg_t chCondWaitS(CondVar *cp); 00061 #if CH_USE_CONDVARS_TIMEOUT 00062 msg_t chCondWaitTimeout(CondVar *cp, systime_t time); 00063 msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time); 00064 #endif 00065 #ifdef __cplusplus 00066 } 00067 #endif 00068 00069 /** 00070 * @brief Data part of a static condition variable initializer. 00071 * @details This macro should be used when statically initializing a condition 00072 * variable that is part of a bigger structure. 00073 * 00074 * @param[in] name the name of the condition variable 00075 */ 00076 #define _CONDVAR_DATA(name) {_THREADSQUEUE_DATA(name.c_queue)} 00077 00078 /** 00079 * @brief Static condition variable initializer. 00080 * @details Statically initialized condition variables require no explicit 00081 * initialization using @p chCondInit(). 00082 * 00083 * @param[in] name the name of the condition variable 00084 */ 00085 #define CONDVAR_DECL(name) CondVar name = _CONDVAR_DATA(name) 00086 00087 #endif /* CH_USE_CONDVARS */ 00088 00089 #endif /* _CHCOND_H_ */ 00090 00091 /** @} */