因為工程的需要用到操作系統(tǒng),這里可以選擇freeRtos或者RT-Thread。我這里選用了RT-Thread。下面就如何用移植,分享如下:
1、打開一個cw32l083的blink工程。
2、打開manage Run-Time Environment工具,選擇RT-Thread,我們這里只選擇kenel。
3、打開RTOS目錄下的board.c文件,添加main.h頭文件的引用、添加系統(tǒng)心路中斷函數(shù)、添加systick初始化。
4、打開rtthconfig.h中內(nèi)存管理的選項:
5、注釋掉interrupts_cw32l083.c中HardFault_Handler、PendSV_Handler兩個函數(shù),避免出現(xiàn)得新定義的錯誤
6、編譯后零錯誤零警告:
8、在main.c中添加rtthreah.h的頭文件引用,再添回兩個任務(wù)函數(shù),并在主程序中啟動:
struct rt_thread thread1;
struct rt_thread thread2;
char thread1_stack[512];
char thread2_stack[512];
void thread1_entry(void*param)
{
while (1)
{
printf("thread1 is runningrn");
rt_thread_mdelay(200);
}
}
void thread2_entry(void*param)
{
while (1)
{
printf("thread2is runningrn");
rt_thread_mdelay(400);
}
}
void thread1_init(void)
{
rt_err_t fd=rt_thread_init(&thread1,"thread1",&thread1_entry,0,&thread1_stack[0],sizeof(thread1_stack),10,10);
if(fd < 0)
{
printf("thread1 init is fail rn");
}
else
{
printf("thread1init is success rn");
}
rt_thread_startup(&thread1);
}
void thread2_init(void)
{
rt_err_t fd=rt_thread_init(&thread2,"thread2",&thread2_entry,0,&thread2_stack[0],sizeof(thread2_stack),10,10);
if(fd < 0)
{
printf("thread2 init is fail rn");
}
else
{
printf("thread2init is success rn");
}
rt_thread_startup(&thread2);
}
int32_t main(void)
{
//配置RCC
RCC_Configuration();
//配置GPIO
GPIO_Configuration();
//配置UART
UART_Configuration();
printf("
CW32L083 UART Printf Example
");
thread1_init();
thread2_init();
while(1)
{
}
}
【實驗效果】
編譯后下載到開發(fā)板,打開串口綜端,就可以看到兩個任打印出相應(yīng)的信息。
【總結(jié)】
移植RT-Threadg nano到cw32l083的主要的就是需要添加systick定時器的中斷函數(shù),以及systick的配置。
審核編輯:湯梓紅
-
操作系統(tǒng)
+關(guān)注
關(guān)注
37文章
6899瀏覽量
123801 -
移植
+關(guān)注
關(guān)注
1文章
383瀏覽量
28198 -
定時器
+關(guān)注
關(guān)注
23文章
3256瀏覽量
115442 -
FreeRTOS
+關(guān)注
關(guān)注
12文章
484瀏覽量
62414 -
RT-Thread
+關(guān)注
關(guān)注
31文章
1305瀏覽量
40419
發(fā)布評論請先 登錄
相關(guān)推薦
i.MX RT1170:VGLite移植RT-Thread Nano過程講解(上)
![i.MX <b class='flag-5'>RT</b>1170:VGLite<b class='flag-5'>移植</b><b class='flag-5'>RT-Thread</b> <b class='flag-5'>Nano</b>過程講解(上)](https://file1.elecfans.com/web2/M00/AD/2F/wKgaomVMUFCAD-6dAABXFv2-2a8881.png)
i.MX RT1170:VGLite移植RT-Thread Nano過程講解(下)
基于 Keil MDK 移植 RT-Thread Nano
基于 Keil MDK 移植 RT-Thread Nano
【國產(chǎn)MCU移植】HC32F460基于Keil MDK 移植 RT-Thread Nano
![【國產(chǎn)MCU<b class='flag-5'>移植</b>】HC32F460基于Keil MDK <b class='flag-5'>移植</b> <b class='flag-5'>RT-Thread</b> <b class='flag-5'>Nano</b>](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
【國產(chǎn)MCU系列】在 HK32F030 上移植 RT-Thread Nano
![【國產(chǎn)MCU系列】在 HK32F030 上<b class='flag-5'>移植</b> <b class='flag-5'>RT-Thread</b> <b class='flag-5'>Nano</b>](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
【國產(chǎn)MCU系列】在 HK32F030 上移植 RT-Thread Nano
![【國產(chǎn)MCU系列】在 HK32F030 上<b class='flag-5'>移植</b> <b class='flag-5'>RT-Thread</b> <b class='flag-5'>Nano</b>](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
基于 Keil MDK 移植 RT-Thread Nano
![基于 Keil MDK <b class='flag-5'>移植</b> <b class='flag-5'>RT-Thread</b> <b class='flag-5'>Nano</b>](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
評論