当前位置:网站首页>RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)
RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)
2022-08-05 10:09:00 【InfoQ】
距离完成 FreeRTOS 的记录也有一段时间了,除了最近在测试的ESP32-C3 ,也该记录一下 RT-Thread。
期间几个月时间关于 RT-Thread 的项目有好几个,感觉最近 RT-Thread 越来越火,
在几年前用过 RT-Thread,那个时候都还没有RT-Thread Studio IDE,现在啥都有了。
RT-Thread官方资料也多,理论,示例,说明应有尽有,自己重新学习一边,做个记录贴。
前言
1、RT-Thread 版本(以哪个版本开始学习)
1.1 RT-Thread Nano

1.2 RT-Thread 标准版


1.3 RT-Thread Smart
2、RT-Thread 开发环境
2.1 开发板(自己画的开发板)

2.2 开发工具

2.3 环境搭建




2.4 RT-Thread Studio For Vscode
3、第一个工程
3.1 根据自己环境新建工程
- 使用 RT-Thread 标准版
- 自己画的开发板,基于STM32F103VGT6




3.2 配合 CubeMX 配置使用






- 原来的hal_conf.h就被cubeMX新生成的替换掉
- RT-Thread Studio 会且只会使用CubeMX生成的 Inc 和 Src 文件夹下的内容
- 主函数 RT-Thread Studio 会在 CubeMX生成的 main 函数前用 _WEAK 声明
- 时钟初始化函数,会使用 CubeMx 中的设置
- 一些基本的构建现在版本的RT-Thread Studio 都会自动设置好,通过
SConscript
。
3.2.1 SConscript 文件修改

SConscript

SConscript

MX_USART1_UART_Init();
drv_usart.c
INIT_BOARD_EXPORT(rt_hw_usart_init);

3.2.2 CubeMX 再次修改配置问题记录
__WEAK int main(void)
__WEAK

SConscript

stm32f1xx_it.c
stm32f1xx_it.c
3.3 创建一个跑马灯任务
led1_blink
led2_blink
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-02-16 QZH first lesson for test
*/
#include <rtthread.h>
#include "main.h"
#include "usart.h"
#include "gpio.h"
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
static struct rt_thread led1_thread; //led1线程
static char led1_thread_stack[256];
static rt_thread_t led2_thread = RT_NULL; //led2线程
static void led1_thread_entry(void *par){
while(1){
LED1_ON;
rt_thread_mdelay(1000);
LED1_OFF;
rt_thread_mdelay(1000);
}
}
static void led2_thread_entry(void *par){
while(1){
LED2_ON;
rt_thread_mdelay(500);
LED2_OFF;
rt_thread_mdelay(500);
}
}
int main(void)
{
MX_GPIO_Init();
MX_USART1_UART_Init();
int count = 1;
rt_err_t rst2;
rst2 = rt_thread_init(&led1_thread,
"led1_blink ",
led1_thread_entry,
RT_NULL,
&led1_thread_stack[0],
sizeof(led1_thread_stack),
RT_THREAD_PRIORITY_MAX -1,
50);
if(rst2 == RT_EOK){
rt_thread_startup(&led1_thread);
}
while (count++)
{
if(count < 11){
LOG_D("Hello RT-Thread!%d",count);
}
if(count >= 0XFFFFFF00) count = 0;
rt_thread_mdelay(1000);
}
return RT_EOK;
}
void led2_Blink(){
led2_thread = rt_thread_create("led2_blink",
led2_thread_entry,
RT_NULL,
256,
RT_THREAD_PRIORITY_MAX -1,
50);
/* 如果获得线程控制块,启动这个线程 */
if (led2_thread != RT_NULL)
rt_thread_startup(led2_thread);
}
MSH_CMD_EXPORT(led2_Blink, Led2 sample);

边栏推荐
猜你喜欢
随机推荐
Complete image segmentation efficiently based on MindSpore and realize Dice!
攻防世界-PWN-new_easypwn
js劫持数组push方法
STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
JS逆向入门学习之回收商网,手机号码简易加密解析
首次去中心化抢劫?近2亿美元损失:跨链桥Nomad 被攻击事件分析
js hijacks the array push method
第六章:activiti流程分流判断之排它网关和并行网关
E-sports, convenience, efficiency, security, key words for OriginOS functions
百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意
Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)
Egg framework usage (2)
The century-old Nordic luxury home appliance brand ASKO smart wine cabinet in the three-temperature area presents the Chinese Valentine’s Day, and tastes the love of the delicacy
What is the function of the regular expression replaceFirst() method?
How can project cost control help project success?
Oracle temporary table space role
公众号如何运维?公众号运维专业团队
无题三
华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)
LeetCode 216. Combined Sum III (2022.08.04)