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

📄 ucos_ii.h

📁 一个中断驱动的具有缓冲区的串口源码(C)
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*
*                              (c) Copyright 1999, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : uCOS_II.H
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                           REVISION HISTORY
*
* $Log:   J:/software/ucos-ii/vc/ucos_ii.h_v  $
*      
*         Rev 1.2   18 Jul 1999 17:45:32   JJL
*         **************************** uC/OS-II REL V2.02 ****************************
*         - OS_MBOX.C:
*           a) Removed last 'else' statement in OSMboxPend() because the code is
*              unreacheable.
*         - OS_Q.C:
*           a) Removed last 'else' statement in OSQPend() because the code is
*              unreacheable.
*         - OS_TASK.C:
*           a) OSTaskCtr is always included.
*         - uCOS_II.H:
*           a) Added check for definition of macro OS_ISR_PROTO_EXT so that the prototype
*              of OSCtxSw() and OSTickISR() can be changed based on compiler specific
*              requirements.  To use a different prototype, simply add:
*                  #define OS_ISR_PROTO_EXT
*              in OS_CPU.H of the port and then define the new prototype format for
*              OSCtxSw() and OSTickISR() in OS_CPU.H of the port.
*           b) OSTaskCtr is always included.    Previously it was conditionally compiled
*              only if OS_TASK_CREATE_EN, OS_TASK_CREATE_EXT_EN or OS_TASK_DEL_EN was
*              set to 1.  It turns out that you MUST always have either OS_TASK_CREATE_EN
*              or OS_TASK_CREATE_EXT_EN set to 1 anyway!
*             
*      
*         Rev 1.1   15 Jul 1999 18:03:46   JJL
*         **************************** uC/OS-II REL V2.01 ****************************
*         - OS_CORE.C:
*           a) Changed 'for' loop inside 'OSEventWaitListInit()' to inline code for
*              speed.  This eliminates the loop overhead.
*           b) The argument 'stk_size' in OSTCBInit() has been changed from INT16U to
*              INT32U to accomodate large stacks.
*         - OS_MBOX.C:
*           a) Changed 'for' loop inside 'OSMboxQuery()' to inline code for speed.
*              This eliminates the loop overhead.
*         - OS_Q.C:
*           a) Added typecast to avoid compiler error/warning:
*              pq = (OS_Q *)pevent->OSEventPtr;
*                   ^^^^^^^^
*              Affected functions:
*                  OSQAccept()
*                  OSQFlush()
*                  OSQPend()
*                  OSQPost()
*                  OSQPostFront()
*           b) Changed 'for' loop inside 'OSQQuery()' to inline code for speed.  This
*              eliminates the loop overhead.
*           c) Added 'msg = (void *)0;' in 'if (OSIntNesting > 0)' case.
*         - OS_SEM.C:
*           a) Second 'if' statement in function OSSemPend() needed to be and 'if else'
*              clause.
*         - OS_TASK.C:
*           a) Stack filling is now done using the ANSI C function 'memset()' for speed.
*           b) Copying of the OS_TCB structure in OSTaskQuery() is now done using 
*              'memcpy()' for speed.
*           c) Function OSTaskStkChk() now cast the value 0 to (OS_STK)0 in while loops.
*         - uCOS_II.H:
*           a) Changed the comment for 'OSTCBStkSize' in the OS_TCB structure to indicate
*              that the size is in number of elements and not bytes.
*           b) The argument 'stk_size' in OSTCBInit() has been changed from INT16U to
*              INT32U to accomodate large stacks.
*      
*         Rev 1.0   01 Jan 1999 17:20:56   JJL
*         **************************** uC/OS-II REL V2.00 ****************************
*         - Initial Product Release
*         
*
*********************************************************************************************************
*/

/*$PAGE*/                                       
/*
*********************************************************************************************************
*                                             MISCELLANEOUS
*********************************************************************************************************
*/

#define  OS_VERSION              203   /* Version of uC/OS-II (Vx.yy multiplied by 100)                */

#ifdef   OS_GLOBALS
#define  OS_EXT
#else
#define  OS_EXT  extern
#endif

#define  OS_PRIO_SELF           0xFF   /* Indicate SELF priority                                       */

#if      OS_TASK_STAT_EN
#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                     */
#define  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                         */
#define  OS_TASK_STAT_ID       65534

                                       /* TASK STATUS (Bit definition for OSTCBStat)                   */
#define  OS_STAT_RDY            0x00   /* Ready to run                                                 */
#define  OS_STAT_SEM            0x01   /* Pending on semaphore                                         */
#define  OS_STAT_MBOX           0x02   /* Pending on mailbox                                           */
#define  OS_STAT_Q              0x04   /* Pending on queue                                             */
#define  OS_STAT_SUSPEND        0x08   /* Task is suspended                                            */

#define  OS_EVENT_TYPE_MBOX        1
#define  OS_EVENT_TYPE_Q           2
#define  OS_EVENT_TYPE_SEM         3

                                       /* TASK OPTIONS (see OSTaskCreateExt())                         */
#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 registers            */


#ifndef  FALSE
#define  FALSE                     0
#endif

#ifndef  TRUE
#define  TRUE                      1
#endif

/*
*********************************************************************************************************
*                                              ERROR CODES
*********************************************************************************************************
*/

#define OS_NO_ERR                 0
#define OS_ERR_EVENT_TYPE         1
#define OS_ERR_PEND_ISR           2
#define OS_ERR_POST_NULL_PTR      3

#define OS_TIMEOUT               10
#define OS_TASK_NOT_EXIST        11

#define OS_MBOX_FULL             20

#define OS_Q_FULL                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_INVALID_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_INVALID_BLKS     111
#define OS_MEM_INVALID_SIZE     112
#define OS_MEM_NO_FREE_BLKS     113
#define OS_MEM_FULL             114

#define OS_TASK_OPT_ERR         130

/*$PAGE*/
/*
*********************************************************************************************************
*                                          EVENT CONTROL BLOCK
*********************************************************************************************************
*/

#if (OS_MAX_EVENTS >= 2)
typedef struct {
    void   *OSEventPtr;                    /* Pointer to message or queue structure                    */
    INT8U   OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur                 */
    INT16U  OSEventCnt;                    /* Count of used when event is a semaphore                  */
    INT8U   OSEventType;                   /* OS_EVENT_TYPE_MBOX, OS_EVENT_TYPE_Q or OS_EVENT_TYPE_SEM */
    INT8U   OSEventGrp;                    /* Group corresponding to tasks waiting for event to occur  */
} OS_EVENT;
#endif

/*$PAGE*/
/*
*********************************************************************************************************
*                                          MESSAGE MAILBOX DATA
*********************************************************************************************************
*/

#if OS_MBOX_EN
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

/*
*********************************************************************************************************
*                                     MEMORY PARTITION DATA STRUCTURES
*********************************************************************************************************
*/

#if OS_MEM_EN && (OS_MAX_MEM_PART >= 2)
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 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  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*/
/*
*********************************************************************************************************
*                                          MESSAGE QUEUE DATA
*********************************************************************************************************
*/

#if OS_Q_EN
typedef struct {
    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
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

/*
*********************************************************************************************************
*                                            TASK STACK DATA
*********************************************************************************************************
*/

#if OS_TASK_CREATE_EXT_EN
typedef struct {

⌨️ 快捷键说明

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