SuperTinyKernel™ RTOS 1.06.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  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.0"
#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 FrtosSemaphoreQueueHandleAsMutex (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)
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 FrtosTaskResolveNotifyTarget (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::TimerHostg_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::Timerg_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.0"

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:46
@ KERNEL_SYNC
Synchronization support (see Event).
Definition stk_common.h:45
@ KERNEL_DYNAMIC
Tasks can be added or removed and therefore exit when done.
Definition stk_common.h:43
Concrete implementation of IKernel.
Definition stk.h:85

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::Mutex).

Definition at line 588 of file freertos_stk.cpp.

589{
590 None = 0x00U,
591 Counting = 0x80U,
592 Mutex = 0x81U,
593};
@ Mutex
Mutex or recursive mutex (backed by 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 2970 of file freertos_stk.cpp.

2972{
2974
2975 if (xWaitForAllBits == pdTRUE)
2977
2978 if (xClearOnExit == pdFALSE)
2980
2981 return opts;
2982}
#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:

◆ EnsureKernelInitialized()

void EnsureKernelInitialized ( )
static

Definition at line 1050 of file freertos_stk.cpp.

1051{
1053 {
1054 g_StkKernel.Initialize(); // default 1 ms tick resolution
1055 }
1056}
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 870 of file freertos_stk.cpp.

871{
872 if (g_PendDrainer == nullptr)
874
875 // Re-start as a 1-tick auto-reload timer each time we have new work.
876 // Restart() is idempotent if already active.
877 return g_TimerHost->Restart(*g_PendDrainer, 1U, 1U);
878}
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
constexpr Timeout NO_WAIT
Timeout value: return immediately if the synchronization object is not yet signaled (non-blocking pol...
Definition stk_common.h:189
int32_t Timeout
Timeout time (ticks).
Definition stk_common.h:125
constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
Definition stk_common.h:183

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 602 of file freertos_stk.cpp.

603{
604 const uint8_t first_byte = *static_cast<const uint8_t *>(obj);
605
606 switch (first_byte)
607 {
608 case static_cast<uint8_t>(SemKind::Counting): return SemKind::Counting;
609 case static_cast<uint8_t>(SemKind::Mutex): return SemKind::Mutex;
610 default: return SemKind::None;
611 }
612}
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 884 of file freertos_stk.cpp.

885{
886 if ((g_PendDrainer != nullptr) && (g_TimerHost != nullptr))
887 g_TimerHost->Restart(*g_PendDrainer, 1U, 1U);
888}

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 4094 of file freertos_stk.cpp.

4095{
4096 const size_t block_size = stk::memory::BlockMemoryPool::AlignBlockSize(max_msg_size);
4097 const size_t slot_cost = block_size + FrtosMessageBuffer::ENVELOPE_SIZE;
4098
4099 if (slot_cost == 0U)
4100 return 0U;
4101
4102 return budget_bytes / slot_cost;
4103}
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 3233 of file freertos_stk.cpp.

3236{
3237 switch (eAction)
3238 {
3239 case eNoAction:
3240 break;
3241
3242 case eSetBits:
3243 slot.value |= ulValue;
3244 break;
3245
3246 case eIncrement:
3247 slot.value++;
3248 break;
3249
3251 slot.value = ulValue;
3252 break;
3253
3255 if (slot.pending)
3256 return pdFAIL; // value not consumed yet
3257 slot.value = ulValue;
3258 slot.pending = true;
3259 break;
3260
3261 default:
3262 return pdFAIL;
3263 }
3264
3265 return pdPASS;
3266}
#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 FrtosQueueSet::FrtosQueueSet(), FrtosSemaphore::FrtosSemaphore(), xEventGroupCreate(), xMessageBufferCreate(), xMessageBufferCreateWithCallback(), xQueueCreate(), xQueueCreateSet(), xSemaphoreCreateBinary(), xSemaphoreCreateCounting(), xSemaphoreCreateMutex(), 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 vEventGroupDelete(), vMessageBufferDelete(), vQueueDelete(), vSemaphoreDelete(), vStreamBufferDelete(), vTaskDelete(), xQueueCreate(), xQueueCreateSet(), xSemaphoreCreateBinary(), xSemaphoreCreateCounting(), xSemaphoreCreateMutex(), 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 2011 of file freertos_stk.cpp.

2012{
2013 if (xQueue == nullptr)
2014 return nullptr;
2015
2016 // GetSemKindFromHandle() returns SemKind::None for FrtosQueue handles
2017 // (and any unrecognised object), SemKind::Counting or SemKind::Mutex for
2018 // FrtosSemaphore handles. Only SemKind::Mutex carries an owner field.
2019 if (GetSemKindFromHandle(xQueue) != SemKind::Mutex)
2020 return nullptr;
2021
2022 return static_cast<FrtosSemaphore *>(xQueue);
2023}
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 735 of file freertos_stk.cpp.

736{
737#if configUSE_QUEUE_SETS
738 // m_set is non-null only when the member was registered with xQueueAddToSet.
739 // Post the member handle as a pointer-sized token. TryPut is ISR-safe.
740 if (host->m_set != nullptr)
741 host->m_set->m_token_mq->TryPut(&member_handle);
742#else
743 STK_UNUSED(member_handle);
744 STK_UNUSED(host);
745#endif
746}
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
Definition stk_defs.h:608

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 3216 of file freertos_stk.cpp.

3217{
3219
3221 return nullptr;
3222
3223 if (xTask == nullptr)
3224 xTask = xTaskGetCurrentTaskHandle();
3225
3226 return static_cast<FrtosTask *>(xTask);
3227}
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:409
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 2961 of file freertos_stk.cpp.

2962{
2964 return snapshot; // timeout or parameter error — return flags snapshot
2965
2966 return static_cast<EventBits_t>(result);
2967}
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:115

◆ 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 848 of file freertos_stk.cpp.

Referenced by EnsurePendDrainer(), and KickPendDrainerFromISR().

◆ g_PendDrainerBuf

Definition at line 847 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 757 of file freertos_stk.cpp.

Referenced by FrtosTimer::EnsureTimerHost().

◆ g_TimerHostBuf

Definition at line 760 of file freertos_stk.cpp.

Referenced by FrtosTimer::EnsureTimerHost().

◆ s_MemStats