[CLI] Update CLI to use RTOS abstraction layer; Also remove a redundant/unused runMemoryTest().
This commit is contained in:
+35
-55
@@ -27,8 +27,9 @@
|
||||
#define CLI_COMMAND_MAX_ARGS 8
|
||||
#define CLI_COMMAND_MAX_LEN 256
|
||||
|
||||
OS_TID cliTaskId;
|
||||
TaskStack<CLI_STACK_SIZE> __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<uint8_t, 256> 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<GRAPHICS_TEST_RUN_STEP; n++) {
|
||||
uint32_t actualRuntime = 0;
|
||||
while ((actualRuntime = RTOS_GET_MS() - start) < runtime ) {
|
||||
for (uint16_t n=0; n < step; n++) {
|
||||
func();
|
||||
}
|
||||
lcdRefresh();
|
||||
noRuns += GRAPHICS_TEST_RUN_STEP;
|
||||
noRuns += 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);
|
||||
const 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);
|
||||
RTOS_WAIT_MS(200);
|
||||
return result;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ int cliTestGraphics()
|
||||
result += RUN_GRAPHICS_TEST(testDrawTextVertical, 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;
|
||||
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);
|
||||
}
|
||||
|
||||
#define MEMORY_TEST_RUN_STEP 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;
|
||||
}
|
||||
|
||||
#define RUN_MEMORY_TEST(name, runtime) runTimedFunctionTest(name, #name, runtime, 100)
|
||||
|
||||
int cliTestMemorySpeed()
|
||||
{
|
||||
@@ -599,29 +580,29 @@ int cliTestMemorySpeed()
|
||||
perMainEnabled = false;
|
||||
|
||||
float result = 0;
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
|
||||
|
||||
LTDC_Cmd(DISABLE);
|
||||
serialPrint("Disabling LCD...");
|
||||
RTOS_WAIT_MS(200);
|
||||
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_RAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_GRAPHICS_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_RAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryReadFrom_SDRAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_8bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_RAM_to_SDRAM_32bit, 200);
|
||||
result += RUN_MEMORY_TEST(testMemoryCopyFrom_SDRAM_to_SDRAM_8bit, 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);
|
||||
|
||||
@@ -646,7 +627,7 @@ int cliTestModelsList()
|
||||
int count=0;
|
||||
|
||||
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();
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user