From e9696920a6d6213dd1e595ac2f73b5cbefdb8f79 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Sat, 10 Oct 2020 22:33:19 +0200 Subject: [PATCH] Testing graphics driver on MD380 --- tests/platform/MD380_display.c | 103 +++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/platform/MD380_display.c diff --git a/tests/platform/MD380_display.c b/tests/platform/MD380_display.c new file mode 100644 index 00000000..a8b9602b --- /dev/null +++ b/tests/platform/MD380_display.c @@ -0,0 +1,103 @@ + +#include +#include +#include + +#include "graphics.h" +#include "gpio.h" + +static OS_TCB App_TaskStartTCB; +static CPU_STK_SIZE App_TaskStartStk[APP_CFG_TASK_START_STK_SIZE]; +static void App_TaskStart(void *p_arg); + +static OS_TCB gfxTCB; +static CPU_STK_SIZE gfxStk[APP_CFG_TASK_START_STK_SIZE]; +static void gfxThread(void *arg); + +static int running = 0; + +int main (void) +{ + OS_ERR err; + running = 1; + + OSInit(&err); + OS_CPU_SysTickInit(); + + OSTaskCreate((OS_TCB *)&App_TaskStartTCB, + (CPU_CHAR *)"App Task Start", + (OS_TASK_PTR ) App_TaskStart, + (void *) 0, + (OS_PRIO ) APP_CFG_TASK_START_PRIO, + (CPU_STK *)&App_TaskStartStk[0], + (CPU_STK )(APP_CFG_TASK_START_STK_SIZE / 10u), + (CPU_STK_SIZE) APP_CFG_TASK_START_STK_SIZE, + (OS_MSG_QTY ) 0, + (OS_TICK ) 0, + (void *) 0, + (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), + (OS_ERR *)&err); + + OSTaskCreate((OS_TCB *)&gfxTCB, + (CPU_CHAR *)"gfx", + (OS_TASK_PTR ) gfxThread, + (void *) 0, + (OS_PRIO ) APP_CFG_TASK_START_PRIO, + (CPU_STK *)&gfxStk[0], + (CPU_STK )(APP_CFG_TASK_START_STK_SIZE / 10u), + (CPU_STK_SIZE) APP_CFG_TASK_START_STK_SIZE, + (OS_MSG_QTY ) 0, + (OS_TICK ) 0, + (void *) 0, + (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), + (OS_ERR *)&err); + + OSStart(&err); + + printf("OSStart returned, quitting\n"); + return 0; +} + +static void App_TaskStart(void *p_arg) +{ + + (void) p_arg; + OS_ERR os_err; + gpio_setMode(GPIOE, 0, OUTPUT); + + while (running) + { + gpio_togglePin(GPIOE, 0); + OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err); + } + + exit(1); +} + +static void gfxThread(void *arg) +{ + (void) arg; + OS_ERR os_err; + + int pos = 0; + + graphics_init(); + + while(1) + { + graphics_clearScreen(); + point_t origin = {0, pos}; + color_t color_red = {255, 0, 0}; + graphics_drawRect(origin, display_screenWidth(), 20, color_red, 1); + graphics_render(); + while(graphics_renderingInProgress()) ; + pos += 20; + if(pos > graphics_screenHeight() - 20) pos = 0; + + OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err); + } + + running = 0; + OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err); + graphics_terminate(); +}