RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
os_cmsis.h File Reference

CMSIS-RTOS2 backend for the generic OS abstraction. More...

#include "cmsis_os2.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  os_cmsis_start_t
 
struct  os_cmsis_timer_cb_t
 

Macros

#define OS_ZERO_INIT   {0}
 
#define OS_QUEUE_STORE_BYTES(item_words, length)   ((size_t)0)
 

Typedefs

typedef osThreadId_t OS_Thread
 
typedef osMutexId_t OS_Mutex
 
typedef osSemaphoreId_t OS_Semaphore
 
typedef osMessageQueueId_t OS_Queue
 
typedef osEventFlagsId_t OS_EventGroup
 
typedef osTimerId_t OS_Timer
 
typedef void * OS_StreamBuffer
 
typedef unsigned long OS_Ulong
 
typedef unsigned int OS_Uint
 
typedef uint8_t OS_Critical
 

Enumerations

enum  {
  OS_WAIT_FOREVER = (int)osWaitForever , OS_NO_WAIT = 0 , OS_SUCCESS = 0 , OS_AND = 1 ,
  OS_OR = 2 , OS_EVENT_CLEAR = 0x10 , OS_AUTO_START = 1 , OS_DONT_START = 0 ,
  OS_INHERIT = 0
}
 
enum  { OS_THREAD_READY = osThreadReady , OS_THREAD_SUSPENDED = osThreadBlocked , OS_THREAD_BLOCKED = osThreadBlocked }
 

Functions

static OS_Ulong os_time_get (void)
 
static int os_kernel_is_running (void)
 
static OS_Uint os_thread_yield (void)
 
static OS_Uint os_thread_is_current (const OS_Thread *t)
 
static OS_Uint os_thread_spawn (OS_Thread *t, const char *name, void(*entry)(void *), void *arg, void *stack, OS_Ulong stack_size, OS_Uint priority, OS_Uint auto_start)
 Create a CMSIS thread. entry receives arg — no heap cookie.
 
static void os_cmsis_generic_entry (void *p)
 
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, OS_Ulong, OS_Uint auto_start)
 
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)
 
static int os_get_current_core_id (void)
 
static OS_Uint os_thread_resume (OS_Thread *t)
 
static OS_Uint os_thread_suspend (OS_Thread *t)
 
static OS_Uint os_thread_delete (OS_Thread *t)
 
static OS_Uint os_thread_terminate (OS_Thread *t)
 
static OS_Uint os_thread_info_get (OS_Thread *t, OS_Uint *state)
 
static OS_Uint os_thread_sleep (OS_Ulong ticks)
 
static int os_thread_is_live (const OS_Thread *t)
 
static void os_thread_clear (OS_Thread *t)
 
static int os_mutex_is_live (const OS_Mutex *m)
 
static int os_thread_state_is_suspended (OS_Uint state)
 
static OS_Uint os_mutex_create (OS_Mutex *m, const char *name, OS_Uint inherit)
 
static OS_Uint os_mutex_get (OS_Mutex *m, OS_Ulong wait)
 
static OS_Uint os_mutex_put (OS_Mutex *m)
 
static OS_Uint os_mutex_delete (OS_Mutex *m)
 
static OS_Uint os_recursive_mutex_create (OS_Mutex *m, const char *name)
 
static OS_Uint os_recursive_mutex_get (OS_Mutex *m, OS_Ulong wait)
 
static OS_Uint os_recursive_mutex_put (OS_Mutex *m)
 
static OS_Uint os_recursive_mutex_delete (OS_Mutex *m)
 
static OS_Uint os_semaphore_create (OS_Semaphore *s, const char *name, OS_Uint initial)
 
static OS_Uint os_semaphore_delete (OS_Semaphore *s)
 
static OS_Uint os_semaphore_put (OS_Semaphore *s)
 
static OS_Uint os_semaphore_get (OS_Semaphore *s, OS_Ulong wait)
 
static OS_Uint os_semaphore_info_get (OS_Semaphore *s, OS_Ulong *count)
 
static OS_Uint os_queue_create (OS_Queue *q, const char *name, OS_Uint item_words, void *, OS_Ulong length)
 
static OS_Uint os_queue_delete (OS_Queue *q)
 
static OS_Uint os_queue_send (OS_Queue *q, void *msg, OS_Ulong wait)
 
static OS_Uint os_queue_receive (OS_Queue *q, void *msg, OS_Ulong wait)
 
static OS_Uint os_event_group_create (OS_EventGroup *g, const char *name)
 
static OS_Uint os_event_group_delete (OS_EventGroup *g)
 
static OS_Uint os_event_group_set (OS_EventGroup *g, OS_Ulong flags)
 
static OS_Uint os_event_group_clear (OS_EventGroup *g, OS_Ulong flags)
 
static OS_Uint os_event_group_get (OS_EventGroup *g, OS_Ulong flags, OS_Uint option, OS_Ulong *actual, OS_Ulong wait)
 
static void os_cmsis_timer_entry (void *arg)
 
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)
 
static OS_Uint os_timer_delete (OS_Timer *t)
 
static OS_Uint os_timer_activate (OS_Timer *t)
 
static OS_Uint os_timer_deactivate (OS_Timer *t)
 
static OS_Uint os_stream_buffer_create (OS_StreamBuffer *b, size_t capacity, size_t trigger)
 
static OS_Uint os_stream_buffer_delete (OS_StreamBuffer *b)
 
static OS_Uint os_stream_buffer_send (OS_StreamBuffer *b, const void *data, size_t len, OS_Ulong wait)
 
static OS_Uint os_stream_buffer_receive (OS_StreamBuffer *b, void *data, size_t len, OS_Ulong wait)
 
static void os_critical_enter (void)
 
static void os_critical_exit (void)
 

Variables

OS_Critical os_critical_mux
 

Detailed Description

CMSIS-RTOS2 backend for the generic OS abstraction.

Included only by OsAbstraction.h when HF_RTOS_CMSIS is selected, or by the product BaseThread TU when PW_RTOS_BACKEND=cmsis_rtos2. Do not include this header from apps.

Create/sleep/yield are static inline 1:1 maps onto osThreadNew / osDelay / osThreadYield. No extra delay and no heap trampoline on os_thread_spawn (argument is the caller's void*).

See also
os/README.md

Macro Definition Documentation

◆ OS_QUEUE_STORE_BYTES

#define OS_QUEUE_STORE_BYTES (   item_words,
  length 
)    ((size_t)0)

The kernel allocates CMSIS-RTOS2 queues; os_queue_create() needs no caller storage.

◆ OS_ZERO_INIT

#define OS_ZERO_INIT   {0}

Typedef Documentation

◆ OS_Critical

typedef uint8_t OS_Critical

◆ OS_EventGroup

typedef osEventFlagsId_t OS_EventGroup

◆ OS_Mutex

typedef osMutexId_t OS_Mutex

◆ OS_Queue

typedef osMessageQueueId_t OS_Queue

◆ OS_Semaphore

typedef osSemaphoreId_t OS_Semaphore

◆ OS_StreamBuffer

typedef void* OS_StreamBuffer

◆ OS_Thread

typedef osThreadId_t OS_Thread

◆ OS_Timer

typedef osTimerId_t OS_Timer

◆ OS_Uint

typedef unsigned int OS_Uint

◆ OS_Ulong

typedef unsigned long OS_Ulong

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OS_WAIT_FOREVER 
OS_NO_WAIT 
OS_SUCCESS 
OS_AND 
OS_OR 
OS_EVENT_CLEAR 

OR into an event-group wait option: clear the awaited bits on success

OS_AUTO_START 
OS_DONT_START 
OS_INHERIT 

◆ anonymous enum

anonymous enum
Enumerator
OS_THREAD_READY 
OS_THREAD_SUSPENDED 
OS_THREAD_BLOCKED 

Function Documentation

◆ os_cmsis_generic_entry()

static void os_cmsis_generic_entry ( void *  p)
inlinestatic

◆ os_cmsis_timer_entry()

static void os_cmsis_timer_entry ( void *  arg)
inlinestatic

◆ os_critical_enter()

static void os_critical_enter ( void  )
inlinestatic

◆ os_critical_exit()

static void os_critical_exit ( void  )
inlinestatic

◆ os_event_group_clear()

static OS_Uint os_event_group_clear ( OS_EventGroup *  g,
OS_Ulong  flags 
)
inlinestatic

◆ os_event_group_create()

static OS_Uint os_event_group_create ( OS_EventGroup *  g,
const char *  name 
)
inlinestatic

◆ os_event_group_delete()

static OS_Uint os_event_group_delete ( OS_EventGroup *  g)
inlinestatic

◆ os_event_group_get()

static OS_Uint os_event_group_get ( OS_EventGroup *  g,
OS_Ulong  flags,
OS_Uint  option,
OS_Ulong *  actual,
OS_Ulong  wait 
)
inlinestatic

◆ os_event_group_set()

static OS_Uint os_event_group_set ( OS_EventGroup *  g,
OS_Ulong  flags 
)
inlinestatic

◆ os_get_current_core_id()

static int os_get_current_core_id ( void  )
inlinestatic

◆ os_kernel_is_running()

static int os_kernel_is_running ( void  )
inlinestatic

◆ os_mutex_create()

static OS_Uint os_mutex_create ( OS_Mutex *  m,
const char *  name,
OS_Uint  inherit 
)
inlinestatic

◆ os_mutex_delete()

static OS_Uint os_mutex_delete ( OS_Mutex *  m)
inlinestatic

◆ os_mutex_get()

static OS_Uint os_mutex_get ( OS_Mutex *  m,
OS_Ulong  wait 
)
inlinestatic

◆ os_mutex_is_live()

static int os_mutex_is_live ( const OS_Mutex *  m)
inlinestatic

◆ os_mutex_put()

static OS_Uint os_mutex_put ( OS_Mutex *  m)
inlinestatic

◆ os_queue_create()

static OS_Uint os_queue_create ( OS_Queue *  q,
const char *  name,
OS_Uint  item_words,
void *  ,
OS_Ulong  length 
)
inlinestatic

◆ os_queue_delete()

static OS_Uint os_queue_delete ( OS_Queue *  q)
inlinestatic

◆ os_queue_receive()

static OS_Uint os_queue_receive ( OS_Queue *  q,
void *  msg,
OS_Ulong  wait 
)
inlinestatic

◆ os_queue_send()

static OS_Uint os_queue_send ( OS_Queue *  q,
void *  msg,
OS_Ulong  wait 
)
inlinestatic

◆ os_recursive_mutex_create()

static OS_Uint os_recursive_mutex_create ( OS_Mutex *  m,
const char *  name 
)
inlinestatic

◆ os_recursive_mutex_delete()

static OS_Uint os_recursive_mutex_delete ( OS_Mutex *  m)
inlinestatic

◆ os_recursive_mutex_get()

static OS_Uint os_recursive_mutex_get ( OS_Mutex *  m,
OS_Ulong  wait 
)
inlinestatic

◆ os_recursive_mutex_put()

static OS_Uint os_recursive_mutex_put ( OS_Mutex *  m)
inlinestatic

◆ os_semaphore_create()

static OS_Uint os_semaphore_create ( OS_Semaphore *  s,
const char *  name,
OS_Uint  initial 
)
inlinestatic

◆ os_semaphore_delete()

static OS_Uint os_semaphore_delete ( OS_Semaphore *  s)
inlinestatic

◆ os_semaphore_get()

static OS_Uint os_semaphore_get ( OS_Semaphore *  s,
OS_Ulong  wait 
)
inlinestatic

◆ os_semaphore_info_get()

static OS_Uint os_semaphore_info_get ( OS_Semaphore *  s,
OS_Ulong *  count 
)
inlinestatic

◆ os_semaphore_put()

static OS_Uint os_semaphore_put ( OS_Semaphore *  s)
inlinestatic

◆ os_stream_buffer_create()

static OS_Uint os_stream_buffer_create ( OS_StreamBuffer *  b,
size_t  capacity,
size_t  trigger 
)
inlinestatic

◆ os_stream_buffer_delete()

static OS_Uint os_stream_buffer_delete ( OS_StreamBuffer *  b)
inlinestatic

◆ os_stream_buffer_receive()

static OS_Uint os_stream_buffer_receive ( OS_StreamBuffer *  b,
void *  data,
size_t  len,
OS_Ulong  wait 
)
inlinestatic

◆ os_stream_buffer_send()

static OS_Uint os_stream_buffer_send ( OS_StreamBuffer *  b,
const void *  data,
size_t  len,
OS_Ulong  wait 
)
inlinestatic

◆ os_thread_clear()

static void os_thread_clear ( OS_Thread *  t)
inlinestatic

◆ os_thread_create()

static OS_Uint os_thread_create ( OS_Thread *  t,
const char *  name,
void(*)(OS_Ulong)  entry,
OS_Ulong  input,
uint8_t *  stack,
OS_Ulong  stack_size,
OS_Uint  priority,
OS_Uint  ,
OS_Ulong  ,
OS_Uint  auto_start 
)
inlinestatic

Generic create (hf-core BaseThread shape). Allocates a start cookie once.

◆ os_thread_create_pinned()

static OS_Uint os_thread_create_pinned ( OS_Thread *  t,
const char *  name,
void(*)(OS_Ulong)  entry,
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 
)
inlinestatic

◆ os_thread_delete()

static OS_Uint os_thread_delete ( OS_Thread *  t)
inlinestatic

◆ os_thread_info_get()

static OS_Uint os_thread_info_get ( OS_Thread *  t,
OS_Uint *  state 
)
inlinestatic

◆ os_thread_is_current()

static OS_Uint os_thread_is_current ( const OS_Thread *  t)
inlinestatic

◆ os_thread_is_live()

static int os_thread_is_live ( const OS_Thread *  t)
inlinestatic

◆ os_thread_resume()

static OS_Uint os_thread_resume ( OS_Thread *  t)
inlinestatic

◆ os_thread_sleep()

static OS_Uint os_thread_sleep ( OS_Ulong  ticks)
inlinestatic

◆ os_thread_spawn()

static OS_Uint os_thread_spawn ( OS_Thread *  t,
const char *  name,
void(*)(void *)  entry,
void *  arg,
void *  stack,
OS_Ulong  stack_size,
OS_Uint  priority,
OS_Uint  auto_start 
)
inlinestatic

Create a CMSIS thread. entry receives arg — no heap cookie.

Parameters
stackoptional static stack; null lets the kernel allocate.
stack_sizestack bytes (CMSIS osThreadAttr_t.stack_size).

◆ os_thread_state_is_suspended()

static int os_thread_state_is_suspended ( OS_Uint  state)
inlinestatic

◆ os_thread_suspend()

static OS_Uint os_thread_suspend ( OS_Thread *  t)
inlinestatic

◆ os_thread_terminate()

static OS_Uint os_thread_terminate ( OS_Thread *  t)
inlinestatic

◆ os_thread_yield()

static OS_Uint os_thread_yield ( void  )
inlinestatic

◆ os_time_get()

static OS_Ulong os_time_get ( void  )
inlinestatic

◆ os_timer_activate()

static OS_Uint os_timer_activate ( OS_Timer *  t)
inlinestatic

◆ os_timer_create()

static OS_Uint os_timer_create ( OS_Timer *  t,
const char *  name,
void(*)(OS_Ulong)  cb,
OS_Ulong  id,
OS_Ulong  initial,
OS_Ulong  reload,
OS_Uint  auto_act 
)
inlinestatic

◆ os_timer_deactivate()

static OS_Uint os_timer_deactivate ( OS_Timer *  t)
inlinestatic

◆ os_timer_delete()

static OS_Uint os_timer_delete ( OS_Timer *  t)
inlinestatic

Variable Documentation

◆ os_critical_mux

OS_Critical os_critical_mux
extern