µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os-c-wrapper.cpp File Reference

Go to the source code of this file.

Functions

os_iterator_t os_children_threads_iter_begin (os_thread_t *thread)
 Get the beginning of the list of children threads.
 
os_iterator_t os_children_threads_iter_end (os_thread_t *thread)
 Get the end of the list of children threads.
 
os_thread_tos_children_threads_iter_get (os_iterator_t iterator)
 Get the thread from the current iterator position.
 
os_iterator_t os_children_threads_iter_next (os_iterator_t iterator)
 Advance the iterator to the next position.
 
os_clock_tos_clock_get_hrclock (void)
 Get hrclock (the high resolution clock).
 
const char * os_clock_get_name (os_clock_t *clock)
 Get the clock name.
 
os_clock_offset_t os_clock_get_offset (os_clock_t *clock)
 Get adjustment offset.
 
os_clock_tos_clock_get_rtclock (void)
 Get rtclock (the real-time clock).
 
os_clock_tos_clock_get_sysclock (void)
 Get sysclock (the system clock).
 
os_clock_timestamp_t os_clock_now (os_clock_t *clock)
 Tell the current time, possibly adjusted for epoch.
 
os_clock_offset_t os_clock_set_offset (os_clock_t *clock, os_clock_offset_t offset)
 Set adjustment offset.
 
os_result_t os_clock_sleep_for (os_clock_t *clock, os_clock_duration_t duration)
 Sleep for a relative duration.
 
os_result_t os_clock_sleep_until (os_clock_t *clock, os_clock_timestamp_t timestamp)
 Sleep until an absolute timestamp.
 
os_clock_timestamp_t os_clock_steady_now (os_clock_t *clock)
 Tell the current time since startup.
 
os_result_t os_clock_wait_for (os_clock_t *clock, os_clock_duration_t timeout)
 Timed wait for an event.
 
void os_condvar_attr_init (os_condvar_attr_t *attr)
 Initialise the condition variable attributes.
 
os_result_t os_condvar_broadcast (os_condvar_t *condvar)
 Notify all threads waiting for a condition variable.
 
void os_condvar_construct (os_condvar_t *condvar, const char *name, const os_condvar_attr_t *attr)
 Construct a statically allocated condition variable object instance.
 
void os_condvar_delete (os_condvar_t *condvar)
 Destruct the condition variable object instance and deallocate it.
 
void os_condvar_destruct (os_condvar_t *condvar)
 Destruct the statically allocated condition variable object instance.
 
const char * os_condvar_get_name (os_condvar_t *condvar)
 Get the condition variable name.
 
os_condvar_tos_condvar_new (const char *name, const os_condvar_attr_t *attr)
 Allocate a condition variable object instance and construct it.
 
os_result_t os_condvar_signal (os_condvar_t *condvar)
 Notify one thread waiting for a condition variable.
 
os_result_t os_condvar_timed_wait (os_condvar_t *condvar, os_mutex_t *mutex, os_clock_duration_t timeout)
 Timed wait for a condition variable to be notified.
 
os_result_t os_condvar_wait (os_condvar_t *condvar, os_mutex_t *mutex)
 Wait for a condition variable to be notified.
 
bool os_evflags_are_waiting (os_evflags_t *evflags)
 Check if there are threads waiting.
 
void os_evflags_attr_init (os_evflags_attr_t *attr)
 Initialise the event flags attributes.
 
os_result_t os_evflags_clear (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
 Clear event flags.
 
void os_evflags_construct (os_evflags_t *evflags, const char *name, const os_evflags_attr_t *attr)
 Construct a statically allocated event flags object instance.
 
void os_evflags_delete (os_evflags_t *evflags)
 Destruct the event flags object instance and deallocate it.
 
void os_evflags_destruct (os_evflags_t *evflags)
 Destruct the statically allocated event flags object instance.
 
os_flags_mask_t os_evflags_get (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mode_t mode)
 Get (and possibly clear) event flags.
 
const char * os_evflags_get_name (os_evflags_t *evflags)
 Get the event flags name.
 
os_evflags_tos_evflags_new (const char *name, const os_evflags_attr_t *attr)
 Allocate an event flags object instance and construct it.
 
os_result_t os_evflags_raise (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
 Raise event flags.
 
os_result_t os_evflags_timed_wait (os_evflags_t *evflags, os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Timed wait for event flags.
 
os_result_t os_evflags_try_wait (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Try to wait for event flags.
 
os_result_t os_evflags_wait (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Wait for event flags.
 
os_irq_state_t os_irq_critical_enter (void)
 Enter an interrupts critical section.
 
void os_irq_critical_exit (os_irq_state_t state)
 Exit the interrupts critical section.
 
os_thread_stack_tos_irq_get_stack (void)
 Get the interrupts stack.
 
bool os_irq_in_handler_mode (void)
 Check if the CPU is in handler mode.
 
os_irq_state_t os_irq_uncritical_enter (void)
 Enter an interrupts uncritical section.
 
void os_irq_uncritical_exit (os_irq_state_t state)
 Exit the interrupts uncritical section.
 
void * os_memory_allocate (os_memory_t *memory, size_t bytes, size_t alignment)
 Allocate a block of memory.
 
bool os_memory_coalesce (os_memory_t *memory)
 Coalesce free blocks.
 
void os_memory_deallocate (os_memory_t *memory, void *addr, size_t bytes, size_t alignment)
 Deallocate the previously allocated block of memory.
 
size_t os_memory_get_allocated_bytes (os_memory_t *memory)
 Get the total size of allocated chunks.
 
size_t os_memory_get_allocated_chunks (os_memory_t *memory)
 Get the number of allocated chunks.
 
os_memory_tos_memory_get_default (void)
 Get the application default memory resource (free store).
 
size_t os_memory_get_free_bytes (os_memory_t *memory)
 Get the total size of free chunks.
 
size_t os_memory_get_free_chunks (os_memory_t *memory)
 Get the number of free chunks.
 
size_t os_memory_get_total_bytes (os_memory_t *memory)
 Get the total size of managed memory.
 
void os_memory_reset (os_memory_t *memory)
 Reset the memory manager to the initial state.
 
void * os_mempool_alloc (os_mempool_t *mempool)
 Allocate a memory block.
 
void os_mempool_attr_init (os_mempool_attr_t *attr)
 Initialise the memory pool attributes.
 
void os_mempool_construct (os_mempool_t *mempool, const char *name, size_t blocks, size_t block_size_bytes, const os_mempool_attr_t *attr)
 Construct a statically allocated memory pool object instance.
 
void os_mempool_delete (os_mempool_t *mempool)
 Destruct the memory pool object instance and deallocate it.
 
void os_mempool_destruct (os_mempool_t *mempool)
 Destruct the statically allocated memory pool object instance.
 
os_result_t os_mempool_free (os_mempool_t *mempool, void *block)
 Free the memory block.
 
size_t os_mempool_get_block_size (os_mempool_t *mempool)
 Get block size.
 
size_t os_mempool_get_capacity (os_mempool_t *mempool)
 Get memory pool capacity.
 
size_t os_mempool_get_count (os_mempool_t *mempool)
 Get blocks count.
 
const char * os_mempool_get_name (os_mempool_t *mempool)
 Get the memory pool name.
 
void * os_mempool_get_pool (os_mempool_t *mempool)
 Get the pool storage address.
 
bool os_mempool_is_empty (os_mempool_t *mempool)
 Check if the memory pool is empty.
 
bool os_mempool_is_full (os_mempool_t *mempool)
 Check if the memory pool is full.
 
os_mempool_tos_mempool_new (const char *name, size_t blocks, size_t block_size_bytes, const os_mempool_attr_t *attr)
 Allocate a memory pool object instance and construct it.
 
os_result_t os_mempool_reset (os_mempool_t *mempool)
 Reset the memory pool.
 
void * os_mempool_timed_alloc (os_mempool_t *mempool, os_clock_duration_t timeout)
 Allocate a memory block with timeout.
 
void * os_mempool_try_alloc (os_mempool_t *mempool)
 Try to allocate a memory block.
 
void os_mqueue_attr_init (os_mqueue_attr_t *attr)
 Initialise the message queue attributes.
 
void os_mqueue_construct (os_mqueue_t *mqueue, const char *name, size_t msgs, size_t msg_size_bytes, const os_mqueue_attr_t *attr)
 Construct a statically allocated message queue object instance.
 
void os_mqueue_delete (os_mqueue_t *mqueue)
 Destruct the message queue object instance and deallocate it.
 
void os_mqueue_destruct (os_mqueue_t *mqueue)
 Destruct the statically allocated message queue object instance.
 
size_t os_mqueue_get_capacity (os_mqueue_t *mqueue)
 Get queue capacity.
 
size_t os_mqueue_get_length (os_mqueue_t *mqueue)
 Get queue length.
 
size_t os_mqueue_get_msg_size (os_mqueue_t *mqueue)
 Get message size.
 
const char * os_mqueue_get_name (os_mqueue_t *mqueue)
 Get the message queue name.
 
bool os_mqueue_is_empty (os_mqueue_t *mqueue)
 Check if the queue is empty.
 
bool os_mqueue_is_full (os_mqueue_t *mqueue)
 Check if the queue is full.
 
os_mqueue_tos_mqueue_new (const char *name, size_t msgs, size_t msg_size_bytes, const os_mqueue_attr_t *attr)
 Allocate a message queue object instance and construct it.
 
os_result_t os_mqueue_receive (os_mqueue_t *mqueue, void *msg, size_t nbytes, os_mqueue_prio_t *mprio)
 Receive a message from the queue.
 
os_result_t os_mqueue_reset (os_mqueue_t *mqueue)
 Reset the message queue.
 
os_result_t os_mqueue_send (os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_mqueue_prio_t mprio)
 Send a message to the queue.
 
os_result_t os_mqueue_timed_receive (os_mqueue_t *mqueue, void *msg, size_t nbytes, os_clock_duration_t timeout, os_mqueue_prio_t *mprio)
 Receive a message from the queue with timeout.
 
os_result_t os_mqueue_timed_send (os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_clock_duration_t timeout, os_mqueue_prio_t mprio)
 Send a message to the queue with timeout.
 
os_result_t os_mqueue_try_receive (os_mqueue_t *mqueue, void *msg, size_t nbytes, os_mqueue_prio_t *mprio)
 Try to receive a message from the queue.
 
os_result_t os_mqueue_try_send (os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_mqueue_prio_t mprio)
 Try to send a message to the queue.
 
const os_mutex_attr_tos_mutex_attr_get_recursive (void)
 Get a recursive mutex attributes object instance.
 
void os_mutex_attr_init (os_mutex_attr_t *attr)
 Initialise the mutex attributes.
 
void os_mutex_attr_recursive_init (os_mutex_attr_t *attr)
 Initialise the recursive mutex attributes.
 
void os_mutex_construct (os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr)
 Construct a statically allocated mutex object instance.
 
void os_mutex_delete (os_mutex_t *mutex)
 Destruct the mutex object instance and deallocate it.
 
void os_mutex_destruct (os_mutex_t *mutex)
 Destruct the statically allocated mutex object instance.
 
const char * os_mutex_get_name (os_mutex_t *mutex)
 Get the mutex name.
 
os_thread_tos_mutex_get_owner (os_mutex_t *mutex)
 Get the thread that owns the mutex.
 
os_thread_prio_t os_mutex_get_prio_ceiling (os_mutex_t *mutex)
 Get the priority ceiling of a mutex.
 
os_mutex_protocol_t os_mutex_get_protocol (os_mutex_t *mutex)
 Get the mutex protocol.
 
os_mutex_robustness_t os_mutex_get_robustness (os_mutex_t *mutex)
 Get the mutex robustness.
 
os_mutex_type_t os_mutex_get_type (os_mutex_t *mutex)
 Get the mutex type.
 
os_result_t os_mutex_lock (os_mutex_t *mutex)
 Lock/acquire the mutex.
 
os_result_t os_mutex_mark_consistent (os_mutex_t *mutex)
 Mark mutex as consistent.
 
os_mutex_tos_mutex_new (const char *name, const os_mutex_attr_t *attr)
 Allocate a mutex object instance and construct it.
 
void os_mutex_recursive_construct (os_mutex_t *mutex, const char *name, const os_mutex_attr_t *attr)
 Construct a statically allocated recursive mutex object instance.
 
os_mutex_tos_mutex_recursive_new (const char *name, const os_mutex_attr_t *attr)
 Allocated a recursive mutex object instance and construct it.
 
os_result_t os_mutex_reset (os_mutex_t *mutex)
 Reset the mutex.
 
os_result_t os_mutex_set_prio_ceiling (os_mutex_t *mutex, os_thread_prio_t prio_ceiling, os_thread_prio_t *old_prio_ceiling)
 Change the priority ceiling of a mutex.
 
os_result_t os_mutex_timed_lock (os_mutex_t *mutex, os_clock_duration_t timeout)
 Timed attempt to lock/acquire the mutex.
 
os_result_t os_mutex_try_lock (os_mutex_t *mutex)
 Try to lock/acquire the mutex.
 
os_result_t os_mutex_unlock (os_mutex_t *mutex)
 Unlock/release the mutex.
 
os_result_t os_sched_initialize (void)
 Initialise the RTOS scheduler.
 
bool os_sched_is_locked (void)
 Check if the scheduler is locked.
 
bool os_sched_is_preemptive (void)
 Check if the scheduler is in preemptive mode.
 
bool os_sched_is_started (void)
 Check if the scheduler was started.
 
os_sched_state_t os_sched_lock (void)
 Lock the scheduler.
 
os_sched_state_t os_sched_set_locked (os_sched_state_t state)
 Lock/unlock the scheduler.
 
bool os_sched_set_preemptive (bool state)
 Set the scheduler preemptive mode.
 
void os_sched_start (void)
 Start the RTOS scheduler.
 
os_statistics_counter_t os_sched_stat_get_context_switches (void)
 Get the total number of context switches.
 
os_statistics_duration_t os_sched_stat_get_cpu_cycles (void)
 Get the total duration of all threads.
 
os_sched_state_t os_sched_unlock (void)
 Unlock the scheduler.
 
void os_semaphore_attr_binary_init (os_semaphore_attr_t *attr, const os_semaphore_count_t initial_value)
 Initialise the binary semaphore attributes.
 
void os_semaphore_attr_counting_init (os_semaphore_attr_t *attr, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value)
 Initialise the counting semaphore attributes.
 
const os_semaphore_attr_tos_semaphore_attr_get_binary (void)
 Get a binary semaphore attributes object instance.
 
void os_semaphore_attr_init (os_semaphore_attr_t *attr)
 Initialise the counting semaphore attributes.
 
void os_semaphore_binary_construct (os_semaphore_t *semaphore, const char *name, const os_semaphore_count_t initial_value)
 Construct a statically allocated binary semaphore object instance.
 
os_semaphore_tos_semaphore_binary_new (const char *name, const os_semaphore_count_t initial_value)
 Allocate a binary semaphore object instance and construct it.
 
void os_semaphore_construct (os_semaphore_t *semaphore, const char *name, const os_semaphore_attr_t *attr)
 Construct a statically allocated semaphore object instance.
 
void os_semaphore_counting_construct (os_semaphore_t *semaphore, const char *name, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value)
 Construct a statically allocated counting semaphore object instance.
 
os_semaphore_tos_semaphore_counting_new (const char *name, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value)
 Allocate a counting semaphore object instance and construct it.
 
void os_semaphore_delete (os_semaphore_t *semaphore)
 Destruct the semaphore object instance.
 
void os_semaphore_destruct (os_semaphore_t *semaphore)
 Destruct the statically allocated semaphore object instance.
 
os_semaphore_count_t os_semaphore_get_initial_value (os_semaphore_t *semaphore)
 Get the semaphore initial count value.
 
os_semaphore_count_t os_semaphore_get_max_value (os_semaphore_t *semaphore)
 Get the semaphore maximum count value.
 
const char * os_semaphore_get_name (os_semaphore_t *semaphore)
 Get the semaphore name.
 
os_semaphore_count_t os_semaphore_get_value (os_semaphore_t *semaphore)
 Get the semaphore count value.
 
os_semaphore_tos_semaphore_new (const char *name, const os_semaphore_attr_t *attr)
 Allocated a semaphore object instance and construct it.
 
os_result_t os_semaphore_post (os_semaphore_t *semaphore)
 Post (unlock) the semaphore.
 
os_result_t os_semaphore_reset (os_semaphore_t *semaphore)
 Reset the semaphore.
 
os_result_t os_semaphore_timed_wait (os_semaphore_t *semaphore, os_clock_duration_t timeout)
 Timed wait to lock the semaphore.
 
os_result_t os_semaphore_try_wait (os_semaphore_t *semaphore)
 Try to lock the semaphore.
 
os_result_t os_semaphore_wait (os_semaphore_t *semaphore)
 Lock the semaphore, possibly waiting.
 
os_clock_timestamp_t os_sysclock_now (void)
 Tell the current time since startup.
 
os_result_t os_sysclock_sleep_for (os_clock_duration_t duration)
 Sleep for a relative duration.
 
os_result_t os_sysclock_sleep_until (os_clock_timestamp_t timestamp)
 Sleep until an absolute timestamp.
 
os_result_t os_sysclock_wait_for (os_clock_duration_t timeout)
 Timed wait for an event.
 
os_thread_tos_this_thread (void)
 Get the current running thread.
 
void os_this_thread_exit (void *exit_ptr)
 Terminate the current running thread.
 
os_result_t os_this_thread_flags_clear (os_flags_mask_t mask, os_flags_mask_t *oflags)
 Clear thread event flags.
 
os_flags_mask_t os_this_thread_flags_get (os_flags_mask_t mask, os_flags_mode_t mode)
 Get/clear thread event flags.
 
os_result_t os_this_thread_flags_timed_wait (os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Timed wait for thread event flags.
 
os_result_t os_this_thread_flags_try_wait (os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Try to wait for thread event flags.
 
os_result_t os_this_thread_flags_wait (os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Wait for thread event flags.
 
void os_this_thread_suspend (void)
 Suspend the current running thread to wait for an event.
 
void os_thread_attr_init (os_thread_attr_t *attr)
 Initialise the thread attributes.
 
void os_thread_construct (os_thread_t *thread, const char *name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t *attr)
 Construct a statically allocated thread object instance.
 
void os_thread_delete (os_thread_t *thread)
 Destruct the thread object instance and deallocate it.
 
void os_thread_destruct (os_thread_t *thread)
 Destruct the statically allocated thread object instance.
 
os_result_t os_thread_flags_raise (os_thread_t *thread, os_flags_mask_t mask, os_flags_mask_t *oflags)
 Raise thread event flags.
 
const char * os_thread_get_name (os_thread_t *thread)
 Get the thread name.
 
os_thread_prio_t os_thread_get_priority (os_thread_t *thread)
 Get the thread current scheduling priority.
 
os_thread_stack_tos_thread_get_stack (os_thread_t *thread)
 Get the thread context stack.
 
os_thread_state_t os_thread_get_state (os_thread_t *thread)
 Get the thread scheduler state.
 
os_thread_user_storage_t * os_thread_get_user_storage (os_thread_t *thread)
 Get the thread user storage.
 
bool os_thread_is_constructed (os_thread_t *thread)
 Check if the thread is constructed.
 
os_result_t os_thread_join (os_thread_t *thread, void **exit_ptr)
 Wait for thread termination.
 
os_result_t os_thread_kill (os_thread_t *thread)
 Force thread termination.
 
os_thread_tos_thread_new (const char *name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t *attr)
 Allocate a thread object instance and construct it.
 
void os_thread_resume (os_thread_t *thread)
 Resume the thread.
 
os_result_t os_thread_set_priority (os_thread_t *thread, os_thread_prio_t prio)
 Set the thread dynamic scheduling priority.
 
bool os_thread_stack_check_bottom_magic (os_thread_stack_t *stack)
 Check if bottom magic word is still there.
 
bool os_thread_stack_check_top_magic (os_thread_stack_t *stack)
 Check if top magic word is still there.
 
size_t os_thread_stack_get_available (os_thread_stack_t *stack)
 Compute how much available stack remains.
 
os_thread_stack_element_tos_thread_stack_get_bottom (os_thread_stack_t *stack)
 Get the stack lowest reserved address.
 
size_t os_thread_stack_get_default_size (void)
 Get the default stack size.
 
size_t os_thread_stack_get_min_size (void)
 Get the min stack size.
 
size_t os_thread_stack_get_size (os_thread_stack_t *stack)
 Get the stack size.
 
os_thread_stack_element_tos_thread_stack_get_top (os_thread_stack_t *stack)
 Get the top stack address.
 
size_t os_thread_stack_set_default_size (size_t size_bytes)
 Set the default stack size.
 
size_t os_thread_stack_set_min_size (size_t size_bytes)
 Set the min stack size.
 
os_statistics_counter_t os_thread_stat_get_context_switches (os_thread_t *thread)
 Get the number of thread context switches.
 
os_statistics_duration_t os_thread_stat_get_cpu_cycles (os_thread_t *thread)
 Get the thread execution time.
 
const os_timer_attr_tos_timer_attr_get_periodic (void)
 Get a periodic timer attributes object instance.
 
void os_timer_attr_init (os_timer_attr_t *attr)
 Initialise the single shot timer attributes.
 
void os_timer_attr_periodic_init (os_timer_attr_t *attr)
 Initialise the periodic timer attributes.
 
void os_timer_construct (os_timer_t *timer, const char *name, os_timer_func_t function, os_timer_func_args_t args, const os_timer_attr_t *attr)
 Construct a statically allocated timer object instance.
 
void os_timer_delete (os_timer_t *timer)
 Destruct the timer object instance and deallocate it.
 
void os_timer_destruct (os_timer_t *timer)
 Destruct the statically allocated timer object instance.
 
const char * os_timer_get_name (os_timer_t *timer)
 Get the timer name.
 
os_timer_tos_timer_new (const char *name, os_timer_func_t function, os_timer_func_args_t args, const os_timer_attr_t *attr)
 Allocate a timer object instance and construct it.
 
os_result_t os_timer_start (os_timer_t *timer, os_clock_duration_t period)
 Start or restart the timer.
 
os_result_t os_timer_stop (os_timer_t *timer)
 Stop the timer.
 
osStatus osDelay (uint32_t millisec)
 Time Delay.
 
osStatus osKernelInitialize (void)
 Initialize the RTOS.
 
int32_t osKernelRunning (void)
 Check if the RTOS scheduler is started.
 
osStatus osKernelStart (void)
 
osMutexId osMutexCreate (const osMutexDef_t *mutex_def)
 Create a mutex.
 
osStatus osMutexDelete (osMutexId mutex_id)
 Delete the mutex.
 
osStatus osMutexRelease (osMutexId mutex_id)
 Release the mutex.
 
osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec)
 Wait for mutex.
 
int32_t osSignalClear (osThreadId thread_id, int32_t signals)
 Clear the specified Signal Flags of an active thread.
 
int32_t osSignalSet (osThreadId thread_id, int32_t signals)
 Set signal flags.
 
osEvent osSignalWait (int32_t signals, uint32_t millisec)
 Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
 
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *args)
 Create a thread.
 
osThreadId osThreadGetId (void)
 Get the current thread.
 
osPriority osThreadGetPriority (osThreadId thread_id)
 Get thread priority.
 
osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority)
 Change thread priority.
 
osStatus osThreadTerminate (osThreadId thread_id)
 Terminate a thread.
 
osStatus osThreadYield (void)
 Yield control.
 
osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *args)
 Create a timer.
 
osStatus osTimerDelete (osTimerId timer_id)
 Delete the timer.
 
osStatus osTimerStart (osTimerId timer_id, uint32_t millisec)
 Start the timer.
 
osStatus osTimerStop (osTimerId timer_id)
 Stop the timer.
 

Function Documentation

◆ osDelay()

osStatus osDelay ( uint32_t  millisec)

Wait for a specified time period in millisec.

The millisec value specifies the number of timer ticks and is therefore an upper bound. The exact time delay depends on the actual time elapsed since the last timer tick.

For a value of 1, the system waits until the next timer tick occurs. That means that the actual time delay may be up to one timer tick less.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3734 of file os-c-wrapper.cpp.

3735{
3737 {
3738 return osErrorISR;
3739 }
3740
3742 clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)));
3743
3744 if (res == ETIMEDOUT)
3745 {
3746 return osEventTimeout;
3747 }
3748 else
3749 {
3750 return osErrorOS;
3751 }
3752}
static constexpr clock::duration_t ticks_cast(Rep_T microsec)
Convert microseconds to ticks.
result_t sleep_for(duration_t duration)
Sleep for a relative duration.
@ osErrorISR
Definition cmsis_os.h:163
@ osErrorOS
Definition cmsis_os.h:168
@ osEventTimeout
Definition cmsis_os.h:159
clock_systick sysclock
The system clock object instance.
bool in_handler_mode(void)
Check if the CPU is in handler mode.
Definition os-sched.h:1101
uint32_t result_t
Type of values returned by RTOS functions.
Definition os-decls.h:95

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osErrorOS, osEventTimeout, os::rtos::clock::sleep_for(), os::rtos::sysclock, and os::rtos::clock_systick::ticks_cast().

◆ osKernelInitialize()

osStatus osKernelInitialize ( void  )

Initialise of the RTOS Kernel to allow peripheral setup and creation of other RTOS objects with the functions:

  • osThreadCreate : Create a thread function.
  • osTimerCreate : Define attributes of the timer callback function.
  • osMutexCreate : Define and initialise a mutex.
  • osSemaphoreCreate : Define and initialise a semaphore.
  • osPoolCreate : Define and initialise a fix-size memory pool.
  • osMessageCreate : Define and initialise a message queue.
  • osMailCreate : Define and initialise a mail queue with fix-size memory blocks.

The RTOS scheduler does not start thread switching until the function osKernelStart is called.

Note
In case that the RTOS Kernel starts thread execution with the function main the function osKernelInitialize stops thread switching. This allows you to setup the system to a defined state before thread switching is resumed with osKernelStart.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3409 of file os-c-wrapper.cpp.

3410{
3412 {
3413 return osErrorISR;
3414 }
3415
3417 return osOK;
3418}
@ osOK
Definition cmsis_os.h:155
result_t initialize(void)
Initialise the RTOS scheduler.
Definition os-core.cpp:164

References os::rtos::interrupts::in_handler_mode(), os::rtos::scheduler::initialize(), osErrorISR, and osOK.

◆ osKernelRunning()

int32_t osKernelRunning ( void  )

Identifies if the RTOS scheduler is started. For systems with the option to start the main function as a thread this allows you to identify that the RTOS scheduler is already running.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 3446 of file os-c-wrapper.cpp.

3447{
3448 return scheduler::started () ? 1 : 0;
3449}
bool started(void)
Check if the scheduler was started.
Definition os-sched.h:829

References os::rtos::scheduler::started().

◆ osKernelStart()

osStatus osKernelStart ( void  )

Start the RTOS Kernel and begin thread switching.

Note
When the CMSIS-RTOS starts thread execution with the function main this function resumes thread switching. The main thread will continue executing after osKernelStart.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3431 of file os-c-wrapper.cpp.

3432{
3434 // In µOS++ this does not return.
3435}
void start(void)
Start the RTOS scheduler.
Definition os-core.cpp:193

References os::rtos::scheduler::start().

◆ osMutexCreate()

osMutexId osMutexCreate ( const osMutexDef_t mutex_def)

Create and initialise a mutex object instance.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4099 of file os-c-wrapper.cpp.

4100{
4102 {
4103 return nullptr;
4104 }
4105
4106 if (mutex_def == nullptr)
4107 {
4108 return nullptr;
4109 }
4110
4111 mutex::attributes attr;
4114
4115 new ((void*)mutex_def->data) mutex (mutex_def->name, attr);
4116
4117 return reinterpret_cast<osMutexId> (mutex_def->data);
4118}
Mutex attributes.
Definition os-mutex.h:202
type_t mx_type
Attribute with the mutex type.
Definition os-mutex.h:273
protocol_t mx_protocol
Attribute with the mutex protocol.
Definition os-mutex.h:263
POSIX compliant mutex.
Definition os-mutex.h:52
@ inherit
Inherit priority from highest priority thread.
Definition os-mutex.h:80
@ recursive
Recursive mutex behaviour.
Definition os-mutex.h:168
osMutex * data
Definition cmsis_os.h:307
const char * name
Definition cmsis_os.h:306
Mutex object storage.
Definition os-c-decls.h:973

References os_mutex_def::data, os::rtos::interrupts::in_handler_mode(), os::rtos::mutex::protocol::inherit, os::rtos::mutex::attributes::mx_protocol, os::rtos::mutex::attributes::mx_type, os_mutex_def::name, and os::rtos::mutex::type::recursive.

◆ osMutexDelete()

osStatus osMutexDelete ( osMutexId  mutex_id)

Delete a mutex object instance. The function releases internal memory obtained for mutex handling. After this call the mutex_id is no longer valid and cannot be used. The mutex may be created again using the function osMutexCreate.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4248 of file os-c-wrapper.cpp.

4249{
4251 {
4252 return osErrorISR;
4253 }
4254
4255 if (mutex_id == nullptr)
4256 {
4257 return osErrorParameter;
4258 }
4259
4260 (reinterpret_cast<rtos::mutex&> (*mutex_id)).~mutex ();
4261 return osOK;
4262}
@ osErrorParameter
Definition cmsis_os.h:160

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osErrorParameter, and osOK.

◆ osMutexRelease()

osStatus osMutexRelease ( osMutexId  mutex_id)

Release a mutex that was obtained with osMutexWait. Other threads that currently wait for the same mutex will be now put into the state READY.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4209 of file os-c-wrapper.cpp.

4210{
4212 {
4213 return osErrorISR;
4214 }
4215
4216 if (mutex_id == nullptr)
4217 {
4218 return osErrorParameter;
4219 }
4220
4221 result_t res;
4222 res = (reinterpret_cast<rtos::mutex&> (*mutex_id)).unlock ();
4223
4224 if (res == result::ok)
4225 {
4226 return osOK;
4227 }
4228 else if ((res == EPERM) || (res == ENOTRECOVERABLE))
4229 {
4230 return osErrorResource;
4231 }
4232 else
4233 {
4234 return osErrorOS;
4235 }
4236}
@ osErrorResource
Definition cmsis_os.h:161
@ ok
Function completed; no errors or events occurred.
Definition os-decls.h:179

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, and osOK.

◆ osMutexWait()

osStatus osMutexWait ( osMutexId  mutex_id,
uint32_t  millisec 
)

Wait until a mutex becomes available. If no other thread has obtained the mutex, the function instantly returns and blocks the mutex object.

The argument millisec specifies how long the system waits for a mutex. While the system waits the thread that is calling this function is put into the state WAITING. The millisec timeout can have the following values:

  • when millisec is 0, the function returns instantly.
  • when millisec is set to osWaitForever the function will wait for an infinite time until the mutex becomes available.
  • all other values specify a time in millisecond for a timeout.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4139 of file os-c-wrapper.cpp.

4140{
4142 {
4143 return osErrorISR;
4144 }
4145
4146 if (mutex_id == nullptr)
4147 {
4148 return osErrorParameter;
4149 }
4150
4151 result_t ret;
4152 if (millisec == osWaitForever)
4153 {
4154 ret = (reinterpret_cast<rtos::mutex&> (*mutex_id)).lock ();
4155 // osErrorResource:
4156 }
4157 else if (millisec == 0)
4158 {
4159 ret = (reinterpret_cast<rtos::mutex&> (*mutex_id)).try_lock ();
4160 }
4161 else
4162 {
4163 ret = (reinterpret_cast<rtos::mutex&> (*mutex_id))
4164 .timed_lock (
4165 clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)));
4166 // osErrorTimeoutResource:
4167 }
4168
4169 if (ret == result::ok)
4170 {
4171 // osOK: the mutex has been obtained.
4172 return osOK;
4173 }
4174 else if (ret == EWOULDBLOCK)
4175 {
4176 // The mutex could not be obtained when no timeout was specified.
4177 // Only for try_lock().
4178 return osErrorResource;
4179 }
4180 else if (ret == ENOTRECOVERABLE)
4181 {
4182 // The mutex could not be obtained when no timeout was specified.
4183 // Only for lock().
4184 return osErrorResource;
4185 }
4186 else if (ret == ETIMEDOUT)
4187 {
4188 // The mutex could not be obtained in the given time.
4189 // Only for timed_lock().
4191 }
4192 else
4193 {
4194 return osErrorOS;
4195 }
4196
4197 /* NOTREACHED */
4198}
#define osWaitForever
Timeout value.
Definition cmsis_os.h:147
@ osErrorTimeoutResource
Definition cmsis_os.h:162

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, osErrorTimeoutResource, osOK, osWaitForever, and os::rtos::clock_systick::ticks_cast().

◆ osSignalClear()

int32_t osSignalClear ( osThreadId  thread_id,
int32_t  signals 
)

Clear the signal flags of an active thread.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3970 of file os-c-wrapper.cpp.

3971{
3972 if (thread_id == nullptr)
3973 {
3974 return (int32_t)0x80000000;
3975 }
3976
3977 if (interrupts::in_handler_mode () || (signals == 0))
3978 {
3979 return (int32_t)0x80000000;
3980 }
3981
3982 flags::mask_t sig;
3983
3984#if defined(OS_INCLUDE_RTOS_THREAD_PUBLIC_FLAGS_CLEAR)
3985 ((thread*)(thread_id))->flags_clear ((flags::mask_t)signals, &sig);
3986#else
3987 assert (((thread*)(thread_id)) == &this_thread::thread ());
3988 // IGNORE THREAD ID!
3989 this_thread::flags_clear ((flags::mask_t)signals, &sig);
3990#endif
3991 return (int32_t)sig;
3992}
Standard thread.
uint32_t mask_t
Type of variables holding flags masks.
Definition os-decls.h:266

References os::rtos::interrupts::in_handler_mode().

◆ osSignalSet()

int32_t osSignalSet ( osThreadId  thread_id,
int32_t  signals 
)

Set the signal flags of an active thread.

Note
Can be invoked from Interrupt Service Routines.

Definition at line 3946 of file os-c-wrapper.cpp.

3947{
3948 if (thread_id == nullptr)
3949 {
3950 return (int32_t)0x80000000;
3951 }
3952
3953 if (signals == (int32_t)0x80000000)
3954 {
3955 return (int32_t)0x80000000;
3956 }
3957
3958 flags::mask_t osig;
3959 ((thread*)(thread_id))->flags_raise ((flags::mask_t)signals, &osig);
3960 return (int32_t)osig;
3961}

◆ osSignalWait()

osEvent osSignalWait ( int32_t  signals,
uint32_t  millisec 
)

Suspend the execution of the current RUNNING thread until all specified signal flags with the parameter signals are set. When the parameter signals is 0 the current RUNNING thread is suspended until any signal is set. When these signal flags are already set, the function returns instantly. Otherwise the thread is put into the state WAITING. Signal flags that are reported as event are automatically cleared.

The argument millisec specifies how long the system waits for the specified signal flags. While the system waits the tread calling this function is put into the state WAITING. The timeout value can have the following values:

  • when millisec is 0, the function returns instantly.
  • when millisec is set to osWaitForever the function will wait an infinite time until a specified signal is set.
  • all other values specify a time in millisecond for a timeout.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 4023 of file os-c-wrapper.cpp.

4024{
4025 osEvent event;
4026
4028 {
4029 event.status = osErrorISR;
4030 return event;
4031 }
4032
4033 if ((uint32_t)signals & 0x80000000)
4034 {
4035 event.status = osErrorValue;
4036 return event;
4037 }
4038
4039 result_t res;
4040 if (millisec == osWaitForever)
4041 {
4042 res = this_thread::flags_wait ((flags::mask_t)signals,
4043 (flags::mask_t*)&event.value.signals);
4044 }
4045 else if (millisec == 0)
4046 {
4047 res = this_thread::flags_try_wait ((flags::mask_t)signals,
4048 (flags::mask_t*)&event.value.signals);
4049 }
4050 else
4051 {
4052 res = this_thread::flags_timed_wait (
4053 (flags::mask_t)signals,
4054 clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)),
4055 (flags::mask_t*)&event.value.signals);
4056 }
4057
4058 if (res == result::ok)
4059 {
4060 event.status = osEventSignal;
4061 }
4062 else if (res == EWOULDBLOCK)
4063 {
4064 event.status = osOK; // Only for try_flags_wait().
4065 }
4066 else if (res == ETIMEDOUT)
4067 {
4068 event.status = osEventTimeout; // Only for timed_flags_wait().
4069 }
4070 else if (res == EPERM)
4071 {
4072 event.status = osErrorISR;
4073 }
4074 else if (res == EINVAL)
4075 {
4076 event.status = osErrorValue;
4077 }
4078 else
4079 {
4080 event.status = osErrorOS;
4081 }
4082
4083 return event;
4084}
@ osErrorValue
Definition cmsis_os.h:167
@ osEventSignal
Definition cmsis_os.h:156
Event structure contains detailed information about an event.
Definition cmsis_os.h:378
osStatus status
Definition cmsis_os.h:379
int32_t signals
Definition cmsis_os.h:384
union osEvent::@0 value

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorValue, osEventSignal, osEventTimeout, osOK, osWaitForever, osEvent::signals, osEvent::status, os::rtos::clock_systick::ticks_cast(), and osEvent::value.

◆ osThreadCreate()

osThreadId osThreadCreate ( const osThreadDef_t thread_def,
void *  args 
)

Find a free slot in the array of thread definitions and initialise the thread.

Start the thread function by adding it to the Active Threads list and set it to state READY. The thread function receives the argument pointer as function argument when the function is started. When the priority of the created thread function is higher than the current RUNNING thread, the created thread function starts instantly and becomes the new RUNNING thread.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3493 of file os-c-wrapper.cpp.

3494{
3496 {
3497 return nullptr;
3498 }
3499
3500 if (thread_def == nullptr)
3501 {
3502 return nullptr;
3503 }
3504
3505 thread::attributes attr;
3506 attr.th_priority = thread_def->tpriority;
3507 attr.th_stack_size_bytes = thread_def->stacksize;
3508
3509 // Creating thread with invalid priority should fail (validator requirement).
3510 if (thread_def->tpriority >= osPriorityError)
3511 {
3512 return nullptr;
3513 }
3514
3515 // Find a free slot in the tread definitions array.
3516 for (uint32_t i = 0; i < thread_def->instances; ++i)
3517 {
3518#pragma GCC diagnostic push
3519#if defined(__clang__)
3520#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
3521#endif
3522 thread* th = (thread*)&thread_def->data[i];
3523 if (th->state () == thread::state::undefined
3524 || th->state () == thread::state::destroyed)
3525 {
3526 if (attr.th_stack_size_bytes > 0)
3527 {
3528 attr.th_stack_address
3529 = &thread_def->stack[(i)
3530 * ((thread_def->stacksize
3531 + sizeof (uint64_t) - 1)
3532 / sizeof (uint64_t))];
3533 }
3534#pragma GCC diagnostic push
3535#if defined(__clang__)
3536#pragma clang diagnostic ignored "-Wcast-function-type"
3537#elif defined(__GNUC__)
3538#pragma GCC diagnostic ignored "-Wcast-function-type"
3539#endif
3540 new (th)
3541 thread (thread_def->name,
3542 reinterpret_cast<thread::func_t> (thread_def->pthread),
3543 args, attr);
3544#pragma GCC diagnostic pop
3545
3546 // No need to yield here, already done by constructor.
3547 return reinterpret_cast<osThreadId> (th);
3548 }
3549#pragma GCC diagnostic pop
3550 }
3551 return nullptr;
3552}
@ osPriorityError
Definition cmsis_os.h:140
@ destroyed
Terminated and resources (like stack) released.
Definition os-thread.h:398
@ undefined
Used to catch uninitialised threads.
Definition os-thread.h:378
os_pthread pthread
Definition cmsis_os.h:279
uint64_t * stack
Definition cmsis_os.h:284
const char * name
Definition cmsis_os.h:278
osPriority tpriority
Definition cmsis_os.h:280
uint32_t stacksize
Definition cmsis_os.h:282
osThread * data
Definition cmsis_os.h:283
uint32_t instances
Definition cmsis_os.h:281
Thread object storage.
Definition os-c-decls.h:563

References os_thread_def::data, os::rtos::thread::state::destroyed, os::rtos::interrupts::in_handler_mode(), os_thread_def::instances, os_thread_def::name, osPriorityError, os_thread_def::pthread, os_thread_def::stack, os_thread_def::stacksize, os::rtos::thread::attributes::th_priority, os::rtos::thread::attributes::th_stack_address, os::rtos::thread::attributes::th_stack_size_bytes, os_thread_def::tpriority, and os::rtos::thread::state::undefined.

◆ osThreadGetId()

osThreadId osThreadGetId ( void  )

Get the thread ID of the current running thread.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3561 of file os-c-wrapper.cpp.

3562{
3564 {
3565 return nullptr;
3566 }
3567
3568 return reinterpret_cast<osThreadId> (&this_thread::thread ());
3569}

References os::rtos::interrupts::in_handler_mode().

◆ osThreadGetPriority()

osPriority osThreadGetPriority ( osThreadId  thread_id)

Get the priority of an active thread. In case of a failure the value osPriorityError is returned.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3699 of file os-c-wrapper.cpp.

3700{
3702 {
3703 return osPriorityError;
3704 }
3705
3706 if (thread_id == nullptr)
3707 {
3708 return osPriorityError;
3709 }
3710
3711 // Call C++ accessor.
3712 thread::priority_t prio
3713 = (reinterpret_cast<rtos::thread&> (*thread_id)).priority ();
3714 return static_cast<osPriority> (prio);
3715}
POSIX compliant thread, using the default RTOS allocator.
Definition os-thread.h:251
osPriority
Definition cmsis_os.h:132

References os::rtos::interrupts::in_handler_mode(), and osPriorityError.

◆ osThreadSetPriority()

osStatus osThreadSetPriority ( osThreadId  thread_id,
osPriority  priority 
)

Change the priority of a running thread. There is no need for an extra yield after it, if the priorities require, there is an implicit reschedule.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3645 of file os-c-wrapper.cpp.

3646{
3648 {
3649 return osErrorISR;
3650 }
3651
3652 if (thread_id == nullptr)
3653 {
3654 return osErrorParameter;
3655 }
3656
3657 thread::state_t state
3658 = (reinterpret_cast<rtos::thread&> (*thread_id)).state ();
3659 if (state == thread::state::undefined || state >= thread::state::destroyed)
3660 {
3661 return osErrorResource;
3662 }
3663
3664 if (priority < osPriorityIdle || priority >= osPriorityError)
3665 {
3666 return osErrorValue;
3667 }
3668
3669 // Call C++ mutator.
3670 thread::priority_t prio = static_cast<thread::priority_t> (priority);
3671 result_t res
3672 = ((reinterpret_cast<rtos::thread&> (*thread_id)).priority (prio));
3673
3674 // A mandatory yield is needed here, must be done
3675 // by the implementation.
3676
3677 if (res == result::ok)
3678 {
3679 return osOK;
3680 }
3681 else if (res == EINVAL)
3682 {
3683 return osErrorValue;
3684 }
3685 else
3686 {
3687 return osErrorOS;
3688 }
3689}

References os::rtos::thread::state::destroyed, os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, osErrorValue, osOK, osPriorityError, and os::rtos::thread::state::undefined.

◆ osThreadTerminate()

osStatus osThreadTerminate ( osThreadId  thread_id)

Remove the thread function from the active thread list. If the thread is currently RUNNING the execution will stop.

Note
In case that osThreadTerminate terminates the currently running task, the function never returns and other threads that are in the READY state are started.
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3583 of file os-c-wrapper.cpp.

3584{
3586 {
3587 return osErrorISR;
3588 }
3589
3590 if (thread_id == nullptr)
3591 {
3592 return osErrorParameter;
3593 }
3594
3595 thread::state_t state
3596 = (reinterpret_cast<rtos::thread&> (*thread_id)).state ();
3597 if (state == thread::state::undefined)
3598 {
3599 return osErrorResource;
3600 }
3601
3602 if ((reinterpret_cast<thread*> (thread_id)) == &this_thread::thread ())
3603 {
3604 this_thread::exit ();
3605 /* NOTREACHED */
3606 }
3607 else
3608 {
3609 (reinterpret_cast<rtos::thread&> (*thread_id)).kill ();
3610 }
3611
3612 return osOK;
3613}
int kill(pid_t pid, int sig)

References os::rtos::interrupts::in_handler_mode(), kill(), osErrorISR, osErrorParameter, osErrorResource, osOK, and os::rtos::thread::state::undefined.

◆ osThreadYield()

osStatus osThreadYield ( void  )

Pass control to the next thread that is in state READY. If there is no other thread in the state READY, the current thread continues execution and no thread switching occurs.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3624 of file os-c-wrapper.cpp.

3625{
3627 {
3628 return osErrorISR;
3629 }
3630
3632
3633 return osOK;
3634}
void yield() noexcept
Yield the CPU to the next ready thread.

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osOK, and this_thread::yield().

◆ osTimerCreate()

osTimerId osTimerCreate ( const osTimerDef_t timer_def,
os_timer_type  type,
void *  args 
)

Create a one-shot or periodic timer and associate it with a callback function argument. The timer is initially stopped and must be started with osTimerStart().

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3822 of file os-c-wrapper.cpp.

3823{
3825 {
3826 return nullptr;
3827 }
3828
3829 if (timer_def == nullptr)
3830 {
3831 return nullptr;
3832 }
3833
3834 timer::attributes attr;
3835 attr.tm_type = (timer::type_t)type;
3836
3837#pragma GCC diagnostic push
3838#if defined(__clang__)
3839#pragma clang diagnostic ignored "-Wcast-function-type-strict"
3840#endif
3841 new ((void*)timer_def->data)
3842 timer (timer_def->name, (timer::func_t)timer_def->ptimer,
3843 (timer::func_args_t)args, attr);
3844#pragma GCC diagnostic pop
3845
3846 return reinterpret_cast<osTimerId> (timer_def->data);
3847}
Timer attributes.
Definition os-timer.h:131
type_t tm_type
Timer type attribute.
Definition os-timer.h:187
User single-shot or periodic timer.
Definition os-timer.h:56
void * func_args_t
Timer call back function arguments.
Definition os-timer.h:62
void(*)(func_args_t args) func_t
Entry point of a timer call back function.
Definition os-timer.h:68
uint8_t type_t
Type of of variables holding timer run types.
Definition os-timer.h:74
const char * name
Definition cmsis_os.h:295
osTimer * data
Definition cmsis_os.h:297
os_ptimer ptimer
Definition cmsis_os.h:296
Timer object storage.
Definition os-c-decls.h:784

References os_timer_def::data, os::rtos::interrupts::in_handler_mode(), os_timer_def::name, os_timer_def::ptimer, and os::rtos::timer::attributes::tm_type.

◆ osTimerDelete()

osStatus osTimerDelete ( osTimerId  timer_id)

Delete the timer object that was created by osTimerCreate.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3920 of file os-c-wrapper.cpp.

3921{
3923 {
3924 return osErrorISR;
3925 }
3926
3927 if (timer_id == nullptr)
3928 {
3929 return osErrorParameter;
3930 }
3931
3932 (reinterpret_cast<rtos::timer&> (*timer_id)).~timer ();
3933 return osOK;
3934}

References os::rtos::interrupts::in_handler_mode(), osErrorISR, osErrorParameter, and osOK.

◆ osTimerStart()

osStatus osTimerStart ( osTimerId  timer_id,
uint32_t  millisec 
)

Start or restart the timer.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3856 of file os-c-wrapper.cpp.

3857{
3859 {
3860 return osErrorISR;
3861 }
3862
3863 if (timer_id == nullptr)
3864 {
3865 return osErrorParameter;
3866 }
3867
3868 result_t res
3869 = (reinterpret_cast<rtos::timer&> (*timer_id))
3870 .start (clock_systick::ticks_cast ((uint64_t)(millisec * 1000u)));
3871
3872 if (res == result::ok)
3873 {
3874 return osOK;
3875 }
3876 else
3877 {
3878 return osErrorOS;
3879 }
3880}

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osOK, and os::rtos::clock_systick::ticks_cast().

◆ osTimerStop()

osStatus osTimerStop ( osTimerId  timer_id)
Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 3886 of file os-c-wrapper.cpp.

3887{
3889 {
3890 return osErrorISR;
3891 }
3892
3893 if (timer_id == nullptr)
3894 {
3895 return osErrorParameter;
3896 }
3897
3898 result_t res = (reinterpret_cast<rtos::timer&> (*timer_id)).stop ();
3899 if (res == result::ok)
3900 {
3901 return osOK;
3902 }
3903 else if (res == EAGAIN)
3904 {
3905 return osErrorResource;
3906 }
3907 else
3908 {
3909 return osErrorOS;
3910 }
3911}

References os::rtos::interrupts::in_handler_mode(), os::rtos::result::ok, osErrorISR, osErrorOS, osErrorParameter, osErrorResource, and osOK.