aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/cpp_wrappers
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-06 09:10:58 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-01-06 09:10:58 +0000
commit739e24c329dc3ca72349dec8f4ce16b69abd62e9 (patch)
treea6bbdfdc6e60ad6045813870c135a95e054ec4cd /os/various/cpp_wrappers
parentaaa126da625b7d63440cf5f28e3ad69a5839def2 (diff)
downloadChibiOS-739e24c329dc3ca72349dec8f4ce16b69abd62e9.tar.gz
ChibiOS-739e24c329dc3ca72349dec8f4ce16b69abd62e9.tar.bz2
ChibiOS-739e24c329dc3ca72349dec8f4ce16b69abd62e9.zip
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
Diffstat (limited to 'os/various/cpp_wrappers')
-rw-r--r--os/various/cpp_wrappers/ch.cpp21
-rw-r--r--os/various/cpp_wrappers/ch.hpp53
2 files changed, 72 insertions, 2 deletions
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
@@ -73,6 +73,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.<br>
+ * 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.<br>
+ * 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,11 +2034,34 @@ 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.
* @pre The array elements must be of the right size for the specified