42#define OS_ZERO_INIT {}
44#define OS_ZERO_INIT {0}
61 return (
OS_Ulong)osKernelGetTickCount();
66 return osKernelGetState() == osKernelRunning;
76 return (t != 0 && *t != 0 && osThreadGetId() == *t) ? 1u : 0u;
85 void (*entry)(
void *),
void *arg,
89 if (t == 0 || entry == 0) {
94 attr.stack_size = (uint32_t)stack_size;
95 attr.stack_mem = stack;
97 attr.priority = (osPriority_t)priority;
99 osThreadId_t
id = osThreadNew(entry, arg, &attr);
105 (void)osThreadSuspend(
id);
134 params->
entry = entry;
137 stack, stack_size, priority, auto_start);
149 OS_Uint auto_start,
int core_id)
153 priority, preempt, slice, auto_start);
176 if (state && t && *t) {
177 *state = (
OS_Uint)osThreadGetState(*t);
194 return (t != 0) && (*t != 0);
204 return (m != 0) && (*m != 0);
208 return (state == (
OS_Uint)osThreadBlocked) ||
209 (state == (
OS_Uint)osThreadInactive);
217 attr.attr_bits = osMutexPrioInherit;
219 *m = osMutexNew(&attr);
239 attr.attr_bits = osMutexRecursive | osMutexPrioInherit;
240 *m = osMutexNew(&attr);
260 *s = osSemaphoreNew(0xFFFFu, initial, &attr);
278 *count = (
OS_Ulong)osSemaphoreGetCount(*s);
284#define OS_QUEUE_STORE_BYTES(item_words, length) ((size_t)0)
291 *q = osMessageQueueNew((uint32_t)length, item_words *
sizeof(uint32_t), &attr);
300 return (osMessageQueuePut(*q, msg, 0, (uint32_t)wait) == osOK) ? (
OS_Uint)
OS_SUCCESS
305 return (osMessageQueueGet(*q, msg, 0, (uint32_t)wait) == osOK) ? (
OS_Uint)
OS_SUCCESS
313 *g = osEventFlagsNew(&attr);
322 return (osEventFlagsSet(*g, (uint32_t)flags) != osFlagsError) ? (
OS_Uint)
OS_SUCCESS
327 return (osEventFlagsClear(*g, (uint32_t)flags) != osFlagsError) ? (
OS_Uint)
OS_SUCCESS
336 const uint32_t opt = (all ? osFlagsWaitAll : osFlagsWaitAny) | (clear ? 0U : osFlagsNoClear);
337 const uint32_t got = osEventFlagsWait(*g, (uint32_t)flags, opt, (uint32_t)wait);
352 params->
cb(params->
id);
369 const osTimerType_t type = (reload != 0u) ? osTimerPeriodic : osTimerOnce;
430 (void)osKernelLock();
434 (void)osKernelUnlock();
static void os_critical_enter(void)
Definition os_cmsis.h:428
@ OS_AUTO_START
Definition os_cmsis.h:54
@ OS_SUCCESS
Definition os_cmsis.h:50
@ OS_EVENT_CLEAR
Definition os_cmsis.h:53
@ OS_DONT_START
Definition os_cmsis.h:55
@ OS_INHERIT
Definition os_cmsis.h:56
@ OS_OR
Definition os_cmsis.h:52
@ OS_WAIT_FOREVER
Definition os_cmsis.h:48
@ OS_AND
Definition os_cmsis.h:51
@ OS_NO_WAIT
Definition os_cmsis.h:49
static OS_Uint os_semaphore_put(OS_Semaphore *s)
Definition os_cmsis.h:267
static void os_cmsis_generic_entry(void *p)
Definition os_cmsis.h:115
static OS_Uint os_queue_delete(OS_Queue *q)
Definition os_cmsis.h:294
static OS_Uint os_thread_create_pinned(OS_Thread *t, const char *name, void(*entry)(OS_Ulong), OS_Ulong input, uint8_t *stack, OS_Ulong stack_size, OS_Uint priority, OS_Uint preempt, OS_Ulong slice, OS_Uint auto_start, int core_id)
Definition os_cmsis.h:144
static OS_Uint os_thread_spawn(OS_Thread *t, const char *name, void(*entry)(void *), void *arg, void *stack, OS_Ulong stack_size, OS_Uint priority, OS_Uint auto_start)
Create a CMSIS thread. entry receives arg — no heap cookie.
Definition os_cmsis.h:84
static int os_mutex_is_live(const OS_Mutex *m)
Definition os_cmsis.h:202
static OS_Uint os_semaphore_get(OS_Semaphore *s, OS_Ulong wait)
Definition os_cmsis.h:271
#define OS_ZERO_INIT
Definition os_cmsis.h:44
void * OS_StreamBuffer
Definition os_cmsis.h:33
static OS_Uint os_thread_suspend(OS_Thread *t)
Definition os_cmsis.h:162
static OS_Uint os_thread_resume(OS_Thread *t)
Definition os_cmsis.h:158
static OS_Uint os_recursive_mutex_create(OS_Mutex *m, const char *name)
Definition os_cmsis.h:235
static OS_Uint os_event_group_set(OS_EventGroup *g, OS_Ulong flags)
Definition os_cmsis.h:320
static OS_Uint os_mutex_put(OS_Mutex *m)
Definition os_cmsis.h:226
static OS_Uint os_event_group_get(OS_EventGroup *g, OS_Ulong flags, OS_Uint option, OS_Ulong *actual, OS_Ulong wait)
Definition os_cmsis.h:330
OS_Critical os_critical_mux
Definition CriticalSection.cpp:11
static OS_Uint os_semaphore_create(OS_Semaphore *s, const char *name, OS_Uint initial)
Definition os_cmsis.h:256
static OS_Uint os_event_group_delete(OS_EventGroup *g)
Definition os_cmsis.h:316
static int os_kernel_is_running(void)
Definition os_cmsis.h:64
static OS_Uint os_mutex_get(OS_Mutex *m, OS_Ulong wait)
Definition os_cmsis.h:222
static OS_Uint os_mutex_delete(OS_Mutex *m)
Definition os_cmsis.h:230
static OS_Uint os_event_group_clear(OS_EventGroup *g, OS_Ulong flags)
Definition os_cmsis.h:325
static OS_Uint os_semaphore_info_get(OS_Semaphore *s, OS_Ulong *count)
Definition os_cmsis.h:275
static void os_critical_exit(void)
Definition os_cmsis.h:432
osEventFlagsId_t OS_EventGroup
Definition os_cmsis.h:31
static OS_Uint os_timer_create(OS_Timer *t, const char *name, void(*cb)(OS_Ulong), OS_Ulong id, OS_Ulong initial, OS_Ulong reload, OS_Uint auto_act)
Definition os_cmsis.h:355
static int os_thread_is_live(const OS_Thread *t)
Definition os_cmsis.h:192
static OS_Uint os_stream_buffer_send(OS_StreamBuffer *b, const void *data, size_t len, OS_Ulong wait)
Definition os_cmsis.h:407
static void os_cmsis_timer_entry(void *arg)
Definition os_cmsis.h:349
unsigned int OS_Uint
Definition os_cmsis.h:36
static void os_thread_clear(OS_Thread *t)
Definition os_cmsis.h:196
static OS_Uint os_queue_receive(OS_Queue *q, void *msg, OS_Ulong wait)
Definition os_cmsis.h:303
static OS_Uint os_thread_delete(OS_Thread *t)
Definition os_cmsis.h:166
static int os_get_current_core_id(void)
Definition os_cmsis.h:156
static OS_Uint os_timer_deactivate(OS_Timer *t)
Definition os_cmsis.h:389
osMessageQueueId_t OS_Queue
Definition os_cmsis.h:30
static OS_Uint os_mutex_create(OS_Mutex *m, const char *name, OS_Uint inherit)
Definition os_cmsis.h:212
unsigned long OS_Ulong
Definition os_cmsis.h:35
osThreadId_t OS_Thread
Definition os_cmsis.h:27
static OS_Uint os_recursive_mutex_put(OS_Mutex *m)
Definition os_cmsis.h:247
static OS_Uint os_recursive_mutex_delete(OS_Mutex *m)
Definition os_cmsis.h:251
static OS_Uint os_stream_buffer_receive(OS_StreamBuffer *b, void *data, size_t len, OS_Ulong wait)
Definition os_cmsis.h:416
osTimerId_t OS_Timer
Definition os_cmsis.h:32
uint8_t OS_Critical
Definition os_cmsis.h:426
static OS_Uint os_timer_activate(OS_Timer *t)
Definition os_cmsis.h:385
static OS_Uint os_stream_buffer_delete(OS_StreamBuffer *b)
Definition os_cmsis.h:402
static OS_Uint os_queue_create(OS_Queue *q, const char *name, OS_Uint item_words, void *, OS_Ulong length)
Definition os_cmsis.h:286
static OS_Uint os_thread_terminate(OS_Thread *t)
Definition os_cmsis.h:170
static OS_Uint os_thread_yield(void)
Definition os_cmsis.h:69
osSemaphoreId_t OS_Semaphore
Definition os_cmsis.h:29
static OS_Ulong os_time_get(void)
Definition os_cmsis.h:59
static OS_Uint os_event_group_create(OS_EventGroup *g, const char *name)
Definition os_cmsis.h:309
static OS_Uint os_queue_send(OS_Queue *q, void *msg, OS_Ulong wait)
Definition os_cmsis.h:298
static OS_Uint os_recursive_mutex_get(OS_Mutex *m, OS_Ulong wait)
Definition os_cmsis.h:243
static OS_Uint os_thread_is_current(const OS_Thread *t)
Definition os_cmsis.h:74
static OS_Uint os_thread_sleep(OS_Ulong ticks)
Definition os_cmsis.h:181
@ OS_THREAD_READY
Definition os_cmsis.h:187
@ OS_THREAD_BLOCKED
Definition os_cmsis.h:189
@ OS_THREAD_SUSPENDED
Definition os_cmsis.h:188
static int os_thread_state_is_suspended(OS_Uint state)
Definition os_cmsis.h:206
static OS_Uint os_timer_delete(OS_Timer *t)
Definition os_cmsis.h:381
static OS_Uint os_stream_buffer_create(OS_StreamBuffer *b, size_t capacity, size_t trigger)
Definition os_cmsis.h:394
static OS_Uint os_semaphore_delete(OS_Semaphore *s)
Definition os_cmsis.h:263
osMutexId_t OS_Mutex
Definition os_cmsis.h:28
static OS_Uint os_thread_create(OS_Thread *t, const char *name, void(*entry)(OS_Ulong), OS_Ulong input, uint8_t *stack, OS_Ulong stack_size, OS_Uint priority, OS_Uint, OS_Ulong, OS_Uint auto_start)
Definition os_cmsis.h:123
static OS_Uint os_thread_info_get(OS_Thread *t, OS_Uint *state)
Definition os_cmsis.h:174
Definition os_cmsis.h:110
void(* entry)(OS_Ulong)
Definition os_cmsis.h:111
OS_Ulong arg
Definition os_cmsis.h:112
Definition os_cmsis.h:344
OS_Ulong id
Definition os_cmsis.h:346
void(* cb)(OS_Ulong)
Definition os_cmsis.h:345