Last CooCox version
Some handlers were defined twice in vectors_sam3s.c, perhaps some others need to be checked ... later!
This commit is contained in:
+12
-12
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ccrtos.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file CoOS.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief API header file of CooCox CoOS.
|
||||
* @details This file including all API functions's declare of CooCox CoOS.
|
||||
*******************************************************************************
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "OsConfig.h"
|
||||
/*---------------------------- Type Define ----------------------------------*/
|
||||
typedef signed char S8;
|
||||
typedef unsigned char U8;
|
||||
typedef unsigned char U8;
|
||||
typedef short S16;
|
||||
typedef unsigned short U16;
|
||||
typedef int S32;
|
||||
@@ -42,16 +42,16 @@ typedef void (*vFUNCPtr)(void);
|
||||
|
||||
|
||||
/*---------------------------- Constant Define -------------------------------*/
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#ifndef Co_NULL
|
||||
#define Co_NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE (0)
|
||||
#ifndef Co_FALSE
|
||||
#define Co_FALSE (0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1)
|
||||
#ifndef Co_TRUE
|
||||
#define Co_TRUE (1)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -120,11 +120,11 @@ extern OS_VER CoGetOSVersion(void); /*!< Get OS version value */
|
||||
|
||||
/* Implement in file "task.c" */
|
||||
#define CoCreateTask(task,argv,prio,stk,stkSz) \
|
||||
CreateTask(task,argv,(prio)|((stkSz)<<8),stk)
|
||||
CreateTask(task,argv,(prio)|(((stkSz)<<8) &0x000FFF00 ),stk)
|
||||
|
||||
|
||||
#define CoCreateTaskEx(task,argv,prio,stk,stkSz,timeSlice,isWaitting) \
|
||||
CreateTask(task,argv,(prio)|((stkSz)<<8)|((timeSlice)<<20)|(isWaitting<<31),stk)
|
||||
CreateTask(task,argv,(prio)|(((stkSz)<<8)&0x000FFF00)|(((timeSlice)<<20)&0x7FF00000)|((isWaitting<<31)&0x80000000),stk)
|
||||
|
||||
extern void CoExitTask(void);
|
||||
extern OS_TID CoGetCurTaskID(void);
|
||||
|
||||
+17
-17
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file config.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsConfig.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief This file use by user to configuration CooCox CoOS.
|
||||
* @note Ensure you have knew every item before modify this file.
|
||||
*******************************************************************************
|
||||
@@ -32,12 +32,12 @@ Defines the lowest priority that be assigned.
|
||||
/*!<
|
||||
Max number of tasks that can be running.
|
||||
*/
|
||||
#define CFG_MAX_USER_TASKS (5)
|
||||
#define CFG_MAX_USER_TASKS (5)
|
||||
|
||||
/*!<
|
||||
Idle task stack size(word).
|
||||
*/
|
||||
#define CFG_IDLE_STACK_SIZE (25)
|
||||
#define CFG_IDLE_STACK_SIZE (25)
|
||||
|
||||
/*!<
|
||||
System frequency (Hz).
|
||||
@@ -52,7 +52,7 @@ systick frequency (Hz).
|
||||
/*!<
|
||||
max systerm api call num in ISR.
|
||||
*/
|
||||
#define CFG_MAX_SERVICE_REQUEST (3)
|
||||
#define CFG_MAX_SERVICE_REQUEST (5)
|
||||
|
||||
/*!<
|
||||
Enable(1) or disable(0) order list schedule.
|
||||
@@ -136,7 +136,7 @@ Enable(1) or disable(0) memory management.
|
||||
Max number of memory.(must be less than 32).
|
||||
*/
|
||||
#if CFG_MM_EN >0
|
||||
#define CFG_MAX_MM (2)
|
||||
#define CFG_MAX_MM (2)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -145,13 +145,13 @@ Max number of memory.(must be less than 32).
|
||||
/*!<
|
||||
Enable(1) or disable(0) kernel heap management.
|
||||
*/
|
||||
#define CFG_KHEAP_EN (0)
|
||||
#define CFG_KHEAP_EN (0)
|
||||
|
||||
/*!<
|
||||
Kernel heap size(word).
|
||||
*/
|
||||
#if CFG_KHEAP_EN >0
|
||||
#define KHEAP_SIZE (50)
|
||||
#define KHEAP_SIZE (50)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -198,28 +198,28 @@ Event sort type.(1)FIFO (2)PRI (3)FIFO+PRI
|
||||
Max number of event.(must be less than 255)
|
||||
Event = semaphore + mailbox + queue;
|
||||
*/
|
||||
#define CFG_MAX_EVENT (10)
|
||||
#define CFG_MAX_EVENT (20)
|
||||
|
||||
/*!<
|
||||
Enable(1) or disable(0) semaphore management.
|
||||
*/
|
||||
#define CFG_SEM_EN (1)
|
||||
#define CFG_SEM_EN (0)
|
||||
|
||||
/*!<
|
||||
Enable(1) or disable(0) mailbox management.
|
||||
*/
|
||||
#define CFG_MAILBOX_EN (1)
|
||||
#define CFG_MAILBOX_EN (0)
|
||||
|
||||
/*!<
|
||||
Enable(1) or disable(0) queue management.
|
||||
*/
|
||||
#define CFG_QUEUE_EN (1)
|
||||
#define CFG_QUEUE_EN (0)
|
||||
|
||||
/*!<
|
||||
Max number of queue.(less than CFG_MAX_EVENT).
|
||||
*/
|
||||
#if CFG_QUEUE_EN >0
|
||||
#define CFG_MAX_QUEUE (2)
|
||||
#define CFG_MAX_QUEUE (2)
|
||||
#endif // CFG_QUEUE_EN
|
||||
|
||||
#endif // CFG_EVENT_EN
|
||||
@@ -232,7 +232,7 @@ Enable(1) or disable(0) flag management.
|
||||
Max number of flag is 32.
|
||||
*/
|
||||
#if CFG_TASK_WAITTING_EN > 0
|
||||
#define CFG_FLAG_EN (1)
|
||||
#define CFG_FLAG_EN (0)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ Enable(1) or disable(0) mutex management.
|
||||
*/
|
||||
#if CFG_TASK_WAITTING_EN > 0
|
||||
#if CFG_TASK_SCHEDULE_EN > 0
|
||||
#define CFG_MUTEX_EN (1)
|
||||
#define CFG_MUTEX_EN (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -258,7 +258,7 @@ Max number of mutex.(must be less than 255).
|
||||
/*!<
|
||||
Enable(1) or disable(0) utility management.
|
||||
*/
|
||||
#define CFG_UTILITY_EN (1)
|
||||
#define CFG_UTILITY_EN (0)
|
||||
|
||||
#if CFG_UTILITY_EN >0
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file core.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsCore.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Header file related to kernel
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file error.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsError.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief rror dispose header file
|
||||
* @details This file use to dispose error which from error configure for OS.
|
||||
*******************************************************************************
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file event.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsEvent.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Event management header file
|
||||
* @details This file including some defines and declares related to event
|
||||
* (semaphore,mailbox,queque) management.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file flag.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsFlag.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Evnet flag management header file
|
||||
* @details This file including some defines and declares about flag management.
|
||||
*******************************************************************************
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file kernelHeap.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsKernelHeap.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Header file related to memory management
|
||||
* @details This file including some defines and function declare related to
|
||||
* kernel heap management.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file mm.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsMm.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Header file related to memory management
|
||||
* @details This file including some defines and function declare related to
|
||||
* memory management.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file mutex.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsMutex.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Mutex management header file
|
||||
* @details This file including some defines and declare related to mutex
|
||||
* management.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file queue.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsQueue.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Queue management header file
|
||||
* @details This file including some defines and declares about queue management.
|
||||
*******************************************************************************
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file serviceReq.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsServiceReq.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Header file related to service request
|
||||
* @details This file including some defines and function declare related to
|
||||
* service request.
|
||||
@@ -26,6 +26,7 @@
|
||||
#define FLAG_REQ (U8)0x3
|
||||
#define QUEUE_REQ (U8)0x4
|
||||
|
||||
|
||||
typedef struct ServiceReqCell
|
||||
{
|
||||
U8 type;
|
||||
@@ -36,6 +37,7 @@ typedef struct ServiceReqCell
|
||||
typedef struct ServiceReqQueue
|
||||
{
|
||||
U8 cnt;
|
||||
U8 head;
|
||||
SQC cell[CFG_MAX_SERVICE_REQUEST];
|
||||
}SRQ,*P_SRQ;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file task.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsTask.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Header file related to task.
|
||||
* @details This file including some defines and function declare related to task.
|
||||
*******************************************************************************
|
||||
@@ -93,9 +93,9 @@ extern P_OSTCB TCBNext; /*!< A pointer to TCB next be scheduled. */
|
||||
extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */
|
||||
|
||||
extern U64 OSCheckTime;
|
||||
extern U8 OSIntNesting; /*!< Use to indicate interrupt nesting level. */
|
||||
extern U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK). */
|
||||
extern BOOL TaskSchedReq;
|
||||
extern volatile U8 OSIntNesting; /*!< Use to indicate interrupt nesting level.*/
|
||||
extern volatile U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK).*/
|
||||
extern volatile BOOL TaskSchedReq;
|
||||
extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE];
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file task.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsTime.c
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Header file related to time management
|
||||
* @details Thie file including some data declare related to time managment.
|
||||
*******************************************************************************
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file timer.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @file OsTimer.h
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Timer manage header file
|
||||
* @details This file including some declares and defines related to timer
|
||||
* management.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file coocox.h
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Gather for all header file of CooCox CoOS.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -17,8 +17,8 @@
|
||||
#ifndef _COOCOX_H
|
||||
#define _COOCOX_H
|
||||
|
||||
#define OS_VERSION (U16)0x0112 /*!< OS version.(format: Vx.xx),
|
||||
e.g. value 0x0111 is version V1.12*/
|
||||
#define OS_VERSION (U16)0x0113 /*!< OS version.(format: Vx.xx),
|
||||
e.g. value 0x0113 is version V1.13*/
|
||||
/*---------------------------- Include ---------------------------------------*/
|
||||
#include "CoOS.h"
|
||||
#include "OsArch.h"
|
||||
|
||||
+10
-10
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file core.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Core implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -17,9 +17,9 @@
|
||||
#include <coocox.h>
|
||||
|
||||
/*---------------------------- Variable Define -------------------------------*/
|
||||
U8 OSIntNesting = 0; /*!< Use to indicate interrupt nesting level*/
|
||||
U8 OSSchedLock = 0; /*!< Task Switch lock. */
|
||||
BOOL TaskSchedReq = FALSE;
|
||||
volatile U8 OSIntNesting = 0; /*!< Use to indicate interrupt nesting level*/
|
||||
volatile U8 OSSchedLock = 0; /*!< Task Switch lock. */
|
||||
volatile BOOL TaskSchedReq = Co_FALSE;
|
||||
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ void CoExitISR(void)
|
||||
Dec8(&OSIntNesting); /* OSIntNesting decrease */
|
||||
if( OSIntNesting == 0) /* Is OSIntNesting == 0? */
|
||||
{
|
||||
if(TaskSchedReq == TRUE)
|
||||
if(TaskSchedReq == Co_TRUE)
|
||||
{
|
||||
OSSchedLock++;
|
||||
Schedule(); /* Call task schedule */
|
||||
@@ -90,13 +90,13 @@ void OsSchedUnlock(void)
|
||||
if(OSSchedLock == 1) /* Is OSSchedLock == 0? */
|
||||
{
|
||||
#if CFG_TASK_WAITTING_EN > 0
|
||||
if(IsrReq == TRUE)
|
||||
if(IsrReq == Co_TRUE)
|
||||
{
|
||||
RespondSRQ(); /* Respond service request */
|
||||
}
|
||||
#endif
|
||||
/* Judge task state change or higher PRI task coming in */
|
||||
if(TaskSchedReq == TRUE)
|
||||
if(TaskSchedReq == Co_TRUE)
|
||||
{
|
||||
Schedule(); /* Call task schedule */
|
||||
}
|
||||
@@ -184,7 +184,7 @@ void CoInitOS(void)
|
||||
OsSchedLock(); /* Lock Schedule */
|
||||
/* Create first task -- IDLE task. */
|
||||
CoCreateTask( CoIdleTask,
|
||||
NULL,
|
||||
Co_NULL,
|
||||
CFG_LOWEST_PRIO,
|
||||
&idle_stk[CFG_IDLE_STACK_SIZE-1],
|
||||
CFG_IDLE_STACK_SIZE
|
||||
|
||||
+35
-35
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file event.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief event management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -22,7 +22,7 @@
|
||||
#if CFG_EVENT_EN > 0
|
||||
|
||||
ECB EventTbl[CFG_MAX_EVENT]= {{0}};/*!< Table which save event control block.*/
|
||||
P_ECB FreeEventList = NULL; /*!< Pointer to free event control block. */
|
||||
P_ECB FreeEventList = Co_NULL; /*!< Pointer to free event control block. */
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ void CreateEventList(void)
|
||||
i=0;
|
||||
pecb1 = &EventTbl[0]; /* Get first item */
|
||||
#if CFG_MAX_EVENT == 1 /* Build event list for only one item */
|
||||
pecb1->eventPtr = NULL;
|
||||
pecb1->eventPtr = Co_NULL;
|
||||
pecb1->id = i; /* Assign ID. */
|
||||
pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */
|
||||
#endif
|
||||
@@ -63,7 +63,7 @@ void CreateEventList(void)
|
||||
pecb2++;
|
||||
}
|
||||
pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */
|
||||
pecb1->eventPtr = NULL; /* Set link for last item */
|
||||
pecb1->eventPtr = Co_NULL; /* Set link for last item */
|
||||
pecb1->id = i;
|
||||
#endif
|
||||
|
||||
@@ -101,10 +101,10 @@ static void ReleaseECB(P_ECB pecb)
|
||||
* @param[in] eventType The type of event which being created.
|
||||
* @param[in] eventSortType Event sort type.
|
||||
* @param[in] eventCounter Event counter,ONLY for EVENT_TYPE_SEM.
|
||||
* @param[in] eventPtr Event struct pointer,ONLY for Queue.NULL for other
|
||||
* @param[in] eventPtr Event struct pointer,ONLY for Queue.Co_NULL for other
|
||||
* event type.
|
||||
* @param[out] None
|
||||
* @retval NULL Invalid pointer,create event fail.
|
||||
* @retval Co_NULL Invalid pointer,create event fail.
|
||||
* @retval others Pointer to event control block which had assigned right now.
|
||||
*
|
||||
* @par Description
|
||||
@@ -119,10 +119,10 @@ P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr)
|
||||
P_ECB pecb;
|
||||
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
if(FreeEventList == NULL) /* Is there no free evnet item */
|
||||
if(FreeEventList == Co_NULL) /* Is there no free evnet item */
|
||||
{
|
||||
OsSchedUnlock(); /* Yes,unlock schedule */
|
||||
return NULL; /* Return error */
|
||||
return Co_NULL; /* Return error */
|
||||
}
|
||||
pecb = FreeEventList;/* Assign the free event item to this event */
|
||||
FreeEventList = FreeEventList->eventPtr; /* Reset free event item */
|
||||
@@ -131,7 +131,7 @@ P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr)
|
||||
pecb->eventType = eventType; /* Initialize event item as user set */
|
||||
pecb->eventSortType = eventSortType;
|
||||
pecb->eventPtr = eventPtr;
|
||||
pecb->eventTCBList = NULL;
|
||||
pecb->eventTCBList = Co_NULL;
|
||||
return pecb; /* Return event item pointer */
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
|
||||
P_OSTCB ptcb;
|
||||
if(opt == OPT_DEL_NO_PEND) /* Do delete event when no task pend? */
|
||||
{
|
||||
if(pecb->eventTCBList != NULL) /* Yes,is there task pend this event? */
|
||||
if(pecb->eventTCBList != Co_NULL) /* Yes,is there task pend this event? */
|
||||
{
|
||||
return E_TASK_WAITING; /* Yes,error return */
|
||||
}
|
||||
@@ -172,7 +172,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
|
||||
else if(opt == OPT_DEL_ANYWAY) /* Do delete event anyway? */
|
||||
{
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
while(pecb->eventTCBList != NULL) /* Is there task pend this event? */
|
||||
while(pecb->eventTCBList != Co_NULL) /* Is there task pend this event? */
|
||||
{ /* Yes,remove it */
|
||||
ptcb = pecb->eventTCBList;/* Get first task in event waiting list */
|
||||
if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */
|
||||
@@ -182,7 +182,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
|
||||
|
||||
/* Set next item as event waiting list head */
|
||||
pecb->eventTCBList = ptcb->waitNext;
|
||||
ptcb->waitNext = NULL; /* Clear link for event waiting list */
|
||||
ptcb->waitNext = Co_NULL; /* Clear link for event waiting list */
|
||||
ptcb->eventID = INVALID_ID; /* Sign that not to use. */
|
||||
|
||||
InsertToTCBRdyList(ptcb); /* Insert task into ready list */
|
||||
@@ -207,7 +207,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
|
||||
* opt == EVENT_SORT_TYPE_FIFO By FIFO.
|
||||
* opt == EVENT_SORT_TYPE_PRIO By priority order,hghest priority
|
||||
* as head,lowest priority as end.
|
||||
* (Highest-->...-->Lowest-->NULL)
|
||||
* (Highest-->...-->Lowest-->Co_NULL)
|
||||
*******************************************************************************
|
||||
*/
|
||||
void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
|
||||
@@ -228,13 +228,13 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
|
||||
|
||||
#if (CFG_EVENT_SORT == 1) || (CFG_EVENT_SORT == 3)
|
||||
{
|
||||
if(ptcb1 == NULL) /* Is no item in event waiting list?*/
|
||||
if(ptcb1 == Co_NULL) /* Is no item in event waiting list?*/
|
||||
{
|
||||
pecb->eventTCBList = ptcb; /* Yes,set task as first item */
|
||||
}
|
||||
else
|
||||
{
|
||||
while(ptcb1->waitNext != NULL)/* No,insert task in last */
|
||||
while(ptcb1->waitNext != Co_NULL)/* No,insert task in last */
|
||||
{
|
||||
ptcb1 = ptcb1->waitNext;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
|
||||
#endif
|
||||
#if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3)
|
||||
{
|
||||
if(ptcb1 == NULL) /* Is no item in event waiting list? */
|
||||
if(ptcb1 == Co_NULL) /* Is no item in event waiting list? */
|
||||
{
|
||||
pecb->eventTCBList = ptcb; /* Yes,set task as first item */
|
||||
}
|
||||
@@ -263,7 +263,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
|
||||
else /* No,find correct place to insert */
|
||||
{
|
||||
ptcb2 = ptcb1->waitNext;
|
||||
while(ptcb2 != NULL) /* Is last item? */
|
||||
while(ptcb2 != Co_NULL) /* Is last item? */
|
||||
{
|
||||
if(ptcb2->prio > ptcb->prio) /* No,is correct place? */
|
||||
{
|
||||
@@ -275,7 +275,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
|
||||
ptcb1->waitNext = ptcb; /* Set link for list */
|
||||
ptcb->waitPrev = ptcb1;
|
||||
ptcb->waitNext = ptcb2;
|
||||
if(ptcb2 != NULL)
|
||||
if(ptcb2 != Co_NULL)
|
||||
{
|
||||
ptcb2->waitPrev = ptcb;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
|
||||
}
|
||||
#endif
|
||||
ptcb->state = TASK_WAITING; /* Set task status to TASK_WAITING state */
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
OsSchedUnlock(); /* Unlock schedule,and call task schedule */
|
||||
}
|
||||
|
||||
@@ -307,16 +307,16 @@ void EventTaskToRdy(P_ECB pecb)
|
||||
P_QCB pqcb;
|
||||
#endif
|
||||
ptcb = pecb->eventTCBList;
|
||||
if(ptcb == NULL)
|
||||
if(ptcb == Co_NULL)
|
||||
return;
|
||||
|
||||
pecb->eventTCBList = ptcb->waitNext;/* Get first task in event waiting list*/
|
||||
if(pecb->eventTCBList != NULL) /* Is no item in event waiting list? */
|
||||
if(pecb->eventTCBList != Co_NULL) /* Is no item in event waiting list? */
|
||||
{
|
||||
pecb->eventTCBList->waitPrev = NULL; /* No,clear link for first item */
|
||||
pecb->eventTCBList->waitPrev = Co_NULL; /* No,clear link for first item */
|
||||
}
|
||||
|
||||
ptcb->waitNext = NULL; /* Clear event waiting link for task*/
|
||||
ptcb->waitNext = Co_NULL; /* Clear event waiting link for task*/
|
||||
ptcb->eventID = INVALID_ID; /* Sign that not to use. */
|
||||
|
||||
if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */
|
||||
@@ -326,7 +326,7 @@ void EventTaskToRdy(P_ECB pecb)
|
||||
if(pecb->eventType == EVENT_TYPE_MBOX)/* Is it a mailbox event? */
|
||||
{
|
||||
ptcb->pmail = pecb->eventPtr; /* Yes,send mail to task */
|
||||
pecb->eventPtr = NULL; /* Clear event sign */
|
||||
pecb->eventPtr = Co_NULL; /* Clear event sign */
|
||||
pecb->eventCounter--;
|
||||
}
|
||||
#if CFG_QUEUE_EN >0
|
||||
@@ -380,28 +380,28 @@ void RemoveEventWaittingList(P_OSTCB ptcb)
|
||||
pecb = &EventTbl[ptcb->eventID]; /* Get event control block */
|
||||
|
||||
/* Is there only one item in event waiting list? */
|
||||
if((ptcb->waitNext == NULL) && (ptcb->waitPrev == NULL))
|
||||
if((ptcb->waitNext == Co_NULL) && (ptcb->waitPrev == Co_NULL))
|
||||
{
|
||||
pecb->eventTCBList = NULL; /* Yes,set event waiting list as NULL */
|
||||
pecb->eventTCBList = Co_NULL; /* Yes,set event waiting list as Co_NULL */
|
||||
}
|
||||
else if(ptcb->waitPrev == NULL)/* Is the first item in event waiting list?*/
|
||||
else if(ptcb->waitPrev == Co_NULL)/* Is the first item in event waiting list?*/
|
||||
{
|
||||
/* Yes,remove task from list,and reset event waiting list */
|
||||
ptcb->waitNext->waitPrev = NULL;
|
||||
ptcb->waitNext->waitPrev = Co_NULL;
|
||||
pecb->eventTCBList = ptcb->waitNext;
|
||||
ptcb->waitNext = NULL;
|
||||
ptcb->waitNext = Co_NULL;
|
||||
}
|
||||
else if(ptcb->waitNext == NULL)/* Is the last item in event waiting list? */
|
||||
else if(ptcb->waitNext == Co_NULL)/* Is the last item in event waiting list? */
|
||||
{
|
||||
ptcb->waitPrev->waitNext = NULL; /* Yes,remove task form list */
|
||||
ptcb->waitPrev = NULL;
|
||||
ptcb->waitPrev->waitNext = Co_NULL; /* Yes,remove task form list */
|
||||
ptcb->waitPrev = Co_NULL;
|
||||
}
|
||||
else /* No, remove task from list */
|
||||
{
|
||||
ptcb->waitPrev->waitNext = ptcb->waitNext;
|
||||
ptcb->waitNext->waitPrev = ptcb->waitPrev;
|
||||
ptcb->waitPrev = NULL;
|
||||
ptcb->waitNext = NULL;
|
||||
ptcb->waitPrev = Co_NULL;
|
||||
ptcb->waitNext = Co_NULL;
|
||||
}
|
||||
ptcb->eventID = INVALID_ID; /* Sign that not to use. */
|
||||
}
|
||||
|
||||
+26
-26
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file flag.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Flag management implementation code of coocox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -31,7 +31,7 @@ static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode);
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Create a flag
|
||||
* @param[in] bAutoReset Reset mode,TRUE(Auto Reset) FLASE(Manual Reset).
|
||||
* @param[in] bAutoReset Reset mode,Co_TRUE(Auto Reset) FLASE(Manual Reset).
|
||||
* @param[in] bInitialState Initial state.
|
||||
* @param[out] None
|
||||
* @retval E_CREATE_FAIL Create flag fail.
|
||||
@@ -99,7 +99,7 @@ StatusType CoDelFlag(OS_FlagID id,U8 opt)
|
||||
OsSchedLock();
|
||||
pnode = pfcb->headNode;
|
||||
|
||||
while(pnode != NULL) /* Ready all tasks waiting for flags */
|
||||
while(pnode != Co_NULL) /* Ready all tasks waiting for flags */
|
||||
{
|
||||
if((pnode->waitFlags&(1<<id)) != 0) /* If no task is waiting on flags */
|
||||
{
|
||||
@@ -305,11 +305,11 @@ StatusType CoWaitForSingleFlag(OS_FlagID id,U32 timeout)
|
||||
/* Block task until the required flag is set */
|
||||
FlagBlock (&flagNode,(1<<id),OPT_WAIT_ONE);
|
||||
curTCB->state = TASK_WAITING;
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
OsSchedUnlock();
|
||||
|
||||
/* The required flag is set and the task is in running state */
|
||||
curTCB->pnode = NULL;
|
||||
curTCB->pnode = Co_NULL;
|
||||
OsSchedLock();
|
||||
|
||||
/* Clear the required flag or not */
|
||||
@@ -323,13 +323,13 @@ StatusType CoWaitForSingleFlag(OS_FlagID id,U32 timeout)
|
||||
InsertDelayList(curTCB,timeout);
|
||||
|
||||
OsSchedUnlock();
|
||||
if(curTCB->pnode == NULL) /* If time-out occurred */
|
||||
if(curTCB->pnode == Co_NULL) /* If time-out occurred */
|
||||
{
|
||||
return E_TIMEOUT;
|
||||
}
|
||||
else /* If flag is set */
|
||||
{
|
||||
curTCB->pnode = NULL;
|
||||
curTCB->pnode = Co_NULL;
|
||||
OsSchedLock();
|
||||
|
||||
/* Clear the required flag or not */
|
||||
@@ -410,10 +410,10 @@ U32 CoWaitForMultipleFlags(U32 flags,U8 waitType,U32 timeout,StatusType *perr)
|
||||
/* Block task until the required flag are set */
|
||||
FlagBlock(&flagNode,flags,waitType);
|
||||
curTCB->state = TASK_WAITING;
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
OsSchedUnlock();
|
||||
|
||||
curTCB->pnode = NULL;
|
||||
curTCB->pnode = Co_NULL;
|
||||
OsSchedLock();
|
||||
springFlag = flags & pfcb->flagRdy;
|
||||
pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt);/* Clear the flags */
|
||||
@@ -428,14 +428,14 @@ U32 CoWaitForMultipleFlags(U32 flags,U8 waitType,U32 timeout,StatusType *perr)
|
||||
InsertDelayList(curTCB,timeout);
|
||||
|
||||
OsSchedUnlock();
|
||||
if(curTCB->pnode == NULL) /* If time-out occurred */
|
||||
if(curTCB->pnode == Co_NULL) /* If time-out occurred */
|
||||
{
|
||||
*perr = E_TIMEOUT;
|
||||
return 0;
|
||||
}
|
||||
else /* If the required flags are set */
|
||||
{
|
||||
curTCB->pnode = NULL;
|
||||
curTCB->pnode = Co_NULL;
|
||||
OsSchedLock();
|
||||
springFlag = flags & FlagCrl.flagRdy;
|
||||
|
||||
@@ -522,7 +522,7 @@ StatusType CoSetFlag(OS_FlagID id)
|
||||
|
||||
OsSchedLock();
|
||||
pnode = pfcb->headNode;
|
||||
while(pnode != NULL)
|
||||
while(pnode != Co_NULL)
|
||||
{
|
||||
if(pnode->waitType == OPT_WAIT_ALL) /* Extract all the bits we want */
|
||||
{
|
||||
@@ -577,7 +577,7 @@ StatusType isr_SetFlag(OS_FlagID id)
|
||||
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
|
||||
{
|
||||
/* Insert the request into service request queue */
|
||||
if(InsertInSRQ(FLAG_REQ,id,NULL) == FALSE)
|
||||
if(InsertInSRQ(FLAG_REQ,id,Co_NULL) == Co_FALSE)
|
||||
{
|
||||
return E_SEV_REQ_FULL; /* The service requst queue is full */
|
||||
}
|
||||
@@ -617,17 +617,17 @@ static void FlagBlock(P_FLAG_NODE pnode,U32 flags,U8 waitType)
|
||||
pnode->waitFlags = flags; /* Save the flags that we need to wait for*/
|
||||
pnode->waitType = waitType; /* Save the type of wait */
|
||||
|
||||
if(pfcb->tailNode == NULL) /* If this is the first NODE to insert? */
|
||||
if(pfcb->tailNode == Co_NULL) /* If this is the first NODE to insert? */
|
||||
{
|
||||
pnode->nextNode = NULL;
|
||||
pnode->prevNode = NULL;
|
||||
pnode->nextNode = Co_NULL;
|
||||
pnode->prevNode = Co_NULL;
|
||||
pfcb->headNode = pnode; /* Insert the NODE to the head */
|
||||
}
|
||||
else /* If it is not the first NODE to insert? */
|
||||
{
|
||||
pfcb->tailNode->nextNode = pnode; /* Insert the NODE to the tail */
|
||||
pnode->prevNode = pfcb->tailNode;
|
||||
pnode->nextNode = NULL;
|
||||
pnode->nextNode = Co_NULL;
|
||||
}
|
||||
pfcb->tailNode = pnode;
|
||||
}
|
||||
@@ -686,27 +686,27 @@ static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode)
|
||||
void RemoveLinkNode(P_FLAG_NODE pnode)
|
||||
{
|
||||
/* If only one NODE in the list*/
|
||||
if((pnode->nextNode == NULL) && (pnode->prevNode == NULL))
|
||||
if((pnode->nextNode == Co_NULL) && (pnode->prevNode == Co_NULL))
|
||||
{
|
||||
FlagCrl.headNode = NULL;
|
||||
FlagCrl.tailNode = NULL;
|
||||
FlagCrl.headNode = Co_NULL;
|
||||
FlagCrl.tailNode = Co_NULL;
|
||||
}
|
||||
else if(pnode->nextNode == NULL) /* If the NODE is tail */
|
||||
else if(pnode->nextNode == Co_NULL) /* If the NODE is tail */
|
||||
{
|
||||
FlagCrl.tailNode = pnode->prevNode;
|
||||
pnode->prevNode->nextNode = NULL;
|
||||
pnode->prevNode->nextNode = Co_NULL;
|
||||
}
|
||||
else if(pnode->prevNode == NULL) /* If the NODE is head */
|
||||
else if(pnode->prevNode == Co_NULL) /* If the NODE is head */
|
||||
{
|
||||
FlagCrl.headNode = pnode->nextNode;
|
||||
pnode->nextNode->prevNode = NULL;
|
||||
pnode->nextNode->prevNode = Co_NULL;
|
||||
}
|
||||
else /* The NODE is in the middle */
|
||||
{
|
||||
pnode->nextNode->prevNode = pnode->prevNode;
|
||||
pnode->prevNode->nextNode = pnode->nextNode;
|
||||
}
|
||||
pnode->waitTask->pnode = NULL;
|
||||
pnode->waitTask->pnode = Co_NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file hook.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief hook management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file kernelHeap.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief kernel heap management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -21,7 +21,7 @@
|
||||
#if CFG_KHEAP_EN >0
|
||||
/*---------------------------- Variable Define -------------------------------*/
|
||||
U32 KernelHeap[KHEAP_SIZE] = {0}; /*!< Kernel heap */
|
||||
P_FMB FMBlist = NULL; /*!< Free memory block list */
|
||||
P_FMB FMBlist = Co_NULL; /*!< Free memory block list */
|
||||
KHeap Kheap = {0}; /*!< Kernel heap control */
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ void CoCreateKheap(void)
|
||||
Kheap.startAddr = (U32)(KernelHeap); /* Initialize kernel heap control */
|
||||
Kheap.endAddr = (U32)(KernelHeap) + KHEAP_SIZE*4;
|
||||
FMBlist = (P_FMB)KernelHeap; /* Initialize free memory block list*/
|
||||
FMBlist->nextFMB = NULL;
|
||||
FMBlist->nextUMB = NULL;
|
||||
FMBlist->preUMB = NULL;
|
||||
FMBlist->nextFMB = Co_NULL;
|
||||
FMBlist->nextUMB = Co_NULL;
|
||||
FMBlist->preUMB = Co_NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void CoCreateKheap(void)
|
||||
* @brief Allocation size bytes of memory block from kernel heap.
|
||||
* @param[in] size Length of menory block.
|
||||
* @param[out] None
|
||||
* @retval NULL Allocate fail.
|
||||
* @retval Co_NULL Allocate fail.
|
||||
* @retval others Pointer to memory block.
|
||||
*
|
||||
* @par Description
|
||||
@@ -72,7 +72,7 @@ void* CoKmalloc(U32 size)
|
||||
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
|
||||
if( size == 0 )
|
||||
{
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -81,10 +81,10 @@ void* CoKmalloc(U32 size)
|
||||
kheapAddr = Kheap.endAddr; /* Get the end address of kernel heap */
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
freeMB = FMBlist; /* Get first item of free memory list */
|
||||
preFMB = NULL;
|
||||
while(freeMB != NULL ) /* Is out of free memory list? */
|
||||
preFMB = Co_NULL;
|
||||
while(freeMB != Co_NULL ) /* Is out of free memory list? */
|
||||
{ /* No */
|
||||
if(freeMB->nextUMB == NULL) /* Is last item of free memory list? */
|
||||
if(freeMB->nextUMB == Co_NULL) /* Is last item of free memory list? */
|
||||
{ /* Yes,get size for this free item */
|
||||
freeSize = kheapAddr - (U32)(freeMB);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ void* CoKmalloc(U32 size)
|
||||
{
|
||||
/* Yes,malloc together(12 is the size of the header information
|
||||
of free memory block ). */
|
||||
if(preFMB != NULL)/* Is first item of free memory block list? */
|
||||
if(preFMB != Co_NULL)/* Is first item of free memory block list? */
|
||||
{ /* No,set the link for list */
|
||||
preFMB->nextFMB = freeMB->nextFMB;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void* CoKmalloc(U32 size)
|
||||
FMBlist = freeMB->nextFMB;
|
||||
}
|
||||
|
||||
if(freeMB->nextUMB != NULL) /* Is last item? */
|
||||
if(freeMB->nextUMB != Co_NULL) /* Is last item? */
|
||||
{ /* No,set the link for list */
|
||||
tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1);
|
||||
tmpUMB->preMB = (void*)((U32)usedMB|0x1);
|
||||
@@ -127,7 +127,7 @@ void* CoKmalloc(U32 size)
|
||||
/* Get new free memory block address */
|
||||
newFMB = (P_FMB)((U32)(freeMB) + size);
|
||||
|
||||
if(preFMB != NULL)/* Is first item of free memory block list? */
|
||||
if(preFMB != Co_NULL)/* Is first item of free memory block list? */
|
||||
{
|
||||
preFMB->nextFMB = newFMB; /* No,set the link for list */
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void* CoKmalloc(U32 size)
|
||||
newFMB->nextUMB = freeMB->nextUMB;
|
||||
newFMB->nextFMB = freeMB->nextFMB;
|
||||
|
||||
if(freeMB->nextUMB != NULL) /* Is last item? */
|
||||
if(freeMB->nextUMB != Co_NULL) /* Is last item? */
|
||||
{ /* No,set the link for list */
|
||||
tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1);
|
||||
tmpUMB->preMB = newFMB;
|
||||
@@ -151,7 +151,7 @@ void* CoKmalloc(U32 size)
|
||||
usedMB->preMB = freeMB->preUMB;
|
||||
}
|
||||
|
||||
if(freeMB->preUMB != NULL) /* Is first item? */
|
||||
if(freeMB->preUMB != Co_NULL) /* Is first item? */
|
||||
{ /* No,set the link for list */
|
||||
tmpUMB = (P_UMB)((U32)(freeMB->preUMB)-1);
|
||||
tmpUMB->nextMB = (void*)((U32)usedMB|0x1);
|
||||
@@ -164,7 +164,7 @@ void* CoKmalloc(U32 size)
|
||||
freeMB = freeMB->nextFMB; /* Get the next item as current item*/
|
||||
}
|
||||
OsSchedUnlock(); /* Unlock schedule */
|
||||
return NULL; /* Error return */
|
||||
return Co_NULL; /* Error return */
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ void CoKfree(void* memBuf)
|
||||
P_UMB usedMB,nextUMB,preUMB;
|
||||
|
||||
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
|
||||
if(memBuf == NULL)
|
||||
if(memBuf == Co_NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ void CoKfree(void* memBuf)
|
||||
preUMB = (P_UMB)((U32)(FMBlist->preUMB)-1);
|
||||
while(preUMB != usedMB)
|
||||
{
|
||||
if(preUMB == NULL)
|
||||
if(preUMB == Co_NULL)
|
||||
{
|
||||
OsSchedUnlock();
|
||||
return;
|
||||
@@ -223,25 +223,25 @@ void CoKfree(void* memBuf)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FMBlist == NULL)
|
||||
if(FMBlist == Co_NULL)
|
||||
{
|
||||
nextUMB = (P_UMB)(Kheap.startAddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FMBlist->nextUMB != NULL)
|
||||
if(FMBlist->nextUMB != Co_NULL)
|
||||
{
|
||||
nextUMB = (P_UMB)((U32)(FMBlist->nextUMB)-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextUMB = NULL;
|
||||
nextUMB = Co_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
while(nextUMB != usedMB)
|
||||
{
|
||||
if(nextUMB == NULL)
|
||||
if(nextUMB == Co_NULL)
|
||||
{
|
||||
OsSchedUnlock();
|
||||
return;
|
||||
@@ -263,15 +263,15 @@ void CoKfree(void* memBuf)
|
||||
/* Is between two free memory block? */
|
||||
if( (((U32)(usedMB->nextMB)&0x1) == 0) && (((U32)(usedMB->preMB)&0x1)==0) )
|
||||
{ /* Yes,is the only one item in kernel heap? */
|
||||
if((usedMB->nextMB == NULL) && (usedMB->preMB == NULL))
|
||||
if((usedMB->nextMB == Co_NULL) && (usedMB->preMB == Co_NULL))
|
||||
{
|
||||
curFMB = (P_FMB)usedMB; /* Yes,release this item */
|
||||
curFMB->nextFMB = NULL;
|
||||
curFMB->nextUMB = NULL;
|
||||
curFMB->preUMB = NULL;
|
||||
curFMB->nextFMB = Co_NULL;
|
||||
curFMB->nextUMB = Co_NULL;
|
||||
curFMB->preUMB = Co_NULL;
|
||||
FMBlist = curFMB;
|
||||
}
|
||||
else if(usedMB->preMB == NULL) /* Is the first item in kernel heap */
|
||||
else if(usedMB->preMB == Co_NULL) /* Is the first item in kernel heap */
|
||||
{
|
||||
/* Yes,release this item,and set link for list */
|
||||
curFMB = (P_FMB)usedMB;
|
||||
@@ -279,14 +279,14 @@ void CoKfree(void* memBuf)
|
||||
|
||||
curFMB->nextFMB = nextFMB->nextFMB;
|
||||
curFMB->nextUMB = nextFMB->nextUMB;
|
||||
curFMB->preUMB = NULL;
|
||||
curFMB->preUMB = Co_NULL;
|
||||
FMBlist = curFMB;
|
||||
}
|
||||
else if(usedMB->nextMB == NULL) /* Is the last item in kernel heap */
|
||||
else if(usedMB->nextMB == Co_NULL) /* Is the last item in kernel heap */
|
||||
{ /* Yes,release this item,and set link for list */
|
||||
curFMB = (P_FMB)(usedMB->preMB);
|
||||
curFMB->nextFMB = NULL;
|
||||
curFMB->nextUMB = NULL;
|
||||
curFMB->nextFMB = Co_NULL;
|
||||
curFMB->nextUMB = Co_NULL;
|
||||
}
|
||||
else /* All no,show this item between two normal FMB */
|
||||
{
|
||||
@@ -300,13 +300,13 @@ void CoKfree(void* memBuf)
|
||||
}
|
||||
else if(((U32)(usedMB->preMB)&0x1) == 0) /* Is between FMB and UMB? */
|
||||
{
|
||||
if(usedMB->preMB == NULL) /* Yes,is the first item in kernel heap? */
|
||||
if(usedMB->preMB == Co_NULL) /* Yes,is the first item in kernel heap? */
|
||||
{
|
||||
/* Yes,release this item,and set link for list */
|
||||
curFMB = (P_FMB)usedMB;
|
||||
nextUMB = (P_UMB)usedMB->nextMB;
|
||||
curFMB->nextUMB = nextUMB;
|
||||
curFMB->preUMB = NULL;
|
||||
curFMB->preUMB = Co_NULL;
|
||||
curFMB->nextFMB = FMBlist;
|
||||
FMBlist = curFMB;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ void CoKfree(void* memBuf)
|
||||
preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */
|
||||
curFMB = (P_FMB)(usedMB); /* new FMB */
|
||||
preFMB = GetPreFMB(usedMB); /* Get previous FMB */
|
||||
if(preFMB == NULL) /* Is previous FMB==NULL? */
|
||||
if(preFMB == Co_NULL) /* Is previous FMB==Co_NULL? */
|
||||
{
|
||||
nextFMB = FMBlist; /* Yes,get next FMB */
|
||||
FMBlist = curFMB; /* Reset new FMB as the first item of FMB list*/
|
||||
@@ -334,11 +334,11 @@ void CoKfree(void* memBuf)
|
||||
preFMB->nextFMB = curFMB; /* Set link for FMB list */
|
||||
}
|
||||
|
||||
if(nextFMB == NULL) /* Is new FMB as last item of FMB list? */
|
||||
if(nextFMB == Co_NULL) /* Is new FMB as last item of FMB list? */
|
||||
{
|
||||
curFMB->preUMB = preUMB; /* Yes,set link for list */
|
||||
curFMB->nextUMB = NULL;
|
||||
curFMB->nextFMB = NULL;
|
||||
curFMB->nextUMB = Co_NULL;
|
||||
curFMB->nextFMB = Co_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -354,7 +354,7 @@ void CoKfree(void* memBuf)
|
||||
preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */
|
||||
nextUMB = (P_UMB)(usedMB->nextMB); /* Get next UMB */
|
||||
|
||||
if(preFMB == NULL ) /* Is previous FMB==NULL? */
|
||||
if(preFMB == Co_NULL ) /* Is previous FMB==Co_NULL? */
|
||||
{
|
||||
nextFMB = FMBlist; /* Yes,get next FMB */
|
||||
FMBlist = curFMB; /* Reset new FMB as the first item of FMB list */
|
||||
@@ -370,12 +370,12 @@ void CoKfree(void* memBuf)
|
||||
curFMB->nextFMB = nextFMB;
|
||||
}
|
||||
|
||||
if(curFMB->preUMB != NULL)/* Is current FMB as first item in kernel heap? */
|
||||
if(curFMB->preUMB != Co_NULL)/* Is current FMB as first item in kernel heap? */
|
||||
{ /* No,set link for list */
|
||||
preUMB = (P_UMB)((U32)(curFMB->preUMB)-1);
|
||||
preUMB->nextMB = (void*)curFMB;
|
||||
}
|
||||
if(curFMB->nextUMB != NULL)/* Is current FMB as last item in kernel heap? */
|
||||
if(curFMB->nextUMB != Co_NULL)/* Is current FMB as last item in kernel heap? */
|
||||
{ /* No,set link for list */
|
||||
nextUMB = (P_UMB)((U32)(curFMB->nextUMB)-1);
|
||||
nextUMB->preMB = (void*)curFMB;
|
||||
|
||||
+28
-25
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file mbox.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Mailbox management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -38,8 +38,8 @@ OS_EventID CoCreateMbox(U8 sortType)
|
||||
P_ECB pecb;
|
||||
|
||||
/* Create a mailbox type event control block */
|
||||
pecb = CreatEvent(EVENT_TYPE_MBOX,sortType,NULL);
|
||||
if(pecb == NULL) /* If failed to create event block */
|
||||
pecb = CreatEvent(EVENT_TYPE_MBOX,sortType,Co_NULL);
|
||||
if(pecb == Co_NULL) /* If failed to create event block */
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ StatusType CoDelMbox(OS_EventID id,U8 opt)
|
||||
* @brief Accept a mailbox
|
||||
* @param[in] id Event ID.
|
||||
* @param[out] perr A pointer to error code.
|
||||
* @retval NULL
|
||||
* @retval Co_NULL
|
||||
* @retval A pointer to mailbox accepted.
|
||||
*
|
||||
* @par Description
|
||||
@@ -108,7 +108,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
|
||||
if(id >= CFG_MAX_EVENT)
|
||||
{
|
||||
*perr = E_INVALID_ID; /* Invalid 'id' */
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
pecb = &EventTbl[id];
|
||||
@@ -117,7 +117,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
|
||||
if(pecb->eventType != EVENT_TYPE_MBOX)/* Invalid event control block type */
|
||||
{
|
||||
*perr = E_INVALID_ID;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
OsSchedLock();
|
||||
@@ -125,7 +125,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
|
||||
{
|
||||
*perr = E_OK;
|
||||
pmail = pecb->eventPtr; /* Get the message */
|
||||
pecb->eventPtr = NULL; /* Clear the mailbox */
|
||||
pecb->eventPtr = Co_NULL; /* Clear the mailbox */
|
||||
pecb->eventCounter = 0;
|
||||
OsSchedUnlock();
|
||||
return pmail; /* Return the message received */
|
||||
@@ -133,8 +133,8 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
|
||||
else /* If the mailbox is empty */
|
||||
{
|
||||
OsSchedUnlock();
|
||||
*perr = E_MBOX_EMPTY; /* Mailbox is empty,return NULL */
|
||||
return NULL;
|
||||
*perr = E_MBOX_EMPTY; /* Mailbox is empty,return Co_NULL */
|
||||
return Co_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
|
||||
* @param[in] id Event ID.
|
||||
* @param[in] timeout The longest time for writting mail.
|
||||
* @param[out] perr A pointer to error code.
|
||||
* @retval NULL
|
||||
* @retval Co_NULL
|
||||
* @retval A pointer to mailbox accept.
|
||||
*
|
||||
* @par Description
|
||||
@@ -163,14 +163,14 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
if(OSIntNesting > 0) /* If the caller is ISR */
|
||||
{
|
||||
*perr = E_CALL;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
|
||||
#if CFG_PAR_CHECKOUT_EN >0
|
||||
if(id >= CFG_MAX_EVENT)
|
||||
{
|
||||
*perr = E_INVALID_ID; /* Invalid 'id',retrun error */
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -179,25 +179,28 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
if(pecb->eventType != EVENT_TYPE_MBOX)
|
||||
{
|
||||
*perr = E_INVALID_ID; /* Invalid event type,not EVENT_TYPE_MBOX */
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(OSSchedLock != 0) /* Judge schedule is locked or not? */
|
||||
{
|
||||
*perr = E_OS_IN_LOCK; /* Schedule is locked */
|
||||
return NULL; /* return NULL */
|
||||
}
|
||||
return Co_NULL; /* return Co_NULL */
|
||||
}
|
||||
OsSchedLock();
|
||||
if( pecb->eventCounter == 1) /* If there is already a message */
|
||||
{
|
||||
*perr = E_OK;
|
||||
pmail = pecb->eventPtr; /* Get the message */
|
||||
pecb->eventPtr = NULL; /* Clear the mailbox */
|
||||
pecb->eventCounter = 0;
|
||||
pecb->eventPtr = Co_NULL; /* Clear the mailbox */
|
||||
pecb->eventCounter = 0;
|
||||
OsSchedUnlock();
|
||||
return pmail; /* Return the message received */
|
||||
}
|
||||
else /* If message is not available, task will pend */
|
||||
{
|
||||
OsSchedUnlock();
|
||||
curTCB = TCBRunning;
|
||||
if(timeout == 0) /* If time-out is not configured */
|
||||
{
|
||||
@@ -206,8 +209,8 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
|
||||
/* Have recived a message or the mailbox have been deleted */
|
||||
pmail = curTCB->pmail;
|
||||
curTCB->pmail = NULL;
|
||||
return pmail; /* Return received message or NULL */
|
||||
curTCB->pmail = Co_NULL;
|
||||
return pmail; /* Return received message or Co_NULL */
|
||||
}
|
||||
else /* If time-out is configured */
|
||||
{
|
||||
@@ -217,17 +220,17 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
EventTaskToWait(pecb,curTCB);
|
||||
InsertDelayList(curTCB,timeout);
|
||||
OsSchedUnlock();
|
||||
if( curTCB->pmail == NULL) /* Time-out occurred */
|
||||
if( curTCB->pmail == Co_NULL) /* Time-out occurred */
|
||||
{
|
||||
*perr = E_TIMEOUT;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
else /* Have recived a message or the mailbox have been deleted*/
|
||||
{
|
||||
*perr = E_OK;
|
||||
pmail = curTCB->pmail;
|
||||
curTCB->pmail = NULL;
|
||||
return pmail; /* Return received message or NULL */
|
||||
curTCB->pmail = Co_NULL;
|
||||
return pmail; /* Return received message or Co_NULL */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,7 +304,7 @@ StatusType isr_PostMail(OS_EventID id,void* pmail)
|
||||
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
|
||||
{
|
||||
/* Insert the request into service request queue */
|
||||
if(InsertInSRQ(MBOX_REQ,id,pmail) == FALSE)
|
||||
if(InsertInSRQ(MBOX_REQ,id,pmail) == Co_FALSE)
|
||||
{
|
||||
return E_SEV_REQ_FULL; /* If service request queue is full */
|
||||
}
|
||||
|
||||
+13
-13
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file mm.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief memory management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -45,7 +45,7 @@ OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum)
|
||||
memory = memBuf;
|
||||
|
||||
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
|
||||
if(memBuf == NULL)
|
||||
if(memBuf == Co_NULL)
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum)
|
||||
memBlk->nextBlock = (P_MemBlk)memory;
|
||||
memBlk = memBlk->nextBlock;
|
||||
}
|
||||
memBlk->nextBlock = NULL;
|
||||
memBlk->nextBlock = Co_NULL;
|
||||
return i; /* Return memory block ID */
|
||||
}
|
||||
}
|
||||
@@ -120,8 +120,8 @@ StatusType CoDelMemoryPartition(OS_MMID mmID)
|
||||
MemoryIDVessel &= ~(1<<mmID);
|
||||
OsSchedUnlock(); /* Unlock schedule */
|
||||
|
||||
memCtl->memAddr = NULL;
|
||||
memCtl->freeBlock = NULL;
|
||||
memCtl->memAddr = Co_NULL;
|
||||
memCtl->freeBlock = Co_NULL;
|
||||
memCtl->blockSize = 0;
|
||||
memCtl->blockNum = 0;
|
||||
return E_OK; /* Return OK */
|
||||
@@ -163,7 +163,7 @@ U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr)
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
memBlk = (P_MemBlk)(memCtl->freeBlock);/* Get the free item in memory list*/
|
||||
fbNum = 0;
|
||||
while(memBlk != NULL) /* Get counter of free item */
|
||||
while(memBlk != Co_NULL) /* Get counter of free item */
|
||||
{
|
||||
fbNum++;
|
||||
memBlk = memBlk->nextBlock; /* Get next free iterm */
|
||||
@@ -179,7 +179,7 @@ U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr)
|
||||
* @brief Get a memory buffer from memory partition
|
||||
* @param[in] mmID Specify memory partition that want to assign buffer.
|
||||
* @param[out] None
|
||||
* @retval NULL Assign buffer fail.
|
||||
* @retval Co_NULL Assign buffer fail.
|
||||
* @retval others Assign buffer successful,and return the buffer pointer.
|
||||
*
|
||||
* @par Description
|
||||
@@ -193,19 +193,19 @@ void* CoGetMemoryBuffer(OS_MMID mmID)
|
||||
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
|
||||
if(mmID >= CFG_MAX_MM)
|
||||
{
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
if( ((1<<mmID)&MemoryIDVessel) == 0)
|
||||
{
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
memCtl = &MemoryTbl[mmID];
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
if(memCtl->freeBlock == NULL ) /* Is there no free item in memory list */
|
||||
if(memCtl->freeBlock == Co_NULL ) /* Is there no free item in memory list */
|
||||
{
|
||||
OsSchedUnlock(); /* Unlock schedule */
|
||||
return NULL; /* Yes,error return */
|
||||
return Co_NULL; /* Yes,error return */
|
||||
}
|
||||
memBlk = (P_MemBlk)memCtl->freeBlock; /* Get free memory block */
|
||||
memCtl->freeBlock = (U8*)memBlk->nextBlock; /* Reset the first free item */
|
||||
@@ -242,7 +242,7 @@ StatusType CoFreeMemoryBuffer(OS_MMID mmID,void* buf)
|
||||
{
|
||||
return E_INVALID_ID;
|
||||
}
|
||||
if(buf == NULL)
|
||||
if(buf == Co_NULL)
|
||||
{
|
||||
return E_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
+24
-24
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file mutex.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Mutex management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -56,7 +56,7 @@ OS_MutexID CoCreateMutex(void)
|
||||
pMutex->originalPrio = 0xff;
|
||||
pMutex->mutexFlag = MUTEX_FREE; /* Mutex is free,not was occupied */
|
||||
pMutex->taskID = INVALID_ID;
|
||||
pMutex->waittingList = NULL;
|
||||
pMutex->waittingList = Co_NULL;
|
||||
return id; /* Return mutex ID */
|
||||
}
|
||||
|
||||
@@ -156,24 +156,24 @@ StatusType CoEnterMutexSection(OS_MutexID mutexID)
|
||||
}
|
||||
|
||||
pCurTcb->state = TASK_WAITING; /* Block current task */
|
||||
TaskSchedReq = TRUE;
|
||||
pCurTcb->TCBnext = NULL;
|
||||
pCurTcb->TCBprev = NULL;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
pCurTcb->TCBnext = Co_NULL;
|
||||
pCurTcb->TCBprev = Co_NULL;
|
||||
|
||||
ptcb = pMutex->waittingList;
|
||||
if(ptcb == NULL) /* If the event waiting list is empty */
|
||||
if(ptcb == Co_NULL) /* If the event waiting list is empty */
|
||||
{
|
||||
pMutex->waittingList = pCurTcb; /* Insert the task to head */
|
||||
}
|
||||
else /* If the event waiting list is not empty */
|
||||
{
|
||||
while(ptcb->TCBnext != NULL) /* Insert the task to tail */
|
||||
while(ptcb->TCBnext != Co_NULL) /* Insert the task to tail */
|
||||
{
|
||||
ptcb = ptcb->TCBnext;
|
||||
}
|
||||
ptcb->TCBnext = pCurTcb;
|
||||
pCurTcb->TCBprev = ptcb;
|
||||
pCurTcb->TCBnext = NULL;
|
||||
pCurTcb->TCBnext = Co_NULL;
|
||||
}
|
||||
}
|
||||
OsSchedUnlock();
|
||||
@@ -217,7 +217,7 @@ StatusType CoLeaveMutexSection(OS_MutexID mutexID)
|
||||
pMutex = &MutexTbl[mutexID]; /* Obtain point of mutex control block*/
|
||||
ptcb = &TCBTbl[pMutex->taskID];
|
||||
ptcb->mutexID = INVALID_ID;
|
||||
if(pMutex->waittingList == NULL) /* If the mutex waiting list is empty */
|
||||
if(pMutex->waittingList == Co_NULL) /* If the mutex waiting list is empty */
|
||||
{
|
||||
pMutex->mutexFlag = MUTEX_FREE; /* The mutex resource is available */
|
||||
pMutex->taskID = INVALID_ID;
|
||||
@@ -232,7 +232,7 @@ StatusType CoLeaveMutexSection(OS_MutexID mutexID)
|
||||
{
|
||||
ptcb = pMutex->waittingList;/* Point to mutex first waiting task */
|
||||
prio = ptcb->prio;
|
||||
while(ptcb != NULL) /* Find the highest priority task */
|
||||
while(ptcb != Co_NULL) /* Find the highest priority task */
|
||||
{
|
||||
if(ptcb->prio < prio)
|
||||
{
|
||||
@@ -268,8 +268,8 @@ StatusType CoLeaveMutexSection(OS_MutexID mutexID)
|
||||
ptcb->prio = prio; /* Raise the task's priority */
|
||||
|
||||
/* Insert the task which acquire the mutex into ready list. */
|
||||
ptcb->TCBnext = NULL;
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
|
||||
InsertToTCBRdyList(ptcb); /* Insert the task into the READY list */
|
||||
OsSchedUnlock();
|
||||
@@ -297,29 +297,29 @@ void RemoveMutexList(P_OSTCB ptcb)
|
||||
pMutex = &MutexTbl[ptcb->mutexID];
|
||||
|
||||
/* If only one task waiting on mutex */
|
||||
if((ptcb->TCBnext ==NULL) && (ptcb->TCBprev == NULL))
|
||||
if((ptcb->TCBnext ==Co_NULL) && (ptcb->TCBprev == Co_NULL))
|
||||
{
|
||||
pMutex->waittingList = NULL; /* Waiting list is empty */
|
||||
pMutex->waittingList = Co_NULL; /* Waiting list is empty */
|
||||
}
|
||||
else if(ptcb->TCBnext == NULL) /* If the task is the last of waiting list*/
|
||||
else if(ptcb->TCBnext == Co_NULL) /* If the task is the last of waiting list*/
|
||||
{
|
||||
/* Remove task from mutex waiting list */
|
||||
ptcb->TCBprev->TCBnext = NULL;
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBprev->TCBnext = Co_NULL;
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
}
|
||||
else if(ptcb->TCBprev == NULL)/* If the task is the first of waiting list*/
|
||||
else if(ptcb->TCBprev == Co_NULL)/* If the task is the first of waiting list*/
|
||||
{
|
||||
/* Remove task from waiting list */
|
||||
ptcb->TCBnext->TCBprev = NULL;
|
||||
ptcb->TCBnext = NULL;
|
||||
ptcb->TCBnext->TCBprev = Co_NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
}
|
||||
else /* If the task is in the middle of waiting list */
|
||||
{
|
||||
/* Remove task from wait list */
|
||||
ptcb->TCBnext->TCBprev = ptcb->TCBprev;
|
||||
ptcb->TCBprev->TCBnext = ptcb->TCBnext;
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBnext = NULL;
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
}
|
||||
|
||||
ptcb->mutexID = INVALID_ID;
|
||||
@@ -330,7 +330,7 @@ void RemoveMutexList(P_OSTCB ptcb)
|
||||
ptcb = pMutex->waittingList;
|
||||
prio = pMutex->originalPrio;
|
||||
pMutex->hipriTaskID = pMutex->taskID;
|
||||
while(ptcb != NULL) /* Find task ID of highest priority task*/
|
||||
while(ptcb != Co_NULL) /* Find task ID of highest priority task*/
|
||||
{
|
||||
if(ptcb->prio < prio)
|
||||
{
|
||||
|
||||
+24
-22
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file queue.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Queue management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -45,7 +45,7 @@ OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType)
|
||||
P_ECB pecb;
|
||||
|
||||
#if CFG_PAR_CHECKOUT_EN >0
|
||||
if((qStart == NULL) || (size == 0))
|
||||
if((qStart == Co_NULL) || (size == 0))
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType)
|
||||
/* Get a event control block and initial the event content */
|
||||
pecb = CreatEvent(EVENT_TYPE_QUEUE,sortType,&QueueTbl[i]);
|
||||
|
||||
if(pecb == NULL ) /* If there is no free EVENT control block*/
|
||||
if(pecb == Co_NULL ) /* If there is no free EVENT control block*/
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ StatusType CoDelQueue(OS_EventID id,U8 opt)
|
||||
if(err == E_OK) /* If the event block have been deleted */
|
||||
{
|
||||
QueueIDVessel &= ~((U32)(1<<(pqcb->id))); /* Update free queue list */
|
||||
pqcb->qStart = NULL;
|
||||
pqcb->qStart = Co_NULL;
|
||||
pqcb->id = 0;
|
||||
pqcb->head = 0;
|
||||
pqcb->tail = 0;
|
||||
@@ -140,7 +140,7 @@ StatusType CoDelQueue(OS_EventID id,U8 opt)
|
||||
* @brief Accept a mail from queue
|
||||
* @param[in] id Event ID.
|
||||
* @param[out] perr A pointer to error code.
|
||||
* @retval NULL
|
||||
* @retval Co_NULL
|
||||
* @retval A pointer to mail accepted.
|
||||
*
|
||||
* @par Description
|
||||
@@ -157,7 +157,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
|
||||
if(id >= CFG_MAX_EVENT)
|
||||
{
|
||||
*perr = E_INVALID_ID; /* Invalid id,return error */
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -166,7 +166,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
|
||||
if(pecb->eventType != EVENT_TYPE_QUEUE)/* Invalid event control block type*/
|
||||
{
|
||||
*perr = E_INVALID_ID;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */
|
||||
@@ -189,7 +189,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
|
||||
{
|
||||
OsSchedUnlock();
|
||||
*perr = E_QUEUE_EMPTY;
|
||||
return NULL; /* Return NULL */
|
||||
return Co_NULL; /* Return Co_NULL */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
|
||||
* @param[in] id Event ID.
|
||||
* @param[in] timeout The longest time for writting mail.
|
||||
* @param[out] perr A pointer to error code.
|
||||
* @retval NULL
|
||||
* @retval Co_NULL
|
||||
* @retval A pointer to mail accept.
|
||||
*
|
||||
* @par Description
|
||||
@@ -218,13 +218,13 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
if(OSIntNesting > 0) /* If the caller is ISR */
|
||||
{
|
||||
*perr = E_CALL;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#if CFG_PAR_CHECKOUT_EN >0
|
||||
if(id >= CFG_MAX_EVENT)
|
||||
{
|
||||
*perr = E_INVALID_ID; /* Invalid event id,return error */
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -233,16 +233,16 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
if(pecb->eventType != EVENT_TYPE_QUEUE) /* The event type is not queue */
|
||||
{
|
||||
*perr = E_INVALID_ID;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
#endif
|
||||
if(OSSchedLock != 0) /* Judge schedule is locked or not? */
|
||||
{
|
||||
*perr = E_OS_IN_LOCK; /* Schedule is locked,return error */
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */
|
||||
|
||||
OsSchedLock();
|
||||
if(pqcb->qSize != 0) /* If there are any messages in the queue */
|
||||
{
|
||||
/* Extract oldest message from the queue */
|
||||
@@ -253,11 +253,13 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
{
|
||||
pqcb->head = 0;
|
||||
}
|
||||
OsSchedUnlock();
|
||||
*perr = E_OK;
|
||||
return pmail; /* Return message received */
|
||||
}
|
||||
else /* If there is no message in the queue*/
|
||||
{
|
||||
OsSchedUnlock();
|
||||
curTCB = TCBRunning;
|
||||
if(timeout == 0) /* If time-out is not configured */
|
||||
{
|
||||
@@ -266,9 +268,9 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
|
||||
/* Have recived message or the queue have been deleted */
|
||||
pmail = curTCB->pmail;
|
||||
curTCB->pmail = NULL;
|
||||
curTCB->pmail = Co_NULL;
|
||||
*perr = E_OK;
|
||||
return pmail; /* Return message received or NULL */
|
||||
return pmail; /* Return message received or Co_NULL */
|
||||
}
|
||||
else /* If time-out is configured */
|
||||
{
|
||||
@@ -278,17 +280,17 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
|
||||
EventTaskToWait(pecb,curTCB);
|
||||
InsertDelayList(curTCB,timeout);
|
||||
OsSchedUnlock();
|
||||
if(curTCB->pmail == NULL) /* If time-out occurred */
|
||||
if(curTCB->pmail == Co_NULL) /* If time-out occurred */
|
||||
{
|
||||
*perr = E_TIMEOUT;
|
||||
return NULL;
|
||||
return Co_NULL;
|
||||
}
|
||||
else /* If event occured */
|
||||
{
|
||||
pmail = curTCB->pmail;
|
||||
curTCB->pmail = NULL;
|
||||
curTCB->pmail = Co_NULL;
|
||||
*perr = E_OK;
|
||||
return pmail; /* Return message received or NULL */
|
||||
return pmail; /* Return message received or Co_NULL */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,7 +374,7 @@ StatusType isr_PostQueueMail(OS_EventID id,void* pmail)
|
||||
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
|
||||
{
|
||||
/* Insert the request into service request queue */
|
||||
if(InsertInSRQ(QUEUE_REQ,id,pmail) == FALSE)
|
||||
if(InsertInSRQ(QUEUE_REQ,id,pmail) == Co_FALSE)
|
||||
{
|
||||
return E_SEV_REQ_FULL; /* If service request queue is full */
|
||||
}
|
||||
|
||||
+12
-9
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file sem.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Semaphore management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -49,8 +49,8 @@ OS_EventID CoCreateSem(U16 initCnt,U16 maxCnt,U8 sortType)
|
||||
#endif
|
||||
|
||||
/* Create a semaphore type event control block */
|
||||
pecb = CreatEvent(EVENT_TYPE_SEM,sortType,NULL);
|
||||
if(pecb == NULL) /* If failed to create event block */
|
||||
pecb = CreatEvent(EVENT_TYPE_SEM,sortType,Co_NULL);
|
||||
if(pecb == Co_NULL) /* If failed to create event block */
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -193,19 +193,22 @@ StatusType CoPendSem(OS_EventID id,U32 timeout)
|
||||
if(OSSchedLock != 0) /* Schdule is locked? */
|
||||
{
|
||||
return E_OS_IN_LOCK; /* Yes,error return */
|
||||
}
|
||||
}
|
||||
OsSchedLock();
|
||||
if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */
|
||||
{
|
||||
pecb->eventCounter--; /* Decrement semaphore only if positive */
|
||||
OsSchedUnlock();
|
||||
return E_OK;
|
||||
}
|
||||
else /* Resource is not available */
|
||||
{
|
||||
OsSchedUnlock();
|
||||
curTCB = TCBRunning;
|
||||
if(timeout == 0) /* If time-out is not configured */
|
||||
{
|
||||
EventTaskToWait(pecb,curTCB); /* Block task until event occurs */
|
||||
curTCB->pmail = NULL;
|
||||
curTCB->pmail = Co_NULL;
|
||||
return E_OK;
|
||||
}
|
||||
else /* If time-out is configured */
|
||||
@@ -217,13 +220,13 @@ StatusType CoPendSem(OS_EventID id,U32 timeout)
|
||||
InsertDelayList(curTCB,timeout);
|
||||
|
||||
OsSchedUnlock();
|
||||
if (curTCB->pmail == NULL) /* If pmail is NULL, time-out occurred*/
|
||||
if (curTCB->pmail == Co_NULL) /* If pmail is Co_NULL, time-out occurred*/
|
||||
{
|
||||
return E_TIMEOUT;
|
||||
}
|
||||
else /* Event occurred or event have been deleted*/
|
||||
{
|
||||
curTCB->pmail = NULL;
|
||||
curTCB->pmail = Co_NULL;
|
||||
return E_OK;
|
||||
}
|
||||
}
|
||||
@@ -300,7 +303,7 @@ StatusType isr_PostSem(OS_EventID id)
|
||||
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
|
||||
{
|
||||
/* Initiate a post service handling request */
|
||||
if(InsertInSRQ(SEM_REQ,id,NULL) == FALSE)
|
||||
if(InsertInSRQ(SEM_REQ,id,Co_NULL) == Co_FALSE)
|
||||
{
|
||||
return E_SEV_REQ_FULL; /* If service request queue is full */
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file serviceReq.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief servive request management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -22,15 +22,15 @@
|
||||
|
||||
#if CFG_MAX_SERVICE_REQUEST > 0
|
||||
/*---------------------------- Variable Define -------------------------------*/
|
||||
SRQ ServiceReq = {0}; /*!< ISR server request queue */
|
||||
SRQ ServiceReq = {0,0}; /*!< ISR server request queue */
|
||||
#endif
|
||||
BOOL IsrReq = FALSE;
|
||||
BOOL IsrReq = Co_FALSE;
|
||||
#if (CFG_TASK_WAITTING_EN > 0)
|
||||
BOOL TimeReq = FALSE; /*!< Time delay dispose request */
|
||||
BOOL TimeReq = Co_FALSE; /*!< Time delay dispose request */
|
||||
#endif
|
||||
|
||||
#if CFG_TMR_EN > 0
|
||||
BOOL TimerReq = FALSE; /*!< Timer dispose request */
|
||||
BOOL TimerReq = Co_FALSE; /*!< Timer dispose request */
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -41,8 +41,8 @@ BOOL TimerReq = FALSE; /*!< Timer dispose request */
|
||||
* @param[in] arg Service request argument.
|
||||
* @param[out] None
|
||||
*
|
||||
* @retval FALSE Successfully insert into service request queue.
|
||||
* @retval TRUE Failure to insert into service request queue.
|
||||
* @retval Co_FALSE Successfully insert into service request queue.
|
||||
* @retval Co_TRUE Failure to insert into service request queue.
|
||||
*
|
||||
* @par Description
|
||||
* @details This function be called to insert a requst into service request
|
||||
@@ -50,26 +50,34 @@ BOOL TimerReq = FALSE; /*!< Timer dispose request */
|
||||
* @note
|
||||
*******************************************************************************
|
||||
*/
|
||||
#if CFG_MAX_SERVICE_REQUEST > 0
|
||||
#if (CFG_MAX_SERVICE_REQUEST > 0)
|
||||
BOOL InsertInSRQ(U8 type,U8 id,void* arg)
|
||||
{
|
||||
U16 cnt;
|
||||
P_SQC pcell;
|
||||
cnt = Inc8(&ServiceReq.cnt); /* Service request counter decrease */
|
||||
if(cnt >= CFG_MAX_SERVICE_REQUEST) /* If counter exceed max */
|
||||
P_SQC pcell;
|
||||
U8 cnt;
|
||||
U8 heed;
|
||||
IRQ_DISABLE_SAVE();
|
||||
if (ServiceReq.cnt >= CFG_MAX_SERVICE_REQUEST)
|
||||
{
|
||||
return FALSE; /* Error return */
|
||||
IRQ_ENABLE_RESTORE ();
|
||||
|
||||
return Co_FALSE; /* Error return */
|
||||
}
|
||||
IsrReq = TRUE;
|
||||
pcell = &ServiceReq.cell[cnt]; /* Save service request type and parameter */
|
||||
pcell->type = type;
|
||||
pcell->id = id;
|
||||
pcell->arg = arg;
|
||||
return TRUE; /* Return OK */
|
||||
cnt = Inc8(&ServiceReq.cnt);
|
||||
heed = ServiceReq.head;
|
||||
IsrReq = Co_TRUE;
|
||||
pcell = &ServiceReq.cell[((cnt+heed)%CFG_MAX_SERVICE_REQUEST)];/*the tail */
|
||||
pcell->type = type; /* Save service request type, */
|
||||
pcell->id = id; /* event id */
|
||||
pcell->arg = arg; /* and parameter */
|
||||
IRQ_ENABLE_RESTORE ();
|
||||
|
||||
return Co_TRUE; /* Return OK */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @brief Respond the request in the service request queue.
|
||||
@@ -85,62 +93,72 @@ BOOL InsertInSRQ(U8 type,U8 id,void* arg)
|
||||
*/
|
||||
void RespondSRQ(void)
|
||||
{
|
||||
|
||||
#if CFG_MAX_SERVICE_REQUEST > 0
|
||||
U16 i;
|
||||
P_SQC pcell;
|
||||
SQC cell;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if (CFG_TASK_WAITTING_EN > 0)
|
||||
if(TimeReq == TRUE) /* Time delay request? */
|
||||
if(TimeReq == Co_TRUE) /* Time delay request? */
|
||||
{
|
||||
TimeDispose(); /* Yes,call handler */
|
||||
TimeReq = FALSE; /* Reset time delay request false */
|
||||
TimeReq = Co_FALSE; /* Reset time delay request Co_FALSE */
|
||||
}
|
||||
#endif
|
||||
#if CFG_TMR_EN > 0
|
||||
if(TimerReq == TRUE) /* Timer request? */
|
||||
if(TimerReq == Co_TRUE) /* Timer request? */
|
||||
{
|
||||
TmrDispose(); /* Yes,call handler */
|
||||
TimerReq = FALSE; /* Reset timer request false */
|
||||
TimerReq = Co_FALSE; /* Reset timer request Co_FALSE */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CFG_MAX_SERVICE_REQUEST > 0
|
||||
pcell = &ServiceReq.cell[0]; /* Get the head item of service request list*/
|
||||
for(i=0;i<ServiceReq.cnt;i++,pcell++)
|
||||
|
||||
while (ServiceReq.cnt != 0)
|
||||
{
|
||||
switch(pcell->type) /* Judge service request type */
|
||||
IRQ_DISABLE_SAVE (); /* need to protect the following */
|
||||
cell = ServiceReq.cell[ServiceReq.head]; /* extract one cell */
|
||||
ServiceReq.head = (ServiceReq.head + 1) % /* move head (pop) */
|
||||
CFG_MAX_SERVICE_REQUEST;
|
||||
ServiceReq.cnt--;
|
||||
IRQ_ENABLE_RESTORE (); /* now use the cell copy */
|
||||
|
||||
switch(cell.type) /* Judge service request type */
|
||||
{
|
||||
#if CFG_SEM_EN > 0
|
||||
case SEM_REQ: /* Semaphore post request,call handler*/
|
||||
CoPostSem(pcell->id);
|
||||
break;
|
||||
case SEM_REQ: /* Semaphore post request,call handler*/
|
||||
CoPostSem(cell.id);
|
||||
break;
|
||||
#endif
|
||||
#if CFG_MAILBOX_EN > 0
|
||||
case MBOX_REQ: /* Mailbox post request,call handler */
|
||||
CoPostMail(pcell->id,pcell->arg);
|
||||
break;
|
||||
case MBOX_REQ: /* Mailbox post request,call handler */
|
||||
CoPostMail(cell.id, cell.arg);
|
||||
break;
|
||||
#endif
|
||||
#if CFG_FLAG_EN > 0
|
||||
case FLAG_REQ: /* Flag set request,call handler */
|
||||
CoSetFlag(pcell->id);
|
||||
break;
|
||||
#endif
|
||||
case FLAG_REQ: /* Flag set request,call handler */
|
||||
CoSetFlag(cell.id);
|
||||
break;
|
||||
#endif
|
||||
#if CFG_QUEUE_EN > 0
|
||||
case QUEUE_REQ: /* Queue post request,call handler */
|
||||
CoPostQueueMail(pcell->id,pcell->arg);
|
||||
break;
|
||||
case QUEUE_REQ: /* Queue post request,call handler */
|
||||
CoPostQueueMail(cell.id, cell.arg);
|
||||
break;
|
||||
#endif
|
||||
default: /* Others,break */
|
||||
break;
|
||||
}
|
||||
pcell->type = 0; /* Initialize the service request cell*/
|
||||
pcell->id = 0;
|
||||
pcell->arg = 0;
|
||||
}
|
||||
ServiceReq.cnt = 0; /* Initialize the service request queue */
|
||||
default: /* Others,break */
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
IsrReq = FALSE;
|
||||
IRQ_DISABLE_SAVE (); /* need to protect the following */
|
||||
|
||||
if (ServiceReq.cnt == 0) /* another item in the queue already? */
|
||||
{
|
||||
IsrReq = Co_FALSE; /* queue still empty here */
|
||||
}
|
||||
IRQ_ENABLE_RESTORE (); /* now it is done and return */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+65
-65
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file task.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief task management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -25,10 +25,10 @@ OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}};
|
||||
/*!< The stack of IDLE task. */
|
||||
OS_STK idle_stk[CFG_IDLE_STACK_SIZE] = {0};
|
||||
|
||||
P_OSTCB FreeTCB = NULL; /*!< pointer to free TCB */
|
||||
P_OSTCB TCBRdy = NULL; /*!< Pointer to the READY list. */
|
||||
P_OSTCB TCBNext = NULL; /*!< Poniter to task that next scheduled by OS */
|
||||
P_OSTCB TCBRunning = NULL; /*!< Pointer to TCB that current running task. */
|
||||
P_OSTCB FreeTCB = Co_NULL; /*!< pointer to free TCB */
|
||||
P_OSTCB TCBRdy = Co_NULL; /*!< Pointer to the READY list. */
|
||||
P_OSTCB TCBNext = Co_NULL; /*!< Poniter to task that next scheduled by OS */
|
||||
P_OSTCB TCBRunning = Co_NULL; /*!< Pointer to TCB that current running task. */
|
||||
U64 OSCheckTime = 0; /*!< The counter of system tick. */
|
||||
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
@@ -80,7 +80,7 @@ void CreateTCBList(void)
|
||||
#endif
|
||||
|
||||
ptcb1->taskID = i;
|
||||
ptcb1->TCBnext = NULL;
|
||||
ptcb1->TCBnext = Co_NULL;
|
||||
FreeTCB = &TCBTbl[0]; /* Initialize FreeTCB as head item of list */
|
||||
}
|
||||
|
||||
@@ -93,8 +93,8 @@ void CreateTCBList(void)
|
||||
* @brief Get sequence number for Assign priority
|
||||
* @param[in] pri Assign priority
|
||||
* @param[out] SequenceNum priority number
|
||||
* @retval TRUE Assign priority in priority queue.
|
||||
* FALSE Assign priority not in priority queue.
|
||||
* @retval Co_TRUE Assign priority in priority queue.
|
||||
* Co_FALSE Assign priority not in priority queue.
|
||||
*
|
||||
* @par Description
|
||||
* @details This function is called in Binary-Scheduling Algorithm
|
||||
@@ -114,7 +114,7 @@ static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum)
|
||||
if(pri == ActivePri[num])
|
||||
{
|
||||
*SequenceNum = num;
|
||||
return TRUE;
|
||||
return Co_TRUE;
|
||||
}
|
||||
else if (pri < ActivePri[num])
|
||||
{
|
||||
@@ -127,7 +127,7 @@ static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum)
|
||||
}
|
||||
}
|
||||
*SequenceNum = num;
|
||||
return FALSE;
|
||||
return Co_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,8 +238,8 @@ static void PrioRemap(OS_TID seqNum)
|
||||
* @brief Get the ready status for assign sequence number
|
||||
* @param[in] seqNum Assign sequence number
|
||||
* @param[out] None
|
||||
* @retval TRUE This priority has ready task
|
||||
* FALSE This priority doesn't have ready task
|
||||
* @retval Co_TRUE This priority has ready task
|
||||
* Co_FALSE This priority doesn't have ready task
|
||||
*
|
||||
* @par Description
|
||||
* @details This function is called in Binary-Scheduling Algorithm
|
||||
@@ -250,9 +250,9 @@ static BOOL GetPrioSeqNumStatus(U8 seqNum)
|
||||
{
|
||||
if( (RdyTaskPriInfo[seqNum/32] & (1<<(seqNum%32))) == 0)
|
||||
{
|
||||
return FALSE;
|
||||
return Co_FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return Co_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -293,10 +293,10 @@ static void SetPrioSeqNumStatus(U8 seqNum, BOOL isRdy)
|
||||
* increate the task num for this priority.
|
||||
*******************************************************************************
|
||||
*/
|
||||
static void ActiveTaskPri(U8 pri)
|
||||
void ActiveTaskPri(U8 pri)
|
||||
{
|
||||
OS_TID seqNum,num;
|
||||
if(GetPriSeqNum(pri,&seqNum) == FALSE)
|
||||
if(GetPriSeqNum(pri,&seqNum) == Co_FALSE)
|
||||
{
|
||||
for(num=PriNum;num>seqNum;num--)
|
||||
{
|
||||
@@ -332,7 +332,7 @@ static void ActiveTaskPri(U8 pri)
|
||||
* remove the priority for queue.
|
||||
*******************************************************************************
|
||||
*/
|
||||
static void DeleteTaskPri(U8 pri)
|
||||
void DeleteTaskPri(U8 pri)
|
||||
{
|
||||
OS_TID seqNum,num;
|
||||
|
||||
@@ -384,7 +384,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
{
|
||||
if(ptcb != tcbInsert) /* Yes,is inserted task equal to running task? */
|
||||
{
|
||||
if(ptcb != NULL) /* No,TCBRunning == NULL? */
|
||||
if(ptcb != Co_NULL) /* No,TCBRunning == Co_NULL? */
|
||||
{ /* N0,OSCheckTime < OSTickCnt? */
|
||||
if(OSCheckTime < OSTickCnt)
|
||||
{ /* Yes,set OSCheckTime for task robin */
|
||||
@@ -398,7 +398,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
GetPriSeqNum(prio,&seqNum);
|
||||
if(GetPrioSeqNumStatus(seqNum) == TRUE)
|
||||
if(GetPrioSeqNumStatus(seqNum) == Co_TRUE)
|
||||
{
|
||||
ptcb = &TCBTbl[RdyTaskPri[seqNum]];
|
||||
RdyTaskPri[seqNum] = tcbInsert->taskID;
|
||||
@@ -411,8 +411,8 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
if(RdyTaskSeqNum == INVALID_ID)
|
||||
{
|
||||
ptcb = TCBRdy;
|
||||
TaskSchedReq = TRUE;
|
||||
if(ptcb == NULL)
|
||||
TaskSchedReq = Co_TRUE;
|
||||
if(ptcb == Co_NULL)
|
||||
{
|
||||
TCBRdy = tcbInsert;
|
||||
}
|
||||
@@ -434,7 +434,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
tcbInsert->TCBnext = ptcbNext; /* Set link for list */
|
||||
ptcb->TCBnext = tcbInsert;
|
||||
tcbInsert->TCBprev = ptcb;
|
||||
if(ptcbNext != NULL)
|
||||
if(ptcbNext != Co_NULL)
|
||||
{
|
||||
ptcbNext->TCBprev = tcbInsert;
|
||||
}
|
||||
@@ -442,14 +442,14 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
|
||||
#else
|
||||
ptcb = TCBRdy;
|
||||
if (ptcb == NULL) /* Is ready list NULL? */
|
||||
if (ptcb == Co_NULL) /* Is ready list Co_NULL? */
|
||||
{
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
TCBRdy = tcbInsert; /* Yse,set tcbInsert as head item of list */
|
||||
}
|
||||
else if (prio < ptcb->prio)/* Is PRI of inserted task higher than TCBRdy? */
|
||||
{
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */
|
||||
ptcb->TCBprev = tcbInsert;
|
||||
TCBRdy = tcbInsert;
|
||||
@@ -457,7 +457,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
else /* No,find correct place */
|
||||
{
|
||||
ptcbNext = ptcb->TCBnext; /* Get next item */
|
||||
while(ptcbNext != NULL) /* Is last item in ready list? */
|
||||
while(ptcbNext != Co_NULL) /* Is last item in ready list? */
|
||||
{ /* No,find correct place */
|
||||
if(prio < ptcbNext->prio) /* Is correct place? */
|
||||
break; /* Yes,break circulation */
|
||||
@@ -467,7 +467,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
|
||||
tcbInsert->TCBnext = ptcbNext; /* Set link for list */
|
||||
ptcb->TCBnext = tcbInsert;
|
||||
tcbInsert->TCBprev = ptcb;
|
||||
if(ptcbNext != NULL)
|
||||
if(ptcbNext != Co_NULL)
|
||||
{
|
||||
ptcbNext->TCBprev = tcbInsert;
|
||||
}
|
||||
@@ -495,57 +495,57 @@ void RemoveFromTCBRdyList(P_OSTCB ptcb)
|
||||
U8 prio;
|
||||
U8 seqNum;
|
||||
BOOL isChange;
|
||||
isChange = FALSE;
|
||||
isChange = Co_FALSE;
|
||||
prio = ptcb->prio;
|
||||
GetPriSeqNum(prio,&seqNum);
|
||||
#endif
|
||||
|
||||
/* Is there only one item in READY list? */
|
||||
if((ptcb->TCBnext == NULL) && (ptcb->TCBprev == NULL) )
|
||||
if((ptcb->TCBnext == Co_NULL) && (ptcb->TCBprev == Co_NULL) )
|
||||
{
|
||||
TCBRdy = NULL; /* Yes,set READY list as NULL */
|
||||
TCBRdy = Co_NULL; /* Yes,set READY list as Co_NULL */
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
isChange = TRUE;
|
||||
isChange = Co_TRUE;
|
||||
#endif
|
||||
}
|
||||
else if(ptcb->TCBprev == NULL) /* Is the first item in READY list? */
|
||||
else if(ptcb->TCBprev == Co_NULL) /* Is the first item in READY list? */
|
||||
{
|
||||
/* Yes,remove task from the list,and reset the head of READY list */
|
||||
TCBRdy = ptcb->TCBnext;
|
||||
ptcb->TCBnext = NULL;
|
||||
TCBRdy->TCBprev = NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
TCBRdy->TCBprev = Co_NULL;
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
if(TCBRdy->prio != prio)
|
||||
isChange = TRUE;
|
||||
isChange = Co_TRUE;
|
||||
|
||||
#endif
|
||||
}
|
||||
else if( ptcb->TCBnext == NULL) /* Is the last item in READY list? */
|
||||
else if( ptcb->TCBnext == Co_NULL) /* Is the last item in READY list? */
|
||||
{ /* Yes,remove task from list */
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
if(ptcb->TCBprev->prio != prio)
|
||||
isChange = TRUE;
|
||||
isChange = Co_TRUE;
|
||||
else
|
||||
RdyTaskPri[seqNum] = ptcb->TCBprev->taskID;
|
||||
#endif
|
||||
ptcb->TCBprev->TCBnext = NULL;
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBprev->TCBnext = Co_NULL;
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
}
|
||||
else /* No, remove task from list */
|
||||
{
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
if((ptcb->TCBprev->prio != prio) && (ptcb->TCBnext->prio != prio))
|
||||
isChange = TRUE;
|
||||
isChange = Co_TRUE;
|
||||
else if((ptcb->TCBprev->prio == prio) && (ptcb->TCBnext->prio != prio))
|
||||
RdyTaskPri[seqNum] = ptcb->TCBprev->taskID;
|
||||
#endif
|
||||
ptcb->TCBprev->TCBnext = ptcb->TCBnext;
|
||||
ptcb->TCBnext->TCBprev = ptcb->TCBprev;
|
||||
ptcb->TCBnext = NULL;
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
}
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
if(isChange == TRUE)
|
||||
if(isChange == Co_TRUE)
|
||||
{
|
||||
RdyTaskPri[seqNum] = INVALID_ID;
|
||||
SetPrioSeqNumStatus(seqNum, 0);
|
||||
@@ -642,7 +642,7 @@ StatusType CoSetPriority(OS_TID taskID,U8 priority)
|
||||
if(ptcb->prio > TCBRdy->prio) /* Yes,Is PRI higher than TCBRdy? */
|
||||
{
|
||||
OsSchedLock(); /* Yes,reorder task in READY list */
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
OsSchedUnlock();
|
||||
}
|
||||
}
|
||||
@@ -657,7 +657,7 @@ StatusType CoSetPriority(OS_TID taskID,U8 priority)
|
||||
ptcb = pMutex->waittingList;
|
||||
prio = pMutex->originalPrio;
|
||||
pMutex->hipriTaskID = pMutex->taskID;
|
||||
while(ptcb != NULL)
|
||||
while(ptcb != Co_NULL)
|
||||
{
|
||||
if(ptcb->prio < prio)
|
||||
{
|
||||
@@ -716,12 +716,12 @@ void Schedule(void)
|
||||
pCurTcb = TCBRunning;
|
||||
pRdyTcb = TCBRdy;
|
||||
|
||||
if((pRdyTcb==NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0))
|
||||
if((pRdyTcb==Co_NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TaskSchedReq = FALSE;
|
||||
TaskSchedReq = Co_FALSE;
|
||||
RunPrio = pCurTcb->prio;
|
||||
RdyPrio = pRdyTcb->prio;
|
||||
|
||||
@@ -790,10 +790,10 @@ static P_OSTCB AssignTCB(void)
|
||||
P_OSTCB ptcb;
|
||||
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
if(FreeTCB == NULL) /* Is there no free TCB */
|
||||
if(FreeTCB == Co_NULL) /* Is there no free TCB */
|
||||
{
|
||||
OsSchedUnlock(); /* Yes,unlock schedule */
|
||||
return NULL; /* Error return */
|
||||
return Co_NULL; /* Error return */
|
||||
}
|
||||
ptcb = FreeTCB; /* Yes,assgin free TCB for this task */
|
||||
/* Set next item as the head of free TCB list */
|
||||
@@ -835,11 +835,11 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
|
||||
prio = parameter&0xff;
|
||||
|
||||
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
|
||||
if(task == NULL)
|
||||
if(task == Co_NULL)
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
if(stk == NULL)
|
||||
if(stk == Co_NULL)
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -856,7 +856,7 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
|
||||
#endif // CFG_PAR_CHECKOUT_EN
|
||||
|
||||
#if CFG_TASK_SCHEDULE_EN == 0
|
||||
if(TCBRunning != NULL)
|
||||
if(TCBRunning != Co_NULL)
|
||||
return E_CREATE_FAIL;
|
||||
#endif
|
||||
|
||||
@@ -864,7 +864,7 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
|
||||
|
||||
ptcb = AssignTCB(); /* Get free TCB to use */
|
||||
|
||||
if(ptcb == NULL) /* Is free TCB equal to NULL? */
|
||||
if(ptcb == Co_NULL) /* Is free TCB equal to Co_NULL? */
|
||||
{
|
||||
return E_CREATE_FAIL; /* Yes,error return */
|
||||
}
|
||||
@@ -884,8 +884,8 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
|
||||
ptcb->taskFuc = task;
|
||||
ptcb->taskStk = stk;
|
||||
#endif
|
||||
ptcb->TCBnext = NULL; /* Initialize TCB link in READY list */
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBnext = Co_NULL; /* Initialize TCB link in READY list */
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
|
||||
#if CFG_ROBIN_EN >0 /* Set task time slice for task robin */
|
||||
timeSlice = (parameter&0x7fff0000)>>20;
|
||||
@@ -897,14 +897,14 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
|
||||
#endif
|
||||
|
||||
#if CFG_FLAG_EN > 0
|
||||
ptcb->pnode = NULL; /* Initialize task as no flag waiting */
|
||||
ptcb->pnode = Co_NULL; /* Initialize task as no flag waiting */
|
||||
#endif
|
||||
|
||||
#if CFG_EVENT_EN > 0
|
||||
ptcb->eventID = INVALID_ID; /* Initialize task as no event waiting*/
|
||||
ptcb->pmail = NULL;
|
||||
ptcb->waitNext = NULL;
|
||||
ptcb->waitPrev = NULL;
|
||||
ptcb->pmail = Co_NULL;
|
||||
ptcb->waitNext = Co_NULL;
|
||||
ptcb->waitPrev = Co_NULL;
|
||||
#endif
|
||||
|
||||
#if CFG_MUTEX_EN > 0
|
||||
@@ -1009,7 +1009,7 @@ StatusType CoDelTask(OS_TID taskID)
|
||||
#endif
|
||||
|
||||
#if CFG_FLAG_EN > 0
|
||||
if(ptcb->pnode != NULL) /* Is task in flag waiting list? */
|
||||
if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list? */
|
||||
{
|
||||
/* Yes,remove task from flag waiting list */
|
||||
RemoveLinkNode(ptcb->pnode);
|
||||
@@ -1025,7 +1025,7 @@ StatusType CoDelTask(OS_TID taskID)
|
||||
}
|
||||
#endif
|
||||
ptcb->state = TASK_DORMANT; /* Release TCB */
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
|
||||
#if CFG_ORDER_LIST_SCHEDULE_EN ==0
|
||||
DeleteTaskPri(ptcb->prio);
|
||||
@@ -1083,7 +1083,7 @@ StatusType CoActivateTask(OS_TID taskID,void *argv)
|
||||
#endif
|
||||
ptcb = &TCBTbl[taskID];
|
||||
#if CFG_PAR_CHECKOUT_EN >0
|
||||
if(ptcb->stkPtr == NULL)
|
||||
if(ptcb->stkPtr == Co_NULL)
|
||||
return E_INVALID_ID;
|
||||
#endif
|
||||
if(ptcb->state != TASK_DORMANT)
|
||||
@@ -1171,7 +1171,7 @@ StatusType CoSuspendTask(OS_TID taskID)
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
}
|
||||
|
||||
ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */
|
||||
@@ -1229,7 +1229,7 @@ StatusType CoAwakeTask(OS_TID taskID)
|
||||
}
|
||||
|
||||
#if CFG_FLAG_EN > 0
|
||||
if(ptcb->pnode != NULL) /* Is task in flag waiting list */
|
||||
if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list */
|
||||
{
|
||||
return E_TASK_WAIT_OTHER; /* Yes,error return */
|
||||
}
|
||||
|
||||
+27
-27
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file time.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief time management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2009 CooCox </center></h2>
|
||||
*******************************************************************************
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#if CFG_TASK_WAITTING_EN > 0
|
||||
|
||||
/*---------------------------- Variable Define -------------------------------*/
|
||||
P_OSTCB DlyList = NULL; /*!< Header pointer to the DELAY list.*/
|
||||
P_OSTCB DlyList = Co_NULL; /*!< Header pointer to the DELAY list.*/
|
||||
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
|
||||
|
||||
if(ticks == 0) /* Is delay tick == 0? */
|
||||
return; /* Yes,do nothing,return */
|
||||
if(DlyList == NULL) /* Is no item in DELAY list? */
|
||||
if(DlyList == Co_NULL) /* Is no item in DELAY list? */
|
||||
{
|
||||
ptcb->delayTick = ticks; /* Yes,set this as first item */
|
||||
DlyList = ptcb;
|
||||
@@ -56,14 +56,14 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
|
||||
deltaTicks = ticks; /* Get task delay ticks */
|
||||
|
||||
/* Find correct place */
|
||||
while(dlyNext != NULL)
|
||||
while(dlyNext != Co_NULL)
|
||||
{
|
||||
/* Get delta ticks with previous item */
|
||||
deltaTicks -= dlyNext->delayTick;
|
||||
if(deltaTicks < 0) /* Is delta ticks<0? */
|
||||
{
|
||||
/* Yes,get correct place */
|
||||
if(dlyNext->TCBprev != NULL) /* Is head item of DELAY list? */
|
||||
if(dlyNext->TCBprev != Co_NULL) /* Is head item of DELAY list? */
|
||||
{
|
||||
dlyNext->TCBprev->TCBnext = ptcb; /* No,insert into */
|
||||
ptcb->TCBprev = dlyNext->TCBprev;
|
||||
@@ -81,7 +81,7 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
|
||||
break;
|
||||
}
|
||||
/* Is last item in DELAY list? */
|
||||
else if((deltaTicks >= 0) && (dlyNext->TCBnext == NULL) )
|
||||
else if((deltaTicks >= 0) && (dlyNext->TCBnext == Co_NULL) )
|
||||
{
|
||||
ptcb->TCBprev = dlyNext; /* Yes,insert into */
|
||||
dlyNext->TCBnext = ptcb;
|
||||
@@ -93,7 +93,7 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
|
||||
}
|
||||
|
||||
ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */
|
||||
TaskSchedReq = TRUE;
|
||||
TaskSchedReq = Co_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,31 +112,31 @@ void RemoveDelayList(P_OSTCB ptcb)
|
||||
{
|
||||
|
||||
/* Is there only one item in the DELAY list? */
|
||||
if((ptcb->TCBprev == NULL) && ( ptcb->TCBnext == NULL))
|
||||
if((ptcb->TCBprev == Co_NULL) && ( ptcb->TCBnext == Co_NULL))
|
||||
{
|
||||
DlyList = NULL; /* Yes,set DELAY list as NULL */
|
||||
DlyList = Co_NULL; /* Yes,set DELAY list as Co_NULL */
|
||||
}
|
||||
else if(ptcb->TCBprev == NULL) /* Is the first item in DELAY list? */
|
||||
else if(ptcb->TCBprev == Co_NULL) /* Is the first item in DELAY list? */
|
||||
{
|
||||
/* Yes,remove task from the DELAY list,and reset the list */
|
||||
DlyList = ptcb->TCBnext;
|
||||
ptcb->TCBnext->delayTick += ptcb->delayTick;
|
||||
ptcb->TCBnext->TCBprev = NULL;
|
||||
ptcb->TCBnext = NULL;
|
||||
ptcb->TCBnext->TCBprev = Co_NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
|
||||
}
|
||||
else if(ptcb->TCBnext == NULL) /* Is the last item in DELAY list? */
|
||||
else if(ptcb->TCBnext == Co_NULL) /* Is the last item in DELAY list? */
|
||||
{
|
||||
ptcb->TCBprev->TCBnext = NULL; /* Yes,remove task form DELAY list */
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBprev->TCBnext = Co_NULL; /* Yes,remove task form DELAY list */
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
}
|
||||
else /* No, remove task from DELAY list */
|
||||
{
|
||||
ptcb->TCBprev->TCBnext = ptcb->TCBnext;
|
||||
ptcb->TCBnext->TCBprev = ptcb->TCBprev;
|
||||
ptcb->TCBnext->delayTick += ptcb->delayTick;
|
||||
ptcb->TCBnext = NULL;
|
||||
ptcb->TCBprev = NULL;
|
||||
ptcb->TCBnext = Co_NULL;
|
||||
ptcb->TCBprev = Co_NULL;
|
||||
}
|
||||
ptcb->delayTick = INVALID_VALUE; /* Set task delay tick value as invalid */
|
||||
}
|
||||
@@ -227,7 +227,7 @@ StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks)
|
||||
|
||||
ptcb = &TCBTbl[taskID];
|
||||
#if CFG_PAR_CHECKOUT_EN >0
|
||||
if(ptcb->stkPtr == NULL)
|
||||
if(ptcb->stkPtr == Co_NULL)
|
||||
{
|
||||
return E_INVALID_ID;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ void TimeDispose(void)
|
||||
P_OSTCB dlyList;
|
||||
|
||||
dlyList = DlyList; /* Get first item of DELAY list */
|
||||
while((dlyList != NULL) && (dlyList->delayTick == 0) )
|
||||
while((dlyList != Co_NULL) && (dlyList->delayTick == 0) )
|
||||
{
|
||||
|
||||
#if CFG_EVENT_EN > 0
|
||||
@@ -327,21 +327,21 @@ void TimeDispose(void)
|
||||
#endif
|
||||
|
||||
#if CFG_FLAG_EN > 0
|
||||
if(dlyList->pnode != NULL) /* Is task in flag waiting list? */
|
||||
if(dlyList->pnode != Co_NULL) /* Is task in flag waiting list? */
|
||||
{
|
||||
RemoveLinkNode(dlyList->pnode); /* Yes,remove task from list */
|
||||
}
|
||||
#endif
|
||||
dlyList->delayTick = INVALID_VALUE; /* Set delay tick value as invalid*/
|
||||
DlyList = dlyList->TCBnext; /* Get next item as the head of DELAY list*/
|
||||
dlyList->TCBnext = NULL;
|
||||
dlyList->TCBnext = Co_NULL;
|
||||
|
||||
InsertToTCBRdyList(dlyList); /* Insert task into READY list */
|
||||
|
||||
dlyList = DlyList; /* Get the first item of DELAY list */
|
||||
if(dlyList != NULL) /* Is DELAY list as NULL? */
|
||||
if(dlyList != Co_NULL) /* Is DELAY list as Co_NULL? */
|
||||
{
|
||||
dlyList->TCBprev = NULL; /* No,initialize the first item */
|
||||
dlyList->TCBprev = Co_NULL; /* No,initialize the first item */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,8 +363,8 @@ void isr_TimeDispose(void)
|
||||
{
|
||||
if(OSSchedLock > 1) /* Is schedule lock? */
|
||||
{
|
||||
IsrReq = TRUE;
|
||||
TimeReq = TRUE; /* Yes,set time request true */
|
||||
IsrReq = Co_TRUE;
|
||||
TimeReq = Co_TRUE; /* Yes,set time request Co_TRUE */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+23
-23
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file timer.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief timer management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
@@ -22,7 +22,7 @@
|
||||
#if CFG_TMR_EN > 0
|
||||
|
||||
TmrCtrl TmrTbl[CFG_MAX_TMR]= {{0}};/*!< Table which save timer control block.*/
|
||||
P_TmrCtrl TmrList = NULL; /*!< The header of the TmrCtrl list. */
|
||||
P_TmrCtrl TmrList = Co_NULL; /*!< The header of the TmrCtrl list. */
|
||||
U32 TmrIDVessel = 0; /*!< Timer ID container. */
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ static void InsertTmrList(OS_TCID tmrID)
|
||||
}
|
||||
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
if(TmrList == NULL) /* Is no item in timer list? */
|
||||
if(TmrList == Co_NULL) /* Is no item in timer list? */
|
||||
{
|
||||
TmrList = &TmrTbl[tmrID]; /* Yes,set this as first item */
|
||||
}
|
||||
@@ -61,13 +61,13 @@ static void InsertTmrList(OS_TCID tmrID)
|
||||
deltaTicks = tmrCnt; /* Get timer tick */
|
||||
|
||||
/* find correct place */
|
||||
while(pTmr != NULL)
|
||||
while(pTmr != Co_NULL)
|
||||
{
|
||||
deltaTicks -= pTmr->tmrCnt; /* Get ticks with previous item */
|
||||
if(deltaTicks < 0) /* Is delta ticks<0? */
|
||||
{
|
||||
/* Yes,get correct place */
|
||||
if(pTmr->tmrPrev!= NULL)/* Is head item of timer list? */
|
||||
if(pTmr->tmrPrev!= Co_NULL)/* Is head item of timer list? */
|
||||
{
|
||||
/* No,insert into */
|
||||
pTmr->tmrPrev->tmrNext = &TmrTbl[tmrID];
|
||||
@@ -86,7 +86,7 @@ static void InsertTmrList(OS_TCID tmrID)
|
||||
break;
|
||||
}
|
||||
/* Is last item in list? */
|
||||
else if((deltaTicks >= 0) && (pTmr->tmrNext == NULL))
|
||||
else if((deltaTicks >= 0) && (pTmr->tmrNext == Co_NULL))
|
||||
{
|
||||
/* Yes,insert into */
|
||||
TmrTbl[tmrID].tmrPrev = pTmr;
|
||||
@@ -121,30 +121,30 @@ static void RemoveTmrList(OS_TCID tmrID)
|
||||
OsSchedLock(); /* Lock schedule */
|
||||
|
||||
/* Is there only one item in timer list? */
|
||||
if((pTmr->tmrPrev == NULL) && (pTmr->tmrNext == NULL))
|
||||
if((pTmr->tmrPrev == Co_NULL) && (pTmr->tmrNext == Co_NULL))
|
||||
{
|
||||
TmrList = NULL; /* Yes,set timer list as NULL */
|
||||
TmrList = Co_NULL; /* Yes,set timer list as Co_NULL */
|
||||
}
|
||||
else if(pTmr->tmrPrev == NULL) /* Is the first item in timer list? */
|
||||
else if(pTmr->tmrPrev == Co_NULL) /* Is the first item in timer list? */
|
||||
{ /* Yes,remove timer from list,and reset timer list */
|
||||
TmrList = pTmr->tmrNext;
|
||||
TmrList->tmrPrev = NULL;
|
||||
TmrList->tmrPrev = Co_NULL;
|
||||
pTmr->tmrNext->tmrCnt += pTmr->tmrCnt;
|
||||
pTmr->tmrNext = NULL;
|
||||
pTmr->tmrNext = Co_NULL;
|
||||
}
|
||||
else if(pTmr->tmrNext == NULL) /* Is the last item in timer list? */
|
||||
else if(pTmr->tmrNext == Co_NULL) /* Is the last item in timer list? */
|
||||
{
|
||||
/* Yes,remove timer form list */
|
||||
pTmr->tmrPrev->tmrNext = NULL;
|
||||
pTmr->tmrPrev = NULL;
|
||||
pTmr->tmrPrev->tmrNext = Co_NULL;
|
||||
pTmr->tmrPrev = Co_NULL;
|
||||
}
|
||||
else /* No, remove timer from list */
|
||||
{
|
||||
pTmr->tmrPrev->tmrNext = pTmr->tmrNext;
|
||||
pTmr->tmrNext->tmrPrev = pTmr->tmrPrev;
|
||||
pTmr->tmrNext->tmrCnt += pTmr->tmrCnt;
|
||||
pTmr->tmrNext = NULL;
|
||||
pTmr->tmrPrev = NULL;
|
||||
pTmr->tmrNext = Co_NULL;
|
||||
pTmr->tmrPrev = Co_NULL;
|
||||
}
|
||||
OsSchedUnlock(); /* Unlock schedule */
|
||||
}
|
||||
@@ -173,7 +173,7 @@ OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func)
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
if(func == NULL)
|
||||
if(func == Co_NULL)
|
||||
{
|
||||
return E_CREATE_FAIL;
|
||||
}
|
||||
@@ -191,8 +191,8 @@ OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func)
|
||||
TmrTbl[i].tmrCnt = tmrCnt;
|
||||
TmrTbl[i].tmrReload = tmrReload;
|
||||
TmrTbl[i].tmrCallBack = func;
|
||||
TmrTbl[i].tmrPrev = NULL;
|
||||
TmrTbl[i].tmrNext = NULL;
|
||||
TmrTbl[i].tmrPrev = Co_NULL;
|
||||
TmrTbl[i].tmrNext = Co_NULL;
|
||||
return i; /* Return timer ID */
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,7 @@ void TmrDispose(void)
|
||||
P_TmrCtrl pTmr;
|
||||
|
||||
pTmr = TmrList; /* Get first item of timer list */
|
||||
while((pTmr != NULL) && (pTmr->tmrCnt == 0) )
|
||||
while((pTmr != Co_NULL) && (pTmr->tmrCnt == 0) )
|
||||
{
|
||||
if(pTmr->tmrType == TMR_TYPE_ONE_SHOT) /* Is a One-shot timer? */
|
||||
{
|
||||
@@ -435,8 +435,8 @@ void isr_TmrDispose(void)
|
||||
{
|
||||
if(OSSchedLock > 1) /* Is schedule lock? */
|
||||
{
|
||||
IsrReq = TRUE;
|
||||
TimerReq = TRUE; /* Yes,set timer request true */
|
||||
IsrReq = Co_TRUE;
|
||||
TimerReq = Co_TRUE; /* Yes,set timer request true */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file utility.c
|
||||
* @version V1.12
|
||||
* @date 2010.03.01
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Utility management implementation code of CooCox CoOS kernel.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file utility.h
|
||||
* @version V1.00 Initial version
|
||||
* @date 2009.06.26
|
||||
* @version V1.1.4
|
||||
* @date 2011.04.20
|
||||
* @brief Utility function header file
|
||||
* @details This file including some defines and declares related to utility
|
||||
* function.
|
||||
|
||||
Reference in New Issue
Block a user