当前位置:网站首页>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);
边栏推荐
- Keil升级到AC6后,到底有哪些变化?
- Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
- 第三章 : redis数据结构种类
- 19. Server-side session technology Session
- [Strong Net Cup 2022] WP-UM
- STM32+ULN2003驱动28BYJ4步进电机(根据圈数正转、反转)
- NowCoderTOP35-40 - continuous update ing
- FPGA:基础入门按键控制LED灯
- 这份阿里强推的并发编程知识点笔记,将是你拿大厂offer的突破口
- Technical dry goods | Hausdorff distance for image segmentation based on MindSpore
猜你喜欢
Oracle temporary table space role
MySQL transactions
JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
three.js debugging tool dat.gui use
Meteorological data processing example - matlab string cutting matching and R language date matching (data splicing)
Introduction to SD NAND Flash!
The JVM collection that Alibaba's top architects have summarized for many years, where can't I check it!
Complete image segmentation efficiently based on MindSpore and realize Dice!
Voice-based social software development - making the most of its value
linux下oracle常见操作以及日常积累知识点(函数、定时任务)
随机推荐
Ali's new launch: Microservices Assault Manual, all operations are written out in PDF
气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)
项目成本控制如何帮助项目成功?
FPGA: Basic Getting Started LED Lights Blinking
产品太多了,如何实现一次登录多产品互通?
Complete image segmentation efficiently based on MindSpore and realize Dice!
我们的Web3创业项目,黄了
static linking and dynamic linking
2022华数杯数学建模思路分析交流
第五章:多线程通信—wait和notify
FPGA: Basic Getting Started Button Controlling LED Lights
[强网杯2022]WP-UM
用户考试分数大于单科科目平均分的查询
企业的数字化转型到底是否可以买来?
C语言的高级用法
【AGC】增长服务1-远程配置示例
蚁剑webshell动态加密连接分析与实践
What is SPL?
Keil升级到AC6后,到底有哪些变化?
【Unity】【UGUI】【在屏幕上显示文本】