From f26d653e462a84bfa73387b66f5e651d5849695f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 08:49:45 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5011 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 409 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 409 insertions(+) create mode 100644 os/various/cpp_wrappers/ch.cpp (limited to 'os/various/cpp_wrappers/ch.cpp') diff --git a/os/various/cpp_wrappers/ch.cpp b/os/various/cpp_wrappers/ch.cpp new file mode 100644 index 000000000..84678349c --- /dev/null +++ b/os/various/cpp_wrappers/ch.cpp @@ -0,0 +1,409 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file ch.cpp + * @brief C++ wrapper code. + * + * @addtogroup cpp_library + * @{ + */ + +#include "ch.hpp" + +namespace chibios_rt { + + /*------------------------------------------------------------------------* + * chibios_rt::System * + *------------------------------------------------------------------------*/ + void System::init(void) { + + chSysInit(); + } + + void System::lock(void) { + + chSysLock(); + } + + void System::unlock(void) { + + chSysUnlock(); + } + + systime_t System::getTime(void) { + + return chTimeNow(); + } + + /*------------------------------------------------------------------------* + * chibios_rt::Timer * + *------------------------------------------------------------------------*/ + void Timer::setI(systime_t time, vtfunc_t vtfunc, void *par) { + + chVTSetI(&timer_ref, time, vtfunc, par); + } + + void Timer::resetI() { + + if (chVTIsArmedI(&timer_ref)) + chVTResetI(&timer_ref); + } + + bool Timer::isArmedI(void) { + + return (bool)chVTIsArmedI(&timer_ref); + } + + /*------------------------------------------------------------------------* + * chibios_rt::ThreadReference * + *------------------------------------------------------------------------*/ + msg_t ThreadReference::suspend(void) { + msg_t msg; + + chSysLock(); + + chDbgAssert(thread_ref != NULL, + "ThreadReference, #1", + "already referenced"); + + thread_ref = chThdSelf(); + chSchGoSleepS(THD_STATE_SUSPENDED); + msg = thread_ref->p_u.rdymsg; + + chSysUnlock(); + return msg; + } + + msg_t ThreadReference::suspendS(void) { + + chDbgAssert(thread_ref == NULL, + "ThreadReference, #2", + "already referenced"); + + thread_ref = chThdSelf(); + chSchGoSleepS(THD_STATE_SUSPENDED); + return thread_ref->p_u.rdymsg; + } + + void ThreadReference::resume(msg_t msg) { + + chSysLock() + + chDbgAssert(thread_ref != NULL, + "ThreadReference, #3", + "not referenced"); + + if (thread_ref) { + Thread *tp = thread_ref; + thread_ref = NULL; + chSchWakeupS(tp, msg); + } + + chSysUnlock(); + } + + void ThreadReference::resumeI(msg_t msg) { + + chDbgAssert(thread_ref != NULL, + "ThreadReference, #4", + "not referenced"); + + if (thread_ref) { + Thread *tp = thread_ref; + thread_ref = NULL; + tp->p_msg = msg; + chSchReadyI(tp); + } + } + + void ThreadReference::requestTerminate(void) { + + chThdTerminate(thread_ref); + } + +#if CH_USE_WAITEXIT || defined(__DOXYGEN__) + msg_t ThreadReference::wait(void) { + + chDbgAssert(thread_ref != NULL, + "ThreadReference, #5", + "not referenced"); + + msg_t msg = chThdWait(thread_ref); + thread_ref = NULL; + return msg; + } +#endif /* CH_USE_WAITEXIT */ + +#if CH_USE_MESSAGES || defined(__DOXYGEN__) + msg_t ThreadReference::sendMessage(msg_t msg) { + + chDbgAssert(thread_ref != NULL, + "ThreadReference, #6", + "not referenced"); + + return chMsgSend(thread_ref, msg); + } + + bool ThreadReference::isPendingMessage(void) { + + return (bool)chMsgIsPendingI(thread_ref); + } +#endif /* CH_USE_MESSAGES */ + +#if CH_USE_DYNAMIC +#endif /* CH_USE_DYNAMIC */ + + /*------------------------------------------------------------------------* + * chibios_rt::BaseThread * + *------------------------------------------------------------------------*/ + BaseThread::BaseThread() : ThreadReference(NULL) { + + } + + msg_t _thd_start(void *arg) { + + return ((BaseThread *)arg)->Main(); + } + + void BaseThread::exit(msg_t msg) { + + chThdExit(msg); + } + + tprio_t BaseThread::setPriority(tprio_t newprio) { + + return chThdSetPriority(newprio); + } + + bool BaseThread::shouldTerminate(void) { + + return (bool)chThdShouldTerminate(); + } + + void BaseThread::sleep(systime_t interval){ + + chThdSleep(interval); + } + + void BaseThread::sleepUntil(systime_t time) { + + chThdSleepUntil(time); + } + +#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_SEMAPHORES + /*------------------------------------------------------------------------* + * chibios_rt::Semaphore * + *------------------------------------------------------------------------*/ + Semaphore::Semaphore(cnt_t n) { + + chSemInit(&sem, n); + } + + void Semaphore::reset(cnt_t n) { + + chSemReset(&sem, n); + } + + msg_t Semaphore::wait(void) { + + return chSemWait(&sem); + } + + msg_t Semaphore::waitTimeout(systime_t time) { + + return chSemWaitTimeout(&sem, time); + } + + void Semaphore::signal(void) { + + chSemSignal(&sem); + } + +#if CH_USE_SEMSW + msg_t Semaphore::signalWait(Semaphore *ssem, Semaphore *wsem) { + + return chSemSignalWait(&ssem->sem, &wsem->sem); + } +#endif /* CH_USE_SEMSW */ +#endif /* CH_USE_SEMAPHORES */ + +#if CH_USE_MUTEXES + /*------------------------------------------------------------------------* + * chibios_rt::Mutex * + *------------------------------------------------------------------------*/ + Mutex::Mutex(void) { + + chMtxInit(&mutex); + } + + bool Mutex::tryLock(void) { + + return chMtxTryLock(&mutex); + } + + void Mutex::lock(void) { + + chMtxLock(&mutex); + } + + void Mutex::unlock(void) { + + chMtxUnlock(); + } + + void Mutex::unlockAll(void) { + + chMtxUnlockAll(); + } + +#if CH_USE_CONDVARS + /*------------------------------------------------------------------------* + * chibios_rt::CondVar * + *------------------------------------------------------------------------*/ + CondVar::CondVar(void) { + + chCondInit(&condvar); + } + + void CondVar::signal(void) { + + chCondSignal(&condvar); + } + + void CondVar::broadcast(void) { + + chCondBroadcast(&condvar); + } + + msg_t CondVar::wait(void) { + + return chCondWait(&condvar); + } + +#if CH_USE_CONDVARS_TIMEOUT + msg_t CondVar::waitTimeout(systime_t time) { + + return chCondWaitTimeout(&condvar, time); + } +#endif /* CH_USE_CONDVARS_TIMEOUT */ +#endif /* CH_USE_CONDVARS */ +#endif /* CH_USE_MUTEXES */ + +#if CH_USE_EVENTS + /*------------------------------------------------------------------------* + * chibios_rt::Event * + *------------------------------------------------------------------------*/ + Event::Event(void) { + + chEvtInit(&event); + } + + void Event::registerOne(EventListener *elp, eventid_t eid) { + + chEvtRegister(&event,elp, eid); + } + + void Event::registerMask(EventListener *elp, eventmask_t emask) { + + chEvtRegisterMask(&event,elp, emask); + } + + void Event::unregister(EventListener *elp) { + + chEvtUnregister(&event, elp); + } + + void Event::broadcastFlags(flagsmask_t flags) { + + chEvtBroadcastFlags(&event, flags); + } + + void Event::broadcastFlagsI(flagsmask_t flags) { + + chEvtBroadcastFlagsI(&event, flags); + } + + flagsmask_t Event::getAndClearFlags(EventListener *elp) { + + return chEvtGetAndClearFlags(elp); + } + + eventmask_t Event::getAndClearEvents(eventmask_t mask) { + + return chEvtGetAndClearEvents(mask); + } + + eventmask_t Event::addEvents(eventmask_t mask) { + + return chEvtAddEvents(mask); + } + + void Event::dispatch(const evhandler_t handlers[], eventmask_t mask) { + + chEvtDispatch(handlers, mask); + } + + eventmask_t Event::waitOne(eventmask_t ewmask) { + + return chEvtWaitOne(ewmask); + } + + eventmask_t Event::waitAny(eventmask_t ewmask) { + + return chEvtWaitAny(ewmask); + } + + eventmask_t Event::waitAll(eventmask_t ewmask) { + + return chEvtWaitAll(ewmask); + } + +#if CH_USE_EVENTS_TIMEOUT + eventmask_t Event::waitOneTimeout(eventmask_t ewmask, systime_t time) { + + return chEvtWaitOneTimeout(ewmask, time); + } + + eventmask_t Event::waitAnyTimeout(eventmask_t ewmask, systime_t time) { + + return chEvtWaitAnyTimeout(ewmask, time); + } + + eventmask_t Event::waitAllTimeout(eventmask_t ewmask, systime_t time) { + + return chEvtWaitAllTimeout(ewmask, time); + } +#endif /* CH_USE_EVENTS_TIMEOUT */ +#endif /* CH_USE_EVENTS */ +} + +/** @} */ -- cgit v1.2.3 From 64e7fd5a530201190720c8b25535998c9ebf8e84 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 10:11:02 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5012 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 148 +++++++++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 59 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 84678349c..99f7440c9 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -167,6 +167,18 @@ namespace chibios_rt { } #endif /* CH_USE_MESSAGES */ +#if CH_USE_EVENTS + void ThreadReference::signalEvents(eventmask_t mask) { + + chEvtSignal(thread_ref, mask); + } + + void ThreadReference::signalEventsI(eventmask_t mask) { + + chEvtSignalI(thread_ref, mask); + } +#endif /* CH_USE_EVENTS */ + #if CH_USE_DYNAMIC #endif /* CH_USE_DYNAMIC */ @@ -182,9 +194,9 @@ namespace chibios_rt { return ((BaseThread *)arg)->Main(); } - void BaseThread::exit(msg_t msg) { + void BaseThread::setName(const char *tname) { - chThdExit(msg); + chRegSetThreadName(tname); } tprio_t BaseThread::setPriority(tprio_t newprio) { @@ -192,6 +204,11 @@ namespace chibios_rt { return chThdSetPriority(newprio); } + void BaseThread::exit(msg_t msg) { + + chThdExit(msg); + } + bool BaseThread::shouldTerminate(void) { return (bool)chThdShouldTerminate(); @@ -219,6 +236,53 @@ namespace chibios_rt { } #endif /* CH_USE_MESSAGES */ +#if CH_USE_EVENTS + eventmask_t BaseThread::getAndClearEvents(eventmask_t mask) { + + return chEvtGetAndClearEvents(mask); + } + + eventmask_t BaseThread::addEvents(eventmask_t mask) { + + return chEvtAddEvents(mask); + } + + eventmask_t BaseThread::waitOneEvent(eventmask_t ewmask) { + + return chEvtWaitOne(ewmask); + } + + eventmask_t BaseThread::waitAnyEvent(eventmask_t ewmask) { + + return chEvtWaitAny(ewmask); + } + + eventmask_t BaseThread::waitAllEvents(eventmask_t ewmask) { + + return chEvtWaitAll(ewmask); + } + +#if CH_USE_EVENTS_TIMEOUT + eventmask_t BaseThread::waitOneEventTimeout(eventmask_t ewmask, + systime_t time) { + + return chEvtWaitOneTimeout(ewmask, time); + } + + eventmask_t BaseThread::waitAnyEventTimeout(eventmask_t ewmask, + systime_t time) { + + return chEvtWaitAnyTimeout(ewmask, time); + } + + eventmask_t BaseThread::waitAllEventsTimeout(eventmask_t ewmask, + systime_t time) { + + return chEvtWaitAllTimeout(ewmask, time); + } +#endif /* CH_USE_EVENTS_TIMEOUT */ +#endif /* CH_USE_EVENTS */ + #if CH_USE_SEMAPHORES /*------------------------------------------------------------------------* * chibios_rt::Semaphore * @@ -320,89 +384,55 @@ namespace chibios_rt { #if CH_USE_EVENTS /*------------------------------------------------------------------------* - * chibios_rt::Event * + * chibios_rt::EventListener * *------------------------------------------------------------------------*/ - Event::Event(void) { - - chEvtInit(&event); - } - - void Event::registerOne(EventListener *elp, eventid_t eid) { - - chEvtRegister(&event,elp, eid); - } - - void Event::registerMask(EventListener *elp, eventmask_t emask) { + flagsmask_t EventListener::getAndClearFlags(void) { - chEvtRegisterMask(&event,elp, emask); + return chEvtGetAndClearFlags(&ev_listener); } - void Event::unregister(EventListener *elp) { + /*------------------------------------------------------------------------* + * chibios_rt::EventSource * + *------------------------------------------------------------------------*/ + EventSource::EventSource(void) { - chEvtUnregister(&event, elp); + ev_source.es_next = (::EventListener *)(void *)&ev_source; } - void Event::broadcastFlags(flagsmask_t flags) { + void EventSource::registerOne(chibios_rt::EventListener *elp, + eventid_t eid) { - chEvtBroadcastFlags(&event, flags); + chEvtRegister(&ev_source, &elp->ev_listener, eid); } - void Event::broadcastFlagsI(flagsmask_t flags) { + void EventSource::registerMask(chibios_rt::EventListener *elp, + eventmask_t emask) { - chEvtBroadcastFlagsI(&event, flags); + chEvtRegisterMask(&ev_source, &elp->ev_listener, emask); } - flagsmask_t Event::getAndClearFlags(EventListener *elp) { + void EventSource::unregister(chibios_rt::EventListener *elp) { - return chEvtGetAndClearFlags(elp); + chEvtUnregister(&ev_source, &elp->ev_listener); } - eventmask_t Event::getAndClearEvents(eventmask_t mask) { + void EventSource::broadcastFlags(flagsmask_t flags) { - return chEvtGetAndClearEvents(mask); + chEvtBroadcastFlags(&ev_source, flags); } - eventmask_t Event::addEvents(eventmask_t mask) { + void EventSource::broadcastFlagsI(flagsmask_t flags) { - return chEvtAddEvents(mask); + chEvtBroadcastFlagsI(&ev_source, flags); } + /*------------------------------------------------------------------------* + * chibios_rt::Event * + *------------------------------------------------------------------------*/ void Event::dispatch(const evhandler_t handlers[], eventmask_t mask) { chEvtDispatch(handlers, mask); } - - eventmask_t Event::waitOne(eventmask_t ewmask) { - - return chEvtWaitOne(ewmask); - } - - eventmask_t Event::waitAny(eventmask_t ewmask) { - - return chEvtWaitAny(ewmask); - } - - eventmask_t Event::waitAll(eventmask_t ewmask) { - - return chEvtWaitAll(ewmask); - } - -#if CH_USE_EVENTS_TIMEOUT - eventmask_t Event::waitOneTimeout(eventmask_t ewmask, systime_t time) { - - return chEvtWaitOneTimeout(ewmask, time); - } - - eventmask_t Event::waitAnyTimeout(eventmask_t ewmask, systime_t time) { - - return chEvtWaitAnyTimeout(ewmask, time); - } - - eventmask_t Event::waitAllTimeout(eventmask_t ewmask, systime_t time) { - - return chEvtWaitAllTimeout(ewmask, time); - } -#endif /* CH_USE_EVENTS_TIMEOUT */ #endif /* CH_USE_EVENTS */ } -- cgit v1.2.3 From d51863a3536e813374f0c56c0034421cbe965ad6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 10:47:01 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5013 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 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 99f7440c9..1ada921da 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -281,6 +281,12 @@ namespace chibios_rt { return chEvtWaitAllTimeout(ewmask, time); } #endif /* CH_USE_EVENTS_TIMEOUT */ + + void BaseThread::dispatchEvents(const evhandler_t handlers[], + eventmask_t mask) { + + chEvtDispatch(handlers, mask); + } #endif /* CH_USE_EVENTS */ #if CH_USE_SEMAPHORES @@ -384,55 +390,47 @@ namespace chibios_rt { #if CH_USE_EVENTS /*------------------------------------------------------------------------* - * chibios_rt::EventListener * + * chibios_rt::EvtListener * *------------------------------------------------------------------------*/ - flagsmask_t EventListener::getAndClearFlags(void) { + flagsmask_t EvtListener::getAndClearFlags(void) { return chEvtGetAndClearFlags(&ev_listener); } /*------------------------------------------------------------------------* - * chibios_rt::EventSource * + * chibios_rt::EvtSource * *------------------------------------------------------------------------*/ - EventSource::EventSource(void) { + EvtSource::EvtSource(void) { - ev_source.es_next = (::EventListener *)(void *)&ev_source; + chEvtInit(&ev_source); } - void EventSource::registerOne(chibios_rt::EventListener *elp, + void EvtSource::registerOne(chibios_rt::EvtListener *elp, eventid_t eid) { chEvtRegister(&ev_source, &elp->ev_listener, eid); } - void EventSource::registerMask(chibios_rt::EventListener *elp, + void EvtSource::registerMask(chibios_rt::EvtListener *elp, eventmask_t emask) { chEvtRegisterMask(&ev_source, &elp->ev_listener, emask); } - void EventSource::unregister(chibios_rt::EventListener *elp) { + void EvtSource::unregister(chibios_rt::EvtListener *elp) { chEvtUnregister(&ev_source, &elp->ev_listener); } - void EventSource::broadcastFlags(flagsmask_t flags) { + void EvtSource::broadcastFlags(flagsmask_t flags) { chEvtBroadcastFlags(&ev_source, flags); } - void EventSource::broadcastFlagsI(flagsmask_t flags) { + void EvtSource::broadcastFlagsI(flagsmask_t flags) { chEvtBroadcastFlagsI(&ev_source, flags); } - - /*------------------------------------------------------------------------* - * chibios_rt::Event * - *------------------------------------------------------------------------*/ - void Event::dispatch(const evhandler_t handlers[], eventmask_t mask) { - - chEvtDispatch(handlers, mask); - } #endif /* CH_USE_EVENTS */ } -- cgit v1.2.3 From c66db01792f60dfc8af534e2d7fbcb326efb4873 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 13:30:07 +0000 Subject: Semaphores wrapper improved and completed. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5016 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (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 1ada921da..5faf6d37c 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -303,21 +303,51 @@ namespace chibios_rt { chSemReset(&sem, n); } + void Semaphore::resetI(cnt_t n) { + + chSemResetI(&sem, n); + } + msg_t Semaphore::wait(void) { return chSemWait(&sem); } + msg_t Semaphore::waitS(void) { + + return chSemWaitS(&sem); + } + msg_t Semaphore::waitTimeout(systime_t time) { return chSemWaitTimeout(&sem, time); } + msg_t Semaphore::waitTimeoutS(systime_t time) { + + return chSemWaitTimeoutS(&sem, time); + } + void Semaphore::signal(void) { chSemSignal(&sem); } + void Semaphore::signalI(void) { + + chSemSignalI(&sem); + } + + void Semaphore::addCounterI(cnt_t n) { + + chSemAddCounterI(&sem, n); + } + + cnt_t Semaphore::getCounterI(void) { + + return chSemGetCounterI(&sem); + } + #if CH_USE_SEMSW msg_t Semaphore::signalWait(Semaphore *ssem, Semaphore *wsem) { -- cgit v1.2.3 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 From f0526e72d81b13f115ffd6dcbca5620f62b14d2f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 15:00:20 +0000 Subject: Added mailboxes to the C++ wrapper. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5018 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (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 d6dd61ff7..b6270d8ba 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -510,6 +510,67 @@ namespace chibios_rt { chEvtBroadcastFlagsI(&ev_source, flags); } #endif /* CH_USE_EVENTS */ + +#if CH_USE_MAILBOXES || defined(__DOXYGEN__) + /*------------------------------------------------------------------------* + * chibios_rt::Mailbox * + *------------------------------------------------------------------------*/ + Mailbox::Mailbox(msg_t *buf, cnt_t n) { + + chMBInit(&mb, buf, n); + } + + void Mailbox::reset(void) { + + chMBReset(&mb); + } + + msg_t Mailbox::post(msg_t msg, systime_t time) { + + return chMBPost(&mb, msg, time); + } + + msg_t Mailbox::postS(msg_t msg, systime_t time) { + + return chMBPostS(&mb, msg, time); + } + + msg_t Mailbox::postI(msg_t msg) { + + return chMBPostI(&mb, msg); + } + + msg_t Mailbox::postAhead(msg_t msg, systime_t time) { + + return chMBPostAhead(&mb, msg, time); + } + + msg_t Mailbox::postAheadS(msg_t msg, systime_t time) { + + return chMBPostAheadS(&mb, msg, time); + } + + msg_t Mailbox::postAheadI(msg_t msg) { + + return chMBPostAheadI(&mb, msg); + } + + msg_t Mailbox::fetch(msg_t *msgp, systime_t time) { + + return chMBFetch(&mb, msgp, time); + } + + msg_t Mailbox::fetchS(msg_t *msgp, systime_t time) { + + return chMBFetchS(&mb, msgp, time); + } + + msg_t Mailbox::fetchI(msg_t *msgp) { + + return chMBFetchI(&mb, msgp); + } + +#endif /* CH_USE_MAILBOXES */ } /** @} */ -- cgit v1.2.3 From 3edb2cf5532bf7c1c43cc2a839d3d0a15e6d7a6a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 2 Jan 2013 18:42:39 +0000 Subject: Added memory pools to the C++ wrapper. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5020 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (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 b6270d8ba..9dc3f79ca 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -569,8 +569,42 @@ namespace chibios_rt { return chMBFetchI(&mb, msgp); } - #endif /* CH_USE_MAILBOXES */ + +#if CH_USE_MEMPOOLS + /*------------------------------------------------------------------------* + * chibios_rt::MemoryPool * + *------------------------------------------------------------------------*/ + MemoryPool::MemoryPool(size_t size, memgetfunc_t provider) { + + chPoolInit(&pool, size, provider); + } + + void MemoryPool::loadArray(void *p, size_t n) { + + chPoolLoadArray(&pool, p, n); + } + + void *MemoryPool::allocI(void) { + + return chPoolAlloc(&pool); + } + + void *MemoryPool::alloc(void) { + + return chPoolAllocI(&pool); + } + + void MemoryPool::free(void *objp) { + + chPoolFree(&pool, objp); + } + + void MemoryPool::freeI(void *objp) { + + chPoolFreeI(&pool, objp); + } +#endif /* CH_USE_MEMPOOLS */ } /** @} */ -- cgit v1.2.3 From 865722b1be24a2672ba271d78bd4a11b20edb84a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 3 Jan 2013 09:52:04 +0000 Subject: Added queues and core. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5021 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 190 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 186 insertions(+), 4 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 9dc3f79ca..6751dc391 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -52,11 +52,29 @@ namespace chibios_rt { return chTimeNow(); } - bool isTimeWithin(systime_t start, systime_t end) { + bool System::isTimeWithin(systime_t start, systime_t end) { return (bool)chTimeIsWithin(start, end); } + /*------------------------------------------------------------------------* + * chibios_rt::Core * + *------------------------------------------------------------------------*/ + void *Core::alloc(size_t size) { + + return chCoreAlloc(size); + } + + void *Core::allocI(size_t size) { + + return chCoreAllocI(size); + } + + size_t Core::getStatus(void) { + + return chCoreStatus(); + } + /*------------------------------------------------------------------------* * chibios_rt::Timer * *------------------------------------------------------------------------*/ @@ -143,7 +161,7 @@ namespace chibios_rt { chThdTerminate(thread_ref); } -#if CH_USE_WAITEXIT || defined(__DOXYGEN__) +#if CH_USE_WAITEXIT msg_t ThreadReference::wait(void) { chDbgAssert(thread_ref != NULL, @@ -156,7 +174,7 @@ namespace chibios_rt { } #endif /* CH_USE_WAITEXIT */ -#if CH_USE_MESSAGES || defined(__DOXYGEN__) +#if CH_USE_MESSAGES msg_t ThreadReference::sendMessage(msg_t msg) { chDbgAssert(thread_ref != NULL, @@ -387,6 +405,59 @@ namespace chibios_rt { return chSemSignalWait(&ssem->sem, &wsem->sem); } #endif /* CH_USE_SEMSW */ + + /*------------------------------------------------------------------------* + * chibios_rt::BinarySemaphore * + *------------------------------------------------------------------------*/ + BinarySemaphore::BinarySemaphore(bool taken) { + + chBSemInit(&bsem, (bool_t)taken); + } + + msg_t BinarySemaphore::wait(void) { + + return chBSemWait(&bsem); + } + + msg_t BinarySemaphore::waitS(void) { + + return chBSemWaitS(&bsem); + } + + msg_t BinarySemaphore::waitTimeout(systime_t time) { + + return chBSemWaitTimeout(&bsem, time); + } + + msg_t BinarySemaphore::waitTimeoutS(systime_t time) { + + return chBSemWaitTimeoutS(&bsem, time); + } + + void BinarySemaphore::reset(bool taken) { + + chBSemReset(&bsem, (bool_t)taken); + } + + void BinarySemaphore::resetI(bool taken) { + + chBSemResetI(&bsem, (bool_t)taken); + } + + void BinarySemaphore::signal(void) { + + chBSemSignal(&bsem); + } + + void BinarySemaphore::signalI(void) { + + chBSemSignalI(&bsem); + } + + bool BinarySemaphore::getStateI(void) { + + return (bool)chBSemGetStateI(&bsem); + } #endif /* CH_USE_SEMAPHORES */ #if CH_USE_MUTEXES @@ -511,7 +582,118 @@ namespace chibios_rt { } #endif /* CH_USE_EVENTS */ -#if CH_USE_MAILBOXES || defined(__DOXYGEN__) +#if CH_USE_QUEUES + /*------------------------------------------------------------------------* + * chibios_rt::InputQueue * + *------------------------------------------------------------------------*/ + InputQueue::InputQueue(uint8_t *bp, size_t size, + qnotify_t infy, void *link) { + + chIQInit(&iq, bp, size, infy, link); + } + + size_t InputQueue::getFullI(void) { + + return chIQGetFullI(&iq); + } + + size_t InputQueue::getEmptyI(void) { + + return chIQGetEmptyI(&iq); + } + + bool InputQueue::isEmptyI(void) { + + return (bool)chIQIsEmptyI(&iq); + } + + bool InputQueue::isFullI(void) { + + return (bool)chIQIsFullI(&iq); + } + + void InputQueue::resetI(void) { + + chIQResetI(&iq); + } + + msg_t InputQueue::putI(uint8_t b) { + + return chIQPutI(&iq, b); + } + + msg_t InputQueue::get() { + + return chIQGet(&iq); + } + + msg_t InputQueue::getTimeout(systime_t time) { + + return chIQGetTimeout(&iq, time); + } + + size_t InputQueue::readTimeout(uint8_t *bp, size_t n, systime_t time) { + + return chIQReadTimeout(&iq, bp, n, time); + } + + /*------------------------------------------------------------------------* + * chibios_rt::OutputQueue * + *------------------------------------------------------------------------*/ + OutputQueue::OutputQueue(uint8_t *bp, size_t size, + qnotify_t onfy, void *link) { + + chOQInit(&oq, bp, size, onfy, link); + } + + size_t OutputQueue::getFullI(void) { + + return chOQGetFullI(&oq); + } + + size_t OutputQueue::getEmptyI(void) { + + return chOQGetEmptyI(&oq); + } + + bool OutputQueue::isEmptyI(void) { + + return (bool)chOQIsEmptyI(&oq); + } + + bool OutputQueue::isFullI(void) { + + return (bool)chOQIsFullI(&oq); + } + + void OutputQueue::resetI(void) { + + chOQResetI(&oq); + } + + msg_t OutputQueue::put(uint8_t b) { + + return chOQPut(&oq, b); + } + + msg_t OutputQueue::putTimeout(uint8_t b, systime_t time) { + + return chOQPutTimeout(&oq, b, time); + } + + msg_t OutputQueue::getI(void) { + + return chOQGetI(&oq); + } + + size_t OutputQueue::writeTimeout(const uint8_t *bp, size_t n, + systime_t time) { + + return chOQWriteTimeout(&oq, bp, n, time); + } +#endif /* CH_USE_QUEUES */ + +#if CH_USE_MAILBOXES /*------------------------------------------------------------------------* * chibios_rt::Mailbox * *------------------------------------------------------------------------*/ -- cgit v1.2.3 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 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 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 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) { -- cgit v1.2.3 From c95f632a674afbf3606d66f950455438efa7aec3 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 3 Jan 2013 18:28:21 +0000 Subject: Added an iclass to the C++ wrapper. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5028 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 5 +++++ 1 file changed, 5 insertions(+) (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 e8db4c013..8437719af 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -556,6 +556,11 @@ namespace chibios_rt { return chEvtGetAndClearFlags(&ev_listener); } + flagsmask_t EvtListener::getAndClearFlagsI(void) { + + return chEvtGetAndClearFlagsI(&ev_listener); + } + /*------------------------------------------------------------------------* * chibios_rt::EvtSource * *------------------------------------------------------------------------*/ -- cgit v1.2.3 From 66205faf65927f86cd1faa8d738e48551fff75e0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Jan 2013 09:38:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5029 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (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 8437719af..5191f2748 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -279,6 +279,14 @@ namespace chibios_rt { chThdYield(); } +#if CH_USE_MESSAGES + ThreadReference BaseThread::waitMessage(void) { + + ThreadReference tr(chMsgWait()); + return tr; + } +#endif /* CH_USE_MESSAGES */ + #if CH_USE_EVENTS eventmask_t BaseThread::getAndClearEvents(eventmask_t mask) { -- cgit v1.2.3 From 77f68f1c5b8f39a9146f5bd644867dde10b24c14 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Jan 2013 10:26:22 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5030 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 110 ++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 41 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 5191f2748..c971a90aa 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -97,6 +97,12 @@ namespace chibios_rt { /*------------------------------------------------------------------------* * chibios_rt::ThreadReference * *------------------------------------------------------------------------*/ + + void ThreadReference::stop(void) { + + chDbgPanic("invoked unimplemented method stop()"); + } + msg_t ThreadReference::suspend(void) { msg_t msg; @@ -158,6 +164,10 @@ namespace chibios_rt { void ThreadReference::requestTerminate(void) { + chDbgAssert(thread_ref != NULL, + "ThreadReference, #5", + "not referenced"); + chThdTerminate(thread_ref); } @@ -165,7 +175,7 @@ namespace chibios_rt { msg_t ThreadReference::wait(void) { chDbgAssert(thread_ref != NULL, - "ThreadReference, #5", + "ThreadReference, #6", "not referenced"); msg_t msg = chThdWait(thread_ref); @@ -178,7 +188,7 @@ namespace chibios_rt { msg_t ThreadReference::sendMessage(msg_t msg) { chDbgAssert(thread_ref != NULL, - "ThreadReference, #6", + "ThreadReference, #7", "not referenced"); return chMsgSend(thread_ref, msg); @@ -186,16 +196,28 @@ namespace chibios_rt { bool ThreadReference::isPendingMessage(void) { + chDbgAssert(thread_ref != NULL, + "ThreadReference, #7", + "not referenced"); + return (bool)chMsgIsPendingI(thread_ref); } msg_t ThreadReference::getMessage(void) { + chDbgAssert(thread_ref != NULL, + "ThreadReference, #8", + "not referenced"); + return chMsgGet(thread_ref); } void ThreadReference::releaseMessage(msg_t msg) { + chDbgAssert(thread_ref != NULL, + "ThreadReference, #9", + "not referenced"); + chMsgRelease(thread_ref, msg); } #endif /* CH_USE_MESSAGES */ @@ -203,11 +225,19 @@ namespace chibios_rt { #if CH_USE_EVENTS void ThreadReference::signalEvents(eventmask_t mask) { + chDbgAssert(thread_ref != NULL, + "ThreadReference, #10", + "not referenced"); + chEvtSignal(thread_ref, mask); } void ThreadReference::signalEventsI(eventmask_t mask) { + chDbgAssert(thread_ref != NULL, + "ThreadReference, #11", + "not referenced"); + chEvtSignalI(thread_ref, mask); } #endif /* CH_USE_EVENTS */ @@ -359,66 +389,66 @@ namespace chibios_rt { #if CH_USE_SEMAPHORES /*------------------------------------------------------------------------* - * chibios_rt::Semaphore * + * chibios_rt::CounterSemaphore * *------------------------------------------------------------------------*/ - Semaphore::Semaphore(cnt_t n) { + CounterSemaphore::CounterSemaphore(cnt_t n) { chSemInit(&sem, n); } - void Semaphore::reset(cnt_t n) { + void CounterSemaphore::reset(cnt_t n) { chSemReset(&sem, n); } - void Semaphore::resetI(cnt_t n) { + void CounterSemaphore::resetI(cnt_t n) { chSemResetI(&sem, n); } - msg_t Semaphore::wait(void) { + msg_t CounterSemaphore::wait(void) { return chSemWait(&sem); } - msg_t Semaphore::waitS(void) { + msg_t CounterSemaphore::waitS(void) { return chSemWaitS(&sem); } - msg_t Semaphore::waitTimeout(systime_t time) { + msg_t CounterSemaphore::waitTimeout(systime_t time) { return chSemWaitTimeout(&sem, time); } - msg_t Semaphore::waitTimeoutS(systime_t time) { + msg_t CounterSemaphore::waitTimeoutS(systime_t time) { return chSemWaitTimeoutS(&sem, time); } - void Semaphore::signal(void) { + void CounterSemaphore::signal(void) { chSemSignal(&sem); } - void Semaphore::signalI(void) { + void CounterSemaphore::signalI(void) { chSemSignalI(&sem); } - void Semaphore::addCounterI(cnt_t n) { + void CounterSemaphore::addCounterI(cnt_t n) { chSemAddCounterI(&sem, n); } - cnt_t Semaphore::getCounterI(void) { + cnt_t CounterSemaphore::getCounterI(void) { return chSemGetCounterI(&sem); } #if CH_USE_SEMSW - msg_t Semaphore::signalWait(chibios_rt::Semaphore *ssem, - chibios_rt::Semaphore *wsem) { + msg_t CounterSemaphore::signalWait(CounterSemaphore *ssem, + CounterSemaphore *wsem) { return chSemSignalWait(&ssem->sem, &wsem->sem); } @@ -607,110 +637,108 @@ namespace chibios_rt { #if CH_USE_QUEUES /*------------------------------------------------------------------------* - * chibios_rt::InputQueue * + * chibios_rt::InQueue * *------------------------------------------------------------------------*/ - InputQueue::InputQueue(uint8_t *bp, size_t size, - qnotify_t infy, void *link) { + InQueue::InQueue(uint8_t *bp, size_t size, qnotify_t infy, void *link) { chIQInit(&iq, bp, size, infy, link); } - size_t InputQueue::getFullI(void) { + size_t InQueue::getFullI(void) { return chIQGetFullI(&iq); } - size_t InputQueue::getEmptyI(void) { + size_t InQueue::getEmptyI(void) { return chIQGetEmptyI(&iq); } - bool InputQueue::isEmptyI(void) { + bool InQueue::isEmptyI(void) { return (bool)chIQIsEmptyI(&iq); } - bool InputQueue::isFullI(void) { + bool InQueue::isFullI(void) { return (bool)chIQIsFullI(&iq); } - void InputQueue::resetI(void) { + void InQueue::resetI(void) { chIQResetI(&iq); } - msg_t InputQueue::putI(uint8_t b) { + msg_t InQueue::putI(uint8_t b) { return chIQPutI(&iq, b); } - msg_t InputQueue::get() { + msg_t InQueue::get() { return chIQGet(&iq); } - msg_t InputQueue::getTimeout(systime_t time) { + msg_t InQueue::getTimeout(systime_t time) { return chIQGetTimeout(&iq, time); } - size_t InputQueue::readTimeout(uint8_t *bp, size_t n, systime_t time) { + size_t InQueue::readTimeout(uint8_t *bp, size_t n, systime_t time) { return chIQReadTimeout(&iq, bp, n, time); } /*------------------------------------------------------------------------* - * chibios_rt::OutputQueue * + * chibios_rt::OutQueue * *------------------------------------------------------------------------*/ - OutputQueue::OutputQueue(uint8_t *bp, size_t size, - qnotify_t onfy, void *link) { + OutQueue::OutQueue(uint8_t *bp, size_t size, qnotify_t onfy, void *link) { chOQInit(&oq, bp, size, onfy, link); } - size_t OutputQueue::getFullI(void) { + size_t OutQueue::getFullI(void) { return chOQGetFullI(&oq); } - size_t OutputQueue::getEmptyI(void) { + size_t OutQueue::getEmptyI(void) { return chOQGetEmptyI(&oq); } - bool OutputQueue::isEmptyI(void) { + bool OutQueue::isEmptyI(void) { return (bool)chOQIsEmptyI(&oq); } - bool OutputQueue::isFullI(void) { + bool OutQueue::isFullI(void) { return (bool)chOQIsFullI(&oq); } - void OutputQueue::resetI(void) { + void OutQueue::resetI(void) { chOQResetI(&oq); } - msg_t OutputQueue::put(uint8_t b) { + msg_t OutQueue::put(uint8_t b) { return chOQPut(&oq, b); } - msg_t OutputQueue::putTimeout(uint8_t b, systime_t time) { + msg_t OutQueue::putTimeout(uint8_t b, systime_t time) { return chOQPutTimeout(&oq, b, time); } - msg_t OutputQueue::getI(void) { + msg_t OutQueue::getI(void) { return chOQGetI(&oq); } - size_t OutputQueue::writeTimeout(const uint8_t *bp, size_t n, - systime_t time) { + size_t OutQueue::writeTimeout(const uint8_t *bp, size_t n, + systime_t time) { return chOQWriteTimeout(&oq, bp, n, time); } -- cgit v1.2.3 From 739e24c329dc3ca72349dec8f4ce16b69abd62e9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 6 Jan 2013 09:10:58 +0000 Subject: Merged another patch to the C++ wrapper. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5036 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 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 c971a90aa..36eaa70df 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -47,6 +47,16 @@ namespace chibios_rt { chSysUnlock(); } + void System::lockFromIsr(void) { + + chSysLockFromIsr(); + } + + void System::unlockFromIsr(void) { + + chSysUnlockFromIsr(); + } + systime_t System::getTime(void) { return chTimeNow(); @@ -813,6 +823,13 @@ namespace chibios_rt { chPoolInit(&pool, size, provider); } + MemoryPool::MemoryPool(size_t size, memgetfunc_t provider, void* p, size_t n) { + + chPoolInit(&pool, size, provider); + chPoolLoadArray(&pool, p, n); + } + + void MemoryPool::loadArray(void *p, size_t n) { chPoolLoadArray(&pool, p, n); @@ -820,12 +837,12 @@ namespace chibios_rt { void *MemoryPool::allocI(void) { - return chPoolAlloc(&pool); + return chPoolAllocI(&pool); } void *MemoryPool::alloc(void) { - return chPoolAllocI(&pool); + return chPoolAlloc(&pool); } void MemoryPool::free(void *objp) { -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 36eaa70df..ea27eddb1 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 5597fabe0b53a7aa76c0c7052ab8edd460b0abfd Mon Sep 17 00:00:00 2001 From: barthess Date: Thu, 18 Apr 2013 14:58:58 +0000 Subject: CPP wrapper. In mailbox class added methods getFreeCountI() and getUsedCountI() git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5594 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (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 ea27eddb1..e6d7442c8 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -812,6 +812,16 @@ namespace chibios_rt { return chMBFetchI(&mb, msgp); } + + cnt_t Mailbox::getFreeCountI(void) { + + return chMBGetFreeCountI(&mb); + } + + cnt_t Mailbox::getUsedCountI(void) { + + return chMBGetUsedCountI(&mb); + } #endif /* CH_USE_MAILBOXES */ #if CH_USE_MEMPOOLS -- cgit v1.2.3 From e4c2e5ed228b6a2d653b4216c9776b72ccb98bc5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 11 May 2013 06:08:17 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5697 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 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 e6d7442c8..9d5a648bf 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -1,21 +1,17 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - This file is part of ChibiOS/RT. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + http://www.apache.org/licenses/LICENSE-2.0 - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ /** * @file ch.cpp -- cgit v1.2.3 From 50fe4f680f80f6c4f7d6b99c29cf923ae7c50204 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 11 May 2013 10:17:48 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5707 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/various/cpp_wrappers/ch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 9d5a648bf..5f2621a61 100644 --- a/os/various/cpp_wrappers/ch.cpp +++ b/os/various/cpp_wrappers/ch.cpp @@ -252,7 +252,7 @@ namespace chibios_rt { #endif /* CH_USE_DYNAMIC */ /*------------------------------------------------------------------------* - * chibios_rt::BaseThread * + * chibios_rt::BaseThread * *------------------------------------------------------------------------*/ BaseThread::BaseThread() : ThreadReference(NULL) { -- cgit v1.2.3