This header file defines all objects when included in a C/C++ source file. When #define osObjectsExternal is present before the header file, the objects are defined as external symbols. A single consistent header file can therefore be used throughout the whole project.
#ifndef _CMSIS_OS_H
#define _CMSIS_OS_H
#define osCMSIS 0x10002
#define osCMSIS_KERNEL 0x10000
#define osKernelSystemId "KERNEL V1.00"
#define osFeature_MainThread 1
#define osFeature_Pool 1
#define osFeature_MailQ 1
#define osFeature_MessageQ 1
#define osFeature_Signals 8
#define osFeature_Semaphore 30
#define osFeature_Wait 1
#define osFeature_SysTick 1
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum {
#define osWaitForever 0xFFFFFFFF
typedef enum {
typedef enum {
typedef void (*
os_pthread) (
void const *argument);
typedef void (*
os_ptimer) (
void const *argument);
typedef struct os_thread_def {
uint32_t instances;
uint32_t stacksize;
typedef struct os_timer_def {
typedef struct os_mutex_def {
uint32_t dummy;
typedef struct os_semaphore_def {
uint32_t dummy;
typedef struct os_pool_def {
uint32_t pool_sz;
uint32_t item_sz;
void *pool;
typedef struct os_messageQ_def {
uint32_t queue_sz;
uint32_t item_sz;
void *pool;
typedef struct os_mailQ_def {
uint32_t queue_sz;
uint32_t item_sz;
void *pool;
typedef struct {
union {
uint32_t v;
void *p;
int32_t signals;
} value;
union {
osMailQId mail_id;
osMessageQId message_id;
} def;
#if (defined (osFeature_SysTick) && (osFeature_SysTick != 0)) // System Timer available
#define osKernelSysTickFrequency 100000000
#define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000)
#endif // System Timer available
#if defined (osObjectsExternal) // object is external
#define osThreadDef(name, priority, instances, stacksz) \
extern const osThreadDef_t os_thread_def_##name
#else // define the object
#define osThreadDef(name, priority, instances, stacksz) \
const osThreadDef_t os_thread_def_##name = \
{ (name), (priority), (instances), (stacksz) }
#endif
#define osThread(name) \
&os_thread_def_##name
#if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available
#endif // Generic Wait available
#if defined (osObjectsExternal) // object is external
#define osTimerDef(name, function) \
extern const osTimerDef_t os_timer_def_##name
#else // define the object
#define osTimerDef(name, function) \
const osTimerDef_t os_timer_def_##name = \
{ (function) }
#endif
#define osTimer(name) \
&os_timer_def_##name
int32_t
osSignalSet (osThreadId thread_id, int32_t signals);
#if defined (osObjectsExternal) // object is external
#define osMutexDef(name) \
extern const osMutexDef_t os_mutex_def_##name
#else // define the object
#define osMutexDef(name) \
const osMutexDef_t os_mutex_def_##name = { 0 }
#endif
#define osMutex(name) \
&os_mutex_def_##name
#if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0)) // Semaphore available
#if defined (osObjectsExternal) // object is external
#define osSemaphoreDef(name) \
extern const osSemaphoreDef_t os_semaphore_def_##name
#else // define the object
#define osSemaphoreDef(name) \
const osSemaphoreDef_t os_semaphore_def_##name = { 0 }
#endif
#define osSemaphore(name) \
&os_semaphore_def_##name
#endif // Semaphore available
#if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
#if defined (osObjectsExternal) // object is external
#define osPoolDef(name, no, type) \
extern const osPoolDef_t os_pool_def_##name
#else // define the object
#define osPoolDef(name, no, type) \
const osPoolDef_t os_pool_def_##name = \
{ (no), sizeof(type), NULL }
#endif
#define osPool(name) \
&os_pool_def_##name
#endif // Memory Pool Management available
#if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queues available
#if defined (osObjectsExternal) // object is external
#define osMessageQDef(name, queue_sz, type) \
extern const osMessageQDef_t os_messageQ_def_##name
#else // define the object
#define osMessageQDef(name, queue_sz, type) \
const osMessageQDef_t os_messageQ_def_##name = \
{ (queue_sz), sizeof (type) }
#endif
#define osMessageQ(name) \
&os_messageQ_def_##name
#endif // Message Queues available
#if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queues available
#if defined (osObjectsExternal) // object is external
#define osMailQDef(name, queue_sz, type) \
extern const osMailQDef_t os_mailQ_def_##name
#else // define the object
#define osMailQDef(name, queue_sz, type) \
const osMailQDef_t os_mailQ_def_##name = \
{ (queue_sz), sizeof (type) }
#endif
#define osMailQ(name) \
&os_mailQ_def_##name
void *
osMailAlloc (osMailQId queue_id, uint32_t millisec);
#endif // Mail Queues available
#ifdef __cplusplus
}
#endif
#endif // _CMSIS_OS_H