dsPIC33E/os_APIs.c
// Function name	: OSTaskCreate()
// Author           : Fabian Kung
// Last modified	: 2 Nov 2009
// Purpose          : Add a new task to the OS's scheduler.
// Arguments		: ptrTaskData = A pointer to the structure structTASK.
//                    ptrTask = a valid pointer to a user routine.
// Return           : 0 if success, 1 or >0 if not successful.
// Others           : Increment global variable gnTaskCount.

Function name  : OSTaskCreate()
Author           : Fabian Kung
Last modified  : 2 Nov 2009
Purpose          : Add a new task to the OS's scheduler.
Arguments              : ptrTaskData = A pointer to the structure structTASK.
ptrTask = a valid pointer to a user routine.
Return           : 0 if success, 1 or >0 if not successful.
Others           : Increment global variable gnTaskCount.
Function name : OSTaskCreate () Author : Fabian Kung Last modified : 2 Nov 2009 Purpose : Add a new task to the OS ' s scheduler . Arguments : ptrTaskData = A pointer to the structure structTASK . ptrTask = a valid pointer to a user routine . Return : 0 if success 1 or > 0 if not successful . Others : Increment global variable gnTaskCount .
BYTE OSCreateTask(TASK_ATTRIBUTE *ptrTaskData, TASK_POINTER ptrTask)
{
	if (gnTaskCount> __MAXTASK) 
	{
		return 1;                           
	}
	else
	{
		ptrTaskData->nState = 0;            
		ptrTaskData->nTimer = 1;
		gfptrTask[gnTaskCount] = ptrTask;	
		gnTaskCount++;                      
		ptrTaskData->nID = gnTaskCount; 	
		return 0;
	}
}
BYTE OSCreateTask ( TASK_ATTRIBUTE * ptrTaskData , TASK_POINTER ptrTask ) { if ( gnTaskCount > __MAXTASK ) { return 1 ; } else { ptrTaskData -> nState = 0 ; ptrTaskData -> nTimer = 1 ; gfptrTask [ gnTaskCount ] = ptrTask ; gnTaskCount ++ ; ptrTaskData -> nID = gnTaskCount ; return 0 ; } }
Function name  : OSTaskCreate()
Author           : Fabian Kung
Last modified  : 2 Nov 2009
Purpose          : Add a new task to the OS's scheduler.
Function name : OSTaskCreate () Author : Fabian Kung Last modified : 2 Nov 2009 Purpose : Add a new task to the OS ' s scheduler .
// Maximum tasks exceeded.
 // Initialize the task state and timer variables.
 // Assign task address to function pointer array.
 // Increment task counter.
 // Initialize the task ID
 // Task ID = current Task Count + 1.
