大家好本人大三菜鳥一枚,第一次寫教程多有不足,敬請原諒,主要是記錄一下自己的學習程序,我會把我自己遇到的問題和解決的程序記錄下來,供大家參考學習,OK,現在開始~~
本教程是基于STM32F103CB和RT_Thread Studio 1.1.5版本
新建工程
Step1:選擇新建RT_Thread專案

Step2:選擇基于芯片或者基于開發板(選擇自己芯片或者開發板)

撰寫Main函式
Step1:添加一下頭檔案 (這個頭檔案默認是沒有的)
#include <board.h>
#include <rtdevice.h>
Step2:撰寫點燈Main函式 代碼如下
#include <rtthread.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include <board.h>
#include <rtdevice.h>
#define LED0 GET_PIN(C,13) //引腳定義
rt_thread_t led_thread = RT_NULL; //執行緒定義
static void Blink_entry(void* parameter);//執行緒宣告
int main(void)
{
led_thread = rt_thread_create("led",
Blink_entry,
RT_NULL,
512,
15,
20);
if(led_thread!=RT_NULL)
rt_thread_startup(led_thread);
else
return -1;
}
static void Blink_entry(void* parameter)
{
int count = 1;
rt_pin_mode(LED0, PIN_MODE_OUTPUT);
while(1)
{
if (count%2==0) {
rt_pin_write(LED0, PIN_LOW);
rt_kprintf("OPEN_LED\n");
} else {
rt_pin_write(LED0, PIN_HIGH);
rt_kprintf("CLOSE_LED\n");
}
count++;
rt_thread_delay(500);
}
}
Step3:通過串口輸出 我們可以看到LED燈已經開始閃爍了,

總結:
在新建專案后必須先添加頭檔案,其他的就沒有什么了,因為畢竟才開始點燈,不足的地方可以私信我或者評論都可以,希望共同進步,一起成長,😀😀😀😀😀😀
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/231495.html
標籤:其他
