kopia lustrzana https://github.com/OpenRTX/OpenRTX
Testing uC/OS-III on x86_64 target
rodzic
4ece7f9e71
commit
6d4979c1af
|
@ -0,0 +1,101 @@
|
|||
##
|
||||
## OpenDMR - Open Source Firmware for DMR Radios
|
||||
##
|
||||
|
||||
##
|
||||
## List here your source files (both .s, .c and .cpp)
|
||||
##
|
||||
SRC := tests/platform/x64_uC.c
|
||||
|
||||
|
||||
##
|
||||
## Drivers' source files and include directories
|
||||
##
|
||||
DRIVERS_INC := -Iopenrtx/include/interfaces/
|
||||
DRIVERS_SRC := \
|
||||
platform/drivers/display/display_libSDL.c
|
||||
|
||||
##
|
||||
## List here additional static libraries with relative path
|
||||
##
|
||||
LIBS :=
|
||||
|
||||
##
|
||||
## List here additional include directories (in the form -Iinclude_dir)
|
||||
##
|
||||
INCLUDE_DIRS :=
|
||||
|
||||
##
|
||||
## List here additional defines
|
||||
##
|
||||
DEFINES := -DSCREEN_WIDTH=160 -DSCREEN_HEIGHT=128
|
||||
|
||||
##
|
||||
## Optimization level
|
||||
##
|
||||
OPTLEVEL := -O0
|
||||
#OPTLEVEL:= -O2
|
||||
#OPTLEVEL:= -O3
|
||||
#OPTLEVEL:= -Os
|
||||
|
||||
##
|
||||
## Operating system's source files and include directories
|
||||
##
|
||||
OS_INC := \
|
||||
-Irtos/uC-OS3/Source -Irtos/uC-OS3/Ports/POSIX -Irtos/uC-OS3/Cfg \
|
||||
-Irtos/uC-CPU/Posix -Irtos/uC-CPU -Irtos/uC-CPU/Cfg \
|
||||
-Irtos/uC-LIB -Irtos/uC-LIB/Cfg
|
||||
|
||||
OS_SRC := \
|
||||
rtos/uC-OS3/Source/__dbg_uCOS-III.c \
|
||||
rtos/uC-OS3/Source/os_cfg_app.c \
|
||||
rtos/uC-OS3/Source/os_core.c \
|
||||
rtos/uC-OS3/Source/os_dbg.c \
|
||||
rtos/uC-OS3/Source/os_flag.c \
|
||||
rtos/uC-OS3/Source/os_mem.c \
|
||||
rtos/uC-OS3/Source/os_msg.c \
|
||||
rtos/uC-OS3/Source/os_mutex.c \
|
||||
rtos/uC-OS3/Source/os_prio.c \
|
||||
rtos/uC-OS3/Source/os_q.c \
|
||||
rtos/uC-OS3/Source/os_sem.c \
|
||||
rtos/uC-OS3/Source/os_stat.c \
|
||||
rtos/uC-OS3/Source/os_task.c \
|
||||
rtos/uC-OS3/Source/os_tick.c \
|
||||
rtos/uC-OS3/Source/os_time.c \
|
||||
rtos/uC-OS3/Source/os_tmr.c \
|
||||
rtos/uC-OS3/Source/os_var.c \
|
||||
rtos/uC-OS3/Ports/POSIX/os_cpu_c.c \
|
||||
rtos/uC-OS3/Cfg/os_app_hooks.c \
|
||||
rtos/uC-CPU/cpu_core.c \
|
||||
rtos/uC-CPU/Posix/cpu_c.c \
|
||||
rtos/uC-LIB/lib_ascii.c \
|
||||
rtos/uC-LIB/lib_math.c \
|
||||
rtos/uC-LIB/lib_mem.c \
|
||||
rtos/uC-LIB/lib_str.c
|
||||
|
||||
##
|
||||
## Exceptions support. Uncomment to disable them and save code size
|
||||
##
|
||||
#EXCEPT := -fno-exceptions -fno-rtti -D__NO_EXCEPTIONS
|
||||
|
||||
##############################################################################
|
||||
## You should not need to modify anything below ##
|
||||
##############################################################################
|
||||
|
||||
ALL_INC := $(OS_INC) $(DRIVERS_INC) $(INCLUDE_DIRS)
|
||||
ALL_SRC := $(SRC) $(OS_SRC) $(DRIVERS_SRC)
|
||||
CONFIGS := $(TARGET) $(CLK_FREQ) $(OPTLEVEL) -DDONT_USE_CMSIS_INIT
|
||||
|
||||
ifeq ("$(VERBOSE)","1")
|
||||
Q :=
|
||||
ECHO := @true
|
||||
else
|
||||
Q := @
|
||||
ECHO := @echo
|
||||
endif
|
||||
|
||||
all:
|
||||
gcc $(ALL_SRC) $(ALL_INC) $(DEFINES) -lSDL2 -lpthread -o openrtx_x64
|
||||
|
||||
#pull in dependecy info for existing .o files
|
||||
-include $(OBJ:.o=.d)
|
|
@ -0,0 +1,140 @@
|
|||
|
||||
#include <app_cfg.h>
|
||||
#include <os.h>
|
||||
#include <stdio.h>
|
||||
#include <lib_mem.h>
|
||||
#include <lib_math.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#undef main
|
||||
|
||||
#include "lcd.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;
|
||||
|
||||
void drawRect(int x, int y, int width, int height, uint16_t color)
|
||||
{
|
||||
int x_max = x + width;
|
||||
int y_max = y + height;
|
||||
if(x_max > lcd_screenWidth()) x_max = lcd_screenWidth();
|
||||
if(y_max > lcd_screenHeight()) y_max = lcd_screenHeight();
|
||||
uint16_t *buf = lcd_getFrameBuffer();
|
||||
|
||||
for(int i=y; i < y_max; i++)
|
||||
{
|
||||
for(int j=x; j < x_max; j++)
|
||||
{
|
||||
buf[j + i*lcd_screenWidth()] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearScreen()
|
||||
{
|
||||
uint16_t *buf = lcd_getFrameBuffer();
|
||||
|
||||
for(int i=0; i < lcd_screenHeight(); i++)
|
||||
{
|
||||
for(int j=0; j < lcd_screenWidth(); j++)
|
||||
{
|
||||
buf[j + i*lcd_screenWidth()] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// OS_CPU_SysTickInit();
|
||||
|
||||
while (running)
|
||||
{
|
||||
printf("uCOS-III is running.\n");
|
||||
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;
|
||||
SDL_Event eventListener;
|
||||
|
||||
lcd_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
SDL_PollEvent(&eventListener);
|
||||
if(eventListener.type == SDL_QUIT) break;
|
||||
|
||||
clearScreen();
|
||||
drawRect(0, pos, lcd_screenWidth(), 20, 0xF800);
|
||||
lcd_render();
|
||||
while(lcd_renderingInProgress()) ;
|
||||
pos += 20;
|
||||
if(pos > lcd_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);
|
||||
lcd_terminate();
|
||||
}
|
Ładowanie…
Reference in New Issue