CooCox 1.1.4 on mbed with simple blinky example

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OsTask.h Source File

OsTask.h

Go to the documentation of this file.
00001 /**
00002  *******************************************************************************
00003  * @file       OsTask.h
00004  * @version    V1.1.4    
00005  * @date       2011.04.20
00006  * @brief      Header file  related to task.
00007  * @details    This file including some defines and function declare related to task.   
00008  *******************************************************************************
00009  * @copy
00010  *
00011  * INTERNAL FILE,DON'T PUBLIC.
00012  * 
00013  * <h2><center>&copy; COPYRIGHT 2009 CooCox </center></h2>
00014  *******************************************************************************
00015  */ 
00016 
00017 #ifndef _TASK_H
00018 #define _TASK_H
00019 
00020 #define  SYS_TASK_NUM   (1)             /*!< System task number.              */
00021 
00022 /*---------------------------- Task Status -----------------------------------*/
00023 #define  TASK_READY     0               /*!< Ready status of task.            */                    
00024 #define  TASK_RUNNING   1               /*!< Running status of task.          */
00025 #define  TASK_WAITING   2               /*!< Waitting status of task.         */
00026 #define  TASK_DORMANT   3               /*!< Dormant status of task.          */ 
00027 
00028 
00029 #define  INVALID_ID     (U8)0xff
00030 #define  INVALID_VALUE  (U32)0xffffffff
00031 #define  MAGIC_WORD     (U32)0x5a5aa5a5
00032 
00033 
00034 /**
00035  * @struct  TCB  task.h     
00036  * @brief   Task control blcok.
00037  * @details This struct use to manage task.     
00038  */
00039 typedef  struct TCB
00040 {
00041     OS_STK      *stkPtr ;                /*!< The current point of task.       */
00042     U8          prio ;                   /*!< Task priority.                   */
00043     U8          state ;                  /*!< TaSk status.                     */
00044     OS_TID      taskID ;                 /*!< Task ID.                         */
00045 
00046 #if CFG_MUTEX_EN > 0
00047     OS_MutexID  mutexID ;                /*!< Mutex ID.                        */
00048 #endif
00049    
00050 #if CFG_EVENT_EN > 0
00051     OS_EventID  eventID ;                /*!< Event ID.                        */
00052 #endif
00053     
00054 #if CFG_ROBIN_EN >0
00055     U16         timeSlice ;              /*!< Task time slice                  */
00056 #endif
00057     
00058 #if CFG_STK_CHECKOUT_EN >0
00059     OS_STK      *stack ;                 /*!< The top point of task.           */
00060 #endif
00061     
00062 #if CFG_EVENT_EN > 0
00063     void*       pmail ;                  /*!< Mail to task.                    */
00064     struct TCB  *waitNext ;  /*!< Point to next TCB in the Event waitting list.*/
00065     struct TCB  *waitPrev ;  /*!< Point to prev TCB in the Event waitting list.*/
00066 #endif
00067 
00068 #if CFG_TASK_SCHEDULE_EN == 0
00069     FUNCPtr     taskFuc;
00070     OS_STK      *taskStk;
00071 #endif  
00072 
00073     
00074 #if CFG_FLAG_EN > 0
00075     void*       pnode ;                  /*!< Pointer to node of event flag.   */
00076 #endif   
00077 
00078 #if CFG_TASK_WAITTING_EN >0
00079     U32         delayTick ;              /*!< The number of ticks which delay. */
00080 #endif    
00081     struct TCB  *TCBnext ;               /*!< The pointer to next TCB.         */
00082     struct TCB  *TCBprev ;               /*!< The pointer to prev TCB.         */
00083 
00084 }OSTCB,*P_OSTCB;
00085 
00086 
00087 /*---------------------------- Variable declare ------------------------------*/
00088 // save tcb ptr that created
00089 extern P_OSTCB  FreeTCB ;      /*!< A pointer to free TCB.                     */
00090 extern OSTCB    TCBTbl [CFG_MAX_USER_TASKS+SYS_TASK_NUM];
00091 extern P_OSTCB  TCBRdy ;       /*!< A pointer to TCB that is ready status      */
00092 extern P_OSTCB  TCBNext ;      /*!< A pointer to TCB next be scheduled.        */    
00093 extern P_OSTCB  TCBRunning ;   /*!< A pointer to TCB that is running.          */
00094 
00095 extern U64      OSCheckTime ;
00096 extern volatile U8   OSIntNesting ; /*!< Use to indicate interrupt nesting level.*/                  
00097 extern volatile U8   OSSchedLock ;  /*!< Schedule is lock(LOCK) or unlock(UN_LOCK).*/    
00098 extern volatile BOOL TaskSchedReq;
00099 extern OS_STK   idle_stk[CFG_IDLE_STACK_SIZE];
00100 
00101 
00102 void  Schedule(void);         /*!< Schedule function                          */
00103 void  IdleTask (void* pdata);  /*!< IDLE task code                             */
00104 void  InsertToTCBRdyList  (P_OSTCB tcbInser);   
00105 void  RemoveFromTCBRdyList(P_OSTCB ptcb);
00106 void  CreateTCBList(void);
00107 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
00108 void  ActiveTaskPri(U8 pri);
00109 void  DeleteTaskPri(U8 pri);
00110 #endif
00111 
00112 #endif