当前位置:网站首页>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);

边栏推荐
- How does the official account operate and maintain?Public account operation and maintenance professional team
- PHP operation mangoDb
- Pytorch Deep Learning Quick Start Tutorial -- Mound Tutorial Notes (3)
- JS逆向入门学习之回收商网,手机号码简易加密解析
- DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从
- 微服务 技术栈
- Huawei's lightweight neural network architecture GhostNet has been upgraded again, and G-GhostNet (IJCV22) has shown its talents on the GPU
- Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
- Which big guy has the 11G GI and ojvm patches in April or January 2020, please help?
- three物体围绕一周呈球形排列
猜你喜欢
Jenkins manual (2) - software configuration
Open Source Summer | How OpenHarmony Query Device Type (eTS)
皕杰报表的下拉框联动
Complete image segmentation efficiently based on MindSpore and realize Dice!
[强网杯2022]WP-UM
华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)
three.js调试工具dat.gui使用
2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing
How can project cost control help project success?
Egg framework usage (1)
随机推荐
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的
无题四
第四章:activiti流程中,变量的传递和获取流程变量 ,设置和获取多个流程变量,设置和获取局部流程变量「建议收藏」
egg框架使用(一)
MySQL事务
19. Server-side session technology Session
ffmpeg drawtext 添加文本水印
[Office] Collection of Microsoft Office download addresses (offline installation and download of Microsoft's official original version)
js劫持数组push方法
七夕浪漫约会不加班,RPA机器人帮你搞定工作
High-quality DeFi application building guide to help developers enjoy DeFi Summer
Development common manual link sharing
项目成本控制如何帮助项目成功?
Getting started with Polkadot parachain development, this article is enough
QSS 选择器
无题二
MySQL之数据视图
高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
Keil升级到AC6后,到底有哪些变化?
Analysis and practice of antjian webshell dynamic encrypted connection