1. RT-Thread Nano?下載
RT-Thread Nano 是一個(gè)極簡(jiǎn)版的硬實(shí)時(shí)內(nèi)核,它是由 C 語(yǔ)言開(kāi)發(fā),采用面向?qū)ο蟮木幊趟季S,具有良好的代碼風(fēng)格,是一款可裁剪的、搶占式實(shí)時(shí)多任務(wù)的 RTOS。其內(nèi)存資源占用極小,功能包括任務(wù)處理、軟件定時(shí)器、信號(hào)量、郵箱和實(shí)時(shí)調(diào)度等相對(duì)完整的實(shí)時(shí)操作系統(tǒng)特性。適用于家電、消費(fèi)電子、醫(yī)療設(shè)備、工控等領(lǐng)域大量使用的 32 位 ARM 入門(mén)級(jí) MCU 的場(chǎng)合。
下圖是 RT-Thread Nano 的軟件框圖,包含支持的 CPU 架構(gòu)與內(nèi)核源碼,還有可拆卸的 FinSH 組件
https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-nano/an0038-nano-introduction
2.移植 (這里是按Cortex-M3移植)
1)把rt-thread源碼復(fù)制到工程下
添加源碼文件
rtthread-nano-master\rt-thread\bsp
rtthread-nano-master\rt-thread\libcpu\arm\cortex-m3
2)增加一個(gè)RTE_Components.h,防止編譯出錯(cuò)
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
- Define the Device Header File:
/
#endif / RTE_COMPONENTS_H */
3)在裸機(jī)可運(yùn)行的代碼上修改如下
實(shí)際上只要?jiǎng)h除時(shí)鐘初始化函數(shù),因?yàn)樵赽oard.c中已調(diào)用,不需要在Main()函數(shù)中再次調(diào)用。這里Main函數(shù)是作為rtthread的一個(gè)任務(wù)來(lái)實(shí)現(xiàn)的。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-448910.html
#include "gd32f3x0.h"
#include "gd32f330c_start.h"
#include "systick.h"
#include <rtthread.h>
#define delay_ms(x) rt_thread_mdelay(x)
/*!
\brief main function
\param[in] none
\param[out] none
\retval none
*/
int main(void)
{
/* enable the LED GPIO clock */
rcu_periph_clock_enable(RCU_GPIOB);
/* configure led GPIO port */
gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_1);
gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1);
gpio_bit_set(GPIOB, GPIO_PIN_1);
while(1){
/* turn on led1 */
gpio_bit_write(GPIOB, GPIO_PIN_1, RESET);
delay_ms(1000);
/* turn off led1 */
gpio_bit_write(GPIOB, GPIO_PIN_1, SET);
delay_ms(1000);
}
}
4)編譯成功
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-448910.html
到了這里,關(guān)于RT-Thread 1. GD32移植RT-Thread Nano的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!