From b5da4b76b5810b41900432832f178280069d8d91 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 3 Jan 2013 16:17:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5027 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 36 +++++++++++++++++---------- os/various/cpp_wrappers/ch.hpp | 55 ++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 44 deletions(-) (limited to 'os/various/cpp_wrappers') diff --git a/os/various/cpp_wrappers/ch.cpp b/os/various/cpp_wrappers/ch.cpp index 6751dc391..e8db4c013 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -188,6 +188,16 @@ namespace chibios_rt { return (bool)chMsgIsPendingI(thread_ref); } + + msg_t ThreadReference::getMessage(void) { + + return chMsgGet(thread_ref); + } + + void ThreadReference::releaseMessage(msg_t msg) { + + chMsgRelease(thread_ref, msg); + } #endif /* CH_USE_MESSAGES */ #if CH_USE_EVENTS @@ -212,9 +222,21 @@ namespace chibios_rt { } + msg_t BaseThread::main(void) { + + return 0; + } + + ThreadReference BaseThread::start(tprio_t prio) { + + (void)prio; + + return *this; + }; + msg_t _thd_start(void *arg) { - return ((BaseThread *)arg)->Main(); + return ((BaseThread *)arg)->main(); } void BaseThread::setName(const char *tname) { @@ -257,18 +279,6 @@ namespace chibios_rt { chThdYield(); } -#if CH_USE_MESSAGES - msg_t BaseThread::getMessage(ThreadReference* trp) { - - return chMsgGet(trp->thread_ref); - } - - void BaseThread::releaseMessage(ThreadReference* trp, msg_t msg) { - - chMsgRelease(trp->thread_ref, msg); - } -#endif /* CH_USE_MESSAGES */ - #if CH_USE_EVENTS eventmask_t BaseThread::getAndClearEvents(eventmask_t mask) { diff --git a/os/various/cpp_wrappers/ch.hpp b/os/various/cpp_wrappers/ch.hpp index 2f2d5bfe0..05bc1b33d 100644 --- a/os/various/cpp_wrappers/ch.hpp +++ b/os/various/cpp_wrappers/ch.hpp @@ -221,7 +221,7 @@ namespace chibios_rt { * * @init */ - ThreadReference(Thread * tp) : thread_ref(tp) { + ThreadReference(Thread *tp) : thread_ref(tp) { }; @@ -330,6 +330,26 @@ namespace chibios_rt { * @api */ bool isPendingMessage(void); + + /** + * @brief Returns an enqueued message or @p NULL. + * + * @param[in] trp the sender thread reference + * @return The incoming message. + * + * @api + */ + msg_t getMessage(void); + + /** + * @brief Releases the next message in queue with a reply. + * + * @param[in] trp the sender thread reference + * @param[in] msg the answer message + * + * @api + */ + void releaseMessage(msg_t msg); #endif /* CH_USE_MESSAGES */ #if CH_USE_EVENTS || defined(__DOXYGEN__) @@ -380,9 +400,7 @@ namespace chibios_rt { * * @api */ - virtual msg_t Main(void) { - return 0; - }; + virtual msg_t main(void); /** * @brief Creates and starts a system thread. @@ -393,12 +411,7 @@ namespace chibios_rt { * * @api */ - virtual ThreadReference start(tprio_t prio) { - - (void)prio; - - return *this; - }; + virtual ThreadReference start(tprio_t prio); /** * @brief Sets the current thread name. @@ -510,26 +523,6 @@ namespace chibios_rt { * @api */ static ThreadReference waitMessage(void); - - /** - * @brief Returns an enqueued message or @p NULL. - * - * @param[in] trp the sender thread reference - * @return The incoming message. - * - * @api - */ - static msg_t getMessage(ThreadReference* trp); - - /** - * @brief Releases the next message in queue with a reply. - * - * @param[in] trp the sender thread reference - * @param[in] msg the answer message - * - * @api - */ - static void releaseMessage(ThreadReference* trp, msg_t msg); #endif /* CH_USE_MESSAGES */ #if CH_USE_EVENTS || defined(__DOXYGEN__) @@ -750,7 +743,7 @@ namespace chibios_rt { * * @api */ - ThreadReference start(tprio_t prio) { + virtual ThreadReference start(tprio_t prio) { msg_t _thd_start(void *arg); thread_ref = chThdCreateStatic(wa, sizeof(wa), prio, _thd_start, this); -- cgit v1.2.3