From 31883c9a647cad3d49ec5113eaf347bcd85f9749 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 e9d4e30941..c631aad641 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -293,6 +293,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 a36a4bedbf..076e15345d 100644 --- a/components/freertos/config/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/config/include/freertos/FreeRTOSConfig.h @@ -251,6 +251,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 + /* ----------------------------------------------- Amazon SMP FreeRTOS ------------------------------------------------- * - All Amazon SMP FreeRTOS specific configurations * ------------------------------------------------------------------------------------------------------------------ */ 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 9e1213bd65..5e6e3571a2 100644 --- a/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options +++ b/components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options @@ -19,3 +19,4 @@ CONFIG_FREERTOS_FPU_IN_ISR=y CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2 CONFIG_FREERTOS_USE_TICK_HOOK=y CONFIG_FREERTOS_USE_IDLE_HOOK=y +CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG=y