CoOS Demonstrator adapted to mbed Hardware.

Dependencies:   mbed

Committer:
ericebert
Date:
Fri Dec 03 19:45:30 2010 +0000
Revision:
0:57690853989a
Some basic LED-Flashing works in the CoOS-RTOS using Tasks

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ericebert 0:57690853989a 1 /**
ericebert 0:57690853989a 2 *******************************************************************************
ericebert 0:57690853989a 3 * @file OsTask.h
ericebert 0:57690853989a 4 * @version V1.1.3
ericebert 0:57690853989a 5 * @date 2010.04.26
ericebert 0:57690853989a 6 * @brief Header file related to task.
ericebert 0:57690853989a 7 * @details This file including some defines and function declare related to task.
ericebert 0:57690853989a 8 *******************************************************************************
ericebert 0:57690853989a 9 * @copy
ericebert 0:57690853989a 10 *
ericebert 0:57690853989a 11 * INTERNAL FILE,DON'T PUBLIC.
ericebert 0:57690853989a 12 *
ericebert 0:57690853989a 13 * <h2><center>&copy; COPYRIGHT 2009 CooCox </center></h2>
ericebert 0:57690853989a 14 *******************************************************************************
ericebert 0:57690853989a 15 */
ericebert 0:57690853989a 16
ericebert 0:57690853989a 17 #ifndef _TASK_H
ericebert 0:57690853989a 18 #define _TASK_H
ericebert 0:57690853989a 19
ericebert 0:57690853989a 20 #define SYS_TASK_NUM (1) /*!< System task number. */
ericebert 0:57690853989a 21
ericebert 0:57690853989a 22 /*---------------------------- Task Status -----------------------------------*/
ericebert 0:57690853989a 23 #define TASK_READY 0 /*!< Ready status of task. */
ericebert 0:57690853989a 24 #define TASK_RUNNING 1 /*!< Running status of task. */
ericebert 0:57690853989a 25 #define TASK_WAITING 2 /*!< Waitting status of task. */
ericebert 0:57690853989a 26 #define TASK_DORMANT 3 /*!< Dormant status of task. */
ericebert 0:57690853989a 27
ericebert 0:57690853989a 28
ericebert 0:57690853989a 29 #define INVALID_ID (U8)0xff
ericebert 0:57690853989a 30 #define INVALID_VALUE (U32)0xffffffff
ericebert 0:57690853989a 31 #define MAGIC_WORD (U32)0x5a5aa5a5
ericebert 0:57690853989a 32
ericebert 0:57690853989a 33
ericebert 0:57690853989a 34 /**
ericebert 0:57690853989a 35 * @struct TCB task.h
ericebert 0:57690853989a 36 * @brief Task control blcok.
ericebert 0:57690853989a 37 * @details This struct use to manage task.
ericebert 0:57690853989a 38 */
ericebert 0:57690853989a 39 typedef struct TCB
ericebert 0:57690853989a 40 {
ericebert 0:57690853989a 41 OS_STK *stkPtr; /*!< The current point of task. */
ericebert 0:57690853989a 42 U8 prio; /*!< Task priority. */
ericebert 0:57690853989a 43 U8 state; /*!< TaSk status. */
ericebert 0:57690853989a 44 OS_TID taskID; /*!< Task ID. */
ericebert 0:57690853989a 45
ericebert 0:57690853989a 46 #if CFG_MUTEX_EN > 0
ericebert 0:57690853989a 47 OS_MutexID mutexID; /*!< Mutex ID. */
ericebert 0:57690853989a 48 #endif
ericebert 0:57690853989a 49
ericebert 0:57690853989a 50 #if CFG_EVENT_EN > 0
ericebert 0:57690853989a 51 OS_EventID eventID; /*!< Event ID. */
ericebert 0:57690853989a 52 #endif
ericebert 0:57690853989a 53
ericebert 0:57690853989a 54 #if CFG_ROBIN_EN >0
ericebert 0:57690853989a 55 U16 timeSlice; /*!< Task time slice */
ericebert 0:57690853989a 56 #endif
ericebert 0:57690853989a 57
ericebert 0:57690853989a 58 #if CFG_STK_CHECKOUT_EN >0
ericebert 0:57690853989a 59 OS_STK *stack; /*!< The top point of task. */
ericebert 0:57690853989a 60 #endif
ericebert 0:57690853989a 61
ericebert 0:57690853989a 62 #if CFG_EVENT_EN > 0
ericebert 0:57690853989a 63 void* pmail; /*!< Mail to task. */
ericebert 0:57690853989a 64 struct TCB *waitNext; /*!< Point to next TCB in the Event waitting list.*/
ericebert 0:57690853989a 65 struct TCB *waitPrev; /*!< Point to prev TCB in the Event waitting list.*/
ericebert 0:57690853989a 66 #endif
ericebert 0:57690853989a 67
ericebert 0:57690853989a 68 #if CFG_TASK_SCHEDULE_EN == 0
ericebert 0:57690853989a 69 FUNCPtr taskFuc;
ericebert 0:57690853989a 70 OS_STK *taskStk;
ericebert 0:57690853989a 71 #endif
ericebert 0:57690853989a 72
ericebert 0:57690853989a 73
ericebert 0:57690853989a 74 #if CFG_FLAG_EN > 0
ericebert 0:57690853989a 75 void* pnode; /*!< Pointer to node of event flag. */
ericebert 0:57690853989a 76 #endif
ericebert 0:57690853989a 77
ericebert 0:57690853989a 78 #if CFG_TASK_WAITTING_EN >0
ericebert 0:57690853989a 79 U32 delayTick; /*!< The number of ticks which delay. */
ericebert 0:57690853989a 80 #endif
ericebert 0:57690853989a 81 struct TCB *TCBnext; /*!< The pointer to next TCB. */
ericebert 0:57690853989a 82 struct TCB *TCBprev; /*!< The pointer to prev TCB. */
ericebert 0:57690853989a 83
ericebert 0:57690853989a 84 }OSTCB,*P_OSTCB;
ericebert 0:57690853989a 85
ericebert 0:57690853989a 86
ericebert 0:57690853989a 87 /*---------------------------- Variable declare ------------------------------*/
ericebert 0:57690853989a 88 // save tcb ptr that created
ericebert 0:57690853989a 89 extern P_OSTCB FreeTCB; /*!< A pointer to free TCB. */
ericebert 0:57690853989a 90 extern OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM];
ericebert 0:57690853989a 91 extern P_OSTCB TCBRdy; /*!< A pointer to TCB that is ready status */
ericebert 0:57690853989a 92 extern P_OSTCB TCBNext; /*!< A pointer to TCB next be scheduled. */
ericebert 0:57690853989a 93 extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */
ericebert 0:57690853989a 94
ericebert 0:57690853989a 95 extern U64 OSCheckTime;
ericebert 0:57690853989a 96 extern volatile U8 OSIntNesting; /*!< Use to indicate interrupt nesting level.*/
ericebert 0:57690853989a 97 extern volatile U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK).*/
ericebert 0:57690853989a 98 extern volatile BOOL TaskSchedReq;
ericebert 0:57690853989a 99 extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE];
ericebert 0:57690853989a 100
ericebert 0:57690853989a 101
ericebert 0:57690853989a 102 void Schedule(void); /*!< Schedule function */
ericebert 0:57690853989a 103 void IdleTask(void* pdata); /*!< IDLE task code */
ericebert 0:57690853989a 104 void InsertToTCBRdyList (P_OSTCB tcbInser);
ericebert 0:57690853989a 105 void RemoveFromTCBRdyList(P_OSTCB ptcb);
ericebert 0:57690853989a 106 void CreateTCBList(void);
ericebert 0:57690853989a 107 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
ericebert 0:57690853989a 108 void ActiveTaskPri(U8 pri);
ericebert 0:57690853989a 109 void DeleteTaskPri(U8 pri);
ericebert 0:57690853989a 110 #endif
ericebert 0:57690853989a 111
ericebert 0:57690853989a 112 #endif