From 04db761f7e787b9f920aa2c264b6133d1b1815ff Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 14:01:11 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5017 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 62 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'os/various/cpp_wrappers/ch.cpp') diff --git a/os/various/cpp_wrappers/ch.cpp b/os/various/cpp_wrappers/ch.cpp index 5faf6d37c..d6dd61ff7 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -52,6 +52,11 @@ namespace chibios_rt { return chTimeNow(); } + bool isTimeWithin(systime_t start, systime_t end) { + + return (bool)chTimeIsWithin(start, end); + } + /*------------------------------------------------------------------------* * chibios_rt::Timer * *------------------------------------------------------------------------*/ @@ -209,6 +214,11 @@ namespace chibios_rt { chThdExit(msg); } + void BaseThread::exitS(msg_t msg) { + + chThdExitS(msg); + } + bool BaseThread::shouldTerminate(void) { return (bool)chThdShouldTerminate(); @@ -224,6 +234,11 @@ namespace chibios_rt { chThdSleepUntil(time); } + void BaseThread::yield(void) { + + chThdYield(); + } + #if CH_USE_MESSAGES msg_t BaseThread::getMessage(ThreadReference* trp) { @@ -289,6 +304,23 @@ namespace chibios_rt { } #endif /* CH_USE_EVENTS */ +#if CH_USE_MUTEXES + void BaseThread::unlockMutex(void) { + + chMtxUnlock(); + } + + void BaseThread::unlockMutexS(void) { + + chMtxUnlockS(); + } + + void BaseThread::unlockAllMutexes(void) { + + chMtxUnlockAll(); + } +#endif /* CH_USE_MUTEXES */ + #if CH_USE_SEMAPHORES /*------------------------------------------------------------------------* * chibios_rt::Semaphore * @@ -349,7 +381,8 @@ namespace chibios_rt { } #if CH_USE_SEMSW - msg_t Semaphore::signalWait(Semaphore *ssem, Semaphore *wsem) { + msg_t Semaphore::signalWait(chibios_rt::Semaphore *ssem, + chibios_rt::Semaphore *wsem) { return chSemSignalWait(&ssem->sem, &wsem->sem); } @@ -370,19 +403,19 @@ namespace chibios_rt { return chMtxTryLock(&mutex); } - void Mutex::lock(void) { + bool Mutex::tryLockS(void) { - chMtxLock(&mutex); + return chMtxTryLockS(&mutex); } - void Mutex::unlock(void) { + void Mutex::lock(void) { - chMtxUnlock(); + chMtxLock(&mutex); } - void Mutex::unlockAll(void) { + void Mutex::lockS(void) { - chMtxUnlockAll(); + chMtxLockS(&mutex); } #if CH_USE_CONDVARS @@ -399,16 +432,31 @@ namespace chibios_rt { chCondSignal(&condvar); } + void CondVar::signalI(void) { + + chCondSignalI(&condvar); + } + void CondVar::broadcast(void) { chCondBroadcast(&condvar); } + void CondVar::broadcastI(void) { + + chCondBroadcastI(&condvar); + } + msg_t CondVar::wait(void) { return chCondWait(&condvar); } + msg_t CondVar::waitS(void) { + + return chCondWaitS(&condvar); + } + #if CH_USE_CONDVARS_TIMEOUT msg_t CondVar::waitTimeout(systime_t time) { -- cgit v1.2.3