134 #define osCMSIS 0x20001U 136 #define osCMSIS_RTX 0x50003U 138 #define osKernelSystemId "RTX V5.3" 140 #define osFeature_MainThread 0 141 #define osFeature_Signals 31U
142 #define osFeature_Semaphore 65535U
143 #define osFeature_Wait 0
144 #define osFeature_SysTick 1
145 #define osFeature_Pool 1
146 #define osFeature_MessageQ 1
147 #define osFeature_MailQ 1
149 #if defined(__CC_ARM) 150 #define os_InRegs __value_in_regs 151 #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 152 #define os_InRegs __attribute__((value_in_regs)) 157 #if (osCMSIS >= 0x20000U) 158 #include "cmsis_os2.h" 174 #if (osCMSIS < 0x20000U) 178 osPriorityBelowNormal = -1,
179 osPriorityNormal = 0,
180 osPriorityAboveNormal = +1,
182 osPriorityRealtime = +3,
183 osPriorityError = 0x84,
184 osPriorityReserved = 0x7FFFFFFF
187 #define osPriority osPriority_t 191 typedef void (*os_pthread) (
void const *argument);
194 typedef void (*os_ptimer) (
void const *argument);
197 #if (osCMSIS < 0x20000U) 203 #define os_timer_type osTimerType_t 207 #define osWaitForever 0xFFFFFFFFU 210 #if (osCMSIS < 0x20000U) 213 osEventSignal = 0x08,
214 osEventMessage = 0x10,
216 osEventTimeout = 0x40,
217 osErrorParameter = 0x80,
218 osErrorResource = 0x81,
219 osErrorTimeoutResource = 0xC1,
221 osErrorISRRecursive = 0x83,
222 osErrorPriority = 0x84,
223 osErrorNoMemory = 0x85,
226 osStatusReserved = 0x7FFFFFFF
229 typedef int32_t osStatus;
230 #define osEventSignal (0x08) 231 #define osEventMessage (0x10) 232 #define osEventMail (0x20) 233 #define osEventTimeout (0x40) 234 #define osErrorOS osError 235 #define osErrorTimeoutResource osErrorTimeout 236 #define osErrorISRRecursive (-126) 237 #define osErrorValue (-127) 238 #define osErrorPriority (-128) 245 #if (osCMSIS < 0x20000U) 246 typedef void *osThreadId;
248 #define osThreadId osThreadId_t 252 #if (osCMSIS < 0x20000U) 253 typedef void *osTimerId;
255 #define osTimerId osTimerId_t 259 #if (osCMSIS < 0x20000U) 260 typedef void *osMutexId;
262 #define osMutexId osMutexId_t 266 #if (osCMSIS < 0x20000U) 267 typedef void *osSemaphoreId;
269 #define osSemaphoreId osSemaphoreId_t 273 typedef void *osPoolId;
276 typedef void *osMessageQId;
279 typedef void *osMailQId;
283 #if (osCMSIS < 0x20000U) 286 osPriority tpriority;
298 #if (osCMSIS < 0x20000U) 310 #if (osCMSIS < 0x20000U) 311 typedef struct os_mutex_def {
315 #define osMutexDef_t osMutexAttr_t 319 #if (osCMSIS < 0x20000U) 320 typedef struct os_semaphore_def {
324 #define osSemaphoreDef_t osSemaphoreAttr_t 328 #if (osCMSIS < 0x20000U) 343 #if (osCMSIS < 0x20000U) 356 #if (osCMSIS < 0x20000U) 392 #if (osCMSIS < 0x20000U) 393 osStatus osKernelInitialize (
void);
398 #if (osCMSIS < 0x20000U) 399 osStatus osKernelStart (
void);
404 #if (osCMSIS < 0x20000U) 405 int32_t osKernelRunning(
void);
408 #if (defined(osFeature_SysTick) && (osFeature_SysTick != 0)) // System Timer available 412 #if (osCMSIS < 0x20000U) 413 uint32_t osKernelSysTick (
void);
415 #define osKernelSysTick osKernelGetSysTimerCount 420 #if (osCMSIS < 0x20000U) 421 #define osKernelSysTickFrequency 100000000 427 #if (osCMSIS < 0x20000U) 428 #define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000) 430 #define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * osKernelGetSysTimerFreq()) / 1000000) 433 #endif // System Timer available 442 #if defined (osObjectsExternal) // object is external 443 #define osThreadDef(name, priority, stacksz) \ 444 extern const osThreadDef_t os_thread_def_##name 445 #else // define the object 446 #if (osCMSIS < 0x20000U) 447 #define osThreadDef(name, priority, stacksz) \ 448 const osThreadDef_t os_thread_def_##name = \ 449 { (name), (priority), 1, (stacksz) } 451 #define osThreadDef(name, priority, stacksz) \ 452 uint64_t os_thread_stack##name[(stacksz)?(((stacksz+7)/8)):1] __attribute__((section(".bss.os.thread.stack"))); \ 453 static osRtxThread_t os_thread_cb_##name __attribute__((section(".bss.os.thread.cb"))); \ 454 const osThreadDef_t os_thread_def_##name = \ 456 { NULL, osThreadDetached, \ 457 &os_thread_cb_##name,\ 459 (stacksz) ? (&os_thread_stack##name) : NULL, \ 461 (priority), 0U, 0U } } 467 #define osThread(name) \ 468 &os_thread_def_##name 474 osThreadId osThreadCreate (
const osThreadDef_t *thread_def,
void *argument);
478 #if (osCMSIS < 0x20000U) 479 osThreadId osThreadGetId (
void);
486 #if (osCMSIS < 0x20000U) 487 osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority);
493 #if (osCMSIS < 0x20000U) 494 osPriority osThreadGetPriority (osThreadId thread_id);
499 #if (osCMSIS < 0x20000U) 500 osStatus osThreadYield (
void);
506 #if (osCMSIS < 0x20000U) 507 osStatus osThreadTerminate (osThreadId thread_id);
517 int32_t osSignalSet (osThreadId thread_id, int32_t signals);
523 int32_t osSignalClear (osThreadId thread_id, int32_t signals);
529 os_InRegs
osEvent osSignalWait (int32_t signals, uint32_t millisec);
537 #if (osCMSIS < 0x20000U) 538 osStatus osDelay (uint32_t millisec);
541 #if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available 546 os_InRegs
osEvent osWait (uint32_t millisec);
548 #endif // Generic Wait available 556 #if defined (osObjectsExternal) // object is external 557 #define osTimerDef(name, function) \ 558 extern const osTimerDef_t os_timer_def_##name 559 #else // define the object 560 #if (osCMSIS < 0x20000U) 561 #define osTimerDef(name, function) \ 562 const osTimerDef_t os_timer_def_##name = { (function) } 564 #define osTimerDef(name, function) \ 565 static osRtxTimer_t os_timer_cb_##name __attribute__((section(".bss.os.timer.cb"))); \ 566 const osTimerDef_t os_timer_def_##name = \ 567 { (function), { NULL, 0U, (&os_timer_cb_##name), osRtxTimerCbSize } } 573 #define osTimer(name) \ 581 osTimerId osTimerCreate (
const osTimerDef_t *timer_def, os_timer_type type,
void *argument);
587 #if (osCMSIS < 0x20000U) 588 osStatus osTimerStart (osTimerId timer_id, uint32_t millisec);
594 #if (osCMSIS < 0x20000U) 595 osStatus osTimerStop (osTimerId timer_id);
601 #if (osCMSIS < 0x20000U) 602 osStatus osTimerDelete (osTimerId timer_id);
610 #if defined (osObjectsExternal) // object is external 611 #define osMutexDef(name) \ 612 extern const osMutexDef_t os_mutex_def_##name 613 #else // define the object 614 #if (osCMSIS < 0x20000U) 615 #define osMutexDef(name) \ 616 const osMutexDef_t os_mutex_def_##name = { 0 } 618 #define osMutexDef(name) \ 619 static osRtxMutex_t os_mutex_cb_##name __attribute__((section(".bss.os.mutex.cb"))); \ 620 const osMutexDef_t os_mutex_def_##name = \ 621 { NULL, osMutexRecursive | osMutexPrioInherit | osMutexRobust, (&os_mutex_cb_##name), osRtxMutexCbSize } 627 #define osMutex(name) \ 633 osMutexId osMutexCreate (
const osMutexDef_t *mutex_def);
639 #if (osCMSIS < 0x20000U) 640 osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec);
642 #define osMutexWait osMutexAcquire 648 #if (osCMSIS < 0x20000U) 649 osStatus osMutexRelease (osMutexId mutex_id);
655 #if (osCMSIS < 0x20000U) 656 osStatus osMutexDelete (osMutexId mutex_id);
662 #if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0U)) // Semaphore available 666 #if defined (osObjectsExternal) // object is external 667 #define osSemaphoreDef(name) \ 668 extern const osSemaphoreDef_t os_semaphore_def_##name 669 #else // define the object 670 #if (osCMSIS < 0x20000U) 671 #define osSemaphoreDef(name) \ 672 const osSemaphoreDef_t os_semaphore_def_##name = { 0 } 674 #define osSemaphoreDef(name) \ 675 static osRtxSemaphore_t os_semaphore_cb_##name __attribute__((section(".bss.os.semaphore.cb"))); \ 676 const osSemaphoreDef_t os_semaphore_def_##name = \ 677 { NULL, 0U, (&os_semaphore_cb_##name), osRtxSemaphoreCbSize } 683 #define osSemaphore(name) \ 684 &os_semaphore_def_##name 690 osSemaphoreId osSemaphoreCreate (
const osSemaphoreDef_t *semaphore_def, int32_t count);
696 int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec);
701 #if (osCMSIS < 0x20000U) 702 osStatus osSemaphoreRelease (osSemaphoreId semaphore_id);
708 #if (osCMSIS < 0x20000U) 709 osStatus osSemaphoreDelete (osSemaphoreId semaphore_id);
712 #endif // Semaphore available 717 #if (defined(osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool available 723 #if defined (osObjectsExternal) // object is external 724 #define osPoolDef(name, no, type) \ 725 extern const osPoolDef_t os_pool_def_##name 726 #else // define the object 727 #if (osCMSIS < 0x20000U) 728 #define osPoolDef(name, no, type) \ 729 const osPoolDef_t os_pool_def_##name = \ 730 { (no), sizeof(type), NULL } 732 #define osPoolDef(name, no, type) \ 733 static osRtxMemoryPool_t os_mp_cb_##name __attribute__((section(".bss.os.mempool.cb"))); \ 734 static uint32_t os_mp_data_##name[osRtxMemoryPoolMemSize((no),sizeof(type))/4] __attribute__((section(".bss.os.mempool.mem"))); \ 735 const osPoolDef_t os_pool_def_##name = \ 736 { (no), sizeof(type), \ 737 { NULL, 0U, (&os_mp_cb_##name), osRtxMemoryPoolCbSize, \ 738 (&os_mp_data_##name), sizeof(os_mp_data_##name) } } 744 #define osPool(name) \ 750 osPoolId osPoolCreate (
const osPoolDef_t *pool_def);
755 void *osPoolAlloc (osPoolId pool_id);
760 void *osPoolCAlloc (osPoolId pool_id);
766 osStatus osPoolFree (osPoolId pool_id,
void *block);
768 #endif // Memory Pool available 773 #if (defined(osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queue available 779 #if defined (osObjectsExternal) // object is external 780 #define osMessageQDef(name, queue_sz, type) \ 781 extern const osMessageQDef_t os_messageQ_def_##name 782 #else // define the object 783 #if (osCMSIS < 0x20000U) 784 #define osMessageQDef(name, queue_sz, type) \ 785 const osMessageQDef_t os_messageQ_def_##name = \ 788 #define osMessageQDef(name, queue_sz, type) \ 789 static osRtxMessageQueue_t os_mq_cb_##name __attribute__((section(".bss.os.msgqueue.cb"))); \ 790 static uint32_t os_mq_data_##name[osRtxMessageQueueMemSize((queue_sz),sizeof(uint32_t))/4] __attribute__((section(".bss.os.msgqueue.mem"))); \ 791 const osMessageQDef_t os_messageQ_def_##name = \ 793 { NULL, 0U, (&os_mq_cb_##name), osRtxMessageQueueCbSize, \ 794 (&os_mq_data_##name), sizeof(os_mq_data_##name) } } 800 #define osMessageQ(name) \ 801 &os_messageQ_def_##name 807 osMessageQId osMessageCreate (
const osMessageQDef_t *queue_def, osThreadId thread_id);
814 osStatus osMessagePut (osMessageQId queue_id, uint32_t
info, uint32_t millisec);
820 os_InRegs
osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec);
822 #endif // Message Queue available 827 #if (defined(osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queue available 833 #if defined (osObjectsExternal) // object is external 834 #define osMailQDef(name, queue_sz, type) \ 835 extern const osMailQDef_t os_mailQ_def_##name 836 #else // define the object 837 #if (osCMSIS < 0x20000U) 838 #define osMailQDef(name, queue_sz, type) \ 839 const osMailQDef_t os_mailQ_def_##name = \ 840 { (queue_sz), sizeof(type), NULL } 842 #define osMailQDef(name, queue_sz, type) \ 843 static void *os_mail_p_##name[2] __attribute__((section(".bss.os"))); \ 844 static osRtxMemoryPool_t os_mail_mp_cb_##name __attribute__((section(".bss.os.mempool.cb"))); \ 845 static osRtxMessageQueue_t os_mail_mq_cb_##name __attribute__((section(".bss.os.msgqueue.cb"))); \ 846 static uint32_t os_mail_mp_data_##name[osRtxMemoryPoolMemSize ((queue_sz),sizeof(type) )/4] __attribute__((section(".bss.os.mempool.mem"))); \ 847 static uint32_t os_mail_mq_data_##name[osRtxMessageQueueMemSize((queue_sz),sizeof(void*))/4] __attribute__((section(".bss.os.msgqueue.mem"))); \ 848 const osMailQDef_t os_mailQ_def_##name = \ 849 { (queue_sz), sizeof(type), (&os_mail_p_##name), \ 850 { NULL, 0U, (&os_mail_mp_cb_##name), osRtxMemoryPoolCbSize, \ 851 (&os_mail_mp_data_##name), sizeof(os_mail_mp_data_##name) }, \ 852 { NULL, 0U, (&os_mail_mq_cb_##name), osRtxMessageQueueCbSize, \ 853 (&os_mail_mq_data_##name), sizeof(os_mail_mq_data_##name) } } 859 #define osMailQ(name) \ 866 osMailQId osMailCreate (
const osMailQDef_t *queue_def, osThreadId thread_id);
872 void *osMailAlloc (osMailQId queue_id, uint32_t millisec);
878 void *osMailCAlloc (osMailQId queue_id, uint32_t millisec);
884 osStatus osMailPut (osMailQId queue_id,
const void *mail);
890 os_InRegs
osEvent osMailGet (osMailQId queue_id, uint32_t millisec);
896 osStatus osMailFree (osMailQId queue_id,
void *mail);
898 #endif // Mail Queue available 905 #endif // CMSIS_OS_H_ uint32_t item_sz
size of an item
uint32_t v
message as 32-bit value
Timer Definition structure contains timer parameters.
Thread Definition structure contains startup information of a thread.
void * mail
pointer to mail
Attributes structure for thread.
osMemoryPoolAttr_t attr
memory pool attributes
int32_t signals
signal flags
Definition structure for mail queue.
uint32_t item_sz
size of an item
uint32_t pool_sz
number of items (elements) in the pool
osTimerAttr_t attr
timer attributes
Attributes structure for memory pool.
os_pthread pthread
start address of thread function
Attributes structure for message queue.
void * p
message or mail as void pointer
osMailQId mail_id
mail id obtained by osMailCreate
Definition structure for message queue.
osStatus status
status code: event or error information
Event structure contains detailed information about an event.
osMessageQueueAttr_t attr
message queue attributes
Attributes structure for timer.
osMessageQueueAttr_t mq_attr
message queue attributes
osMessageQId message_id
message id obtained by osMessageCreate
os_ptimer ptimer
start address of a timer function
uint32_t queue_sz
number of elements in the queue
osMemoryPoolAttr_t mp_attr
memory pool attributes
uint32_t queue_sz
number of elements in the queue
Definition structure for memory block allocation.
osThreadAttr_t attr
thread attributes