int equeue_sema_create(equeue_sema_t *s) { 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; }
// This is used to initialize the lock used by event loop even // if it is not ran in a separate thread. void ns_event_loop_init(void) { event_mutex_id = osMutexNew(&event_mutex_attr); MBED_ASSERT(event_mutex_id != NULL); // If a separate event loop thread is not used, the signaling // happens via event flags instead of thread flags. This allows one to // perform the initialization from any thread and removes need to know the id // of event loop dispatch thread. #if MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_DISPATCH_FROM_APPLICATION event_flag_id = osEventFlagsNew(&event_flags_attr); MBED_ASSERT(event_flag_id != NULL); #endif }