|
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 /** 00022 * @file chmsg.h 00023 * @brief Messages macros and structures. 00024 * 00025 * @addtogroup messages 00026 * @{ 00027 */ 00028 00029 #ifndef _CHMSG_H_ 00030 #define _CHMSG_H_ 00031 00032 #if CH_USE_MESSAGES || defined(__DOXYGEN__) 00033 00034 /** 00035 * @name Macro Functions 00036 * @{ 00037 */ 00038 /** 00039 * @brief Evaluates to TRUE if the thread has pending messages. 00040 * 00041 * @iclass 00042 */ 00043 #define chMsgIsPendingI(tp) \ 00044 ((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue) 00045 00046 /** 00047 * @brief Returns the message carried by the specified thread. 00048 * @pre This function must be invoked immediately after exiting a call 00049 * to @p chMsgWait(). 00050 * 00051 * @param[in] tp pointer to the thread 00052 * @return The message carried by the sender. 00053 * 00054 * @api 00055 */ 00056 #define chMsgGet(tp) ((tp)->p_msg) 00057 00058 /** 00059 * @brief Releases the thread waiting on top of the messages queue. 00060 * @pre Invoke this function only after a message has been received 00061 * using @p chMsgWait(). 00062 * 00063 * @param[in] tp pointer to the thread 00064 * @param[in] msg message to be returned to the sender 00065 * 00066 * @sclass 00067 */ 00068 #define chMsgReleaseS(tp, msg) chSchWakeupS(tp, msg) 00069 /** @} */ 00070 00071 #ifdef __cplusplus 00072 extern "C" { 00073 #endif 00074 msg_t chMsgSend(Thread *tp, msg_t msg); 00075 Thread * chMsgWait(void); 00076 void chMsgRelease(Thread *tp, msg_t msg); 00077 #ifdef __cplusplus 00078 } 00079 #endif 00080 00081 #endif /* CH_USE_MESSAGES */ 00082 00083 #endif /* _CHMSG_H_ */ 00084 00085 /** @} */