From 1332f2934a14a258b34950fae6b2af9a46ff62fd Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 8 Mar 2024 21:47:46 +0800 Subject: [PATCH] feat(freertos): Add application task tag support This commit enables support for application task tag. - Added CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG option - Added basic unit test --- components/freertos/Kconfig | 7 ++++ .../config/include/freertos/FreeRTOSConfig.h | 4 +++ .../freertos/kernel/tasks/test_app_task_tag.c | 35 +++++++++++++++++++ .../freertos/sdkconfig.ci.freertos_options | 1 + 4 files changed, 47 insertions(+) create mode 100644 components/freertos/test_apps/freertos/kernel/tasks/test_app_task_tag.c diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index f82ac3cd44..39fe855738 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -324,6 +324,13 @@ menu "FreeRTOS" esp_pm_dump_locks, if the proportion of rejected sleeps is too high, please increase this value to improve scheduling efficiency + config FREERTOS_USE_APPLICATION_TASK_TAG + bool "configUSE_APPLICATION_TASK_TAG" + default n + help + Enables task tagging functionality and its associated API (see configUSE_APPLICATION_TASK_TAG + documentation for more details). + endmenu # Kernel menu "Port" diff --git a/components/freertos/config/include/freertos/FreeRTOSConfig.h b/components/freertos/config/include/freertos/FreeRTOSConfig.h index 314051f1bf..af7ea730d8 100644 --- a/components/freertos/config/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/config/include/freertos/FreeRTOSConfig.h @@ -255,6 +255,10 @@ #endif /* CONFIG_FREERTOS_SMP */ #endif /* def __ASSEMBLER__ */ +#if CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG + #define configUSE_APPLICATION_TASK_TAG 1 +#endif // CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG + /* -------------- List Data Integrity Checks --------------- */ #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES diff --git a/components/freertos/test_apps/freertos/kernel/tasks/test_app_task_tag.c b/components/freertos/test_apps/freertos/kernel/tasks/test_app_task_tag.c new file mode 100644 index 0000000000..3322a41270 --- /dev/null +++ b/components/freertos/test_apps/freertos/kernel/tasks/test_app_task_tag.c @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "unity.h" +#include "test_utils.h" + +#if CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG + +static BaseType_t tag_cb(void *arg) +{ + BaseType_t *tag_cb_called = (BaseType_t *)arg; + *tag_cb_called = pdTRUE; + return pdTRUE; +} + +TEST_CASE("Test application task tag", "[freertos]") +{ + BaseType_t tag_cb_called = pdFALSE; + + // Set the app task tag for current task + vTaskSetApplicationTaskTag(NULL, tag_cb); + // Check app task tag is correct + TEST_ASSERT_EQUAL(tag_cb, xTaskGetApplicationTaskTag(NULL)); + // Test the app task tag by calling it + TEST_ASSERT_EQUAL(pdTRUE, xTaskCallApplicationTaskHook(NULL, (void *)&tag_cb_called)); + TEST_ASSERT_EQUAL(pdTRUE, tag_cb_called); +} + +#endif // CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG diff --git a/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options b/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options index 680d6646fe..2fcaa43c78 100644 --- a/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options +++ b/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options @@ -21,3 +21,4 @@ CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES=y CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1=y CONFIG_FREERTOS_USE_TICK_HOOK=y CONFIG_FREERTOS_USE_IDLE_HOOK=y +CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG=y