[CLI] Update CLI to use RTOS abstraction layer; Also remove a redundant/unused runMemoryTest().

This commit is contained in:
Max Paperno
2018-09-08 19:07:43 -04:00
parent 691d3e6e33
commit 942ae1847d
3 changed files with 39 additions and 61 deletions
+35 -55
View File
@@ -27,8 +27,9 @@
#define CLI_COMMAND_MAX_ARGS 8 #define CLI_COMMAND_MAX_ARGS 8
#define CLI_COMMAND_MAX_LEN 256 #define CLI_COMMAND_MAX_LEN 256
OS_TID cliTaskId; RTOS_TASK_HANDLE cliTaskId;
TaskStack<CLI_STACK_SIZE> __ALIGNED(8) cliStack; // stack must be aligned to 8 bytes otherwise printf for %f does not work! RTOS_DEFINE_STACK(cliStack, CLI_STACK_SIZE);
Fifo<uint8_t, 256> cliRxFifo; Fifo<uint8_t, 256> cliRxFifo;
uint8_t cliTracesEnabled = true; uint8_t cliTracesEnabled = true;
char cliLastLine[CLI_COMMAND_MAX_LEN+1]; char cliLastLine[CLI_COMMAND_MAX_LEN+1];
@@ -349,7 +350,7 @@ int cliTestNew()
#if defined(COLORLCD) #if defined(COLORLCD)
extern bool perMainEnabled; extern bool perMainEnabled;
typedef void (*graphichTestFunc)(void); typedef void (*timedTestFunc_t)(void);
void testDrawSolidFilledRectangle() void testDrawSolidFilledRectangle()
{ {
@@ -420,23 +421,22 @@ void testClear()
lcdClear(); lcdClear();
} }
#define GRAPHICS_TEST_RUN_STEP 100 #define RUN_GRAPHICS_TEST(name, runtime) runTimedFunctionTest(name, #name, runtime, 100)
#define RUN_GRAPHICS_TEST(name, runtime) runGraphicsTest(name, #name, runtime)
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; uint32_t noRuns = 0;
while (((uint32_t)CoGetOSTime() - start) < runtime/2 ) { uint32_t actualRuntime = 0;
for (int n=0; n<GRAPHICS_TEST_RUN_STEP; n++) { while ((actualRuntime = RTOS_GET_MS() - start) < runtime ) {
for (uint16_t n=0; n < step; n++) {
func(); func();
} }
lcdRefresh(); lcdRefresh();
noRuns += GRAPHICS_TEST_RUN_STEP; noRuns += step;
} }
uint32_t actualRuntime = (uint32_t)CoGetOSTime() - start; const float result = (noRuns * 500.0f) / (float)actualRuntime; // runs/second
float result = (noRuns * 500.0f) / (float)actualRuntime; // runs/second serialPrint("Test %s speed: %lu.%02u, (%lu runs in %lu ms)", name, uint32_t(result), uint16_t((result - uint32_t(result)) * 100.0f), noRuns, actualRuntime);
serialPrint("Test %s speed: %0.2f, (%d runs in %d ms)", name, result, noRuns, actualRuntime*2);
RTOS_WAIT_MS(200); RTOS_WAIT_MS(200);
return result; return result;
} }
@@ -469,7 +469,7 @@ int cliTestGraphics()
result += RUN_GRAPHICS_TEST(testDrawTextVertical, 1000); result += RUN_GRAPHICS_TEST(testDrawTextVertical, 1000);
result += RUN_GRAPHICS_TEST(testClear, 1000); result += RUN_GRAPHICS_TEST(testClear, 1000);
serialPrint("Total speed: %0.2f", result); serialPrint("Total speed: %lu.%02u", uint32_t(result), uint16_t((result - uint32_t(result)) * 100.0f));
perMainEnabled = true; perMainEnabled = true;
if (pulsesStarted()) { if (pulsesStarted()) {
@@ -565,26 +565,7 @@ void testMemoryCopyFrom_SDRAM_to_SDRAM_8bit()
memoryCopy((uint8_t *)LCD_FIRST_FRAME_BUFFER, (const uint8_t * )LCD_SECOND_FRAME_BUFFER, MEMORY_SPEED_BLOCK_SIZE); memoryCopy((uint8_t *)LCD_FIRST_FRAME_BUFFER, (const uint8_t * )LCD_SECOND_FRAME_BUFFER, MEMORY_SPEED_BLOCK_SIZE);
} }
#define MEMORY_TEST_RUN_STEP 100 #define RUN_MEMORY_TEST(name, runtime) runTimedFunctionTest(name, #name, runtime, 100)
#define RUN_MEMORY_TEST(name, runtime) runMemoryTest(name, #name, runtime)
float runMemoryTest(graphichTestFunc func, const char * name, uint32_t runtime)
{
uint32_t start = (uint32_t)CoGetOSTime();
uint32_t noRuns = 0;
while (((uint32_t)CoGetOSTime() - start) < runtime/2 ) {
for (int n=0; n<MEMORY_TEST_RUN_STEP; n++) {
func();
}
noRuns += MEMORY_TEST_RUN_STEP;
}
uint32_t actualRuntime = (uint32_t)CoGetOSTime() - start;
float result = (noRuns * 500.0f) / (float)actualRuntime; // runs/second
serialPrint("Test %s speed: %0.2f, (%d runs in %d ms)", name, result, noRuns, actualRuntime*2);
RTOS_WAIT_MS(200);
return result;
}
int cliTestMemorySpeed() int cliTestMemorySpeed()
{ {
@@ -599,29 +580,29 @@ int cliTestMemorySpeed()
perMainEnabled = false; perMainEnabled = false;
float result = 0; float result = 0;
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_32bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
LTDC_Cmd(DISABLE); LTDC_Cmd(DISABLE);
serialPrint("Disabling LCD..."); serialPrint("Disabling LCD...");
RTOS_WAIT_MS(200); RTOS_WAIT_MS(200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_32bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200); result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
serialPrint("Total speed: %0.2f", result); serialPrint("Total speed: %lu.%02u", uint32_t(result), uint16_t((result - uint32_t(result)) * 100.0f));
LTDC_Cmd(ENABLE); LTDC_Cmd(ENABLE);
@@ -646,7 +627,7 @@ int cliTestModelsList()
int count=0; int count=0;
serialPrint("Starting fetching RF data 100x..."); serialPrint("Starting fetching RF data 100x...");
uint32_t start = (uint32_t)CoGetOSTime(); const uint32_t start = RTOS_GET_MS();
const list<ModelsCategory*>& cats = modList.getCategories(); const list<ModelsCategory*>& cats = modList.getCategories();
while(1) { while(1) {
@@ -668,8 +649,7 @@ int cliTestModelsList()
} }
done: done:
uint32_t actualRuntime = (uint32_t)CoGetOSTime() - start; serialPrint("Done fetching %ix RF data: %lu ms", count, (RTOS_GET_MS() - start));
serialPrint("Done fetching %ix RF data: %d ms", count, actualRuntime*2);
return 0; return 0;
} }
@@ -1339,5 +1319,5 @@ void cliTask(void * pdata)
void cliStart() 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);
} }
+2 -5
View File
@@ -29,13 +29,10 @@ extern uint8_t cliTracesEnabled;
#include "fifo.h" #include "fifo.h"
extern Fifo<uint8_t, 256> cliRxFifo; extern Fifo<uint8_t, 256> cliRxFifo;
#include "tasks_arm.h" #include "tasks_arm.h"
#define CLI_STACK_SIZE 1000 extern RTOS_TASK_HANDLE cliTaskId;
extern OS_TID cliTaskId; extern RTOS_DEFINE_STACK(cliStack, CLI_STACK_SIZE);
extern TaskStack<CLI_STACK_SIZE> cliStack;
#endif #endif
void cliStart(); void cliStart();
void cliStackPaint();
uint32_t cliStackFree();
#endif // _CLI_H_ #endif // _CLI_H_
+1
View File
@@ -27,6 +27,7 @@
#define MENUS_STACK_SIZE 2000 #define MENUS_STACK_SIZE 2000
#define MIXER_STACK_SIZE 512 #define MIXER_STACK_SIZE 512
#define AUDIO_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 MIXER_TASK_PRIO 5
#define AUDIO_TASK_PRIO 7 #define AUDIO_TASK_PRIO 7