SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
freertos_stk.cpp File Reference
#include <stdio.h>
#include "stk.h"
#include "sync/stk_sync.h"
#include "time/stk_time.h"
#include "memory/stk_memory.h"
#include "FreeRTOS.h"
Include dependency graph for freertos_stk.cpp:

Go to the source code of this file.

Classes

struct  FrtosTask
struct  FrtosTask::NotifySlot
struct  FrtosQueue
struct  FrtosMutexBase
struct  FrtosRecursiveMutex
struct  FrtosFastMutex
struct  FrtosSemaphore
struct  FrtosQueueSet
struct  FrtosTimer
struct  PendCall
struct  FrtosPendDrainer
struct  FrtosEventGroup
struct  FrtosStreamBuffer
struct  FrtosMessageBuffer
struct  FrtosMessageBuffer::MsgEnvelope

Macros

#define FREERTOS_STK_WRAPPER_VERSION   "FreeRTOS-STK Wrapper v1.1"
#define FREERTOS_STK_MIN_STACK_WORDS   STK_STACK_SIZE_MIN

Typedefs

using FrtosKernel

Enumerations

enum class  SemKind : uint8_t {
  None = 0x00U ,
  Counting = 0x80U ,
  Mutex = 0x81U
}

Functions

template<typename T>
static constexpr size_t StkGetWordCountForType ()
static int32_t FreertosStrcmp (const char str1[], const char str2[])
void * malloc (size_t size)
void free (void *ptr)
template<typename T, typename... Args>
static T * ObjAlloc (Args &&...args)
template<typename T>
static void ObjFree (T *obj)
template<typename T>
static T * ObjAllocArray (size_t count)
static void ObjFreeArray (void *ptr)
template<typename T>
static void ObjFreeRaw (T *obj)
__stk_weak void * pvPortMalloc (size_t xWantedSize)
__stk_weak void vPortFree (void *pv)
size_t xPortGetFreeHeapSize (void)
size_t xPortGetMinimumEverFreeHeapSize (void)
void vPortGetHeapStats (HeapStats_t *pxHeapStats)
static int32_t FrtosPrioToStkWeight (UBaseType_t p)
static UBaseType_t StkWeightToFrtosPrio (int32_t w)
static stk::Timeout FrtosTimeoutToStk (TickType_t t)
static bool IsIrqContext ()
void vPortEnterCritical (void)
void vPortExitCritical (void)
void taskYIELD_impl (void)
static SemKind GetSemKindFromHandle (const void *obj)
template<typename THost>
static void QueueSetNotify (void *member_handle, THost *host)
static bool EnsurePendDrainer ()
static void KickPendDrainerFromISR ()
static void EnsureKernelInitialized ()
void vTaskStartScheduler (void)
void vTaskEndScheduler (void)
 End scheduling (KERNEL_DYNAMIC only). Included for API completeness.
void vTaskSuspendAll (void)
 Suspend the scheduler (disables preemption; interrupts remain enabled).
BaseType_t xTaskResumeAll (void)
TickType_t xTaskGetTickCount (void)
 Return the tick count since the scheduler started.
TickType_t xTaskGetTickCountFromISR (void)
 Return the tick count from ISR context (ISR-safe).
UBaseType_t uxTaskGetNumberOfTasks (void)
 Return the number of tasks currently under kernel management.
BaseType_t xTaskGetSchedulerState (void)
BaseType_t xTaskCreate (TaskFunction_t pvTaskCode, const char *pcName, uint32_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask)
TaskHandle_t xTaskCreateStatic (TaskFunction_t pvTaskCode, const char *pcName, uint32_t ulStackDepth, void *pvParameters, UBaseType_t uxPriority, StackType_t *puxStackBuffer, StaticTask_t *pxTaskBuffer)
void vTaskDelete (TaskHandle_t xTaskToDelete)
void vTaskSuspend (TaskHandle_t xTaskToSuspend)
void vTaskResume (TaskHandle_t xTaskToResume)
BaseType_t xTaskResumeFromISR (TaskHandle_t xTaskToResume)
BaseType_t xTaskAbortDelay (TaskHandle_t xTask)
void vTaskDelay (TickType_t xTicksToDelay)
void vTaskDelayUntil (TickType_t *pxPreviousWakeTime, TickType_t xTimeIncrement)
BaseType_t xTaskDelayUntil (TickType_t *pxPreviousWakeTime, TickType_t xTimeIncrement)
void vTaskPrioritySet (TaskHandle_t xTask, UBaseType_t uxNewPriority)
UBaseType_t uxTaskPriorityGet (TaskHandle_t xTask)
UBaseType_t uxTaskPriorityGetFromISR (TaskHandle_t xTask)
eTaskState eTaskGetState (TaskHandle_t xTask)
TaskHandle_t xTaskGetCurrentTaskHandle (void)
TaskHandle_t xTaskGetHandle (const char *pcNameToQuery)
const char * pcTaskGetName (TaskHandle_t xTaskToQuery)
UBaseType_t uxTaskGetStackHighWaterMark (TaskHandle_t xTask)
StackType_t uxTaskGetStackHighWaterMark2 (TaskHandle_t xTask)
UBaseType_t uxTaskGetSystemState (TaskStatus_t *pxTaskStatusArray, UBaseType_t uxArraySize, uint32_t *pulTotalRunTime)
BaseType_t xTaskCreateRestrictedStatic (const TaskParameters_restricted_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask)
BaseType_t xTaskCreateRestricted (const TaskParameters_restricted_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask)
void vTaskList (char *pcWriteBuffer)
void vTaskGetRunTimeStats (char *pcWriteBuffer)
QueueHandle_t xQueueCreate (UBaseType_t uxQueueLength, UBaseType_t uxItemSize)
QueueHandle_t xQueueCreateStatic (UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue)
void vQueueDelete (QueueHandle_t xQueue)
BaseType_t xQueueSend (QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait)
BaseType_t xQueueSendToBack (QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait)
BaseType_t xQueueSendToFront (QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait)
BaseType_t xQueueReceive (QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait)
BaseType_t xQueuePeek (QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait)
BaseType_t xQueuePeekFromISR (QueueHandle_t xQueue, void *pvBuffer)
UBaseType_t uxQueueMessagesWaiting (QueueHandle_t xQueue)
UBaseType_t uxQueueMessagesWaitingFromISR (QueueHandle_t xQueue)
UBaseType_t uxQueueSpacesAvailable (QueueHandle_t xQueue)
BaseType_t xQueueReset (QueueHandle_t xQueue)
BaseType_t xQueueOverwrite (QueueHandle_t xQueue, const void *pvItemToQueue)
BaseType_t xQueueOverwriteFromISR (QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xQueueSendFromISR (QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xQueueReceiveFromISR (QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xQueueSendToBackFromISR (QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xQueueSendToFrontFromISR (QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xQueueIsQueueEmptyFromISR (const QueueHandle_t xQueue)
BaseType_t xQueueIsQueueFullFromISR (const QueueHandle_t xQueue)
static FrtosSemaphore * QueueHandleAsMutex (QueueHandle_t xQueue)
TaskHandle_t xQueueGetMutexHolder (QueueHandle_t xQueue)
TaskHandle_t xQueueGetMutexHolderFromISR (QueueHandle_t xQueue)
QueueSetHandle_t xQueueCreateSet (UBaseType_t uxEventQueueLength)
BaseType_t xQueueAddToSet (QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet)
BaseType_t xQueueRemoveFromSet (QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet)
QueueSetMemberHandle_t xQueueSelectFromSet (QueueSetHandle_t xQueueSet, TickType_t xTicksToWait)
QueueSetMemberHandle_t xQueueSelectFromSetFromISR (QueueSetHandle_t xQueueSet)
SemaphoreHandle_t xSemaphoreCreateBinary (void)
SemaphoreHandle_t xSemaphoreCreateBinaryStatic (StaticSemaphore_t *pxSemaphoreBuffer)
SemaphoreHandle_t xSemaphoreCreateCounting (UBaseType_t uxMaxCount, UBaseType_t uxInitialCount)
SemaphoreHandle_t xSemaphoreCreateCountingStatic (UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer)
static SemaphoreHandle_t CreateMutexInternal (bool recursive)
static SemaphoreHandle_t CreateMutexStaticInternal (StaticSemaphore_t *pxMutexBuffer, bool recursive)
SemaphoreHandle_t xSemaphoreCreateMutex (void)
SemaphoreHandle_t xSemaphoreCreateMutexStatic (StaticSemaphore_t *pxMutexBuffer)
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex (void)
 Create a recursive mutex (same implementation as xSemaphoreCreateMutex).
SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic (StaticSemaphore_t *pxMutexBuffer)
void vSemaphoreDelete (SemaphoreHandle_t xSemaphore)
BaseType_t xSemaphoreTake (SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait)
BaseType_t xSemaphoreTakeFromISR (SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xSemaphoreTakeRecursive (SemaphoreHandle_t xMutex, TickType_t xTicksToWait)
BaseType_t xSemaphoreGive (SemaphoreHandle_t xSemaphore)
BaseType_t xSemaphoreGiveRecursive (SemaphoreHandle_t xMutex)
BaseType_t xSemaphoreGiveFromISR (SemaphoreHandle_t xSemaphore, BaseType_t *pxHigherPriorityTaskWoken)
UBaseType_t uxSemaphoreGetCount (SemaphoreHandle_t xSemaphore)
TaskHandle_t xSemaphoreGetMutexHolder (SemaphoreHandle_t xMutex)
TaskHandle_t xSemaphoreGetMutexHolderFromISR (SemaphoreHandle_t xMutex)
TimerHandle_t xTimerCreate (const char *pcTimerName, TickType_t xTimerPeriodInTicks, UBaseType_t uxAutoReload, void *pvTimerID, TimerCallbackFunction_t pxCallbackFunction)
TimerHandle_t xTimerCreateStatic (const char *pcTimerName, TickType_t xTimerPeriodInTicks, UBaseType_t uxAutoReload, void *pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer)
BaseType_t xTimerDelete (TimerHandle_t xTimer, TickType_t)
BaseType_t xTimerStart (TimerHandle_t xTimer, TickType_t)
BaseType_t xTimerStop (TimerHandle_t xTimer, TickType_t)
BaseType_t xTimerReset (TimerHandle_t xTimer, TickType_t xTicksToWait)
BaseType_t xTimerChangePeriod (TimerHandle_t xTimer, TickType_t xNewPeriod, TickType_t xTicksToWait)
BaseType_t xTimerStartFromISR (TimerHandle_t xTimer, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTimerStopFromISR (TimerHandle_t xTimer, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTimerResetFromISR (TimerHandle_t xTimer, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTimerChangePeriodFromISR (TimerHandle_t xTimer, TickType_t xNewPeriod, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTimerPendFunctionCall (PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait)
BaseType_t xTimerPendFunctionCallFromISR (PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTimerIsTimerActive (TimerHandle_t xTimer)
void * pvTimerGetTimerID (TimerHandle_t xTimer)
void vTimerSetTimerID (TimerHandle_t xTimer, void *pvNewID)
const char * pcTimerGetName (TimerHandle_t xTimer)
TickType_t xTimerGetPeriod (TimerHandle_t xTimer)
TickType_t xTimerGetExpiryTime (TimerHandle_t xTimer)
static EventBits_t StkFlagsToFrtos (uint32_t result, EventBits_t snapshot=0U)
static uint32_t BuildStkFlagsOpts (BaseType_t xClearOnExit, BaseType_t xWaitForAllBits)
EventGroupHandle_t xEventGroupCreate (void)
EventGroupHandle_t xEventGroupCreateStatic (StaticEventGroup_t *pxEventGroupBuffer)
void vEventGroupDelete (EventGroupHandle_t xEventGroup)
EventBits_t xEventGroupSetBits (EventGroupHandle_t xEventGroup, EventBits_t uxBitsToSet)
EventBits_t xEventGroupClearBits (EventGroupHandle_t xEventGroup, EventBits_t uxBitsToClear)
EventBits_t xEventGroupGetBits (EventGroupHandle_t xEventGroup)
EventBits_t xEventGroupWaitBits (EventGroupHandle_t xEventGroup, EventBits_t uxBitsToWaitFor, BaseType_t xClearOnExit, BaseType_t xWaitForAllBits, TickType_t xTicksToWait)
BaseType_t xEventGroupSetBitsFromISR (EventGroupHandle_t xEventGroup, EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken)
EventBits_t xEventGroupClearBitsFromISR (EventGroupHandle_t xEventGroup, EventBits_t uxBitsToClear)
EventBits_t xEventGroupSync (EventGroupHandle_t xEventGroup, EventBits_t uxBitsToSet, EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait)
static FrtosTask * ResolveNotifyTarget (TaskHandle_t xTask, UBaseType_t uxIndex)
static BaseType_t NotifyApplyAction (FrtosTask::NotifySlot &slot, uint32_t ulValue, eNotifyAction eAction)
BaseType_t xTaskNotifyGiveIndexed (TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify)
uint32_t ulTaskNotifyTakeIndexed (UBaseType_t uxIndexToWait, BaseType_t ulClearCountOnExit, TickType_t xTicksToWait)
BaseType_t xTaskNotifyIndexed (TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction)
BaseType_t xTaskNotifyWaitIndexed (UBaseType_t uxIndexToWait, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait)
BaseType_t xTaskNotifyFromISRIndexed (TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTaskNotifyGive (TaskHandle_t xTaskToNotify)
uint32_t ulTaskNotifyTake (BaseType_t ulClearCountOnExit, TickType_t xTicksToWait)
BaseType_t xTaskNotify (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction)
BaseType_t xTaskNotifyWait (uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait)
BaseType_t xTaskNotifyFromISR (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTaskNotifyAndQueryIndexed (TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue)
BaseType_t xTaskNotifyAndQuery (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue)
BaseType_t xTaskNotifyAndQueryFromISRIndexed (TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTaskNotifyAndQueryFromISR (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xTaskNotifyStateClearIndexed (TaskHandle_t xTask, UBaseType_t uxIndexToClear)
BaseType_t xTaskNotifyStateClear (TaskHandle_t xTask)
uint32_t ulTaskNotifyValueClearIndexed (TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear)
uint32_t ulTaskNotifyValueClear (TaskHandle_t xTask, uint32_t ulBitsToClear)
void vTaskSetThreadLocalStoragePointer (TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue)
void * pvTaskGetThreadLocalStoragePointer (TaskHandle_t xTaskToQuery, BaseType_t xIndex)
StreamBufferHandle_t xStreamBufferCreate (size_t xBufferSizeBytes, size_t xTriggerLevelBytes)
StreamBufferHandle_t xStreamBufferCreateStatic (size_t xBufferSizeBytes, size_t xTriggerLevelBytes, uint8_t *pucStreamBufferStorageArea, StaticStreamBuffer_t *pxStaticStreamBuffer)
void vStreamBufferDelete (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferSend (StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait)
size_t xStreamBufferSendFromISR (StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *pxHigherPriorityTaskWoken)
size_t xStreamBufferReceive (StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait)
size_t xStreamBufferReceiveFromISR (StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t *pxHigherPriorityTaskWoken)
size_t xStreamBufferBytesAvailable (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferSpacesAvailable (StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferIsEmpty (StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferIsFull (StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferReset (StreamBufferHandle_t xStreamBuffer)
BaseType_t xStreamBufferSetTriggerLevel (StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevelBytes)
BaseType_t xStreamBufferResetFromISR (StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken)
size_t xStreamBufferGetTriggerLevel (StreamBufferHandle_t xStreamBuffer)
size_t xStreamBufferNextMessageLengthBytes (StreamBufferHandle_t xStreamBuffer)
StreamBufferHandle_t xStreamBufferCreateWithCallback (size_t xBufferSizeBytes, size_t xTriggerLevelBytes, StreamBufferCallbackFunction_t pxSendCompletedCallback, StreamBufferCallbackFunction_t pxReceiveCompletedCallback)
StreamBufferHandle_t xStreamBufferCreateStaticWithCallback (size_t xBufferSizeBytes, size_t xTriggerLevelBytes, uint8_t *pucStreamBufferStorageArea, StaticStreamBuffer_t *pxStaticStreamBuffer, StreamBufferCallbackFunction_t pxSendCompletedCallback, StreamBufferCallbackFunction_t pxReceiveCompletedCallback)
static size_t MsgBufSlotCount (size_t budget_bytes, size_t max_msg_size)
MessageBufferHandle_t xMessageBufferCreate (size_t xBufferSizeBytes, size_t xMaxMessageSize)
MessageBufferHandle_t xMessageBufferCreateStatic (size_t xMaxMessageSize, size_t xMessageCount, uint8_t *pucMessageBufferStorageArea, StaticMessageBuffer_t *pxStaticMessageBuffer)
MessageBufferHandle_t xMessageBufferCreateWithCallback (size_t xBufferSizeBytes, size_t xMaxMessageSize, StreamBufferCallbackFunction_t pxSendCompletedCallback, StreamBufferCallbackFunction_t pxReceiveCompletedCallback)
MessageBufferHandle_t xMessageBufferCreateStaticWithCallback (size_t xMaxMessageSize, size_t xMessageCount, uint8_t *pucMessageBufferStorageArea, StaticMessageBuffer_t *pxStaticMessageBuffer, StreamBufferCallbackFunction_t pxSendCompletedCallback, StreamBufferCallbackFunction_t pxReceiveCompletedCallback)
void vMessageBufferDelete (MessageBufferHandle_t xMessageBuffer)
size_t xMessageBufferSend (MessageBufferHandle_t xMessageBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait)
size_t xMessageBufferReceive (MessageBufferHandle_t xMessageBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait)
BaseType_t xMessageBufferIsEmpty (MessageBufferHandle_t xMessageBuffer)
BaseType_t xMessageBufferIsFull (MessageBufferHandle_t xMessageBuffer)
size_t xMessageBufferSpacesAvailable (MessageBufferHandle_t xMessageBuffer)
BaseType_t xMessageBufferReset (MessageBufferHandle_t xMessageBuffer)
size_t xMessageBufferSendFromISR (MessageBufferHandle_t xMessageBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t *pxHigherPriorityTaskWoken)
size_t xMessageBufferReceiveFromISR (MessageBufferHandle_t xMessageBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t *pxHigherPriorityTaskWoken)
BaseType_t xMessageBufferResetFromISR (MessageBufferHandle_t xMessageBuffer, BaseType_t *pxHigherPriorityTaskWoken)
size_t xMessageBufferNextLengthBytes (MessageBufferHandle_t xMessageBuffer)

Variables

static stk::memory::MemoryAllocator::Stats s_MemStats (10240U)
static FrtosKernel g_StkKernel
static stk::time::TimerHost * g_TimerHost = nullptr
static stk::Word g_TimerHostBuf [StkGetWordCountForType< stk::time::TimerHost >()]
static stk::sync::PipeT< PendCall, 8U > g_PendCallPipe
static stk::Word g_PendDrainerBuf [StkGetWordCountForType< stk::time::TimerHost::Timer >()]
static stk::time::TimerHost::Timer * g_PendDrainer = nullptr

Macro Definition Documentation

◆ FREERTOS_STK_MIN_STACK_WORDS

#define FREERTOS_STK_MIN_STACK_WORDS   STK_STACK_SIZE_MIN

Definition at line 41 of file freertos_stk.cpp.

Referenced by xTaskCreate(), and xTaskCreateStatic().

◆ FREERTOS_STK_WRAPPER_VERSION

#define FREERTOS_STK_WRAPPER_VERSION   "FreeRTOS-STK Wrapper v1.1"

Definition at line 25 of file freertos_stk.cpp.

Typedef Documentation

◆ FrtosKernel

using FrtosKernel
Initial value:
, 16U ,
SwitchStrategyFixedPriority< 32 > SwitchStrategyFP32
Shorthand alias for SwitchStrategyFixedPriority<32>: 32 priority levels (0..31), using a single 32-bi...
PlatformArmCortexM PlatformDefault
Default platform implementation.
@ KERNEL_TICKLESS
Tickless mode. To use this mode STK_TICKLESS_IDLE must be defined to 1 in stk_config....
Definition stk_common.h:51
@ KERNEL_SYNC
Synchronization support (see Event).
Definition stk_common.h:50
@ KERNEL_DYNAMIC
Tasks can be added or removed and therefore exit when done.
Definition stk_common.h:48
Concrete implementation of IKernel.
Definition stk.h:100

Definition at line 357 of file freertos_stk.cpp.

Enumeration Type Documentation

◆ SemKind

enum class SemKind : uint8_t
strong
Enumerator
None 

Sentinel: not a FrtosSemaphore (e.g. plain FrtosQueue).

Counting 

Binary or counting semaphore (backed by stk::sync::Semaphore).

Mutex 

Mutex or recursive mutex (backed by stk::sync::FastMutex or stk::sync::Mutex).

Definition at line 591 of file freertos_stk.cpp.

592{
593 None = 0x00U,
594 Counting = 0x80U,
595 Mutex = 0x81U,
596};
@ Mutex
Mutex or recursive mutex (backed by stk::sync::FastMutex or stk::sync::Mutex).
@ None
Sentinel: not a FrtosSemaphore (e.g. plain FrtosQueue).
@ Counting
Binary or counting semaphore (backed by stk::sync::Semaphore).

Function Documentation

◆ BuildStkFlagsOpts()

uint32_t BuildStkFlagsOpts ( BaseType_t xClearOnExit,
BaseType_t xWaitForAllBits )
inlinestatic

Definition at line 3088 of file freertos_stk.cpp.

3090{
3092
3093 if (xWaitForAllBits == pdTRUE)
3095
3096 if (xClearOnExit == pdFALSE)
3098
3099 return opts;
3100}
#define pdFALSE
Definition FreeRTOS.h:264
#define pdTRUE
Definition FreeRTOS.h:263
static const uint32_t OPT_NO_CLEAR
Do not clear matched flags after a successful wait.
static const uint32_t OPT_WAIT_ALL
Wait for ALL of the specified flags to be set simultaneously (AND semantics).
static const uint32_t OPT_WAIT_ANY
Wait for ANY of the specified flags to be set (OR semantics, default).

References stk::sync::EventFlags::OPT_NO_CLEAR, stk::sync::EventFlags::OPT_WAIT_ALL, stk::sync::EventFlags::OPT_WAIT_ANY, pdFALSE, and pdTRUE.

Referenced by xEventGroupWaitBits().

Here is the caller graph for this function:

◆ CreateMutexInternal()

SemaphoreHandle_t CreateMutexInternal ( bool recursive)
static

Definition at line 2416 of file freertos_stk.cpp.

2417{
2420 static_cast<uint16_t>(0U),
2421 static_cast<uint16_t>(1U),
2422 recursive);
2423
2424 if ((s == nullptr) || (s->m_mtx == nullptr))
2425 {
2426 ObjFree(s);
2427 return nullptr;
2428 }
2429
2430 return static_cast<SemaphoreHandle_t>(s);
2431}
static void ObjFree(T *obj)
static T * ObjAlloc(Args &&...args)
void * SemaphoreHandle_t
Definition FreeRTOS.h:312
FrtosMutexBase * m_mtx

References FrtosSemaphore::m_mtx, Mutex, ObjAlloc(), and ObjFree().

Referenced by xSemaphoreCreateMutex(), and xSemaphoreCreateRecursiveMutex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateMutexStaticInternal()

SemaphoreHandle_t CreateMutexStaticInternal ( StaticSemaphore_t * pxMutexBuffer,
bool recursive )
static

Definition at line 2434 of file freertos_stk.cpp.

2435{
2436 if (pxMutexBuffer == nullptr)
2437 return nullptr;
2438
2439 static_assert(sizeof(StaticSemaphore_t) >= sizeof(FrtosSemaphore),
2440 "StaticSemaphore_t is too small to hold FrtosSemaphore. "
2441 "Increase STATIC_SEMAPHORE_TCB_SIZE_WORDS in freertos_stk.h.");
2442
2443 FrtosSemaphore *s = new (pxMutexBuffer) FrtosSemaphore(
2445 static_cast<uint16_t>(0U),
2446 static_cast<uint16_t>(1U),
2447 recursive);
2448
2449 if (s->m_mtx == nullptr)
2450 {
2451 s->~FrtosSemaphore();
2452 return nullptr;
2453 }
2454
2455 s->m_cb_owned = false;
2456 return static_cast<SemaphoreHandle_t>(s);
2457}

References FrtosSemaphore::m_cb_owned, FrtosSemaphore::m_mtx, Mutex, and FrtosSemaphore::~FrtosSemaphore().

Referenced by xSemaphoreCreateMutexStatic(), and xSemaphoreCreateRecursiveMutexStatic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureKernelInitialized()

void EnsureKernelInitialized ( )
static

Definition at line 1111 of file freertos_stk.cpp.

1112{
1114 {
1115 g_StkKernel.Initialize(); // default 1 ms tick resolution
1116 }
1117}
static StkKernel g_StkKernel
@ KSTATE_INACTIVE
Not ready, IKernel::Initialize() must be called.

References g_StkKernel, and stk::IKernel::KSTATE_INACTIVE.

Referenced by vTaskStartScheduler(), xTaskCreate(), and xTaskCreateStatic().

Here is the caller graph for this function:

◆ EnsurePendDrainer()

bool EnsurePendDrainer ( )
static

Definition at line 931 of file freertos_stk.cpp.

932{
933 if (g_PendDrainer == nullptr)
935
936 // Re-start as a 1-tick auto-reload timer each time we have new work.
937 // Restart() is idempotent if already active.
938 return g_TimerHost->Restart(*g_PendDrainer, 1U, 1U);
939}
static stk::time::TimerHost * g_TimerHost
static stk::Word g_PendDrainerBuf[StkGetWordCountForType< stk::time::TimerHost::Timer >()]
static stk::time::TimerHost::Timer * g_PendDrainer

References g_PendDrainer, g_PendDrainerBuf, and g_TimerHost.

Referenced by xTimerPendFunctionCall().

Here is the caller graph for this function:

◆ free()

void free ( void * ptr)

◆ FreertosStrcmp()

int32_t FreertosStrcmp ( const char str1[],
const char str2[] )
static

Definition at line 50 of file freertos_stk.cpp.

51{
52 size_t index = 0U;
53 int32_t result = 0;
54
55 // Loop until the end of either string or until a mismatch is found
56 while ((str1[index] != '\0') && (str2[index] != '\0') && (str1[index] == str2[index]))
57 {
58 index++;
59 }
60
61 // Calculate the difference between the characters where the loop stopped
62 // Cast to int to match standard strcmp return type
63 result = static_cast<int32_t>(str1[index]) - static_cast<int32_t>(str2[index]);
64
65 return result;
66}

Referenced by xTaskGetHandle().

Here is the caller graph for this function:

◆ FrtosPrioToStkWeight()

int32_t FrtosPrioToStkWeight ( UBaseType_t p)
inlinestatic

Definition at line 301 of file freertos_stk.cpp.

302{
303 // Clamp to [0 .. configMAX_PRIORITIES-1] then pass through directly:
304 // STK FP32 level == FreeRTOS priority (both 0 = lowest).
307
308 return static_cast<int32_t>(p);
309}
unsigned long UBaseType_t
Definition FreeRTOS.h:258
#define configMAX_PRIORITIES
Definition FreeRTOS.h:152

References configMAX_PRIORITIES.

Referenced by FrtosTask::FrtosTask(), vTaskPrioritySet(), xTaskCreate(), and xTaskCreateStatic().

Here is the caller graph for this function:

◆ FrtosTimeoutToStk()

stk::Timeout FrtosTimeoutToStk ( TickType_t t)
inlinestatic

< Block indefinitely.

Definition at line 330 of file freertos_stk.cpp.

331{
332 if (t == portMAX_DELAY)
333 return stk::WAIT_INFINITE;
334
335 if (t == 0U)
336 return stk::NO_WAIT;
337
338 return static_cast<stk::Timeout>(t);
339}
#define portMAX_DELAY
Definition FreeRTOS.h:262
static constexpr Timeout NO_WAIT
Timeout value: return immediately if the synchronization object is not yet signaled (non-blocking pol...
Definition stk_common.h:234
int32_t Timeout
Timeout time (ticks).
Definition stk_common.h:170
static constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
Definition stk_common.h:228

References stk::NO_WAIT, portMAX_DELAY, and stk::WAIT_INFINITE.

Referenced by ulTaskNotifyTakeIndexed(), vTaskDelay(), xEventGroupSync(), xEventGroupWaitBits(), xMessageBufferReceive(), xMessageBufferSend(), xQueuePeek(), xQueueReceive(), xQueueSelectFromSet(), xQueueSend(), xQueueSendToFront(), xSemaphoreTake(), xStreamBufferReceive(), xStreamBufferSend(), xTaskNotifyWaitIndexed(), and xTimerPendFunctionCall().

Here is the caller graph for this function:

◆ GetSemKindFromHandle()

SemKind GetSemKindFromHandle ( const void * obj)
static

Definition at line 605 of file freertos_stk.cpp.

606{
607 const uint8_t first_byte = *static_cast<const uint8_t *>(obj);
608
609 switch (first_byte)
610 {
611 case static_cast<uint8_t>(SemKind::Counting): return SemKind::Counting;
612 case static_cast<uint8_t>(SemKind::Mutex): return SemKind::Mutex;
613 default: return SemKind::None;
614 }
615}
SemKind

References Counting, Mutex, and None.

Referenced by QueueHandleAsMutex(), xQueueAddToSet(), and xQueueRemoveFromSet().

Here is the caller graph for this function:

◆ IsIrqContext()

bool IsIrqContext ( )
inlinestatic

Definition at line 344 of file freertos_stk.cpp.

345{
346 return stk::hw::IsInsideISR();
347}
bool IsInsideISR()
Check whether the CPU is currently executing inside a hardware interrupt service routine (ISR).

References stk::hw::IsInsideISR().

Here is the call graph for this function:

◆ KickPendDrainerFromISR()

void KickPendDrainerFromISR ( )
static

Definition at line 945 of file freertos_stk.cpp.

946{
947 if ((g_PendDrainer != nullptr) && (g_TimerHost != nullptr))
948 g_TimerHost->Restart(*g_PendDrainer, 1U, 1U);
949}

References g_PendDrainer, and g_TimerHost.

Referenced by xTimerPendFunctionCallFromISR().

Here is the caller graph for this function:

◆ malloc()

void * malloc ( size_t size)

◆ MsgBufSlotCount()

size_t MsgBufSlotCount ( size_t budget_bytes,
size_t max_msg_size )
static

Definition at line 4212 of file freertos_stk.cpp.

4213{
4214 const size_t block_size = stk::memory::BlockMemoryPool::AlignBlockSize(max_msg_size);
4215 const size_t slot_cost = block_size + FrtosMessageBuffer::ENVELOPE_SIZE;
4216
4217 if (slot_cost == 0U)
4218 return 0U;
4219
4220 return budget_bytes / slot_cost;
4221}
static constexpr size_t AlignBlockSize(size_t raw_size)
Round a raw block size up to the nearest multiple of BLOCK_ALIGN.
static constexpr size_t ENVELOPE_SIZE

References stk::memory::BlockMemoryPool::AlignBlockSize(), and FrtosMessageBuffer::ENVELOPE_SIZE.

Referenced by xMessageBufferCreate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NotifyApplyAction()

BaseType_t NotifyApplyAction ( FrtosTask::NotifySlot & slot,
uint32_t ulValue,
eNotifyAction eAction )
static

Definition at line 3351 of file freertos_stk.cpp.

3354{
3355 switch (eAction)
3356 {
3357 case eNoAction:
3358 break;
3359
3360 case eSetBits:
3361 slot.value |= ulValue;
3362 break;
3363
3364 case eIncrement:
3365 slot.value++;
3366 break;
3367
3369 slot.value = ulValue;
3370 break;
3371
3373 if (slot.pending)
3374 return pdFAIL; // value not consumed yet
3375 slot.value = ulValue;
3376 slot.pending = true;
3377 break;
3378
3379 default:
3380 return pdFAIL;
3381 }
3382
3383 return pdPASS;
3384}
#define pdPASS
Definition FreeRTOS.h:265
#define pdFAIL
Definition FreeRTOS.h:266
@ eIncrement
Definition FreeRTOS.h:298
@ eSetValueWithOverwrite
Definition FreeRTOS.h:299
@ eSetBits
Definition FreeRTOS.h:297
@ eNoAction
Definition FreeRTOS.h:296
@ eSetValueWithoutOverwrite
Definition FreeRTOS.h:300
volatile bool pending
true if a value was set but not yet consumed
volatile uint32_t value
notification value word

References eIncrement, eNoAction, eSetBits, eSetValueWithoutOverwrite, eSetValueWithOverwrite, pdFAIL, pdPASS, FrtosTask::NotifySlot::pending, and FrtosTask::NotifySlot::value.

Referenced by xTaskNotifyAndQueryIndexed(), and xTaskNotifyIndexed().

Here is the caller graph for this function:

◆ ObjAlloc()

template<typename T, typename... Args>
T * ObjAlloc ( Args &&... args)
static

Definition at line 137 of file freertos_stk.cpp.

138{
139 T *obj = nullptr;
140
141 void *ptr = pvPortMalloc(sizeof(T));
142 if (ptr != nullptr)
143 obj = new (ptr) T(static_cast<Args &&>(args)...);
144
145 return obj;
146}
__stk_weak void * pvPortMalloc(size_t xWantedSize)

References pvPortMalloc().

Referenced by CreateMutexInternal(), FrtosQueueSet::FrtosQueueSet(), FrtosSemaphore::FrtosSemaphore(), xEventGroupCreate(), xMessageBufferCreate(), xMessageBufferCreateWithCallback(), xQueueCreate(), xQueueCreateSet(), xSemaphoreCreateBinary(), xSemaphoreCreateCounting(), xStreamBufferCreate(), xStreamBufferCreateWithCallback(), xTaskCreate(), and xTimerCreate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ObjAllocArray()

template<typename T>
T * ObjAllocArray ( size_t count)
static

Definition at line 164 of file freertos_stk.cpp.

165{
166 if (count == 0U)
167 return nullptr;
168
169 void *ptr = pvPortMalloc(sizeof(T) * count);
170 return static_cast<T *>(ptr);
171}

References pvPortMalloc().

Referenced by FrtosQueue::AllocBuffer(), FrtosMessageBuffer::FrtosMessageBuffer(), FrtosQueueSet::FrtosQueueSet(), xStreamBufferCreate(), xStreamBufferCreateWithCallback(), and xTaskCreate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ObjFree()

template<typename T>
void ObjFree ( T * obj)
static

Definition at line 150 of file freertos_stk.cpp.

151{
152 if (obj != nullptr)
153 {
154 obj->~T();
155
156 if (obj->m_cb_owned)
157 vPortFree(obj);
158 }
159}
__stk_weak void vPortFree(void *pv)

References vPortFree().

Referenced by CreateMutexInternal(), vEventGroupDelete(), vMessageBufferDelete(), vQueueDelete(), vSemaphoreDelete(), vStreamBufferDelete(), vTaskDelete(), xQueueCreate(), xQueueCreateSet(), xSemaphoreCreateBinary(), xSemaphoreCreateCounting(), xTaskCreate(), and xTimerDelete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ObjFreeArray()

void ObjFreeArray ( void * ptr)
inlinestatic

Definition at line 175 of file freertos_stk.cpp.

176{
177 vPortFree(ptr);
178}

References vPortFree().

Referenced by xStreamBufferCreate(), xStreamBufferCreateWithCallback(), FrtosMessageBuffer::~FrtosMessageBuffer(), FrtosQueue::~FrtosQueue(), FrtosQueueSet::~FrtosQueueSet(), FrtosStreamBuffer::~FrtosStreamBuffer(), and FrtosTask::~FrtosTask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ObjFreeRaw()

template<typename T>
void ObjFreeRaw ( T * obj)
static

Definition at line 184 of file freertos_stk.cpp.

185{
186 if (obj != nullptr)
187 {
188 obj->~T();
189 vPortFree(obj);
190 }
191}

References vPortFree().

Referenced by xMessageBufferCreate(), xMessageBufferCreateWithCallback(), FrtosQueueSet::~FrtosQueueSet(), and FrtosSemaphore::~FrtosSemaphore().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QueueHandleAsMutex()

FrtosSemaphore * QueueHandleAsMutex ( QueueHandle_t xQueue)
inlinestatic

Definition at line 2081 of file freertos_stk.cpp.

2082{
2083 if (xQueue == nullptr)
2084 return nullptr;
2085
2086 // GetSemKindFromHandle() returns SemKind::None for FrtosQueue handles
2087 // (and any unrecognised object), SemKind::Counting or SemKind::Mutex for
2088 // FrtosSemaphore handles. Only SemKind::Mutex carries an owner field.
2089 if (GetSemKindFromHandle(xQueue) != SemKind::Mutex)
2090 return nullptr;
2091
2092 return static_cast<FrtosSemaphore *>(xQueue);
2093}
static SemKind GetSemKindFromHandle(const void *obj)

References GetSemKindFromHandle(), and Mutex.

Referenced by xQueueGetMutexHolder(), and xQueueGetMutexHolderFromISR().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QueueSetNotify()

template<typename THost>
void QueueSetNotify ( void * member_handle,
THost * host )
inlinestatic

Definition at line 796 of file freertos_stk.cpp.

797{
798#if configUSE_QUEUE_SETS
799 // m_set is non-null only when the member was registered with xQueueAddToSet.
800 // Post the member handle as a pointer-sized token. TryPut is ISR-safe.
801 if (host->m_set != nullptr)
802 host->m_set->m_token_mq->TryPut(&member_handle);
803#else
804 STK_UNUSED(member_handle);
805 STK_UNUSED(host);
806#endif
807}
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:715

References STK_UNUSED.

Referenced by xQueueOverwrite(), xQueueOverwriteFromISR(), xQueueSend(), xQueueSendFromISR(), xQueueSendToFront(), xQueueSendToFrontFromISR(), xSemaphoreGive(), and xSemaphoreGiveFromISR().

Here is the caller graph for this function:

◆ ResolveNotifyTarget()

FrtosTask * ResolveNotifyTarget ( TaskHandle_t xTask,
UBaseType_t uxIndex )
static

< Number of per-task notification slots (indexed API).

< Number of per-task notification slots (indexed API).

Definition at line 3334 of file freertos_stk.cpp.

3335{
3337
3339 return nullptr;
3340
3341 if (xTask == nullptr)
3342 xTask = xTaskGetCurrentTaskHandle();
3343
3344 return static_cast<FrtosTask *>(xTask);
3345}
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:516
TaskHandle_t xTaskGetCurrentTaskHandle(void)
#define configTASK_NOTIFICATION_ARRAY_ENTRIES
Definition FreeRTOS.h:168

References configTASK_NOTIFICATION_ARRAY_ENTRIES, STK_ASSERT, and xTaskGetCurrentTaskHandle().

Referenced by ulTaskNotifyTakeIndexed(), ulTaskNotifyValueClearIndexed(), xTaskNotifyAndQueryIndexed(), xTaskNotifyGiveIndexed(), xTaskNotifyIndexed(), xTaskNotifyStateClearIndexed(), and xTaskNotifyWaitIndexed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StkFlagsToFrtos()

EventBits_t StkFlagsToFrtos ( uint32_t result,
EventBits_t snapshot = 0U )
inlinestatic

Definition at line 3079 of file freertos_stk.cpp.

3080{
3082 return snapshot; // timeout, aborted wait (ERROR_CANCELED) or error — return flags snapshot
3083
3084 return static_cast<EventBits_t>(result);
3085}
uint32_t EventBits_t
Definition FreeRTOS.h:380
static bool IsError(uint32_t result)
Checks if a return value from Set(), Clear(), or Wait() is an error.

References stk::sync::EventFlags::IsError().

Referenced by xEventGroupClearBits(), xEventGroupClearBitsFromISR(), xEventGroupSetBits(), xEventGroupSync(), and xEventGroupWaitBits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StkGetWordCountForType()

template<typename T>
constexpr size_t StkGetWordCountForType ( )
staticconstexpr

Definition at line 44 of file freertos_stk.cpp.

45{
46 return ((sizeof(T) + sizeof(stk::Word) - 1) / sizeof(stk::Word));
47}
uintptr_t Word
Native processor word type.
Definition stk_common.h:160

◆ StkWeightToFrtosPrio()

UBaseType_t StkWeightToFrtosPrio ( int32_t w)
inlinestatic

Definition at line 311 of file freertos_stk.cpp.

312{
313 if (w < 0)
314 return 0U;
315
316 UBaseType_t p = static_cast<UBaseType_t>(w);
317
320
321 return p;
322}

References configMAX_PRIORITIES.

Referenced by uxTaskGetSystemState(), uxTaskPriorityGet(), and vTaskList().

Here is the caller graph for this function:

Variable Documentation

◆ g_PendCallPipe

stk::sync::PipeT<PendCall, 8U > g_PendCallPipe
static

◆ g_PendDrainer

stk::time::TimerHost::Timer* g_PendDrainer = nullptr
static

Definition at line 909 of file freertos_stk.cpp.

Referenced by EnsurePendDrainer(), and KickPendDrainerFromISR().

◆ g_PendDrainerBuf

Definition at line 908 of file freertos_stk.cpp.

Referenced by EnsurePendDrainer().

◆ g_StkKernel

FrtosKernel g_StkKernel
static

Definition at line 365 of file freertos_stk.cpp.

Referenced by FrtosTimer::EnsureTimerHost().

◆ g_TimerHost

stk::time::TimerHost* g_TimerHost = nullptr
static

Definition at line 818 of file freertos_stk.cpp.

Referenced by FrtosTimer::EnsureTimerHost().

◆ g_TimerHostBuf

Definition at line 821 of file freertos_stk.cpp.

Referenced by FrtosTimer::EnsureTimerHost().

◆ s_MemStats