From 42a90cc8cebf186c64bbae50a16a90a9979b80f4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 28 Mar 2008 11:39:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/lib/ch.cpp | 9 +++++++-- src/lib/ch.hpp | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/ch.cpp b/src/lib/ch.cpp index d1e739915..653a48dec 100644 --- a/src/lib/ch.cpp +++ b/src/lib/ch.cpp @@ -29,12 +29,12 @@ namespace chibios_rt { chSysInit(); } - void Lock(void) { + void System::Lock(void) { chSysLock(); } - void Unlock(void) { + void System::Unlock(void) { chSysUnlock(); } @@ -125,6 +125,11 @@ namespace chibios_rt { #endif /* CH_USE_SLEEP */ #ifdef CH_USE_MESSAGES + msg_t BaseThread::SendMessage(::Thread* tp, msg_t msg) { + + return chMsgSend(tp, msg); + } + msg_t BaseThread::SendMessage(msg_t msg) { return chMsgSend(thread_ref, msg); diff --git a/src/lib/ch.hpp b/src/lib/ch.hpp index d9fffc229..177e9bb46 100644 --- a/src/lib/ch.hpp +++ b/src/lib/ch.hpp @@ -146,6 +146,11 @@ namespace chibios_rt { #endif /* CH_USE_SLEEP */ #ifdef CH_USE_MESSAGES + /** + * Sends a message to the thread and returns the answer. + */ + static msg_t SendMessage(::Thread *tp, msg_t msg); + /** * Sends a message to the thread and returns the answer. */ @@ -178,6 +183,25 @@ namespace chibios_rt { virtual msg_t Main(void); }; + /** + * Enhanced threads template class. This class introduces thread names + * and static working area allocation. + */ + template + class EnhancedThread : public BaseThread { + protected: + WorkingArea(wa, N); // Thread working area. + + public: + const char *name; + + EnhancedThread(const char *tname, tprio_t prio, tmode_t mode) : + BaseThread(prio, mode, wa, sizeof wa) { + + name = tname; + } + }; + #ifdef CH_USE_SEMAPHORES /** * Class encapsulating a /p Semaphore. -- cgit v1.2.3