Skip to content

Commit f51aaf7

Browse files
xTaskCreateStatic added.
1 parent 6a85399 commit f51aaf7

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

cpputest-for-freertos-lib/src/cpputest_for_freertos_task.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ namespace test {
4848
} //namespace test
4949
} //namespace cms
5050

51+
//dummy task control block
52+
struct tskTaskControlBlock
53+
{
54+
int dummy;
55+
};
56+
5157
extern "C" BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
5258
const char * const pcName,
5359
const configSTACK_DEPTH_TYPE uxStackDepth,
@@ -64,6 +70,27 @@ extern "C" BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
6470
return pdPASS;
6571
}
6672

73+
extern "C" TaskHandle_t xTaskCreateStatic(
74+
TaskFunction_t pxTaskCode,
75+
const char * const pcName,
76+
const configSTACK_DEPTH_TYPE uxStackDepth,
77+
void * const pvParameters,
78+
UBaseType_t uxPriority,
79+
StackType_t * const puxStackBuffer,
80+
StaticTask_t * const pxTaskBuffer )
81+
{
82+
(void)pxTaskCode;
83+
(void)pcName;
84+
(void)uxStackDepth;
85+
(void)pvParameters;
86+
(void)uxPriority;
87+
(void)puxStackBuffer;
88+
(void)pxTaskBuffer;
89+
90+
static struct tskTaskControlBlock dummy = {};
91+
return &dummy;
92+
}
93+
6794
extern "C" void vTaskDelete( TaskHandle_t xTaskToDelete )
6895
{
6996
(void)xTaskToDelete;

cpputest-for-freertos-lib/tests/cpputest_for_freertos_task_tests.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,26 @@ TEST(TaskTests, task_delay_until_method_returns_true_if_sleep_was_needed)
9494
auto count2 = xTaskGetTickCount();
9595
CHECK_EQUAL(10, count2 - count1);
9696
}
97+
98+
static void staticTaskCode(void * parameters)
99+
{
100+
(void)parameters;
101+
//for testing, does nothing
102+
}
103+
104+
TEST(TaskTests, task_create_static_is_available)
105+
{
106+
static StaticTask_t staticTaskBuffer;
107+
static std::array<StackType_t, 200> staticStack;
108+
109+
auto taskHandle = xTaskCreateStatic(
110+
staticTaskCode, /* Function that implements the task. */
111+
"TEST", /* Text name for the task. */
112+
staticStack.size(), /* Number of indexes in the xStack array. */
113+
( void * ) 1, /* Parameter passed into the task. */
114+
tskIDLE_PRIORITY,/* Priority at which the task is created. */
115+
staticStack.data(), /* Array to use as the task's stack. */
116+
&staticTaskBuffer ); /* Variable to hold the task's data structure. */
117+
118+
CHECK_TRUE(taskHandle != nullptr);
119+
}

0 commit comments

Comments
 (0)