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 +++++++++++++++-- os/various/cpp_wrappers/ch.hpp | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) (limited to 'os/various') 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) { diff --git a/os/various/cpp_wrappers/ch.hpp b/os/various/cpp_wrappers/ch.hpp index 073024ce5..e92fbcc9e 100644 --- a/os/various/cpp_wrappers/ch.hpp +++ b/os/various/cpp_wrappers/ch.hpp @@ -72,6 +72,36 @@ namespace chibios_rt { */ static void unlock(void); + /** + * @brief Enters the kernel lock mode from within an interrupt handler. + * @note This API may do nothing on some architectures, it is required + * because on ports that support preemptable interrupt handlers + * it is required to raise the interrupt mask to the same level of + * the system mutual exclusion zone.
+ * It is good practice to invoke this API before invoking any I-class + * syscall from an interrupt handler. + * @note This API must be invoked exclusively from interrupt handlers. + * + * @special + */ + static void lockFromIsr(void); + + /** + * @brief Leaves the kernel lock mode from within an interrupt handler. + * + * @note This API may do nothing on some architectures, it is required + * because on ports that support preemptable interrupt handlers + * it is required to raise the interrupt mask to the same level of + * the system mutual exclusion zone.
+ * It is good practice to invoke this API after invoking any I-class + * syscall from an interrupt handler. + * @note This API must be invoked exclusively from interrupt handlers. + * + * @special + */ + static void unlockFromIsr(void); + + /** * @brief Returns the system time as system ticks. * @note The system tick time interval is implementation dependent. @@ -2004,10 +2034,33 @@ namespace chibios_rt { /** * @brief MemoryPool constructor. * + * @param[in] size the size of the objects contained in this memory pool, + * the minimum accepted size is the size of a pointer to + * void. + * @param[in] provider memory provider function for the memory pool or + * @p NULL if the pool is not allowed to grow + * automatically + * * @init */ MemoryPool(size_t size, memgetfunc_t provider); + /** + * @brief MemoryPool constructor. + * + * @param[in] size the size of the objects contained in this memory pool, + * the minimum accepted size is the size of a pointer to + * void. + * @param[in] provider memory provider function for the memory pool or + * @p NULL if the pool is not allowed to grow + * automatically + * @param[in] p pointer to the array first element + * @param[in] n number of elements in the array + * + * @init + */ + MemoryPool(size_t size, memgetfunc_t provider, void* p, size_t n); + /** * @brief Loads a memory pool with an array of static objects. * @pre The memory pool must be already been initialized. -- cgit v1.2.3