当前位置:网站首页>RT - Thread record (a, RT, RT Thread version - Thread Studio development environment and cooperate CubeMX quick-and-dirty)
RT - Thread record (a, RT, RT Thread version - Thread Studio development environment and cooperate CubeMX quick-and-dirty)
2022-08-05 10:18: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 Modify the configuration problem record again
__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);

边栏推荐
- Go compilation principle series 6 (type checking)
- Microservice Technology Stack
- The founder of the DFINITY Foundation talks about the ups and downs of the bear market, and where should DeFi projects go?
- Jenkins manual (2) - software configuration
- FPGA: Basic Getting Started LED Lights Blinking
- Bias lock/light lock/heavy lock lock is healthier. How is locking and unlocking accomplished?
- FPGA: Basic Getting Started Button Controlling LED Lights
- 单片机:温度控制DS18B20
- 2022华数杯数学建模思路分析交流
- IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
猜你喜欢
Pycharm 常用外部工具
Tanabata romantic date without overtime, RPA robot helps you get the job done
Analysis and practice of antjian webshell dynamic encrypted connection
SD NAND Flash简介!
产品太多了,如何实现一次登录多产品互通?
【AGC】增长服务1-远程配置示例
Jenkins使用手册(2) —— 软件配置
NowCoderTOP35-40 - continuous update ing
Egg framework usage (2)
JS逆向入门学习之回收商网,手机号码简易加密解析
随机推荐
企业的数字化转型到底是否可以买来?
Egg framework usage (2)
Complete image segmentation efficiently based on MindSpore and realize Dice!
华为轻量级神经网络架构GhostNet再升级,GPU上大显身手的G-GhostNet(IJCV22)
SQL外连接之交集、并集、差集查询
多线程(进阶) - 2.5w字总结
【翻译】混沌网+SkyWalking:为混沌工程提供更好的可观察性
Development common manual link sharing
[Office] Collection of Microsoft Office download addresses (offline installation and download of Microsoft's official original version)
PHP 操作mangoDb
LeetCode 216. Combined Sum III (2022.08.04)
你最隐秘的性格在哪?
Is digital transformation a business buy-in?
哪位大佬有20年4月或者1月的11G GI和ojvm补丁呀,帮忙发下?
创建一个 Dapp,为什么要选择波卡?
leetcode: 529. Minesweeper Game
Go compilation principle series 6 (type checking)
第五章:activiti流程分流判断,判断走不同的任务节点
5. Deploy the web project to the cloud server
语音社交软件开发——充分发挥其价值