From 942ae1847de10400d41c1ef21b04b436c2e65e8f Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Sat, 8 Sep 2018 19:07:43 -0400 Subject: [PATCH] [CLI] Update CLI to use RTOS abstraction layer; Also remove a redundant/unused runMemoryTest(). --- radio/src/cli.cpp | 90 +++++++++++++++++-------------------------- radio/src/cli.h | 9 ++--- radio/src/tasks_arm.h | 1 + 3 files changed, 39 insertions(+), 61 deletions(-) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index 67e4b632c..95051aa25 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -27,8 +27,9 @@ #define CLI_COMMAND_MAX_ARGS 8 #define CLI_COMMAND_MAX_LEN 256 -OS_TID cliTaskId; -TaskStack __ALIGNED(8) cliStack; // stack must be aligned to 8 bytes otherwise printf for %f does not work! +RTOS_TASK_HANDLE cliTaskId; +RTOS_DEFINE_STACK(cliStack, CLI_STACK_SIZE); + Fifo cliRxFifo; uint8_t cliTracesEnabled = true; char cliLastLine[CLI_COMMAND_MAX_LEN+1]; @@ -349,7 +350,7 @@ int cliTestNew() #if defined(COLORLCD) extern bool perMainEnabled; -typedef void (*graphichTestFunc)(void); +typedef void (*timedTestFunc_t)(void); void testDrawSolidFilledRectangle() { @@ -420,23 +421,22 @@ void testClear() lcdClear(); } -#define GRAPHICS_TEST_RUN_STEP 100 -#define RUN_GRAPHICS_TEST(name, runtime) runGraphicsTest(name, #name, runtime) +#define RUN_GRAPHICS_TEST(name, runtime) runTimedFunctionTest(name, #name, runtime, 100) -float runGraphicsTest(graphichTestFunc func, const char * name, uint32_t runtime) +float runTimedFunctionTest(timedTestFunc_t func, const char * name, uint32_t runtime, uint16_t step) { - uint32_t start = (uint32_t)CoGetOSTime(); + const uint32_t start = RTOS_GET_MS(); uint32_t noRuns = 0; - while (((uint32_t)CoGetOSTime() - start) < runtime/2 ) { - for (int n=0; n& cats = modList.getCategories(); while(1) { @@ -668,8 +649,7 @@ int cliTestModelsList() } done: - uint32_t actualRuntime = (uint32_t)CoGetOSTime() - start; - serialPrint("Done fetching %ix RF data: %d ms", count, actualRuntime*2); + serialPrint("Done fetching %ix RF data: %lu ms", count, (RTOS_GET_MS() - start)); return 0; } @@ -1339,5 +1319,5 @@ void cliTask(void * pdata) void cliStart() { - cliTaskId = CoCreateTaskEx(cliTask, NULL, 10, &cliStack.stack[CLI_STACK_SIZE-1], CLI_STACK_SIZE, 1, false); + RTOS_CREATE_TASK(cliTaskId, cliTask, "CLI", cliStack, CLI_STACK_SIZE, CLI_TASK_PRIO); } diff --git a/radio/src/cli.h b/radio/src/cli.h index 06579fff3..fdb96d6d1 100644 --- a/radio/src/cli.h +++ b/radio/src/cli.h @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -29,13 +29,10 @@ extern uint8_t cliTracesEnabled; #include "fifo.h" extern Fifo cliRxFifo; #include "tasks_arm.h" -#define CLI_STACK_SIZE 1000 -extern OS_TID cliTaskId; -extern TaskStack cliStack; +extern RTOS_TASK_HANDLE cliTaskId; +extern RTOS_DEFINE_STACK(cliStack, CLI_STACK_SIZE); #endif void cliStart(); -void cliStackPaint(); -uint32_t cliStackFree(); #endif // _CLI_H_ diff --git a/radio/src/tasks_arm.h b/radio/src/tasks_arm.h index 2096606ca..26b913f72 100644 --- a/radio/src/tasks_arm.h +++ b/radio/src/tasks_arm.h @@ -27,6 +27,7 @@ #define MENUS_STACK_SIZE 2000 #define MIXER_STACK_SIZE 512 #define AUDIO_STACK_SIZE 512 +#define CLI_STACK_SIZE 1000 // only consumed with CLI build option #define MIXER_TASK_PRIO 5 #define AUDIO_TASK_PRIO 7