中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 在pcDuino上學(xué)習(xí)μC/OS II

        在pcDuino上學(xué)習(xí)μC/OS II

        作者: 時間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

        前言

        本文引用地址:http://www.antipu.com.cn/article/201609/303410.htm

        uC/OS II(Micro Control Operation System Two)是一個可以基于ROM運(yùn)行的、可裁減的、搶占式、實時多任務(wù)內(nèi)核,具有高度可移植性,特別適合于微處理器和控制器,是和很多商業(yè)操作系統(tǒng)性能相當(dāng)?shù)膶崟r操作系統(tǒng)(RTOS)。為了提供最好的移植性能,uC/OS II最大程度上使用ANSI C語言進(jìn)行開發(fā),并且已經(jīng)移植到近40多種處理器體系上,涵蓋了從8位到64位各種CPU(包括DSP)。 uC/OS II可以簡單的視為一個多任務(wù)調(diào)度器,在這個任務(wù)調(diào)度器之上完善并添加了和多任務(wù)操作系統(tǒng)相關(guān)的系統(tǒng)服務(wù),如信號量、郵箱等。其主要特點有公開源代碼,代碼結(jié)構(gòu)清晰、明了,注釋詳盡,組織有條理,可移植性好,可裁剪,可固化。內(nèi)核屬于搶占式,最多可以管理60個任務(wù)。從1992年開始,由于高度可靠性、移植性和安全性,uC/OS II已經(jīng)廣泛使用在從照相機(jī)到航空電子產(chǎn)品的各種應(yīng)用中。

        想學(xué)習(xí)操作系統(tǒng)的同學(xué)的可以好好分析這個系統(tǒng)的代碼

        ucos下載編譯

        $sudo apt-get install git git-core

        $git clone https://github.com/Pillar1989/ucos-ii-for-

        $cd arduino

        $make

        $cd ..

        $make

        ucos-ii測試

        編寫測試程序:

        1 /*

        2 *************************************************************************************************** ******

        3 * sample.c

        4 *

        5 * Description: This sample program uses the ucos linux port to start 5 simple tasks.

        6 *

        7 * Author: Philip Mitchell

        8 *

        9 *************************************************************************************************** ******

        10 */

        11

        12 #include

        13 #include

        14 #include “ucos_ii.h”

        15 #include

        16 #include

        17

        18 int led_pin = 1;

        19 int btn_pin = 5;

        20

        21 void hardware_init()

        22 {

        23 pinMode(led_pin, OUTPUT);

        24 }

        25 /* Function common to all tasks */

        26

        27 void MyTask( void *p_arg )

        28 {

        29

        30 char* sTaskName = (char*)p_arg;

        31 static flag1 = 1;

        32 #if OS_CRITICAL_METHOD == 3

        33 OS_CPU_SR cpu_sr = 0;

        34 #endif

        35

        36 while(1)

        37 {

        38 /* printf uses mutex to get terminal access, therefore must enter critical section */

        39 OS_ENTER_CRITICAL();

        40 printf( “Name: %sn”, sTaskName );

        41 if(!strcmp(sTaskName,”Task 1″))

        42 {

        43 if(flag1 == 1)

        44 {

        45 flag1 = 0;

        46 printf(“HIGHn”);

        47 digitalWrite(led_pin, HIGH);

        48 }

        49 else

        50 {

        51 flag1 = 1;

        52 printf(“LOWn”);

        53 digitalWrite(led_pin, LOW);

        54 }

        55 }

        56 OS_EXIT_CRITICAL();

        57

        58 /* Delay so other tasks may execute. */

        59 OSTimeDly(50);

        60 }/* while */

        61

        62 }

        63

        64

        65 int main (void)

        66 {

        67 /* pthreads allocates its own memory for task stacks. This UCOS linux port needs a minimum stack size

        68 in order to pass the function information within the port. */

        69 hardware_init();

        70 INT8U Stk1[ OSMinStkSize() ];

        71 INT8U Stk2[ OSMinStkSize() ];

        72 INT8U Stk3[ OSMinStkSize() ];

        73 INT8U Stk4[ OSMinStkSize() ];

        74 INT8U Stk5[ OSMinStkSize() ];

        75

        76 char sTask1[] = “Task 1″;

        77 char sTask2[] = “Task 2″;

        78 char sTask3[] = “Task 3″;

        79 char sTask4[] = “Task 4″;

        80 // char sTask5[] = “Task 5″;

        81

        82 OSInit();

        83

        84 OSTaskCreate( MyTask, sTask1, (void*)Stk1, 4 );

        85 // OSTaskCreate( MyTask, sTask2, (void*)Stk2, 5 );

        86 // OSTaskCreate( MyTask, sTask3, (void*)Stk3, 6 );

        87 // OSTaskCreate( MyTask, sTask4, (void*)Stk4, 7 );

        88 // OSTaskCreate( MyTask, sTask5, (void*)Stk5, 8 );

        89

        90 OSStart();

        91

        92 return 0;

        93 }

        94

        連接一個led燈到1腳,執(zhí)行剛剛編譯出來的程序

        ubuntu@ubuntu:~/ucos-ii-for-$ ./ucos_sample

        1Name: Task 1

        HIGH

        Name: Task 1

        LOW

        Name: Task 1

        HIGH

        Name: Task 1

        LOW

        Name: Task 1

        板子上接到1 pin的led會不斷的閃爍



        關(guān)鍵詞: pcDuino μC/OS II

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉