⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucos_ii.h

📁 事件驱动程序设计很好的框架
💻 H
📖 第 1 页 / 共 5 页
字号:
/*$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_FLAG_EN > 0)    OS_EVENT        *OSTCBEventPtr;         /* Pointer to          event control block                 */#endif#if (OS_EVENT_EN) && (OS_EVENT_MULTI_EN > 0)    OS_EVENT       **OSTCBEventMultiPtr;    /* Pointer to multiple event control blocks                */#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_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                                        */    INT8U            OSTCBStatPend;         /* Task PEND status                                        */    INT8U            OSTCBPrio;             /* Task priority (0 == highest)                            */    INT8U            OSTCBX;                /* Bit position in group  corresponding to task priority   */    INT8U            OSTCBY;                /* Index into ready table corresponding to task priority   */#if OS_LOWEST_PRIO <= 63    INT8U            OSTCBBitX;             /* Bit mask to access bit position in ready table          */    INT8U            OSTCBBitY;             /* Bit mask to access bit position in ready group          */#else    INT16U           OSTCBBitX;             /* Bit mask to access bit position in ready table          */    INT16U           OSTCBBitY;             /* Bit mask to access bit position in ready group          */#endif#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    INT8U            OSTCBTaskName[OS_TASK_NAME_SIZE];#endif} OS_TCB;/*$PAGE*//**************************************************************************************************************************                                                   TIMER DATA TYPES*************************************************************************************************************************/#if OS_TMR_EN > 0typedef  void (*OS_TMR_CALLBACK)(void *ptmr, void *parg);typedef  struct  os_tmr {    INT8U            OSTmrType;                       /* Should be set to OS_TMR_TYPE                                  */    OS_TMR_CALLBACK  OSTmrCallback;                   /* Function to call when timer expires                           */    void            *OSTmrCallbackArg;                /* Argument to pass to function when timer expires               */    void            *OSTmrNext;                       /* Double link list pointers                                     */    void            *OSTmrPrev;    INT32U           OSTmrMatch;                      /* Timer expires when OSTmrTime == OSTmrMatch                    */    INT32U           OSTmrDly;                        /* Delay time before periodic update starts                      */    INT32U           OSTmrPeriod;                     /* Period to repeat timer                                        */#if OS_TMR_CFG_NAME_SIZE > 0    INT8U            OSTmrName[OS_TMR_CFG_NAME_SIZE]; /* Name to give the timer                                        */#endif    INT8U            OSTmrOpt;                        /* Options (see OS_TMR_OPT_xxx)                                  */    INT8U            OSTmrState;                      /* Indicates the state of the timer:                             */                                                      /*     OS_TMR_STATE_UNUSED                                       */                                                      /*     OS_TMR_STATE_RUNNING                                      */                                                      /*     OS_TMR_STATE_STOPPED                                      */} OS_TMR;typedef  struct  os_tmr_wheel {    OS_TMR          *OSTmrFirst;                      /* Pointer to first timer in linked list                         */    INT16U           OSTmrEntries;} OS_TMR_WHEEL;#endif/*$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_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 > 0OS_EXT  INT8U             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          */#endifOS_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               */#if OS_LOWEST_PRIO <= 63OS_EXT  INT8U             OSRdyGrp;                        /* Ready list group                         */OS_EXT  INT8U             OSRdyTbl[OS_RDY_TBL_SIZE];       /* Table of tasks which are ready to run    */#elseOS_EXT  INT16U            OSRdyGrp;                        /* Ready list group                         */OS_EXT  INT16U            OSRdyTbl[OS_RDY_TBL_SIZE];       /* Table of tasks which are ready to run    */#endifOS_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 > 0OS_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 > 0OS_EXT  volatile  INT32U  OSTime;                   /* Current value of system time (in ticks)         */#endif#if OS_TMR_EN > 0OS_EXT  INT16U            OSTmrFree;                /* Number of free entries in the timer pool        */OS_EXT  INT16U            OSTmrUsed;                /* Number of timers used                           */OS_EXT  INT32U            OSTmrTime;                /* Current timer time                              */OS_EXT  OS_EVENT         *OSTmrSem;                 /* Sem. used to gain exclusive access to timers    */OS_EXT  OS_EVENT         *OSTmrSemSignal;           /* Sem. used to signal the update of timers        */OS_EXT  OS_TMR            OSTmrTbl[OS_TMR_CFG_MAX]; /* Table containing pool of timers                 */OS_EXT  OS_TMR           *OSTmrFreeList;            /* Pointer to free list of timers                  */OS_EXT  OS_STK            OSTmrTaskStk[OS_TASK_TMR_STK_SIZE];OS_EXT  OS_TMR_WHEEL      OSTmrWheelTbl[OS_TMR_CFG_WHEEL_SIZE];#endifextern  INT8U   const     OSUnMapTbl[256];          /* Priority->Index    lookup table                 *//*$PAGE*//***********************************************************************************************************                                          FUNCTION PROTOTYPES*                                     (Target Independent Functions)**********************************************************************************************************//***********************************************************************************************************                                            MISCELLANEOUS**********************************************************************************************************/#if (OS_EVENT_EN)#if (OS_EVENT_NAME_SIZE > 1)INT8U         OSEventNameGet          (OS_EVENT        *pevent,                                       INT8U           *pname,                                       INT8U           *perr);void          OSEventNameSet          (OS_EVENT        *pevent,                                       INT8U           *pname,                                       INT8U           *perr);#endif#if (OS_EVENT_MULTI_EN > 0)INT16U        OSEventPendMulti        (OS_EVENT       **pevents_pend,                                       OS_EVENT       **pevents_rdy,                                       void           **pmsgs_rdy,                                       INT16U           timeout,                                       INT8U           *perr);#endif#endif/***********************************************************************************************************                                         EVENT FLAGS MANAGEMENT**********************************************************************************************************/#if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)#if OS_FLAG_ACCEPT_EN > 0OS_FLAGS      OSFlagAccept            (OS_FLAG_GRP     *pgrp,                                       OS_FLAGS         flags,                                       INT8U            wait_type,                                       INT8U           *perr);#endifOS_FLAG_GRP  *OSFlagCreate            (OS_FLAGS         flags,                                      INT8U            *perr);#if OS_FLAG_DEL_EN > 0OS_FLAG_GRP  *OSFlagDel               (OS_FLAG_GRP     *pgrp,                                       INT8U            opt,                                       INT8U           *perr);#endif#if (OS_FLAG_EN > 0) && (OS_FLAG_NAME_SIZE > 1)INT8U         OSFlagNameGet           (OS_FLAG_GRP     *pgrp,                                       INT8U           *pname,                                       INT8U           *perr);void          OSFlagNameSet           (OS_FLAG_GRP     *pgrp,                                       INT8U           *pname,                                       INT8U           *perr);#endifOS_FLAGS      OSFlagPend              (OS_FLAG_GRP     *pgrp,                                       OS_FLAGS         flags,                                       INT8U            wait_type,                                       INT16U           timeout,                                       INT8U           *perr);OS_FLAGS      OSFlagPendGetFlagsRdy   (void);OS_FLAGS      OSFlagPost              (OS_FLAG_GRP     *pgrp,                                       OS_FLAGS         flags,                                       INT8U            opt,                                       INT8U           *perr);#if OS_FLAG_QUERY_EN > 0OS_FLAGS      OSFlagQuery             (OS_FLAG_GRP     *pgrp,                                       INT8U           *perr);#endif#endif/**********************************************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -