📄 ucos_ii.h
字号:
typedef struct os_mem_data {
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 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*/
/*
*********************************************************************************************************
* MUTUAL EXCLUSION SEMAPHORE DATA
*********************************************************************************************************
*/
#if OS_MUTEX_EN > 0
typedef struct os_mutex_data {
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 */
INT8U OSValue; /* Mutex value (0 = used, 1 = available) */
INT8U OSOwnerPrio; /* Mutex owner's task priority or 0xFF if no owner */
INT8U OSMutexPIP; /* Priority Inheritance Priority or 0xFF if no owner */
} OS_MUTEX_DATA;
#endif
/*
*********************************************************************************************************
* MESSAGE QUEUE DATA
*********************************************************************************************************
*/
#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 where 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 os_q_data {
void *OSMsg; /* 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 tasks waiting for event to occur */
} OS_Q_DATA;
#endif
/*
*********************************************************************************************************
* SEMAPHORE DATA
*********************************************************************************************************
*/
#if OS_SEM_EN > 0
typedef struct os_sem_data {
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
/*
*********************************************************************************************************
* TASK STACK DATA
*********************************************************************************************************
*/
#if OS_TASK_CREATE_EXT_EN > 0
typedef struct os_stk_data {
INT32U OSFree; /* Number of free bytes on the stack */
INT32U OSUsed; /* Number of bytes used on the stack */
} OS_STK_DATA;
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TASK CONTROL BLOCK
*********************************************************************************************************
*/
typedef struct os_tcb {
OS_STK *OSTCBStkPtr; /* Pointer to current top of stack */
#if OS_TASK_CREATE_EXT_EN > 0
void *OSTCBExtPtr; /* Pointer to user definable data for TCB extension */
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() */
INT16U OSTCBId; /* Task ID (0..65535) */
#endif
struct os_tcb *OSTCBNext; /* Pointer to next TCB in the TCB list */
struct os_tcb *OSTCBPrev; /* Pointer to previous TCB in the TCB list */
#if OS_EVENT_EN
OS_EVENT *OSTCBEventPtr; /* Pointer to event control block */
#endif
#if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
void *OSTCBMsg; /* Message received from OSMboxPost() or OSQPost() */
#endif
#if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
#if OS_TASK_DEL_EN > 0
OS_FLAG_NODE *OSTCBFlagNode; /* Pointer to event flag node */
#endif
OS_FLAGS OSTCBFlagsRdy; /* Event flags that made task ready to run */
#endif
INT16U OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
INT8U OSTCBStat; /* Task status */
BOOLEAN OSTCBPendTO; /* Flag indicating PEND timed out (TRUE == timed out) */
INT8U OSTCBPrio; /* Task priority (0 == highest, 63 == lowest) */
INT8U OSTCBX; /* Bit position in group corresponding to task priority (0..7) */
INT8U OSTCBY; /* Index into ready table corresponding to task priority */
INT8U OSTCBBitX; /* Bit mask to access bit position in ready table */
INT8U OSTCBBitY; /* Bit mask to access bit position in ready group */
#if OS_TASK_DEL_EN > 0
INT8U OSTCBDelReq; /* Indicates whether a task needs to delete itself */
#endif
#if OS_TASK_PROFILE_EN > 0
INT32U OSTCBCtxSwCtr; /* Number of time the task was switched in */
INT32U OSTCBCyclesTot; /* Total number of clock cycles the task has been running */
INT32U OSTCBCyclesStart; /* Snapshot of cycle counter at start of task resumption */
OS_STK *OSTCBStkBase; /* Pointer to the beginning of the task stack */
INT32U OSTCBStkUsed; /* Number of bytes used from the stack */
#endif
#if OS_TASK_NAME_SIZE > 1
char OSTCBTaskName[OS_TASK_NAME_SIZE];
#endif
} OS_TCB;
/*$PAGE*/
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
OS_EXT INT32U OSCtxSwCtr; /* Counter of number of context switches */
#if OS_EVENT_EN && (OS_MAX_EVENTS > 0)
OS_EXT OS_EVENT *OSEventFreeList; /* Pointer to list of free EVENT control blocks */
OS_EXT OS_EVENT OSEventTbl[OS_MAX_EVENTS];/* Table of EVENT control blocks */
#endif
#if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
OS_EXT OS_FLAG_GRP OSFlagTbl[OS_MAX_FLAGS]; /* Table containing event flag groups */
OS_EXT OS_FLAG_GRP *OSFlagFreeList; /* Pointer to free list of event flag groups */
#endif
#if OS_TASK_STAT_EN > 0
OS_EXT INT8S OSCPUUsage; /* Percentage of CPU used */
OS_EXT INT32U OSIdleCtrMax; /* Max. value that idle ctr can take in 1 sec. */
OS_EXT INT32U OSIdleCtrRun; /* Val. reached by idle ctr at run time in 1 sec. */
OS_EXT BOOLEAN OSStatRdy; /* Flag indicating that the statistic task is rdy */
OS_EXT OS_STK OSTaskStatStk[OS_TASK_STAT_STK_SIZE]; /* Statistics task stack */
#endif
OS_EXT INT8U OSIntNesting; /* Interrupt nesting level */
OS_EXT INT8U OSLockNesting; /* Multitasking lock nesting level */
OS_EXT INT8U OSPrioCur; /* Priority of current task */
OS_EXT INT8U OSPrioHighRdy; /* Priority of highest priority task */
OS_EXT INT8U OSRdyGrp; /* Ready list group */
OS_EXT INT8U OSRdyTbl[OS_RDY_TBL_SIZE]; /* Table of tasks which are ready to run */
OS_EXT BOOLEAN OSRunning; /* Flag indicating that kernel is running */
OS_EXT INT8U OSTaskCtr; /* Number of tasks created */
OS_EXT volatile INT32U OSIdleCtr; /* Idle counter */
OS_EXT OS_STK OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE]; /* Idle task stack */
OS_EXT OS_TCB *OSTCBCur; /* Pointer to currently running TCB */
OS_EXT OS_TCB *OSTCBFreeList; /* Pointer to list of free TCBs */
OS_EXT OS_TCB *OSTCBHighRdy; /* Pointer to highest priority TCB R-to-R */
OS_EXT OS_TCB *OSTCBList; /* Pointer to doubly linked list of TCBs */
OS_EXT OS_TCB *OSTCBPrioTbl[OS_LOWEST_PRIO + 1];/* Table of pointers to created TCBs */
OS_EXT OS_TCB OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS]; /* Table of TCBs */
#if OS_TICK_STEP_EN > 0
OS_EXT INT8U OSTickStepState; /* Indicates the state of the tick step feature */
#endif
#if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
OS_EXT OS_MEM *OSMemFreeList; /* Pointer to free list of memory partitions */
OS_EXT OS_MEM OSMemTbl[OS_MAX_MEM_PART];/* Storage for memory partition manager */
#endif
#if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
OS_EXT OS_Q *OSQFreeList; /* Pointer to list of free QUEUE control blocks */
OS_EXT OS_Q OSQTbl[OS_MAX_QS]; /* Table of QUEUE control blocks */
#endif
#if OS_TIME_GET_SET_EN > 0
OS_EXT volatile INT32U OSTime; /* Current value of system time (in ticks) */
#endif
extern INT8U const OSMapTbl[8]; /* Priority->Bit Mask lookup table */
extern INT8U const OSUnMapTbl[256]; /* Priority->Index lookup table */
/*$PAGE*/
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
* (Target Independent Functions)
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MISCELLANEOUS
*********************************************************************************************************
*/
#if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
INT8U OSEventNameGet(OS_EVENT *pevent, char *pname, INT8U *err);
void OSEventNameSet(OS_EVENT *pevent, char *pname, INT8U *err);
#endif
/*
*********************************************************************************************************
* EVENT FLAGS MANAGEMENT
*********************************************************************************************************
*/
#if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
#if OS_FLAG_ACCEPT_EN > 0
OS_FLAGS OSFlagAccept(OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT8U *err);
#endif
OS_FLAG_GRP *OSFlagCreate(OS_FLAGS flags, INT8U *err);
#if OS_FLAG_DEL_EN > 0
OS_FLAG_GRP *OSFlagDel(OS_FLAG_GRP *pgrp, INT8U opt, INT8U *err);
#endif
#if (OS_FLAG_EN > 0) && (OS_FLAG_NAME_SIZE > 1)
INT8U OSFlagNameGet(OS_FLAG_GRP *pgrp, char *pname, INT8U *err);
void OSFlagNameSet(OS_FLAG_GRP *pgrp, char *pname, INT8U *err);
#endif
OS_FLAGS OSFlagPend(OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *err);
OS_FLAGS OSFlagPendGetFlagsRdy(void);
OS_FLAGS OSFlagPost(OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U opt, INT8U *err);
#if OS_FLAG_QUERY_EN > 0
OS_FLAGS OSFlagQuery(OS_FLAG_GRP *pgrp, INT8U *err);
#endif
#endif
/*
*********************************************************************************************************
* MESSAGE MAILBOX MANAGEMENT
*********************************************************************************************************
*/
#if OS_MBOX_EN > 0
#if OS_MBOX_ACCEPT_EN > 0
void *OSMboxAccept(OS_EVENT *pevent);
#endif
OS_EVENT *OSMboxCreate(void *msg);
#if OS_MBOX_DEL_EN > 0
OS_EVENT *OSMboxDel(OS_EVENT *pevent, INT8U opt, INT8U *err);
#endif
void *OSMboxPend(OS_EVENT *pevent, INT16U timeout, INT8U *err);
#if OS_MBOX_POST_EN > 0
INT8U OSMboxPost(OS_EVENT *pevent, void *msg);
#endif
#if OS_MBOX_POST_OPT_EN > 0
INT8U OSMboxPostOpt(OS_EVENT *pevent, void *msg, INT8U opt);
#endif
#if OS_MBOX_QUERY_EN > 0
INT8U OSMboxQuery(OS_EVENT *pevent, OS_MBOX_DATA *p_mbox_data);
#endif
#endif
/*
*********************************************************************************************************
* MEMORY MANAGEMENT
*********************************************************************************************************
*/
#if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
OS_MEM *OSMemCreate(void *addr, INT32U nblks, INT32U blksize, INT8U *err);
void *OSMemGet(OS_MEM *pmem, INT8U *err);
#if OS_MEM_NAME_SIZE > 1
INT8U OSMemNameGet(OS_MEM *pmem, char *pname, INT8U *err);
void OSMemNameSet(OS_MEM *pmem, char *pname, INT8U *err);
#endif
INT8U OSMemPut(OS_MEM *pmem, void *pblk);
#if OS_MEM_QUERY_EN > 0
INT8U OSMemQuery(OS_MEM *pmem, OS_MEM_DATA *p_mem_data);
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -