103#define osCMSIS 0x00010002
106#define osCMSIS_KERNEL 0x00010000
109#define osKernelSystemId "µOS++"
112#define osFeature_MainThread 0
113#define osFeature_Pool 1
114#define osFeature_MailQ 1
115#define osFeature_MessageQ 1
116#define osFeature_Signals 8
117#define osFeature_Semaphore 30
118#define osFeature_Wait 1
119#define osFeature_SysTick 1
152#define osWaitForever 0xFFFFFFFF
270#pragma GCC diagnostic push
271#pragma GCC diagnostic ignored "-Wpadded"
288#pragma GCC diagnostic pop
321#pragma GCC diagnostic push
322#pragma GCC diagnostic ignored "-Wpadded"
390#pragma GCC diagnostic pop
422#if (defined (osFeature_SysTick) && (osFeature_SysTick != 0))
444#define osKernelSysTickFrequency (OS_INTEGER_SYSTICK_FREQUENCY_HZ)
457#define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000)
478#if defined (osObjectsExternal)
479#define osThreadDef(name, priority, instances, stacksz) \
480extern const osThreadDef_t os_thread_def_##name
482#define osThreadAllocatedDef(name, priority, instances, stacksz) \
484 osThread data[instances]; \
486const osThreadDef_t os_thread_def_##name = \
489 (os_pthread)(name), \
493 &os_thread_##name.data[0], \
496#define osThreadStaticDef(name, priority, instances, stacksz) \
498 uint64_t stack[(instances)*((stacksz+sizeof(uint64_t)-1)/sizeof(uint64_t))]; \
499 osThread data[instances]; \
501const osThreadDef_t os_thread_def_##name = \
504 (os_pthread)(name), \
508 &os_thread_##name.data[0], \
509 &os_thread_##name.stack[0] \
511#if defined(osObjectsStatic)
512#define osThreadDef(name, priority, instances, stacksz) osThreadStaticDef(name, priority, instances, stacksz)
514#define osThreadDef(name, priority, instances, stacksz) osThreadAllocatedDef(name, priority, instances, stacksz)
528#define osThread(name) \
616#if (defined (osFeature_Wait) && (osFeature_Wait != 0))
647#if defined (osObjectsExternal)
648#define osTimerDef(name, function) \
649extern const osTimerDef_t os_timer_def_##name
651#define osTimerDef(name, function) \
655const osTimerDef_t os_timer_def_##name = \
658 (os_ptimer)(function), \
659 &os_timer_##name.data \
673#define osTimer(name) \
777#if defined (osObjectsExternal)
778#define osMutexDef(name) \
779extern const osMutexDef_t os_mutex_def_##name
781#define osMutexDef(name) \
782osMutex os_mutex_data_##name; \
783const osMutexDef_t os_mutex_def_##name = \
786 &os_mutex_data_##name \
800#define osMutex(name) \
860#if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0))
869#if defined (osObjectsExternal)
870#define osSemaphoreDef(name) \
871extern const osSemaphoreDef_t os_semaphore_def_##name
873#define osSemaphoreDef(name) \
874osSemaphore os_semaphore_data_##name; \
875const osSemaphoreDef_t os_semaphore_def_##name = \
878 &os_semaphore_data_##name \
890#define osSemaphore(name) \
891&os_semaphore_def_##name
948#if (defined (osFeature_Pool) && (osFeature_Pool != 0))
959#if defined (osObjectsExternal)
960#define osPoolDef(name, no, type) \
961extern const osPoolDef_t os_pool_def_##name
963#define osPoolAllocatedDef(name, items, type) \
967const osPoolDef_t os_pool_def_##name = \
974 &os_pool_##name.data \
976#define osPoolStaticDef(name, items, type) \
983const osPoolDef_t os_pool_def_##name = \
988 &os_pool_##name.storage, \
989 sizeof(os_pool_##name.storage), \
990 &os_pool_##name.data \
992#if defined(osObjectsStatic)
993#define osPoolDef(name, items, type) osPoolStaticDef(name, items, type)
995#define osPoolDef(name, items, type) osPoolAllocatedDef(name, items, type)
1006#define osPool(name) \
1058#if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0))
1069#if defined (osObjectsExternal)
1070#define osMessageQDef(name, queue_sz, type) \
1071extern const osMessageQDef_t os_messageQ_def_##name
1073#define osMessageQAllocatedDef(name, items, type) \
1076} os_messageQ_##name; \
1077const osMessageQDef_t os_messageQ_def_##name = { \
1083 &os_messageQ_##name.data \
1085#define osMessageQStaticDef(name, items, type) \
1089 void* queue[items]; \
1090 os_mqueue_index_t links[2 * items]; \
1091 os_mqueue_prio_t prios[items]; \
1093} os_messageQ_##name; \
1094const osMessageQDef_t os_messageQ_def_##name = { \
1098 &os_messageQ_##name.storage, \
1099 sizeof(os_messageQ_##name.storage), \
1100 &os_messageQ_##name.data \
1103#if defined(osObjectsStatic)
1104#define osMessageQDef(name, items, type) osMessageQStaticDef(name, items, type)
1106#define osMessageQDef(name, items, type) osMessageQAllocatedDef(name, items, type)
1120#define osMessageQ(name) \
1121&os_messageQ_def_##name
1170#if (defined (osFeature_MailQ) && (osFeature_MailQ != 0))
1180#if defined (osObjectsExternal)
1181#define osMailQDef(name, queue_sz, type) \
1182extern const osMailQDef_t os_mailQ_def_##name
1184#define osMailQAllocatedDef(name, items, type) \
1191 void* queue[items]; \
1192 os_mqueue_index_t links[2 * items]; \
1193 os_mqueue_prio_t prios[items]; \
1196const osMailQDef_t os_mailQ_def_##name = { \
1205 &os_mailQ_##name.data \
1207#define osMailQStaticDef(name, items, type) \
1214 void* queue[items]; \
1215 os_mqueue_index_t links[2 * items]; \
1216 os_mqueue_prio_t prios[items]; \
1219const osMailQDef_t os_mailQ_def_##name = { \
1224 &os_mailQ_##name.pool_storage, \
1225 sizeof(os_mailQ_##name.pool_storage), \
1226 &os_mailQ_##name.queue_storage, \
1227 sizeof(os_mailQ_##name.queue_storage), \
1228 &os_mailQ_##name.data \
1230#if defined(osObjectsStatic)
1231#define osMailQDef(name, items, type) osMailQStaticDef(name, items, type)
1233#define osMailQDef(name, items, type) osMailQAllocatedDef(name, items, type)
1244#define osMailQ(name) \
osStatus osMutexRelease(osMutexId mutex_id)
Release the mutex.
osStatus osDelay(uint32_t millisec)
Time Delay.
#define osSemaphore(name)
Access a Semaphore definition.
osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority)
Change thread priority.
#define osMutex(name)
Access a mutex.
osEvent osMailGet(osMailQId mail_id, uint32_t millisec)
Get a mail from a queue.
#define osTimer(name)
Access the timer.
struct os_timer_def osTimerDef_t
Timer definition structure contains timer parameters.
osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, void *args)
Create a timer.
osStatus osTimerStart(osTimerId timer_id, uint32_t millisec)
Start the timer.
#define osMessageQ(name)
Access a Message Queue.
osPoolId osPoolCreate(const osPoolDef_t *pool_def)
Create a memory pool.
osStatus osMailPut(osMailQId mail_id, void *mail)
Put a mail to a queue.
osEvent osSignalWait(int32_t signals, uint32_t millisec)
Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
osMutex * osMutexId
Mutex ID identifies the mutex (pointer to a mutex control block).
void(* os_pthread)(void const *argument)
Entry point of a thread.
int32_t osKernelRunning(void)
Check if the RTOS scheduler is started.
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
Set signal flags.
osPriority osThreadGetPriority(osThreadId thread_id)
Get thread priority.
osStatus osPoolFree(osPoolId pool_id, void *block)
Free a memory block.
struct os_mail_queue_s os_mail_queue_t
osMessageQ * osMessageQId
Message ID identifies the message queue (pointer to a message queue control block).
osStatus osKernelInitialize(void)
Initialize the RTOS.
struct os_messageQ_def osMessageQDef_t
Definition structure for message queue.
osPool * osPoolId
Pool ID identifies the memory pool (pointer to a memory pool control block).
osStatus osTimerStop(osTimerId timer_id)
Stop the timer.
osMutexId osMutexCreate(const osMutexDef_t *mutex_def)
Create a mutex.
osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec)
Wait for mutex.
#define osPool(name)
Access a Memory Pool definition.
osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
Get a message or Wait for a Message from a Queue.
osStatus osTimerDelete(osTimerId timer_id)
Delete the timer.
os_timer_attr_t osTimerAttr
void(* os_ptimer)(void const *argument)
Entry point of a timer call back function.
void * osMailAlloc(osMailQId mail_id, uint32_t millisec)
Allocate a memory block from a mail.
@ osPriorityRealtime
priority: realtime (highest)
@ osPriorityAboveNormal
priority: above normal
@ osPriorityBelowNormal
priority: below normal
@ osPriorityNormal
priority: normal (default)
@ osPriorityIdle
priority: idle (lowest)
@ osPriorityLow
priority: low
@ osPriorityHigh
priority: high
@ osPriorityError
system cannot determine priority or thread has illegal priority
void * osMailCAlloc(osMailQId mail_id, uint32_t millisec)
Allocate and clear a memory block from a mail.
osEvent osWait(uint32_t millisec)
Wait for Signal, Message, Mail, or Timeout.
int32_t osSignalClear(osThreadId thread_id, int32_t signals)
Clear the specified Signal Flags of an active thread.
osTimer * osTimerId
Timer ID identifies the timer (pointer to a timer control block).
struct os_thread_def osThreadDef_t
Thread definition structure contains startup information of a thread.
osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, int32_t count)
Create a semaphore.
void * osPoolCAlloc(osPoolId pool_id)
Allocate and clear a memory block.
osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *args)
Create a thread.
void * osPoolAlloc(osPoolId pool_id)
Allocate a memory block.
os_mempool_attr_t osPoolAttr
osStatus osKernelStart(void)
osStatus osMailFree(osMailQId mail_id, void *mail)
Free a memory block from a mail.
osStatus osSemaphoreRelease(osSemaphoreId semaphore_id)
Release the semaphore.
osThreadId osThreadGetId(void)
Get the current thread.
struct os_mailQ_def osMailQDef_t
Definition structure for mail queue.
osMailQId osMailCreate(const osMailQDef_t *mail_def, osThreadId thread_id)
Create a mail queue.
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
Delete the semaphore.
os_semaphore_attr_t osSemaphoreAttr
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a message to a queue.
osStatus osMutexDelete(osMutexId mutex_id)
Delete the mutex.
struct os_mutex_def osMutexDef_t
Mutex definition structure contains setup information for a mutex.
struct os_pool_def osPoolDef_t
Definition structure for memory block allocation.
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
struct os_semaphore_def osSemaphoreDef_t
Semaphore definition structure contains setup information for a semaphore.
uint32_t osKernelSysTick(void)
Get the system timer counter.
os_mqueue_attr_t osMessageQAttr
osSemaphore * osSemaphoreId
Semaphore ID identifies the semaphore (pointer to a semaphore control block).
#define osMailQ(name)
Access a mail queue definition.
os_timer_type
Timer type value for the timer definition.
@ osTimerPeriodic
repeating timer
@ osTimerOnce
one-shot timer
os_thread_attr_t osThreadAttr
os_mutex_attr_t osMutexAttr
osStatus
Status code values returned by CMSIS-RTOS functions.
@ osEventMail
function completed; mail event occurred.
@ osErrorISR
not allowed in ISR context: the function cannot be called from interrupt service routines.
@ osErrorTimeoutResource
resource not available within given time: a specified resource was not available within the timeout p...
@ osErrorValue
value of a parameter is out of range.
@ osEventSignal
function completed; signal event occurred.
@ osErrorOS
unspecified RTOS error: run-time error but no other error message fits.
@ osEventTimeout
function completed; timeout occurred.
@ osErrorResource
resource not available: a specified resource was not available.
@ osOK
function completed; no error or event occurred.
@ osErrorPriority
system cannot determine priority or thread has illegal priority.
@ osErrorParameter
parameter error: a mandatory parameter was missing or specified an incorrect object.
@ os_status_reserved
prevent from enum down-size compiler optimization.
@ osEventMessage
function completed; message event occurred.
@ osErrorNoMemory
system is out of memory: it was impossible to allocate or reserve memory for the operation.
@ osErrorISRRecursive
function called multiple times from ISR with same object.
osStatus osThreadTerminate(osThreadId thread_id)
Terminate a thread.
#define osThread(name)
Access a Thread definition.
osStatus osThreadYield(void)
Yield control.
osMailQ * osMailQId
Mail ID identifies the mail queue (pointer to a mail queue control block).
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create a message queue.
osThread * osThreadId
Thread ID identifies the thread (pointer to a thread control block).
@ os_thread_priority_error
@ os_thread_priority_below_normal
@ os_thread_priority_high
@ os_thread_priority_realtime
@ os_thread_priority_idle
@ os_thread_priority_normal
@ os_thread_priority_above_normal
Event structure contains detailed information about an event.
uint32_t v
message as 32-bit value
void * p
message or mail as void pointer
osStatus status
status code: event or error information
int32_t signals
signal flags
osMailQId mail_id
mail id obtained by osMailCreate
osMessageQId message_id
message id obtained by osMessageCreate
Definition structure for mail queue.
uint32_t items
number of elements in the queue
void * queue
pointer to memory array for queue
uint32_t queue_item_sz
size of a queue item
uint32_t pool_item_sz
size of a pool item
void * pool
pointer to memory array for pool
Memory pool object storage.
Definition structure for message queue.
void * queue
pointer to memory array for messages
uint32_t items
number of elements in the queue
uint32_t item_sz
size of an item
Message queue attributes.
Message queue object storage.
Mutex definition structure contains setup information for a mutex.
Definition structure for memory block allocation.
uint32_t item_sz
size of an item
void * pool
pointer to memory for pool
uint32_t items
number of items (elements) in the pool
Semaphore definition structure contains setup information for a semaphore.
Semaphore object storage.
Thread definition structure contains startup information of a thread.
os_pthread pthread
start address of thread function
osPriority tpriority
initial thread priority
uint32_t stacksize
stack size requirements in bytes; 0 is default stack size
uint32_t instances
maximum number of instances of that thread function
Timer definition structure contains timer parameters.
os_ptimer ptimer
start address of a timer function