diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index dafa3d1f4..d715286bd 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -486,6 +486,7 @@ if(ARCH STREQUAL ARM) option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" OFF) option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY option(DEBUG_INTERRUPTS "Count interrupts" OFF) + option(DEBUG_TASKS "Task switching statistics" OFF) if(TIMERS EQUAL 3) add_definitions(-DTIMERS=3) @@ -517,6 +518,10 @@ if(ARCH STREQUAL ARM) add_definitions(-DDEBUG_INTERRUPTS) set(DEBUG ON) endif() + if(DEBUG_TASKS) + add_definitions(-DDEBUG_TASKS) + set(DEBUG ON) + endif() if(CLI) add_definitions(-DCLI) set(FIRMWARE_SRC ${FIRMWARE_SRC} cli.cpp) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index 41fef09ed..3bcd12439 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -373,6 +373,60 @@ void printInterrupts() } #endif //#if defined(DEBUG_INTERRUPTS) +#if defined(DEBUG_TASKS) + +void printTaskSwitchLog() +{ + serialPrint("Tasks legend [, ]:"); + for(int n = 0; n <= CFG_MAX_USER_TASKS+1; n++) { + if (0 == n) { + serialPrint("%d: Idle", n); + } + if (cliTaskId == n) { + serialPrint("%d: CLI", n); + } + else if (menusTaskId == n) { + serialPrint("%d: menus", n); + } + else if (mixerTaskId == n) { + serialPrint("%d: mixer", n); + } + else if (audioTaskId == n) { + serialPrint("%d: audio", n); + } +#if defined(BLUETOOTH) + else if (btTaskId == n) { + serialPrint("%d: BT", n); + } +#endif + } + serialCrlf(); + + serialPrint("Tasks switch log at %u [