This is a fork of the `events` subdirectory of https://github.com/ARMmbed/mbed-os

Dependents:   HelloWorld_CCA01M1 HelloWorld_CCA02M1 CI-data-logger-server HelloWorld_CCA02M1 ... more

This is a fork of the events subdirectory of https://github.com/ARMmbed/mbed-os.

Note, you must import this library with import name: events!!!

Revision:
9828:b778d3912beb
Parent:
9821:b387aa0c25b4
--- a/equeue/equeue_mbed.cpp	Fri Jun 02 15:11:51 2017 -0500
+++ b/equeue/equeue_mbed.cpp	Thu Jun 15 15:47:15 2017 -0500
@@ -86,18 +86,21 @@
 #ifdef MBED_CONF_RTOS_PRESENT
 
 int equeue_sema_create(equeue_sema_t *s) {
-    MBED_STATIC_ASSERT(sizeof(equeue_sema_t) >= sizeof(Semaphore),
-            "The equeue_sema_t must fit the class Semaphore");
-    new (s) Semaphore(0);
-    return 0;
+    osEventFlagsAttr_t attr;
+    memset(&attr, 0, sizeof(attr));
+    attr.cb_mem = &s->mem;
+    attr.cb_size = sizeof(s->mem);
+
+    s->id = osEventFlagsNew(&attr);
+    return !s->id ? -1 : 0;
 }
 
 void equeue_sema_destroy(equeue_sema_t *s) {
-    reinterpret_cast<Semaphore*>(s)->~Semaphore();
+    osEventFlagsDelete(s->id);
 }
 
 void equeue_sema_signal(equeue_sema_t *s) {
-    reinterpret_cast<Semaphore*>(s)->release();
+    osEventFlagsSet(s->id, 1);
 }
 
 bool equeue_sema_wait(equeue_sema_t *s, int ms) {
@@ -105,7 +108,7 @@
         ms = osWaitForever;
     }
 
-    return (reinterpret_cast<Semaphore*>(s)->wait(ms) > 0);
+    return (osEventFlagsWait(s->id, 1, osFlagsWaitAny, ms) == 1);
 }
 
 #else