在./bearpi-pico_h3863/application/samples下新建设demo目录,在然后目录中添加demo.c
demo.h
CMakeLists.txt
三个文件
demo.c中填入
#include "common_def.h"
#include "osal_debug.h"
#include "cmsis_os2.h"
#include "app_init.h"
#define TASKS_TEST_TASK_STACK_SIZE 0x1000
#define TASKS_TEST_TASK_PRIO (osPriority_t)(17)
#define TASKS_TEST_DURATION_MS 1000
static void *tasks_test_task(const char *arg)
{
unused(arg);
while (1) {
osal_printk("shy hello word\r\n");
osDelay(TASKS_TEST_DURATION_MS);
}
return NULL;
}
static void tasks_test_entry(void)
{
osThreadAttr_t attr;
attr.name = "TasksTask";
attr.attr_bits = 0U;
attr.cb_mem = NULL;
attr.cb_size = 0U;
attr.stack_mem = NULL;
attr.stack_size = TASKS_TEST_TASK_STACK_SIZE;
attr.priority = TASKS_TEST_TASK_PRIO;
if (osThreadNew((osThreadFunc_t)tasks_test_task, NULL, &attr) == NULL) {
/* Create task fail. */
}
}
/* Run the tasks_test_entry. */
app_run(tasks_test_entry);
CMakeLists.txt中
set(SOURCES_LIST
${CMAKE_CURRENT_SOURCE_DIR}/demo.c
)
set(PUBLIC_HEADER_LIST
${CMAKE_CURRENT_SOURCE_DIR}
)
set(SOURCES "${SOURCES_LIST}" PARENT_SCOPE)
set(PUBLIC_HEADER "${PUBLIC_HEADER_LIST}" PARENT_SCOPE)
在bearpi-pico_h3863/application/samples/CMakeLists.txt中添加
if(DEFINED CONFIG_ENABLE_MY_SAMPLE)
add_subdirectory_if_exist(demo)
endif()
在earpi-pico_h3863/application/samples/Kconfig
中添加
config ENABLE_MY_SAMPLE
bool
prompt "Enable the Sample of demo."
default n
depends on SAMPLE_ENABLE
help
This option means enable the sample of products.
然后./build.py menuconfig ws63-liteos-app
选择
编译
./build.py -c ws63-liteos-app
烧录
然后串口112500 就可以在调试串口看到