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