COSII中uCOSII.H源碼中文注釋版
《COSII中uCOSII.H源碼中文注釋版》由會員分享,可在線閱讀,更多相關《COSII中uCOSII.H源碼中文注釋版(38頁珍藏版)》請在裝配圖網上搜索。
1、xilentz的網絡文摘 博客園 首頁 新隨筆 聯(lián)系 訂閱 管理 隨筆 - 204 文章 - 0評論 - 10trackbacks - 0 uCOS_II.H /* ********************************************************************************************************* * uC/OS-II * The Real-Time Kernel * * (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL * A
2、ll Rights Reserved * * File : uCOS_II.H * By : Jean J. Labrosse ********************************************************************************************************* */ /* ********************************************************************************************************* * MISCELL
3、ANEOUS ********************************************************************************************************* */ #define OS_VERSION 252 /* Version of uC/OS-II (Vx.yy mult. by 100) */ #ifdef OS_GLOBALS #define OS_EXT #else #define OS_EXT extern #endif #ifndef FALSE #define FALSE 0 #e
4、ndif #ifndef TRUE #define TRUE 1 #endif #define OS_PRIO_SELF 0xFF /* Indicate SELF priority */ #if OS_TASK_STAT_EN > 0 #define OS_N_SYS_TASKS 2 /* Number of system tasks */ #else #define OS_N_SYS_TASKS 1 #endif #define OS_STAT_PRIO (OS_LOWEST_PRIO - 1) /* Statistic task priority */ #d
5、efine OS_IDLE_PRIO (OS_LOWEST_PRIO) /* IDLE task priority */ #define OS_EVENT_TBL_SIZE ((OS_LOWEST_PRIO) / 8 + 1) /* Size of event table */ #define OS_RDY_TBL_SIZE ((OS_LOWEST_PRIO) / 8 + 1) /* Size of ready table */ #define OS_TASK_IDLE_ID 65535 /* I.D. numbers for Idle and Stat tasks */ #def
6、ine OS_TASK_STAT_ID 65534 #define OS_EVENT_EN (((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)) //能使隊列代碼產生&&申請隊列控制塊最大數(shù)不為零||能使郵箱代碼產生|| //能使信號量代碼產生||能使互斥量代碼產生 /*$PAGE*/ /* **************************************************************************
7、******************************* * TASK STATUS (Bit definition for OSTCBStat) ********************************************************************************************************* */ #define OS_STAT_RDY 0x00 /* Ready to run */ #define OS_STAT_SEM 0x01 /* Pending on semaphore */ #define OS_S
8、TAT_MBOX 0x02 /* Pending on mailbox */ #define OS_STAT_Q 0x04 /* Pending on queue */ #define OS_STAT_SUSPEND 0x08 /* Task is suspended */ #define OS_STAT_MUTEX 0x10 /* Pending on mutual exclusion semaphore */ #define OS_STAT_FLAG 0x20 /* Pending on event flag group */ /* *********************
9、************************************************************************************ * OS_EVENT types ********************************************************************************************************* */ #define OS_EVENT_TYPE_UNUSED 0 #define OS_EVENT_TYPE_MBOX 1 #define OS_EVENT_TYPE_Q
10、 2 #define OS_EVENT_TYPE_SEM 3 #define OS_EVENT_TYPE_MUTEX 4 #define OS_EVENT_TYPE_FLAG 5 /* ********************************************************************************************************* * EVENT FLAGS *******************************************************************************
11、************************** */ #define OS_FLAG_WAIT_CLR_ALL 0 /* Wait for ALL the bits specified to be CLR (i.e. 0) */ #define OS_FLAG_WAIT_CLR_AND 0 #define OS_FLAG_WAIT_CLR_ANY 1 /* Wait for ANY of the bits specified to be CLR (i.e. 0) */ #define OS_FLAG_WAIT_CLR_OR 1 #define OS_FLAG_WAIT_
12、SET_ALL 2 /* Wait for ALL the bits specified to be SET (i.e. 1) */ #define OS_FLAG_WAIT_SET_AND 2 #define OS_FLAG_WAIT_SET_ANY 3 /* Wait for ANY of the bits specified to be SET (i.e. 1) */ #define OS_FLAG_WAIT_SET_OR 3 #define OS_FLAG_CONSUME 0x80 /* Consume the flags if condition(s) satisfie
13、d */ #define OS_FLAG_CLR 0 #define OS_FLAG_SET 1 /* ********************************************************************************************************* * Possible values for opt argument of OSSemDel(), OSMboxDel(), OSQDel() and OSMutexDel() *********************************************
14、************************************************************ */ #define OS_DEL_NO_PEND 0 #define OS_DEL_ALWAYS 1 /* ********************************************************************************************************* * OS???PostOpt() OPTIONS * * These #defines are used to establish the
15、 options for OSMboxPostOpt() and OSQPostOpt(). ********************************************************************************************************* */ #define OS_POST_OPT_NONE 0x00 /* Post to highest priority task waiting */ #define OS_POST_OPT_BROADCAST 0x01 /* Broadcast message to ALL tas
16、ks waiting */ #define OS_POST_OPT_FRONT 0x02 /* Post to highest priority task waiting */ /* ********************************************************************************************************* * TASK OPTIONS (see OSTaskCreateExt()) *******************************************************
17、************************************************** */ #define OS_TASK_OPT_STK_CHK 0x0001 /* Enable stack checking for the task */ #define OS_TASK_OPT_STK_CLR 0x0002 /* Clear the stack when the task is create */ #define OS_TASK_OPT_SAVE_FP 0x0004 /* Save the contents of any floating-point registe
18、rs */ /* ********************************************************************************************************* * ERROR CODES ********************************************************************************************************* */ #define OS_NO_ERR 0 #define OS_ERR_EVENT_TYPE 1 #def
19、ine OS_ERR_PEND_ISR 2 #define OS_ERR_POST_NULL_PTR 3 #define OS_ERR_PEVENT_NULL 4 #define OS_ERR_POST_ISR 5 #define OS_ERR_QUERY_ISR 6 #define OS_ERR_INVALID_OPT 7 #define OS_ERR_TASK_WAITING 8 #define OS_TIMEOUT 10 #define OS_TASK_NOT_EXIST 11 #define OS_MBOX_FULL 20 #define OS_Q_FULL
20、30 #define OS_PRIO_EXIST 40 #define OS_PRIO_ERR 41 #define OS_PRIO_INVALID 42 #define OS_SEM_OVF 50 #define OS_TASK_DEL_ERR 60 #define OS_TASK_DEL_IDLE 61 #define OS_TASK_DEL_REQ 62 #define OS_TASK_DEL_ISR 63 #define OS_NO_MORE_TCB 70 #define OS_TIME_NOT_DLY 80 #define OS_TIME_INVALI
21、D_MINUTES 81 #define OS_TIME_INVALID_SECONDS 82 #define OS_TIME_INVALID_MILLI 83 #define OS_TIME_ZERO_DLY 84 #define OS_TASK_SUSPEND_PRIO 90 #define OS_TASK_SUSPEND_IDLE 91 #define OS_TASK_RESUME_PRIO 100 #define OS_TASK_NOT_SUSPENDED 101 #define OS_MEM_INVALID_PART 110 #define OS_MEM_IN
22、VALID_BLKS 111 #define OS_MEM_INVALID_SIZE 112 #define OS_MEM_NO_FREE_BLKS 113 #define OS_MEM_FULL 114 #define OS_MEM_INVALID_PBLK 115 #define OS_MEM_INVALID_PMEM 116 #define OS_MEM_INVALID_PDATA 117 #define OS_MEM_INVALID_ADDR 118 #define OS_ERR_NOT_MUTEX_OWNER 120 #define OS_TASK_OPT_ER
23、R 130 #define OS_ERR_DEL_ISR 140 #define OS_ERR_CREATE_ISR 141 #define OS_FLAG_INVALID_PGRP 150 #define OS_FLAG_ERR_WAIT_TYPE 151 #define OS_FLAG_ERR_NOT_RDY 152 #define OS_FLAG_INVALID_OPT 153 #define OS_FLAG_GRP_DEPLETED 154 /*$PAGE*/ /* **********************************************
24、*********************************************************** * EVENT CONTROL BLOCK ********************************************************************************************************* */ #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 0) typedef struct { INT8U OSEventType; /* Type of event con
25、trol block (see OS_EVENT_TYPE_???) */ //事件控制塊類型(見OS_EVENT_TYPE) INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */ //事件群體響應去等待任務事件發(fā)生 INT16U OSEventCnt; /* Semaphore Count (not used if other EVENT type) */ //信號量,在其它事件中不用 void *OSEventPtr; /* Pointer to message
26、 or queue structure */ //消息或者隊列結構指針 INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */ //任務列表等待事件發(fā)生 } OS_EVENT; #endif /* ********************************************************************************************************* * EVENT FLAGS CONTROL BLOCK
27、 ********************************************************************************************************* */ #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0) typedef struct { /* Event Flag Group */ INT8U OSFlagType; /* Should be set to OS_EVENT_TYPE_FLAG */ void *OSFlagWai
28、tList; /* Pointer to first NODE of task waiting on event flag */ OS_FLAGS OSFlagFlags; /* 8, 16 or 32 bit flags */ } OS_FLAG_GRP; typedef struct { /* Event Flag Wait List Node */ void *OSFlagNodeNext; /* Pointer to next NODE in wait list */ void *OSFlagNodePrev; /* Pointer to previous NODE
29、in wait list */ void *OSFlagNodeTCB; /* Pointer to TCB of waiting task */ void *OSFlagNodeFlagGrp; /* Pointer to Event Flag Group */ OS_FLAGS OSFlagNodeFlags; /* Event flag to wait on */ INT8U OSFlagNodeWaitType; /* Type of wait: */ /* OS_FLAG_WAIT_AND */ /* OS_FLAG_WAIT_ALL */ /* O
30、S_FLAG_WAIT_OR */ /* OS_FLAG_WAIT_ANY */ } OS_FLAG_NODE; #endif /* ********************************************************************************************************* * MESSAGE MAILBOX DATA ***********************************************************************************************
31、********** */ #if OS_MBOX_EN > 0 typedef struct { void *OSMsg; /* Pointer to message in mailbox */ INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */ INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */ } OS_MBOX_DATA; #endif
32、/* ********************************************************************************************************* * MEMORY PARTITION DATA STRUCTURES ********************************************************************************************************* */ #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART >
33、 0) typedef struct { /* MEMORY CONTROL BLOCK */ void *OSMemAddr; /* Pointer to beginning of memory partition */ void *OSMemFreeList; /* Pointer to list of free memory blocks */ INT32U OSMemBlkSize; /* Size (in bytes) of each block of memory */ INT32U OSMemNBlks; /* Total number of blocks in
34、 this partition */ INT32U OSMemNFree; /* Number of memory blocks remaining in this partition */ } OS_MEM; typedef struct { void *OSAddr; /* Pointer to the beginning address of the memory partition */ void *OSFreeList; /* Pointer to the beginning of the free list of memory blocks */ INT32U
35、 OSBlkSize; /* Size (in bytes) of each memory block */ INT32U OSNBlks; /* Total number of blocks in the partition */ INT32U OSNFree; /* Number of memory blocks free */ INT32U OSNUsed; /* Number of memory blocks used */ } OS_MEM_DATA; #endif /*$PAGE*/ /* *********************************
36、************************************************************************ * MUTUAL EXCLUSION SEMAPHORE DATA ********************************************************************************************************* */ #if OS_MUTEX_EN > 0 typedef struct { INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /*
37、 List of tasks waiting for event to occur */ INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */ INT8U OSValue; /* Mutex value (0 = used, 1 = available) */ INT8U OSOwnerPrio; /* Mutex owners task priority or 0xFF if no owner */ INT8U OSMutexPIP; /* Priority Inheri
38、tance Priority or 0xFF if no owner */ } OS_MUTEX_DATA; #endif /* ********************************************************************************************************* * MESSAGE QUEUE DATA *****************************************************************************************************
39、**** */ #if OS_Q_EN > 0 typedef struct os_q { /* QUEUE CONTROL BLOCK */ struct os_q *OSQPtr; /* Link to next queue control block in list of free blocks */ void **OSQStart; /* Pointer to start of queue data */ void **OSQEnd; /* Pointer to end of queue data */ void **OSQIn; /* Pointer to w
40、here next message will be inserted in the Q */ void **OSQOut; /* Pointer to where next message will be extracted from the Q */ INT16U OSQSize; /* Size of queue (maximum number of entries) */ INT16U OSQEntries; /* Current number of entries in the queue */ } OS_Q; typedef struct { void *OSM
41、sg; /* Pointer to next message to be extracted from queue */ INT16U OSNMsgs; /* Number of messages in message queue */ INT16U OSQSize; /* Size of message queue */ INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */ INT8U OSEventGrp; /* Group corresponding to t
42、asks waiting for event to occur */ } OS_Q_DATA; #endif /* ********************************************************************************************************* * SEMAPHORE DATA ********************************************************************************************************* */
43、#if OS_SEM_EN > 0 typedef struct { INT16U OSCnt; /* Semaphore count */ INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */ INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */ } OS_SEM_DATA; #endif /* ****************************
44、***************************************************************************** * TASK STACK DATA ********************************************************************************************************* */ #if OS_TASK_CREATE_EXT_EN > 0 typedef struct { INT32U OSFree; /* Number of free bytes o
45、n the stack */ INT32U OSUsed; /* Number of bytes used on the stack */ } OS_STK_DATA; #endif /*$PAGE*/ /* ********************************************************************************************************* * TASK CONTROL BLOCK *********************************************************
46、************************************************ */ typedef struct os_tcb { OS_STK *OSTCBStkPtr; /* Pointer to current top of stack */ //OS_STK為unsigned int 指向當前堆頂部的指針 #if OS_TASK_CREATE_EXT_EN > 0 // 使OS_TASK_CREATE_EXT中包含代碼 void *OSTCBExtPtr; /* Pointer to user definable data for TCB ex
47、tension */ //用戶定義用于TCB擴展的數(shù)據(jù)指針 OS_STK *OSTCBStkBottom; /* Pointer to bottom of stack */ //堆底部指針 INT32U OSTCBStkSize; /* Size of task stack (in number of stack elements) */ //任務堆棧大小 INT16U OSTCBOpt; /* Task options as passed by OSTaskCreateExt() */ //由OSTaskCreateExt() 傳遞的任務選項 INT16U O
48、STCBId; /* Task ID (0..65535) */ //任務ID #endif struct os_tcb *OSTCBNext; /* Pointer to next TCB in the TCB list */ //在TCB列表中指向下一個TCB struct os_tcb *OSTCBPrev; /* Pointer to previous TCB in the TCB list */ //指向前一個TCB #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
5. 裝配圖網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 市教育局冬季運動會安全工作預案
- 2024年秋季《思想道德與法治》大作業(yè)及答案3套試卷
- 2024年教師年度考核表個人工作總結(可編輯)
- 2024年xx村兩委涉案資金退還保證書
- 2024年憲法宣傳周活動總結+在機關“弘揚憲法精神推動發(fā)改工作高質量發(fā)展”專題宣講報告會上的講話
- 2024年XX村合作社年報總結
- 2024-2025年秋季第一學期初中歷史上冊教研組工作總結
- 2024年小學高級教師年終工作總結匯報
- 2024-2025年秋季第一學期初中物理上冊教研組工作總結
- 2024年xx鎮(zhèn)交通年度總結
- 2024-2025年秋季第一學期小學語文教師工作總結
- 2024年XX村陳規(guī)陋習整治報告
- 2025年學校元旦迎新盛典活動策劃方案
- 2024年學校周邊安全隱患自查報告
- 2024年XX鎮(zhèn)農村規(guī)劃管控述職報告