tlled 发表于 2023-10-27 16:56

【CW32L031CxTx StartKit评估板测评】移植rt_thread finsSH组件

这篇来移植下rt-thread nano finSH组件。
在上篇https://bbs.21ic.com/icview-3336376-1-1.html将系统移植到开发板,不能串口shell操作,下面移植finSH组件,实现串口操作。

一、添加finSH组件

1.1、选择shell选项


1.2、添加源码到项目


二、配置串口

shell需要配置串口的收发

2.1、使能串口


2.2、串口设置




三、程序

main.c
#include "main.h"
#include "led/led.h"
#include "key/key.h"
#include "usart/usart.h"
#include <rtthread.h>

static char thread1_stack;
static char thread2_stack;
static struct rt_thread thread1;
static struct rt_thread thread2;


void task1_entry(void *parameter)
{
        while(1)
        {
                led1_tog();
                //rt_kprintf("task1 run \n");
                rt_thread_mdelay(100);   
        }
}

void task2_entry(void *parameter)
{
        while(1)
        {
                led2_tog();
                //rt_kprintf("task2 run \n");
                rt_thread_mdelay(200);   
        }
}   

int main(void)
{
        rt_thread_init(&thread1,
                                                                        "task1",
                                                                        task1_entry,
                                                                        RT_NULL,
                                                                        &thread1_stack,
                                                                        sizeof(thread1_stack),
                                                                        20,
                                                                        10);
        rt_thread_init(&thread2,
                                                                        "task2",
                                                                        task2_entry,
                                                                        RT_NULL,
                                                                        &thread2_stack,
                                                                        sizeof(thread1_stack),
                                                                        19,
                                                                        10);
        rt_thread_startup(&thread1);
        rt_thread_startup(&thread2);
       
        return 0;
}

四、程序运行

在shell下串口输入命令,开发板响应

星辰大海不退缩 发表于 2025-11-17 22:16

不能串口shell操作,下面移植finSH组件,实现串口操作。
页: [1]
查看完整版本: 【CW32L031CxTx StartKit评估板测评】移植rt_thread finsSH组件