当前位置:网站首页>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.cINIT_BOARD_EXPORT(rt_hw_usart_init);
3.2.2 CubeMX 再次修改配置问题记录
__WEAK int main(void)__WEAK
SConscript
stm32f1xx_it.cstm32f1xx_it.c3.3 创建一个跑马灯任务
led1_blinkled2_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
- 基于MindSpore高效完成图像分割,实现Dice!
- Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
- LeetCode 216. Combined Sum III (2022.08.04)
- MySQL使用聚合函数可以不搭配GROUP BY分组吗?
- 第五章:redis持久化,包括rdb和aof两种方式[通俗易懂]
- 手写柯里化 - toString 理解
- 你最隐秘的性格在哪?
- Is digital transformation a business buy-in?
- 第四章:redis 数组结构的set和一些通用命令「建议收藏」
猜你喜欢

DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从

Huawei's lightweight neural network architecture GhostNet has been upgraded again, and G-GhostNet (IJCV22) has shown its talents on the GPU

After Keil upgrades to AC6, what changes?

【 temperature warning program DE development 】 event driven model instance

MySQL transactions

一文道清什么是SPL

three.js调试工具dat.gui使用

19. Server-side session technology Session

微服务 技术栈

阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
随机推荐
SD NAND Flash简介!
Voice conversion相关语音数据集综合汇总
无题六
无题二
MySQL transactions
LeetCode 216. Combined Sum III (2022.08.04)
5. Deploy the web project to the cloud server
Development common manual link sharing
使用工具类把对象中的null值转换为空字符串(集合也可以使用)
企业的数字化转型到底是否可以买来?
Jenkins manual (2) - software configuration
JS逆向入门学习之回收商网,手机号码简易加密解析
Open Source Summer | How OpenHarmony Query Device Type (eTS)
【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
Where is your most secretive personality?
第三章 : redis数据结构种类
机器学习-基础知识 - Precision, Recall, Sensitivity, Specificity, Accuracy, FNR, FPR, TPR, TNR, F1 Score, Bal
创建一个 Dapp,为什么要选择波卡?
Egg framework usage (1)
uniapp connect ibeacon