59 const UINT prio = (priority == 0u) ? 16u : (UINT)priority;
60 const UINT pre = (preempt == 0u) ? prio : (UINT)preempt;
61 const ULONG ts = (slice == 0u) ? TX_NO_TIME_SLICE : (ULONG)slice;
62 const UINT as = auto_start ? TX_AUTO_START : TX_DONT_START;
63 return (
OS_Uint)tx_thread_create(t, (CHAR*)name, (VOID (*)(ULONG))entry,
64 (ULONG)input, stack, (ULONG)stack_size,
74 OS_Uint auto_start,
int core_id)
78 priority, preempt, slice, auto_start);
83{
return (
OS_Uint)tx_thread_resume(t); }
85{
return (
OS_Uint)tx_thread_suspend(t); }
87{
return (
OS_Uint)tx_thread_delete(t); }
89{
return (
OS_Uint)tx_thread_terminate(t); }
93 CHAR *unused_name = 0;
96 UINT unused_preempt = 0;
97 ULONG unused_slice = 0;
98 TX_THREAD *unused_next = 0;
99 TX_THREAD *unused_suspended = 0;
101 const UINT err = tx_thread_info_get(t, &unused_name, &s, &unused_run,
102 &unused_prio, &unused_preempt,
103 &unused_slice, &unused_next,
111{
return (
OS_Uint)tx_thread_sleep((ULONG)ticks); }
113{ (void)tx_thread_relinquish();
return OS_SUCCESS; }
115{
return tx_thread_identify() != TX_NULL; }
117{
return (t != 0 && tx_thread_identify() == t) ? 1u : 0u; }
121 return (
OS_Uint)tx_mutex_create(m, (CHAR*)name,
122 inherit ? TX_INHERIT : TX_NO_INHERIT);
125{
return (
OS_Uint)tx_mutex_get(m, (ULONG)wait); }
127{
return (
OS_Uint)tx_mutex_put(m); }
129{
return (
OS_Uint)tx_mutex_delete(m); }
142 return (
OS_Uint)tx_semaphore_create(s, (CHAR*)name, (ULONG)initial);
145{
return (
OS_Uint)tx_semaphore_delete(s); }
147{
return (
OS_Uint)tx_semaphore_put(s); }
149{
return (
OS_Uint)tx_semaphore_get(s, (ULONG)wait); }
152 CHAR *unused_name = 0;
153 TX_THREAD *unused_first = 0;
154 ULONG unused_suspended = 0;
155 TX_SEMAPHORE *unused_next = 0;
157 const UINT err = tx_semaphore_info_get(s, &unused_name, &c, &unused_first,
158 &unused_suspended, &unused_next);
174 return (t != 0) && (t->tx_thread_id != 0u);
179 t->tx_thread_id = 0u;
184 return (m != 0) && (m->tx_mutex_id != 0u);
188 return (state != (
OS_Uint)TX_READY) &&
189 (state != (
OS_Uint)TX_COMPLETED) &&
190 (state != (
OS_Uint)TX_TERMINATED);
194#define OS_QUEUE_STORE_BYTES(item_words, length) \
195 ((size_t)(item_words) * sizeof(ULONG) * (size_t)(length))
200 return (
OS_Uint)tx_queue_create(q, (CHAR*)name, (UINT)item_words, store,
201 (ULONG)(length * item_words *
sizeof(ULONG)));
204{
return (
OS_Uint)tx_queue_delete(q); }
206{
return (
OS_Uint)tx_queue_send(q, msg, (ULONG)wait); }
208{
return (
OS_Uint)tx_queue_receive(q, msg, (ULONG)wait); }
211{
return (
OS_Uint)tx_event_flags_create(g, (CHAR*)name); }
213{
return (
OS_Uint)tx_event_flags_delete(g); }
215{
return (
OS_Uint)tx_event_flags_set(g, (ULONG)flags, TX_OR); }
217{
return (
OS_Uint)tx_event_flags_set(g, (ULONG)~flags, TX_AND); }
225 const UINT opt = all ? (clear ? TX_AND_CLEAR : TX_AND) : (clear ? TX_OR_CLEAR : TX_OR);
226 const UINT err = tx_event_flags_get(g, (ULONG)flags, opt, &got, (ULONG)wait);
238 const UINT err = tx_timer_create(t, (CHAR*)name, (VOID (*)(ULONG))cb,
239 (ULONG)
id, (ULONG)initial,
240 (ULONG)reload, TX_NO_ACTIVATE);
241 if (err != TX_SUCCESS) {
245 return (
OS_Uint)tx_timer_activate(t);
250{
return (
OS_Uint)tx_timer_delete(t); }
252{
return (
OS_Uint)tx_timer_activate(t); }
254{
return (
OS_Uint)tx_timer_deactivate(t); }
258{ (void)capacity; (void)trigger; *b = 0;
return OS_SUCCESS; }
262{ (void)b; (void)data; (void)len; (void)wait;
return (
OS_Uint)1; }
264{ (void)b; (void)data; (void)len; (void)wait;
return (
OS_Uint)1; }
void * OS_StreamBuffer
Definition os_cmsis.h:33
osEventFlagsId_t OS_EventGroup
Definition os_cmsis.h:31
unsigned int OS_Uint
Definition os_cmsis.h:36
osMessageQueueId_t OS_Queue
Definition os_cmsis.h:30
unsigned long OS_Ulong
Definition os_cmsis.h:35
osThreadId_t OS_Thread
Definition os_cmsis.h:27
osTimerId_t OS_Timer
Definition os_cmsis.h:32
uint8_t OS_Critical
Definition os_cmsis.h:426
osSemaphoreId_t OS_Semaphore
Definition os_cmsis.h:29
osMutexId_t OS_Mutex
Definition os_cmsis.h:28
static void os_critical_enter(void)
Definition os_threadx.h:268
@ OS_THREAD_READY
Definition os_threadx.h:167
@ OS_THREAD_BLOCKED
Definition os_threadx.h:169
@ OS_THREAD_SUSPENDED
Definition os_threadx.h:168
static OS_Uint os_semaphore_put(OS_Semaphore *s)
Definition os_threadx.h:146
TX_TIMER OS_Timer
Definition os_threadx.h:32
static OS_Uint os_queue_delete(OS_Queue *q)
Definition os_threadx.h:203
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_threadx.h:69
static OS_Uint os_queue_create(OS_Queue *q, const char *name, OS_Uint item_words, void *store, OS_Ulong length)
Definition os_threadx.h:197
UINT OS_Critical
Definition os_threadx.h:266
static int os_mutex_is_live(const OS_Mutex *m)
Definition os_threadx.h:182
static OS_Uint os_semaphore_get(OS_Semaphore *s, OS_Ulong wait)
Definition os_threadx.h:148
void * OS_StreamBuffer
Definition os_threadx.h:33
static OS_Uint os_thread_suspend(OS_Thread *t)
Definition os_threadx.h:84
static OS_Uint os_thread_resume(OS_Thread *t)
Definition os_threadx.h:82
TX_SEMAPHORE OS_Semaphore
Definition os_threadx.h:29
static OS_Uint os_recursive_mutex_create(OS_Mutex *m, const char *name)
Definition os_threadx.h:131
static OS_Uint os_event_group_set(OS_EventGroup *g, OS_Ulong flags)
Definition os_threadx.h:214
static OS_Uint os_mutex_put(OS_Mutex *m)
Definition os_threadx.h:126
static OS_Uint os_event_group_get(OS_EventGroup *g, OS_Ulong flags, OS_Uint option, OS_Ulong *actual, OS_Ulong wait)
Definition os_threadx.h:218
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_threadx.h:140
static OS_Uint os_event_group_delete(OS_EventGroup *g)
Definition os_threadx.h:212
static int os_kernel_is_running(void)
Definition os_threadx.h:114
static OS_Uint os_mutex_get(OS_Mutex *m, OS_Ulong wait)
Definition os_threadx.h:124
static OS_Uint os_mutex_delete(OS_Mutex *m)
Definition os_threadx.h:128
static OS_Uint os_event_group_clear(OS_EventGroup *g, OS_Ulong flags)
Definition os_threadx.h:216
static OS_Uint os_semaphore_info_get(OS_Semaphore *s, OS_Ulong *count)
Definition os_threadx.h:150
static void os_critical_exit(void)
Definition os_threadx.h:270
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_threadx.h:233
static int os_thread_is_live(const OS_Thread *t)
Definition os_threadx.h:172
TX_EVENT_FLAGS_GROUP OS_EventGroup
Definition os_threadx.h:31
static OS_Uint os_stream_buffer_send(OS_StreamBuffer *b, const void *data, size_t len, OS_Ulong wait)
Definition os_threadx.h:261
@ OS_AUTO_START
Definition os_threadx.h:45
@ OS_SUCCESS
Definition os_threadx.h:41
@ OS_EVENT_CLEAR
Definition os_threadx.h:44
@ OS_DONT_START
Definition os_threadx.h:46
@ OS_INHERIT
Definition os_threadx.h:47
@ OS_OR
Definition os_threadx.h:43
@ OS_WAIT_FOREVER
Definition os_threadx.h:39
@ OS_AND
Definition os_threadx.h:42
@ OS_NO_WAIT
Definition os_threadx.h:40
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 preempt, OS_Ulong slice, OS_Uint auto_start)
Definition os_threadx.h:52
unsigned int OS_Uint
Definition os_threadx.h:36
static void os_thread_clear(OS_Thread *t)
Definition os_threadx.h:176
TX_MUTEX OS_Mutex
Definition os_threadx.h:28
static OS_Uint os_queue_receive(OS_Queue *q, void *msg, OS_Ulong wait)
Definition os_threadx.h:207
static OS_Uint os_thread_delete(OS_Thread *t)
Definition os_threadx.h:86
TX_QUEUE OS_Queue
Definition os_threadx.h:30
static int os_get_current_core_id(void)
Definition os_threadx.h:81
static OS_Uint os_timer_deactivate(OS_Timer *t)
Definition os_threadx.h:253
static OS_Uint os_mutex_create(OS_Mutex *m, const char *name, OS_Uint inherit)
Definition os_threadx.h:119
unsigned long OS_Ulong
Definition os_threadx.h:35
static OS_Uint os_recursive_mutex_put(OS_Mutex *m)
Definition os_threadx.h:135
static OS_Uint os_recursive_mutex_delete(OS_Mutex *m)
Definition os_threadx.h:137
static OS_Uint os_stream_buffer_receive(OS_StreamBuffer *b, void *data, size_t len, OS_Ulong wait)
Definition os_threadx.h:263
static OS_Uint os_timer_activate(OS_Timer *t)
Definition os_threadx.h:251
static OS_Uint os_stream_buffer_delete(OS_StreamBuffer *b)
Definition os_threadx.h:259
static OS_Uint os_thread_terminate(OS_Thread *t)
Definition os_threadx.h:88
static OS_Uint os_thread_yield(void)
Definition os_threadx.h:112
static OS_Ulong os_time_get(void)
Definition os_threadx.h:50
TX_THREAD OS_Thread
Definition os_threadx.h:27
static OS_Uint os_event_group_create(OS_EventGroup *g, const char *name)
Definition os_threadx.h:210
static OS_Uint os_queue_send(OS_Queue *q, void *msg, OS_Ulong wait)
Definition os_threadx.h:205
static OS_Uint os_recursive_mutex_get(OS_Mutex *m, OS_Ulong wait)
Definition os_threadx.h:133
static OS_Uint os_thread_is_current(const OS_Thread *t)
Definition os_threadx.h:116
static OS_Uint os_thread_sleep(OS_Ulong ticks)
Definition os_threadx.h:110
static int os_thread_state_is_suspended(OS_Uint state)
Definition os_threadx.h:186
static OS_Uint os_timer_delete(OS_Timer *t)
Definition os_threadx.h:249
static OS_Uint os_stream_buffer_create(OS_StreamBuffer *b, size_t capacity, size_t trigger)
Definition os_threadx.h:257
static OS_Uint os_semaphore_delete(OS_Semaphore *s)
Definition os_threadx.h:144
static OS_Uint os_thread_info_get(OS_Thread *t, OS_Uint *state)
Definition os_threadx.h:90