RT-thread Nano移植
2021/12/13 23:17:39
本文主要是介绍RT-thread Nano移植,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
RT-thread Nano移植
- 一、添加Nano软件包
- 二、新建工程
- 三、代码编写
- 参考
一、添加Nano软件包
RT-Thread Nano软件包地址:https://www.rt-thread.org/download/cube/RealThread.RT-Thread.pdsc
打开CubeMX
,选择Help
下的Manage embedded software packages
:
选择From Url...
:
点击New
,并添加上述的Nano
软件包地址https://www.rt-thread.org/download/cube/RealThread.RT-Thread.pdsc
:
勾选并OK
后,成功:
同时,安装RT-Thread
:
同意:
安装成功:
二、新建工程
RCC
配置:
SYS
设置:
时钟树设置:
选择组件:
选择RT-Thread
组件,OK:
将选择的模块进行勾选:
NVIC
配置:
生成代码:
三、代码编写
添加新文件:
添加.c
文件:
app_rt_thread.c
:
#include "rtthread.h" #include "main.h" #include "stdio.h" struct rt_thread led1_thread; rt_uint8_t rt_led1_thread_stack[128]; void led1_task_entry(void *parameter); //初始化线程函数 void MX_RT_Thread_Init(void) { //初始化LED1线程 rt_thread_init(&led1_thread,"led1",led1_task_entry,RT_NULL,&rt_led1_thread_stack[0],sizeof(rt_led1_thread_stack),3,20); //开启线程调度 rt_thread_startup(&led1_thread); } //主任务 void MX_RT_Thread_Process(void) { printf("Hello RT_Thread!!!"); rt_thread_delay(2000); } //LED1任务 void led1_task_entry(void *parameter) { while(1) { HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3, GPIO_PIN_RESET); rt_thread_delay(500); HAL_GPIO_WritePin(GPIOA,GPIO_PIN_3, GPIO_PIN_SET); rt_thread_delay(500); } }
修改board.c
的77行:
将rtconfig.h
的145行取消注释:
在main.c
中添加代码:
extern void MX_RT_Thread_Init(void); extern void MX_RT_Thread_Process(void);
在while
循环中添加以下代码:
HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_4); rt_thread_delay(1000);
参考
STM32的RT-Thread-Nano移植
基于 STM32CubeMX 添加 RT-Thread 操作系统组件(一)- 详细介绍操作步骤
这篇关于RT-thread Nano移植的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)