30 #define TRACE_LEVEL TRACE_LEVEL_OFF
53 #if (osCMSIS >= 0x10001)
66 #if (osCMSIS >= 0x10001)
71 osKernelStart(NULL, NULL);
89 osThreadDef_t threadDef;
92 memset(&threadDef, 0,
sizeof(threadDef));
95 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
96 threadDef.pthread = (os_pthread) taskCode;
97 threadDef.tpriority = (osPriority) params->
priority;
98 threadDef.instances = 1;
99 threadDef.stacksize = params->
stackSize *
sizeof(uint32_t);
100 #elif defined(osCMSIS_RTX) && (osCMSIS_RTX >= 0x50000)
101 threadDef.pthread = (os_pthread) taskCode;
102 threadDef.attr.name =
name;
103 threadDef.attr.attr_bits = 0;
104 threadDef.attr.cb_mem = NULL;
105 threadDef.attr.cb_size = 0;
106 threadDef.attr.stack_mem = NULL;
107 threadDef.attr.stack_size = params->
stackSize *
sizeof(uint32_t);
108 threadDef.attr.priority = (osPriority_t) params->
priority;
109 threadDef.attr.tz_module = 0;
110 #elif defined(osCMSIS_FreeRTOS)
111 threadDef.pthread = (os_pthread) taskCode;
112 threadDef.attr.name =
name;
113 threadDef.attr.attr_bits = 0;
114 threadDef.attr.cb_mem = NULL;
115 threadDef.attr.cb_size = 0;
116 threadDef.attr.stack_mem = NULL;
117 threadDef.attr.stack_size = params->
stackSize *
sizeof(uint32_t);
118 threadDef.attr.priority = (osPriority_t) params->
priority;
119 threadDef.attr.tz_module = 0;
122 threadDef.pthread = (os_pthread) taskCode;
123 threadDef.tpriority = (osPriority) params->
priority;
124 threadDef.instances = 1;
129 threadId = osThreadCreate(&threadDef, arg);
143 #if (osCMSIS >= 0x20000)
151 osThreadTerminate((osThreadId_t) taskId);
155 osThreadTerminate((osThreadId) taskId);
189 #if defined(osCMSIS_RTX) || defined(osCMSIS_FreeRTOS)
193 if(osKernelRunning())
196 osThreadSuspendAll();
208 #if defined(osCMSIS_RTX) || defined(osCMSIS_FreeRTOS)
212 if(osKernelRunning())
230 osSemaphoreDef_t semaphoreDef;
232 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
233 semaphoreDef.semaphore =
event->cb;
234 #elif defined(osCMSIS_RTX) && (osCMSIS_RTX >= 0x50000)
235 semaphoreDef.name = NULL;
236 semaphoreDef.attr_bits = 0;
237 semaphoreDef.cb_mem = NULL;
238 semaphoreDef.cb_size = 0;
239 #elif defined(osCMSIS_FreeRTOS)
240 semaphoreDef.name = NULL;
241 semaphoreDef.attr_bits = 0;
242 semaphoreDef.cb_mem = NULL;
243 semaphoreDef.cb_size = 0;
245 semaphoreDef.dummy = 0;
249 event->id = osSemaphoreCreate(&semaphoreDef, 1);
252 if(event->
id != NULL)
255 osSemaphoreWait(event->
id, 0);
275 if(event->
id != NULL)
278 osSemaphoreDelete(event->
id);
291 osSemaphoreRelease(event->
id);
302 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
304 while(osSemaphoreWait(event->
id, 0) > 0)
309 osSemaphoreWait(event->
id, 0);
331 ret = osSemaphoreWait(event->
id, osWaitForever);
335 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
342 n =
MIN(timeout, 10000);
344 ret = osSemaphoreWait(event->
id,
n);
349 }
while(ret == 0 && timeout > 0);
352 ret = osSemaphoreWait(event->
id, timeout);
356 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
361 while(osSemaphoreWait(event->
id, 0) > 0)
373 #elif defined(osCMSIS_RTX) && (osCMSIS_RTX >= 0x50000)
383 #elif defined(osCMSIS_FreeRTOS)
417 osSemaphoreRelease(event->
id);
435 osSemaphoreDef_t semaphoreDef;
437 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
438 semaphoreDef.semaphore = semaphore->cb;
439 #elif defined(osCMSIS_RTX) && (osCMSIS_RTX >= 0x50000)
440 semaphoreDef.name = NULL;
441 semaphoreDef.attr_bits = 0;
442 semaphoreDef.cb_mem = NULL;
443 semaphoreDef.cb_size = 0;
444 #elif defined(osCMSIS_FreeRTOS)
445 semaphoreDef.name = NULL;
446 semaphoreDef.attr_bits = 0;
447 semaphoreDef.cb_mem = NULL;
448 semaphoreDef.cb_size = 0;
450 semaphoreDef.dummy = 0;
454 semaphore->
id = osSemaphoreCreate(&semaphoreDef, count);
457 if(semaphore->
id != NULL)
476 if(semaphore->
id != NULL)
479 osSemaphoreDelete(semaphore->
id);
500 ret = osSemaphoreWait(semaphore->
id, osWaitForever);
504 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
511 n =
MIN(timeout, 10000);
513 ret = osSemaphoreWait(semaphore->
id,
n);
518 }
while(ret == 0 && timeout > 0);
521 ret = osSemaphoreWait(semaphore->
id, timeout);
525 #if defined(osCMSIS_RTX) || defined(osCMSIS_FreeRTOS)
557 osSemaphoreRelease(semaphore->
id);
570 osMutexDef_t mutexDef;
572 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
573 mutexDef.mutex = mutex->cb;
574 #elif defined(osCMSIS_RTX) && (osCMSIS_RTX >= 0x50000)
575 mutexDef.name = NULL;
576 mutexDef.attr_bits = 0;
577 mutexDef.cb_mem = NULL;
578 mutexDef.cb_size = 0;
579 #elif defined(osCMSIS_FreeRTOS)
580 mutexDef.name = NULL;
581 mutexDef.attr_bits = 0;
582 mutexDef.cb_mem = NULL;
583 mutexDef.cb_size = 0;
589 mutex->
id = osMutexCreate(&mutexDef);
592 if(mutex->
id != NULL)
611 if(mutex->
id != NULL)
614 osMutexDelete(mutex->
id);
627 osMutexWait(mutex->
id, osWaitForever);
639 osMutexRelease(mutex->
id);
652 #if defined(osCMSIS_RTX) && (osCMSIS_RTX < 0x50000)
654 extern uint32_t rt_time_get(
void);
657 time = rt_time_get();
658 #elif defined(osCMSIS_RTX) && (osCMSIS_RTX >= 0x50000)
659 time = osKernelGetTickCount();
660 #elif defined(osCMSIS_FreeRTOS)
661 time = osKernelGetTickCount();
664 time = osKernelSysTick();
692 size, (uintptr_t)
p);
710 TRACE_DEBUG(
"Freeing memory at 0x%08" PRIXPTR
"\r\n", (uintptr_t)
p);