diff --git a/src/estd/port/freertos/wrapper/task.h b/src/estd/port/freertos/wrapper/task.h index 8ec53e70..48659f4c 100644 --- a/src/estd/port/freertos/wrapper/task.h +++ b/src/estd/port/freertos/wrapper/task.h @@ -70,6 +70,21 @@ class task return pcTaskGetName(t); } + void delay(const TickType_t xTicksToDelay) const + { + vTaskDelay(xTicksToDelay); + } + + void resume() const + { + vTaskResume(t); + } + + void suspend() const + { + vTaskSuspend(t); + } + #if configUSE_APPLICATION_TASK_TAG TaskHookFunction_t tag() const { @@ -120,15 +135,21 @@ class task #endif #if configSUPPORT_STATIC_ALLOCATION - BaseType_t create_static(TaskFunction_t pvTaskCode, - const char * const pcName, + using static_type = StaticTask_t; + + static task create_static(TaskFunction_t pvTaskCode, + const char* const pcName, const configSTACK_DEPTH_TYPE uxStackDepth, - void *pvParameters, + void* pvParameters, UBaseType_t uxPriority, StackType_t* const puxStackBuffer, - StaticTask_t* const pxTaskBuffer) + static_type* const pxTaskBuffer) { - return xTaskCreate(pvTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, &t); + return task(xTaskCreateStatic(pvTaskCode, + pcName, uxStackDepth, + pvParameters, uxPriority, + puxStackBuffer, + pxTaskBuffer)); } #endif diff --git a/test/unity/freertos.cpp b/test/unity/freertos.cpp index ab3b9793..6bc5952f 100644 --- a/test/unity/freertos.cpp +++ b/test/unity/freertos.cpp @@ -6,10 +6,30 @@ #include +using namespace estd::freertos::wrapper; + +static void test_task1(void* p) +{ + +} + +static void test_static_task_wrapper() +{ + // DEBT: Do a malloc for these in SPIRAM for ESP32 + static task::static_type storage; + static unsigned char stack[2048]; + + task t = task::create_static(test_task1, "unity:freertos1", + sizeof stack / 4, nullptr, 3, stack, &storage); + + t.suspend(); + t.resume(); +} + #ifdef ESP_IDF_TESTING TEST_CASE("freertos tests", "[freertos]") { - + RUN_TEST(test_static_task_wrapper); } #endif diff --git a/test/unity/thread.cpp b/test/unity/thread.cpp index 6201d05c..e3f95e2f 100644 --- a/test/unity/thread.cpp +++ b/test/unity/thread.cpp @@ -324,6 +324,7 @@ static void test_event_groups() } +// DEBT: Move some of this out to 'freertos.cpp' test area static void test_freertos() { freertos::sync_sem.create_binary();