[开发板] 【CW32L031CxTx StartKit评估板测评】移植rt_thread finsSH组件

[复制链接]
 楼主| tlled 发表于 2023-10-27 16:56 | 显示全部楼层 |阅读模式
这篇来移植下rt-thread nano finSH组件。
在上篇https://bbs.21ic.com/icview-3336376-1-1.html将系统移植到开发板,不能串口shell操作,下面移植finSH组件,实现串口操作。

一、添加finSH组件

1.1、选择shell选项
200.png

1.2、添加源码到项目
201.png

二、配置串口

shell需要配置串口的收发

2.1、使能串口
202.png

2.2、串口设置
203.png

205.png

三、程序

main.c
  1. #include "main.h"
  2. #include "led/led.h"
  3. #include "key/key.h"
  4. #include "usart/usart.h"
  5. #include <rtthread.h>

  6. static char thread1_stack[128];
  7. static char thread2_stack[128];
  8. static struct rt_thread thread1;
  9. static struct rt_thread thread2;


  10. void task1_entry(void *parameter)
  11. {
  12.         while(1)
  13.         {
  14.                 led1_tog();
  15.                 //rt_kprintf("task1 run \n");
  16.                 rt_thread_mdelay(100);   
  17.         }
  18. }

  19. void task2_entry(void *parameter)
  20. {
  21.         while(1)
  22.         {
  23.                 led2_tog();
  24.                 //rt_kprintf("task2 run \n");
  25.                 rt_thread_mdelay(200);   
  26.         }
  27. }   

  28. int main(void)
  29. {
  30.         rt_thread_init(&thread1,  
  31.                                                                         "task1",  
  32.                                                                         task1_entry,
  33.                                                                         RT_NULL,  
  34.                                                                         &thread1_stack[0],  
  35.                                                                         sizeof(thread1_stack),  
  36.                                                                         20,
  37.                                                                         10);  
  38.         rt_thread_init(&thread2,  
  39.                                                                         "task2",  
  40.                                                                         task2_entry,  
  41.                                                                         RT_NULL,  
  42.                                                                         &thread2_stack[0],  
  43.                                                                         sizeof(thread1_stack),  
  44.                                                                         19,
  45.                                                                         10);  
  46.         rt_thread_startup(&thread1);
  47.         rt_thread_startup(&thread2);
  48.        
  49.         return 0;
  50. }


四、程序运行

在shell下串口输入命令,开发板响应
204.png
您需要登录后才可以回帖 登录 | 注册

本版积分规则

132

主题

701

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部

132

主题

701

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部