Skip to content

API guide

Which class to reach for, by task. Each row links the page with a compiled example and the memory and timing notes.

Task Use Header Page
Run a loop in its own task, start and stop it BaseThread BaseThread.h BaseThread
Start and stop a group of threads BaseThreadsManager<Enum, Max> BaseThreadsManager.h Utility
Protect shared data RtosMutex with std::lock_guard RtosMutex.h Synchronization
Lock with a timeout and a named mutex Mutex and MutexGuard Mutex.h, MutexGuard.h Synchronization
Wake one task from another SignalSemaphore SignalSemaphore.h Synchronization
Wait for any or all of several events OsEventFlags OsEventFlags.h Synchronization
Keep an interrupt out of a few lines CriticalGuard CriticalGuard.h Synchronization
Pass values between tasks OsQueue<T, N> OsQueue.h Queues
Call a function every N ms PeriodicTimer PeriodicTimer.h Timers
Share status flags hf::FlagsSaver<Id, N> FlagsSaver.h Generic templates
Share the latest value of a struct hf::SeqlockSnapshot<T> SeqlockSnapshot.h Generic templates
Keep the last N errors hf::ErrorHistory<R, N> ErrorHistory.h Generic templates
Wait until a condition holds, with a timeout TestLogicWithTimeout() Utility.h Utility
Read time, sleep RtosTime::GetCurrentTimeUs(), os_delay_msec() RtosMutex.h, OsUtility.h Utility

Conventions

  • Results are bool. True means the operation happened; false means a timeout or a failed kernel call.
  • Timeouts are milliseconds in a uint32_t. UINT32_MAX waits forever; 0 does not wait.
  • Objects are not copyable. Each owns a kernel handle; RtosMutex and RtosSharedMutex can be moved.
  • Task context only. The queue, event-flag, mutex, semaphore and generic-template calls use the task-level kernel API. From an interrupt, use the kernel's FromISR calls and hand the work to a task.

Next: BaseThread.